From owner-svn-src-all@FreeBSD.ORG Fri Dec 26 17:59:03 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C150F7C9; Fri, 26 Dec 2014 17:59:03 +0000 (UTC) Received: from mail-wi0-x22d.google.com (mail-wi0-x22d.google.com [IPv6:2a00:1450:400c:c05::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 512D5665DF; Fri, 26 Dec 2014 17:59:03 +0000 (UTC) Received: by mail-wi0-f173.google.com with SMTP id r20so17406265wiv.12; Fri, 26 Dec 2014 09:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=gKtl2rInpapjacQjAr9JU3pBL3VGHJwUzmuO3VUprjQ=; b=YT+Qy5TrNndQPaUH5Ifc4+lQJ3n7Vv08uunA5Fit+KpmnyjaCoOtdEfvz88g6/xKtU AwAHUzDBRSPRT+6a98d5MFOKs9/01WE6h/a2H5ajHGnNPfdt7kV8eApbk08PDjhc2Nv9 PduP+fWbS5MMC9pYjuv0X7+XFRt/5kWrB6HE9SByTgAagZwbcGfdwm672oNXuo6i6gRp TE4x10NJRLnsNzWHlYA/kiIfjfidhXsRrBiAX1XkV59sW/ziApqhNUd+HGDPtAlj38Z8 ILNMMS4Ue5jb1CLgcLFd7h/053g8V9tzlvnrvmDK94uenB7v52TwD+CIScfsB/lLVwG7 oZ7w== MIME-Version: 1.0 X-Received: by 10.180.80.163 with SMTP id s3mr69465539wix.59.1419616741798; Fri, 26 Dec 2014 09:59:01 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.106.195 with HTTP; Fri, 26 Dec 2014 09:59:01 -0800 (PST) In-Reply-To: <201412261745.sBQHjoMj029672@svn.freebsd.org> References: <201412261745.sBQHjoMj029672@svn.freebsd.org> Date: Fri, 26 Dec 2014 09:59:01 -0800 X-Google-Sender-Auth: rZ4ZuWBd3fBB2xfSU_TBREHebhI Message-ID: Subject: Re: svn commit: r276249 - head/sys/arm/ti/am335x From: Adrian Chadd To: Luiz Otavio O Souza Content-Type: text/plain; charset=UTF-8 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" 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, 26 Dec 2014 17:59:04 -0000 Holy crap, great catch! -adrian On 26 December 2014 at 09:45, Luiz Otavio O Souza wrote: > Author: loos > Date: Fri Dec 26 17:45:49 2014 > New Revision: 276249 > URL: https://svnweb.freebsd.org/changeset/base/276249 > > Log: > 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. > > Discussed with: ian, adrian > MFC after: 2 weeks > > Modified: > head/sys/arm/ti/am335x/am335x_usbss.c > > Modified: head/sys/arm/ti/am335x/am335x_usbss.c > ============================================================================== > --- head/sys/arm/ti/am335x/am335x_usbss.c Fri Dec 26 15:04:03 2014 (r276248) > +++ head/sys/arm/ti/am335x/am335x_usbss.c Fri Dec 26 17:45:49 2014 (r276249) > @@ -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, >