diff options
author | Mateusz Kozyra <mkoz@semihalf.com> | 2022-09-06 14:54:00 +0000 |
---|---|---|
committer | Kornel Dulęba <kd@FreeBSD.org> | 2022-09-07 07:44:58 +0000 |
commit | 299b6c9cb1a9a3e3a7a59913dc4f1ea5dff040d5 (patch) | |
tree | f80c9fdf95600a1bbcafb1c0161d442876390a63 | |
parent | a5a918b7a906eaa88e0833eac70a15989d535b02 (diff) | |
download | src-299b6c9cb1a9a3e3a7a59913dc4f1ea5dff040d5.tar.gz src-299b6c9cb1a9a3e3a7a59913dc4f1ea5dff040d5.zip |
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
-rw-r--r-- | sys/dev/uart/uart_bus_acpi.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/sys/dev/uart/uart_bus_acpi.c b/sys/dev/uart/uart_bus_acpi.c index 1018412392dd..8a2eec143577 100644 --- a/sys/dev/uart/uart_bus_acpi.c +++ b/sys/dev/uart/uart_bus_acpi.c @@ -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); |