diff --git a/sys/arm/ti/am335x/am335x_dmtimer.c b/sys/arm/ti/am335x/am335x_dmtimer.c index 7b97e0f611f9bf..1e3410a9e93fb8 100644 --- a/sys/arm/ti/am335x/am335x_dmtimer.c +++ b/sys/arm/ti/am335x/am335x_dmtimer.c @@ -298,9 +298,9 @@ am335x_dmtimer_attach(device_t dev) return (ENXIO); } - err = clk_get_by_name(dev, "sys_clkin_ck@40", &sys_clkin); + err = clk_get_by_name(dev, "sys_clkin_ck", &sys_clkin); if (err != 0) { - device_printf(dev, "Cant find sys_clkin_ck@40 err: %d\n", err); + device_printf(dev, "Cant find sys_clkin_ck err: %d\n", err); return (ENXIO); } diff --git a/sys/arm/ti/am335x/am335x_dmtpps.c b/sys/arm/ti/am335x/am335x_dmtpps.c index 32f975a310dec5..19ad1002b8e201 100644 --- a/sys/arm/ti/am335x/am335x_dmtpps.c +++ b/sys/arm/ti/am335x/am335x_dmtpps.c @@ -485,9 +485,9 @@ dmtpps_attach(device_t dev) return (ENXIO); } - err = clk_get_by_name(dev, "sys_clkin_ck@40", &sys_clkin); + err = clk_get_by_name(dev, "sys_clkin_ck", &sys_clkin); if (err != 0) { - device_printf(dev, "Cant find sys_clkin_ck@40 err: %d\n", err); + device_printf(dev, "Cant find sys_clkin_ck err: %d\n", err); return (ENXIO); } diff --git a/sys/arm/ti/am335x/am335x_musb.c b/sys/arm/ti/am335x/am335x_musb.c index 24a204e42c9cb4..852f611a22a231 100644 --- a/sys/arm/ti/am335x/am335x_musb.c +++ b/sys/arm/ti/am335x/am335x_musb.c @@ -253,15 +253,15 @@ musbotg_attach(device_t dev) /* FIXME: The devicetree needs to be updated to get a handle to the gate * usbotg_fck@47c. see TRM 8.1.12.2 CM_WKUP CM_CLKDCOLDO_DPLL_PER. */ - err = clk_get_by_name(dev, "usbotg_fck@47c", &clk_usbotg_fck); + err = clk_get_by_name(dev, "usbotg_fck", &clk_usbotg_fck); if (err) { - device_printf(dev, "Can not find usbotg_fck@47c\n"); + device_printf(dev, "Can not find usbotg_fck\n"); return (ENXIO); } err = clk_enable(clk_usbotg_fck); if (err) { - device_printf(dev, "Can not enable usbotg_fck@47c\n"); + device_printf(dev, "Can not enable usbotg_fck\n"); return (ENXIO); } diff --git a/sys/arm/ti/clk/ti_dpll_clock.c b/sys/arm/ti/clk/ti_dpll_clock.c index 9252dc1abfe1df..d2d2e8ab93a1a4 100644 --- a/sys/arm/ti/clk/ti_dpll_clock.c +++ b/sys/arm/ti/clk/ti_dpll_clock.c @@ -154,7 +154,7 @@ parse_dpll_reg(struct ti_dpll_softc *sc) { ssize_t numbytes_regs; uint32_t num_regs; phandle_t node; - cell_t reg_cells[4]; + cell_t reg_cells[6]; if (sc->dpll_type == TI_AM3_DPLL_X2_CLOCK || sc->dpll_type == TI_OMAP4_DPLL_X2_CLOCK) { @@ -172,7 +172,7 @@ parse_dpll_reg(struct ti_dpll_softc *sc) { num_regs = numbytes_regs / sizeof(cell_t); /* Sanity check */ - if (num_regs > 4) + if (num_regs > 6) return (ENXIO); OF_getencprop(node, "reg", reg_cells, numbytes_regs); @@ -184,7 +184,7 @@ parse_dpll_reg(struct ti_dpll_softc *sc) { case TI_AM3_DPLL_CLOCK: case TI_AM3_DPLL_CORE_CLOCK: case TI_AM3_DPLL_X2_CLOCK: - if (num_regs != 3) + if (num_regs < 3) return (ENXIO); sc->dpll_def.ti_clkmode_offset = reg_cells[0]; sc->dpll_def.ti_idlest_offset = reg_cells[1]; @@ -192,13 +192,15 @@ parse_dpll_reg(struct ti_dpll_softc *sc) { break; case TI_OMAP2_DPLL_CORE_CLOCK: - if (num_regs != 2) + if (num_regs < 2) return (ENXIO); sc->dpll_def.ti_clkmode_offset = reg_cells[0]; sc->dpll_def.ti_clksel_offset = reg_cells[1]; break; default: + if (num_regs < 4) + return (ENXIO); sc->dpll_def.ti_clkmode_offset = reg_cells[0]; sc->dpll_def.ti_idlest_offset = reg_cells[1]; sc->dpll_def.ti_clksel_offset = reg_cells[2]; diff --git a/sys/arm/ti/clk/ti_gate_clock.c b/sys/arm/ti/clk/ti_gate_clock.c index 71512b8490abf3..41e5ff06f33f80 100644 --- a/sys/arm/ti/clk/ti_gate_clock.c +++ b/sys/arm/ti/clk/ti_gate_clock.c @@ -185,7 +185,7 @@ ti_gate_attach(device_t dev) if (err) { /* free_clkdef will be called in ti_gate_new_pass */ DPRINTF(sc->sc_dev, "find_parent_clock_names failed\n"); - bus_attach_children(sc->dev); + bus_attach_children(sc->sc_dev); return (0); } @@ -194,7 +194,7 @@ ti_gate_attach(device_t dev) if (err) { /* free_clkdef will be called in ti_gate_new_pass */ DPRINTF(sc->sc_dev, "register_clk failed\n"); - bus_attach_children(sc->dev); + bus_attach_children(sc->sc_dev); return (0); } @@ -202,7 +202,7 @@ ti_gate_attach(device_t dev) free_clkdef(&sc->gate_def.clkdef); - bus_attach_children(sc->dev); + bus_attach_children(sc->sc_dev); return (0); } diff --git a/sys/arm/ti/clk/ti_mux_clock.c b/sys/arm/ti/clk/ti_mux_clock.c index ac570ba5843964..75c848b149f5e2 100644 --- a/sys/arm/ti/clk/ti_mux_clock.c +++ b/sys/arm/ti/clk/ti_mux_clock.c @@ -167,7 +167,7 @@ ti_mux_attach(device_t dev) if (err) { /* free_clkdef will be called in ti_mux_new_pass */ DPRINTF(sc->sc_dev, "find_parent_clock_names failed\n"); - bus_attach_children(sc->dev); + bus_attach_children(sc->sc_dev); return (0); } @@ -176,7 +176,7 @@ ti_mux_attach(device_t dev) if (err) { /* free_clkdef will be called in ti_mux_new_pass */ DPRINTF(sc->sc_dev, "register_clk failed\n"); - bus_attach_children(sc->dev); + bus_attach_children(sc->sc_dev); return (0); } @@ -184,7 +184,7 @@ ti_mux_attach(device_t dev) free_clkdef(&sc->mux_def.clkdef); - bus_attach_children(sc->dev); + bus_attach_children(sc->sc_dev); return (0); } diff --git a/sys/arm/ti/ti_gpio.h b/sys/arm/ti/ti_gpio.h index ac695f9b00af4c..2d2a7a04f6afc6 100644 --- a/sys/arm/ti/ti_gpio.h +++ b/sys/arm/ti/ti_gpio.h @@ -28,6 +28,8 @@ #ifndef TI_GPIO_H #define TI_GPIO_H +#include + /* The maximum number of banks for any SoC */ #define MAX_GPIO_BANKS 6 diff --git a/sys/conf/options.arm b/sys/conf/options.arm index 5fe10b5e074b4d..9f65386a9f80d3 100644 --- a/sys/conf/options.arm +++ b/sys/conf/options.arm @@ -19,6 +19,7 @@ PLATFORM opt_global.h SOCDEV_PA opt_global.h SOCDEV_VA opt_global.h PV_STATS opt_pmap.h +FORCE_SIMPLE_PM_BUS opt_global.h # Allow 'simple-bus' code to handle 'simple-pm-bus' DT nodes SOC_ALLWINNER_A10 opt_global.h SOC_ALLWINNER_A13 opt_global.h SOC_ALLWINNER_A20 opt_global.h diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 3ad6515ed3b720..78ea3ea9cddc31 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -147,7 +147,8 @@ EARLY_DRIVER_MODULE(simplebus, simplebus, simplebus_driver, 0, 0, static int simplebus_probe(device_t dev) { - + bool is_simple_bus = false; + if (!ofw_bus_status_okay(dev)) return (ENXIO); /* @@ -166,7 +167,11 @@ simplebus_probe(device_t dev) * have children but aren't really buses in our world. Without a * ranges property we will fail to attach, so just fail to probe too. */ - if (!(ofw_bus_is_compatible(dev, "simple-bus") && + is_simple_bus = ofw_bus_is_compatible(dev, "simple-bus"); +#ifdef FORCE_SIMPLE_PM_BUS + is_simple_bus = is_simple_bus || ofw_bus_is_compatible(dev, "simple-pm-bus"); +#endif + if (!(is_simple_bus && ofw_bus_has_prop(dev, "ranges")) && (ofw_bus_get_type(dev) == NULL || strcmp(ofw_bus_get_type(dev), "soc") != 0)) diff --git a/sys/dev/syscon/syscon_generic.c b/sys/dev/syscon/syscon_generic.c index 6f039a680644c4..6bb7903410429a 100644 --- a/sys/dev/syscon/syscon_generic.c +++ b/sys/dev/syscon/syscon_generic.c @@ -164,6 +164,7 @@ syscon_generic_attach(device_t dev) { struct syscon_generic_softc *sc; int rid, rv; + bool is_simple_bus = false; sc = device_get_softc(dev); sc->dev = dev; @@ -184,7 +185,12 @@ syscon_generic_attach(device_t dev) syscon_generic_detach(dev); return (ENXIO); } - if (ofw_bus_is_compatible(dev, "simple-bus")) { + + is_simple_bus = ofw_bus_is_compatible(dev, "simple-bus"); +#ifdef FORCE_SIMPLE_PM_BUS + is_simple_bus = is_simple_bus || ofw_bus_is_compatible(dev, "simple-pm-bus"); +#endif + if (is_simple_bus) { rv = simplebus_attach_impl(sc->dev); if (rv != 0) { device_printf(dev, "Failed to create simplebus\n");