From 683011190950a5f30edd7b784bff50c7effa269e Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Thu, 30 Aug 2018 14:32:47 +0000 Subject: [PATCH] omap4_prcm: Delay the frequencies read check Same as r333305, with Linux 4.17 dts the compatible for the prcm added 'simplebus', it mean that the simplebus driver will attach to it at the BUS_PASS_BUS pass. Change the pass for the prcm driver to be at BUS_PASS_BUS so we will win the attach. This introduce a problem as this driver needs the omap_scm one to be already attached. omap_scm also attach at BUS_PASS_BUS but after the prcm one as it is after in the dtb and the simplebus driver simpy walk the tree to attach it's children. Use the bus_new_pass method to defer the frequencies read at BUS_PASS_TIMER. This fixes booting on pandaboard Approved by: re (rgrimes) --- sys/arm/ti/omap4/omap4_prcm_clks.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/sys/arm/ti/omap4/omap4_prcm_clks.c b/sys/arm/ti/omap4/omap4_prcm_clks.c index ecf698a0208e..1ed3a0f6c4d2 100644 --- a/sys/arm/ti/omap4/omap4_prcm_clks.c +++ b/sys/arm/ti/omap4/omap4_prcm_clks.c @@ -176,6 +176,7 @@ struct omap4_prcm_softc { struct resource *sc_res; int sc_rid; int sc_instance; + int attach_done; }; static int omap4_clk_generic_activate(struct ti_clock_dev *clkdev); @@ -1446,10 +1447,8 @@ static int omap4_prcm_attach(device_t dev) { struct omap4_prcm_softc *sc; - unsigned int freq; const struct ofw_compat_data *ocd; - sc = device_get_softc(dev); ocd = ofw_bus_search_compatible(dev, compat_data); sc->sc_instance = (int)ocd->ocd_data; @@ -1463,6 +1462,22 @@ omap4_prcm_attach(device_t dev) ti_cpu_reset = omap4_prcm_reset; + return (0); +} + +static void +omap4_prcm_new_pass(device_t dev) +{ + struct omap4_prcm_softc *sc = device_get_softc(dev); + unsigned int freq; + + if (sc->attach_done || + bus_current_pass < (BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY)) { + bus_generic_new_pass(dev); + return; + } + sc->attach_done = 1; + /* * In order to determine ARM frequency we need both RPM and CM1 * instances up and running. So wait until all CRM devices are @@ -1473,12 +1488,16 @@ omap4_prcm_attach(device_t dev) arm_tmr_change_frequency(freq / 2); } - return (0); + return; } static device_method_t omap4_prcm_methods[] = { DEVMETHOD(device_probe, omap4_prcm_probe), DEVMETHOD(device_attach, omap4_prcm_attach), + + /* Bus interface */ + DEVMETHOD(bus_new_pass, omap4_prcm_new_pass), + {0, 0}, }; @@ -1491,5 +1510,5 @@ static driver_t omap4_prcm_driver = { static devclass_t omap4_prcm_devclass; EARLY_DRIVER_MODULE(omap4_prcm, simplebus, omap4_prcm_driver, - omap4_prcm_devclass, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY); + omap4_prcm_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); MODULE_VERSION(omap4_prcm, 1);