diff options
author | landonf <landonf@FreeBSD.org> | 2016-06-25 04:33:00 +0000 |
---|---|---|
committer | landonf <landonf@FreeBSD.org> | 2016-06-25 04:33:00 +0000 |
commit | 61ca174a62a383aa36616626d0d9c04058348677 (patch) | |
tree | 74f4267a73d73476a3043084863be45261b8f639 /sys/mips | |
parent | a81bd10601a23230513279495def77f6243bb232 (diff) | |
download | FreeBSD-src-61ca174a62a383aa36616626d0d9c04058348677.zip FreeBSD-src-61ca174a62a383aa36616626d0d9c04058348677.tar.gz |
bhnd(4): Perform explicit chipc child enumeration.
Replaces use of DEVICE_IDENTIFY with explicit enumeration of chipc
child devices using the chipc capability structure.
This is a precursor to PMU support, which requires more complex resource
assignment handling than achievable with the static device name-based
hints table.
Reviewed by: Michael Zhilin <mizkha@gmail.com> (Broadcom MIPS support)
Approved by: re (gjb), adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D6896
Diffstat (limited to 'sys/mips')
-rw-r--r-- | sys/mips/broadcom/uart_bus_chipc.c | 67 |
1 files changed, 6 insertions, 61 deletions
diff --git a/sys/mips/broadcom/uart_bus_chipc.c b/sys/mips/broadcom/uart_bus_chipc.c index 29b84ec..84d2c7a 100644 --- a/sys/mips/broadcom/uart_bus_chipc.c +++ b/sys/mips/broadcom/uart_bus_chipc.c @@ -45,84 +45,29 @@ __FBSDID("$FreeBSD$"); #include <dev/uart/uart_bus.h> #include <dev/uart/uart_cpu.h> -#include <dev/bhnd/cores/chipc/chipcvar.h> - #include "uart_if.h" #include "bhnd_chipc_if.h" +#include "bcm_socinfo.h" -static int uart_chipc_probe(device_t dev); - -extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; - -static void -uart_chipc_identify(driver_t *driver, device_t parent) -{ - struct chipc_caps *caps; - - if (device_find_child(parent, "uart", -1) != NULL) - return; - - caps = BHND_CHIPC_GET_CAPS(parent); - - if (caps == NULL) { - device_printf(parent, "error: can't retrieve ChipCommon " - "capabilities\n"); - return; - } - - if (caps->num_uarts == 0) - return; - - /* - * TODO: add more than one UART - */ - BUS_ADD_CHILD(parent, 0, "uart", -1); -} static int uart_chipc_probe(device_t dev) { struct uart_softc *sc; - struct resource *res; - int rid; - int err; - - rid = 0; - res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (res == NULL) { - device_printf(dev, "can't allocate main resource\n"); - return (ENXIO); - } + struct bcm_socinfo *socinfo; sc = device_get_softc(dev); sc->sc_class = &uart_ns8250_class; - sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); - if (sc->sc_sysdev == NULL) { - device_printf(dev, "missing sysdev\n"); - return (EINVAL); - } - - bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); - - sc->sc_sysdev->bas.bst = rman_get_bustag(res); - sc->sc_sysdev->bas.bsh = rman_get_bushandle(res); - sc->sc_bas.bst = sc->sc_sysdev->bas.bst; - sc->sc_bas.bsh = sc->sc_sysdev->bas.bsh; - - err = bus_release_resource(dev, SYS_RES_MEMORY, rid, res); - if (err) { - device_printf(dev, "can't release resource [%d]\n", rid); - return (ENXIO); - } - /* We use internal SoC clock generator with non-standart freq MHz */ - return (uart_bus_probe(dev, 0, sc->sc_sysdev->bas.rclk, 0, 0)); + /* TODO: UART rate should be calculated from CPU clock speed + * as fetched from bhnd bus */ + socinfo = bcm_get_socinfo(); + return (uart_bus_probe(dev, 0, socinfo->uartrate, 0, 0)); } static device_method_t uart_chipc_methods[] = { /* Device interface */ - DEVMETHOD(device_identify, uart_chipc_identify), DEVMETHOD(device_probe, uart_chipc_probe), DEVMETHOD(device_attach, uart_bus_attach), DEVMETHOD(device_detach, uart_bus_detach), |