From patchwork Fri May 17 04:33:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 244495 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 98A772C008F for ; Fri, 17 May 2013 14:33:59 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7CE674A020; Fri, 17 May 2013 06:33:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id INsMcF-m4TnP; Fri, 17 May 2013 06:33:57 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 71EC14A028; Fri, 17 May 2013 06:33:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D93EA4A028 for ; Fri, 17 May 2013 06:33:47 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ayjAULwtbFtP for ; Fri, 17 May 2013 06:33:39 +0200 (CEST) X-Greylist: delayed 53500 seconds by postgrey-1.27 at theia; Fri, 17 May 2013 06:33:32 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pb0-f51.google.com (mail-pb0-f51.google.com [209.85.160.51]) by theia.denx.de (Postfix) with ESMTPS id 7FEF54A020 for ; Fri, 17 May 2013 06:33:32 +0200 (CEST) Received: by mail-pb0-f51.google.com with SMTP id jt11so1873061pbb.24 for ; Thu, 16 May 2013 21:33:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent:x-gm-message-state; bh=OAycwWLfv9JZMUQAWYZiTUZs3s6vTkzBV/12NoxTqxM=; b=EI/V3YRCuGa++UPZSnaHFya/HQDDqOAOP9/PlE4jyLTiBxm0F57Q+iR1P4FrjdQJRU eC7Us0m2YEcATetlTr8YOeph6tdbpP6LfxhEf7UUVi1tM4WGiPQleBcVnAQw4QzVE5Y1 QtWY8yeYHN8TfQAbrIlMVCjLQdmna8nB1uj3Ep6rZfslMTCnOQ0wVpMjiuEgrtgX75YO VYknDpcg/tCb1XlL3GrC4AHs9Hqs3gW2tueeoQzNTpdU91EoQjXOVKxvfnms7S4wnD7W 6x1Hav9RRaK6qzxRqHxgg0Maj1/nHoS2QzmmuF5/MSaA9az9tCApQiw7zhq+8a+y4B9P g0oQ== X-Received: by 10.68.20.193 with SMTP id p1mr27673166pbe.218.1368765210172; Thu, 16 May 2013 21:33:30 -0700 (PDT) Received: from panicking (220-128-110-82.HINET-IP.hinet.net. [220.128.110.82]) by mx.google.com with ESMTPSA id ya4sm9526498pbb.24.2013.05.16.21.33.27 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 May 2013 21:33:29 -0700 (PDT) Date: Fri, 17 May 2013 06:33:23 +0200 From: Michael Trimarchi To: U-Boot@lists.denx.de Message-ID: <20130517043322.GA26779@panicking> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQkdWjsTA9sb6Z1PUWjIBHAj+AESl2+31x30zOOIXONdlnWlCFDFJNatogVyXc8wJZPGYDVA Cc: Tom Rini , Marek Vasut Subject: [U-Boot] [PATCH OMAP-ULPI] This patch fix the omap access to the tranceiver configuration registers using the ulpi bus. X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch fix the omap access to the tranceiver configuration registers using the ulpi bus. As reported by the documentation the bit31 is used only to check if the transaction is done or still running and the reading and writing operation have different offset and have different values. What we need to do at the end of a transaction is leave the bus in done state. Anyway an error using the ulpi omap register is not recovable so any error give out the usage of this interface. Signed-off-by: Michael Trimarchi Reviewed-by: Igor Grinberg --- drivers/usb/ulpi/omap-ulpi-viewport.c | 40 +++++++-------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/drivers/usb/ulpi/omap-ulpi-viewport.c b/drivers/usb/ulpi/omap-ulpi-viewport.c index 3c1ea1a..2a42033 100644 --- a/drivers/usb/ulpi/omap-ulpi-viewport.c +++ b/drivers/usb/ulpi/omap-ulpi-viewport.c @@ -22,18 +22,19 @@ #include #include -#define OMAP_ULPI_WR_OPSEL (3 << 21) -#define OMAP_ULPI_ACCESS (1 << 31) +#define OMAP_ULPI_WR_OPSEL (2 << 22) +#define OMAP_ULPI_RD_OPSEL (3 << 22) +#define OMAP_ULPI_START (1 << 31) /* - * Wait for the ULPI Access to complete + * Wait for having ulpi in done state */ static int ulpi_wait(struct ulpi_viewport *ulpi_vp, u32 mask) { int timeout = CONFIG_USB_ULPI_TIMEOUT; while (--timeout) { - if ((readl(ulpi_vp->viewport_addr) & mask)) + if (!(readl(ulpi_vp->viewport_addr) & mask)) return 0; udelay(1); @@ -43,40 +44,15 @@ static int ulpi_wait(struct ulpi_viewport *ulpi_vp, u32 mask) } /* - * Wake the ULPI PHY up for communication - * - * returns 0 on success. - */ -static int ulpi_wakeup(struct ulpi_viewport *ulpi_vp) -{ - int err; - - if (readl(ulpi_vp->viewport_addr) & OMAP_ULPI_ACCESS) - return 0; /* already awake */ - - writel(OMAP_ULPI_ACCESS, ulpi_vp->viewport_addr); - - err = ulpi_wait(ulpi_vp, OMAP_ULPI_ACCESS); - if (err) - debug("ULPI wakeup timed out\n"); - - return err; -} - -/* * Issue a ULPI read/write request */ static int ulpi_request(struct ulpi_viewport *ulpi_vp, u32 value) { int err; - err = ulpi_wakeup(ulpi_vp); - if (err) - return err; - writel(value, ulpi_vp->viewport_addr); - err = ulpi_wait(ulpi_vp, OMAP_ULPI_ACCESS); + err = ulpi_wait(ulpi_vp, OMAP_ULPI_START); if (err) debug("ULPI request timed out\n"); @@ -85,7 +61,7 @@ static int ulpi_request(struct ulpi_viewport *ulpi_vp, u32 value) int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value) { - u32 val = ((ulpi_vp->port_num & 0xf) << 24) | + u32 val = (OMAP_ULPI_START | (ulpi_vp->port_num & 0xf) << 24) | OMAP_ULPI_WR_OPSEL | ((u32)reg << 16) | (value & 0xff); return ulpi_request(ulpi_vp, val); @@ -95,7 +71,7 @@ u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg) { int err; u32 val = ((ulpi_vp->port_num & 0xf) << 24) | - OMAP_ULPI_WR_OPSEL | ((u32)reg << 16); + OMAP_ULPI_RD_OPSEL | ((u32)reg << 16); err = ulpi_request(ulpi_vp, val); if (err)