From owner-svn-src-all@FreeBSD.ORG Fri Jan 9 03:32:52 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A815ADC9; Fri, 9 Jan 2015 03:32:52 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7973A792; Fri, 9 Jan 2015 03:32:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t093WqZ9087265; Fri, 9 Jan 2015 03:32:52 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t093WqfM087264; Fri, 9 Jan 2015 03:32:52 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201501090332.t093WqfM087264@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Fri, 9 Jan 2015 03:32:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r276877 - stable/10/sys/arm/ti/am335x X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2015 03:32:52 -0000 Author: loos Date: Fri Jan 9 03:32:51 2015 New Revision: 276877 URL: https://svnweb.freebsd.org/changeset/base/276877 Log: MFC r276249: Fix the musb initialization sequence on AM335x. According to http://e2e.ti.com/support/arm/sitara_arm/f/791/t/210729 the USB reset pulse has an undocumented duration of 200ns and during this period the module must not be acessed. We wait for 100us to take into account for some imprecision of the early DELAY() loop. This fixes the eventual 'External Non-Linefetch Abort (S)' that happens at boot while resetting the musb subsystem. While here, enable the USB subsystem clock before the first access. Modified: stable/10/sys/arm/ti/am335x/am335x_usbss.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/ti/am335x/am335x_usbss.c ============================================================================== --- stable/10/sys/arm/ti/am335x/am335x_usbss.c Fri Jan 9 03:26:18 2015 (r276876) +++ stable/10/sys/arm/ti/am335x/am335x_usbss.c Fri Jan 9 03:32:51 2015 (r276877) @@ -288,21 +288,30 @@ musbotg_attach(device_t dev) return (ENXIO); } + /* Enable device clocks. */ + ti_prcm_clk_enable(MUSB0_CLK); + /* - * Reset USBSS, USB0 and USB1 + * Reset USBSS, USB0 and USB1. + * The registers of USB subsystem must not be accessed while the + * reset pulse is active (200ns). */ + USBSS_WRITE4(sc, USBSS_SYSCONFIG, USBSS_SYSCONFIG_SRESET); + DELAY(100); + i = 10; + while (USBSS_READ4(sc, USBSS_SYSCONFIG) & USBSS_SYSCONFIG_SRESET) { + DELAY(100); + if (i-- == 0) { + device_printf(dev, "reset timeout.\n"); + return (ENXIO); + } + } + + /* Read the module revision. */ rev = USBSS_READ4(sc, USBSS_REVREG); device_printf(dev, "TI AM335X USBSS v%d.%d.%d\n", (rev >> 8) & 7, (rev >> 6) & 3, rev & 63); - ti_prcm_clk_enable(MUSB0_CLK); - - USBSS_WRITE4(sc, USBSS_SYSCONFIG, - USBSS_SYSCONFIG_SRESET); - while (USBSS_READ4(sc, USBSS_SYSCONFIG) & - USBSS_SYSCONFIG_SRESET) - ; - err = bus_setup_intr(dev, sc->sc_irq_res[0], INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *)musbotg_usbss_interrupt, sc,