From owner-svn-src-head@freebsd.org Sun May 6 14:37:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32932FBB547; Sun, 6 May 2018 14:37:12 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CF40585C5E; Sun, 6 May 2018 14:37:11 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AABB86088; Sun, 6 May 2018 14:37:11 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w46EbBFS004843; Sun, 6 May 2018 14:37:11 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w46EbB1Q004842; Sun, 6 May 2018 14:37:11 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201805061437.w46EbB1Q004842@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Sun, 6 May 2018 14:37:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333305 - head/sys/arm/ti/am335x X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/ti/am335x X-SVN-Commit-Revision: 333305 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2018 14:37:12 -0000 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);