From patchwork Sat Nov 5 20:59:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jana Rapava X-Patchwork-Id: 123891 X-Patchwork-Delegate: marek.vasut@gmail.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 30919B6F6F for ; Sun, 6 Nov 2011 07:55:33 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 990DD29004; Sat, 5 Nov 2011 21:55:31 +0100 (CET) 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 KWZA+lx6yN-G; Sat, 5 Nov 2011 21:55:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D2B5928FE0; Sat, 5 Nov 2011 21:55:28 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C5E728FE0 for ; Sat, 5 Nov 2011 21:55:27 +0100 (CET) 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 PB3EgVCOtBnf for ; Sat, 5 Nov 2011 21:55:26 +0100 (CET) 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-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by theia.denx.de (Postfix) with ESMTPS id 85A7C28FDD for ; Sat, 5 Nov 2011 21:55:24 +0100 (CET) Received: by faas12 with SMTP id s12so3803855faa.3 for ; Sat, 05 Nov 2011 13:55:24 -0700 (PDT) Received: by 10.152.109.33 with SMTP id hp1mr3391704lab.36.1320526524449; Sat, 05 Nov 2011 13:55:24 -0700 (PDT) Received: from hex.kolej.mff.cuni.cz (janalaptop.kolej.mff.cuni.cz. [78.128.199.214]) by mx.google.com with ESMTPS id nw10sm3569527lab.4.2011.11.05.13.55.23 (version=SSLv3 cipher=OTHER); Sat, 05 Nov 2011 13:55:23 -0700 (PDT) From: Jana Rapava To: u-boot@lists.denx.de Date: Sat, 5 Nov 2011 21:59:13 +0100 Message-Id: <1320526753-30544-1-git-send-email-fermata7@gmail.com> X-Mailer: git-send-email 1.7.6.3 Cc: Jana Rapava Subject: [U-Boot] [PATCH] usb: adjust Efika USB code to generic ULPI framework X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch changes Efika USB support code to use generic ULPI implementation instead of driver's own. Signed-off-by: Jana Rapava Cc: Marek Vasut Cc: Remy Bohmer Cc: Stefano Babic Cc: Igor Grinberg --- board/efikamx/efikamx-usb.c | 105 +++++-------------------------------------- include/configs/efikamx.h | 1 + 2 files changed, 13 insertions(+), 93 deletions(-) diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c index 3b42256..2a0341f 100644 --- a/board/efikamx/efikamx-usb.c +++ b/board/efikamx/efikamx-usb.c @@ -205,104 +205,21 @@ void control_regs_setup(struct mx5_usb_control_regs *control) udelay(10000); } -#define ULPI_ADDR_SHIFT 16 -#define ulpi_write_mask(value) ((value) & 0xff) -#define ulpi_read_mask(value) (((value) >> 8) & 0xff) - -int ulpi_wait(struct usb_ehci *ehci, u32 ulpi_value, u32 ulpi_mask) +void ulpi_set_flags(struct usb_ehci *ehci, struct ulpi_regs *ulpi) { - int timeout = ULPI_TIMEOUT; - u32 tmp; - - writel(ulpi_value, &ehci->ulpi_viewpoint); - - /* Wait for the bits in ulpi_mask to become zero. */ - while (--timeout) { - tmp = readl(&ehci->ulpi_viewpoint); - if (!(tmp & ulpi_mask)) - break; - WATCHDOG_RESET(); - } - - return !timeout; -} - -int ulpi_wakeup(struct usb_ehci *ehci) -{ - if (readl(&ehci->ulpi_viewpoint) & ULPI_SS) - return 0; /* already awake */ - return ulpi_wait(ehci, ULPI_WU, ULPI_WU); -} - -void ulpi_write(struct usb_ehci *ehci, u32 reg, u32 value) -{ - u32 tmp; - if (ulpi_wakeup(ehci)) { - printf("ULPI wakeup timed out\n"); - return; - } - - tmp = ulpi_wait(ehci, ULPI_RWRUN | ULPI_RWCTRL | - reg << ULPI_ADDR_SHIFT | ulpi_write_mask(value), ULPI_RWRUN); - if (tmp) - printf("ULPI write timed out\n"); -} - -u32 ulpi_read(struct usb_ehci *ehci, u32 reg) -{ - if (ulpi_wakeup(ehci)) { - printf("ULPI wakeup timed out\n"); - return 0; - } - - if (ulpi_wait(ehci, ULPI_RWRUN | reg << ULPI_ADDR_SHIFT, ULPI_RWRUN)) { - printf("ULPI read timed out\n"); - return 0; - } - - return ulpi_read_mask(readl(&ehci->ulpi_viewpoint)); -} - -void ulpi_init(struct usb_ehci *ehci, struct ulpi_regs *ulpi) -{ - u32 tmp = 0; - int reg, i; - - /* Assemble ID from four ULPI ID registers (8 bits each). */ - for (reg = ULPI_ID_REGS_COUNT - 1; reg >= 0; reg--) - tmp |= ulpi_read(ehci, reg) << (reg * 8); - - /* Split ID into vendor and product ID. */ - debug("Found ULPI TX, ID %04x:%04x\n", tmp >> 16, tmp & 0xffff); - - /* ULPI integrity check */ - for (i = 0; i < 2; i++) { - ulpi_write(ehci, (u32)&ulpi->scratch_write, - ULPI_TEST_VALUE << i); - tmp = ulpi_read(ehci, (u32)&ulpi->scratch_write); - - if (tmp != (ULPI_TEST_VALUE << i)) { - printf("ULPI integrity check failed\n"); - return; - } - } - - /* Set ULPI flags. */ - ulpi_write(ehci, (u32)&ulpi->otg_ctrl_write, - ULPI_OTG_EXTVBUSIND | + ulpi_otg_ctrl_flags(ehci, ulpi, WRITE, ULPI_OTG_EXTVBUSIND | ULPI_OTG_DM_PULLDOWN | ULPI_OTG_DP_PULLDOWN); - ulpi_write(ehci, (u32)&ulpi->function_ctrl_write, - ULPI_FC_XCVRSEL | ULPI_FC_OPMODE_NORMAL | - ULPI_FC_SUSPENDM); - ulpi_write(ehci, (u32)&ulpi->iface_ctrl_write, 0); - ulpi_write(ehci, (u32)&ulpi->otg_ctrl_set, - ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT); + ulpi_function_ctrl_flags(ehci, ulpi, WRITE, ULPI_FC_XCVRSEL | + ULPI_FC_OPMODE_NORMAL | ULPI_FC_SUSPENDM); + ulpi_iface_ctrl_flags(ehci, ulpi, WRITE, 0); /* - * NOTE: This violates USB specification, but otherwise, USB on Efika - * doesn't charge VBUS and as a result, USB doesn't work. + * NOTE: Setting ULPI_OTG_CHRGVBUS violates USB specification, + * but otherwise, USB on Efika doesn't charge VBUS + * and as a result, USB doesn't work. */ - ulpi_write(ehci, (u32)&ulpi->otg_ctrl_set, ULPI_OTG_CHRGVBUS); + ulpi_otg_ctrl_flags(ehci, ulpi, SET, ULPI_OTG_DRVVBUS | + ULPI_OTG_DRVVBUS_EXT | ULPI_OTG_CHRGVBUS); } /* @@ -353,6 +270,7 @@ void ehci1_init(struct usb_ehci *ehci, struct ulpi_regs *ulpi) udelay(10000); ulpi_init(ehci, ulpi); + ulpi_set_flags(ehci, ulpi); } void ehci2_init(struct usb_ehci *ehci, struct ulpi_regs *ulpi) @@ -372,6 +290,7 @@ void ehci2_init(struct usb_ehci *ehci, struct ulpi_regs *ulpi) udelay(10000); ulpi_init(ehci, ulpi); + ulpi_set_flags(ehci, ulpi); } int ehci_hcd_init(void) diff --git a/include/configs/efikamx.h b/include/configs/efikamx.h index 537a1e4..988236b 100644 --- a/include/configs/efikamx.h +++ b/include/configs/efikamx.h @@ -188,6 +188,7 @@ #define CONFIG_EHCI_IS_TDI #define CONFIG_USB_STORAGE #define CONFIG_USB_KEYBOARD +#define CONFIG_USB_ULPI #endif /* CONFIG_CMD_USB */ /*