Date: Sun, 6 May 2018 14:37:11 +0000 (UTC) From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333305 - head/sys/arm/ti/am335x Message-ID: <201805061437.w46EbB1Q004842@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: manu Date: Sun May 6 14:37:11 2018 New Revision: 333305 URL: https://svnweb.freebsd.org/changeset/base/333305 Log: am335x_prcm: Delay the frequencies read check With Linux 4.17 dts the compatible for the prcm added 'simplebus' we 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 ti_scm one to be already attached. ti_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 BeagleBone* Reported by: many Modified: head/sys/arm/ti/am335x/am335x_prcm.c Modified: head/sys/arm/ti/am335x/am335x_prcm.c ============================================================================== --- head/sys/arm/ti/am335x/am335x_prcm.c Sun May 6 14:19:50 2018 (r333304) +++ head/sys/arm/ti/am335x/am335x_prcm.c Sun May 6 14:37:11 2018 (r333305) @@ -136,6 +136,7 @@ struct am335x_prcm_softc { struct resource * res[2]; bus_space_tag_t bst; bus_space_handle_t bsh; + int attach_done; }; static struct resource_spec am335x_prcm_spec[] = { @@ -424,7 +425,6 @@ static int am335x_prcm_attach(device_t dev) { struct am335x_prcm_softc *sc = device_get_softc(dev); - unsigned int sysclk, fclk; if (am335x_prcm_sc) return (ENXIO); @@ -440,6 +440,24 @@ am335x_prcm_attach(device_t dev) am335x_prcm_sc = sc; ti_cpu_reset = am335x_prcm_reset; + return (0); +} + +static void +am335x_prcm_new_pass(device_t dev) +{ + struct am335x_prcm_softc *sc = device_get_softc(dev); + unsigned int sysclk, fclk; + + sc = device_get_softc(dev); + if (sc->attach_done || + bus_current_pass < (BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY)) { + bus_generic_new_pass(dev); + return; + } + + sc->attach_done = 1; + if (am335x_clk_get_sysclk_freq(NULL, &sysclk) != 0) sysclk = 0; if (am335x_clk_get_arm_fclk_freq(NULL, &fclk) != 0) @@ -447,15 +465,24 @@ am335x_prcm_attach(device_t dev) if (sysclk && fclk) device_printf(dev, "Clocks: System %u.%01u MHz, CPU %u MHz\n", sysclk/1000000, (sysclk % 1000000)/100000, fclk/1000000); - else + else { device_printf(dev, "can't read frequencies yet (SCM device not ready?)\n"); + goto fail; + } - return (0); + return; + +fail: + device_detach(dev); + return; } static device_method_t am335x_prcm_methods[] = { DEVMETHOD(device_probe, am335x_prcm_probe), DEVMETHOD(device_attach, am335x_prcm_attach), + + /* Bus interface */ + DEVMETHOD(bus_new_pass, am335x_prcm_new_pass), { 0, 0 } }; @@ -468,7 +495,7 @@ static driver_t am335x_prcm_driver = { static devclass_t am335x_prcm_devclass; EARLY_DRIVER_MODULE(am335x_prcm, simplebus, am335x_prcm_driver, - am335x_prcm_devclass, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY); + am335x_prcm_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); MODULE_VERSION(am335x_prcm, 1); MODULE_DEPEND(am335x_prcm, ti_scm, 1, 1, 1);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805061437.w46EbB1Q004842>