From patchwork Mon Jun 10 16:18:04 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: 250290 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 E5E562C0092 for ; Tue, 11 Jun 2013 02:26:11 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 39BAE4A047; Mon, 10 Jun 2013 18:26:10 +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 0+0tmfwODSoA; Mon, 10 Jun 2013 18:26:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 479E14A04E; Mon, 10 Jun 2013 18:26:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 671044A04E for ; Mon, 10 Jun 2013 18:26:02 +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 ao7x2j7bcH2m for ; Mon, 10 Jun 2013 18:25:56 +0200 (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-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by theia.denx.de (Postfix) with ESMTPS id A7E194A047 for ; Mon, 10 Jun 2013 18:25:51 +0200 (CEST) Received: by mail-wg0-f51.google.com with SMTP id e11so928444wgh.18 for ; Mon, 10 Jun 2013 09:25:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent:x-gm-message-state; bh=kFeBxM7AtwEjmylb2ZMwzmfIkR+bxHFQKemDD1aK60M=; b=WYkB0LpbnwTgW674BuK60k6l2yQSWYScLVoYMLo3wXo2BonRs8qk09L9gLqWlVuBTx ZNGHZb72bNYzkFSLN2DePp2T+hqk7QXhz5fDQdn2uaWAG8KmI7NFtlhJC4SiRIuAQqlR RpZ4Gy6fdNaKdOEKPfCt5bbk1hSAgYrVSu8RI1AHeUtIfodPUALfkJJqJUpv5ilOWXmt v1fEjgSL4KWBn3Q35Istg5m0cR3i111kNhzI+JuU7hBrvE21bfWUm8T6VhK54VQidM/7 q8l+6acz5Z393RXGB3EfK8U0qMoRuBn+B8Aguxq9pCj3RMpjCXmZnmfbM3EzN+kFfUYz 6Tkg== X-Received: by 10.194.24.225 with SMTP id x1mr5942530wjf.62.1370881090444; Mon, 10 Jun 2013 09:18:10 -0700 (PDT) Received: from panicking (net-2-39-215-52.cust.dsl.vodafone.it. [2.39.215.52]) by mx.google.com with ESMTPSA id x13sm12325201wib.3.2013.06.10.09.18.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 10 Jun 2013 09:18:09 -0700 (PDT) Date: Mon, 10 Jun 2013 18:18:04 +0200 From: Michael Trimarchi To: U-Boot@lists.denx.de Message-ID: <20130610161804.GA16619@panicking> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQlJp+iZhk/iAQMa3aCdX3r7cg3ZHY3o3qU3HKUvXb3/jUmRz//WGaq2gUlZ4jHHZld3E8zr Cc: Tom Rini , Marek Vasut Subject: [U-Boot] [PATCH v4] usb: omap: ulpi: fix ulpi transceiver access 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 transceiver 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 recoverable so any error give out the usage of this interface. Tested on a custom OMAP5430 board with a TUSB1210 ULPI PHY on USBB1. Signed-off-by: Michael Trimarchi Acked-by: Igor Grinberg Tested-by: Lubomir Popov Cc: Stefano Babic Cc: Marek Vasut Cc: Tom Rini --- - changes for V4 * The OMAP INSNREG05_ULPI register expects a value of 1 for Port 1 and of 2 for Port 2 in the PORTSEL field. * BIT31 OMAP_ULPI_START is used in the read function too - changes for V3 Fix patch subject - changes for V2 Fix commit message --- drivers/usb/ulpi/omap-ulpi-viewport.c | 42 +++++++-------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/drivers/usb/ulpi/omap-ulpi-viewport.c b/drivers/usb/ulpi/omap-ulpi-viewport.c index 3c1ea1a..4db7fa4 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 + 1) & 0xf) << 24) | OMAP_ULPI_WR_OPSEL | ((u32)reg << 16) | (value & 0xff); return ulpi_request(ulpi_vp, val); @@ -94,8 +70,8 @@ int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value) 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); + u32 val = OMAP_ULPI_START | (((ulpi_vp->port_num + 1) & 0xf) << 24) | + OMAP_ULPI_RD_OPSEL | ((u32)reg << 16); err = ulpi_request(ulpi_vp, val); if (err)