uart_bus_acpi: Read clock frequency from bus

It is stored in the clock-frequency property.
In case of failure, fallback to the harcoded value stored in the
compat data.
Also, while here improve style.
Tested on LS1046ARDB and x86 PC.

Reviewed by:	mw
Obtained from:	Semihalf
Differential Revision: https://reviews.freebsd.org/D36326
This commit is contained in:
Mateusz Kozyra 2022-09-06 16:54:00 +02:00 committed by Kornel Dulęba
parent a5a918b7a9
commit 299b6c9cb1

View file

@ -83,19 +83,29 @@ uart_acpi_find_device(device_t dev)
static int
uart_acpi_probe(device_t dev)
{
struct uart_softc *sc;
struct acpi_uart_compat_data *cd;
struct uart_softc *sc;
uint32_t rclk;
ssize_t size;
sc = device_get_softc(dev);
rclk = 0;
if ((cd = uart_acpi_find_device(dev)) != NULL) {
sc->sc_class = cd->cd_class;
if (cd->cd_desc != NULL)
device_set_desc(dev, cd->cd_desc);
return (uart_bus_probe(dev, cd->cd_regshft, cd->cd_regiowidth,
cd->cd_rclk, 0, 0, cd->cd_quirks));
}
return (ENXIO);
cd = uart_acpi_find_device(dev);
if (cd == NULL)
return (ENXIO);
sc->sc_class = cd->cd_class;
if (cd->cd_desc != NULL)
device_set_desc(dev, cd->cd_desc);
size = device_get_property(dev, "clock-frequency", &rclk,
sizeof(rclk), DEVICE_PROP_UINT32);
if (size < 0 || rclk == 0)
rclk = cd->cd_rclk;
return (uart_bus_probe(dev, cd->cd_regshft, cd->cd_regiowidth,
rclk, 0, 0, cd->cd_quirks));
}
DRIVER_MODULE(uart, acpi, uart_acpi_driver, 0, 0);