From patchwork Thu Jul 8 08:33:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar Gupta X-Patchwork-Id: 110798 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o688XWQw026264 for ; Thu, 8 Jul 2010 08:33:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754691Ab0GHIdZ (ORCPT ); Thu, 8 Jul 2010 04:33:25 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:47012 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754381Ab0GHIdS (ORCPT ); Thu, 8 Jul 2010 04:33:18 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o688X8h7010785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Jul 2010 03:33:10 -0500 Received: from psplinux050.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o688X4qB010640; Thu, 8 Jul 2010 14:03:04 +0530 (IST) Received: from psplinux050.india.ti.com (localhost [127.0.0.1]) by psplinux050.india.ti.com (8.13.1/8.13.1) with ESMTP id o688X34U030106; Thu, 8 Jul 2010 14:03:03 +0530 Received: (from a0393629@localhost) by psplinux050.india.ti.com (8.13.1/8.13.1/Submit) id o688X3Oe030103; Thu, 8 Jul 2010 14:03:03 +0530 From: Ajay Kumar Gupta To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, felipe.balbi@nokia.com, gregkh@suse.de, Ajay Kumar Gupta Subject: [PATCH 4/4] usb: ehci_omap: fix device detect issue with modules Date: Thu, 8 Jul 2010 14:03:02 +0530 Message-Id: <1278577982-30046-5-git-send-email-ajay.gupta@ti.com> X-Mailer: git-send-email 1.6.2.4 In-Reply-To: <1278577982-30046-4-git-send-email-ajay.gupta@ti.com> References: <1278577982-30046-1-git-send-email-ajay.gupta@ti.com> <1278577982-30046-2-git-send-email-ajay.gupta@ti.com> <1278577982-30046-3-git-send-email-ajay.gupta@ti.com> <1278577982-30046-4-git-send-email-ajay.gupta@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 08 Jul 2010 08:33:33 +0000 (UTC) diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 5450e62..116ae28 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -38,6 +38,7 @@ #include #include #include +#include #include /* @@ -236,6 +237,35 @@ static void omap_usb_utmi_init(struct ehci_hcd_omap *omap, u8 tll_channel_mask) /*-------------------------------------------------------------------------*/ +static void omap_ehci_soft_phy_reset(struct ehci_hcd_omap *omap, u8 port) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(1000); + unsigned reg = 0; + + reg = ULPI_FUNC_CTRL_RESET + /* FUNCTION_CTRL_SET register */ + | (ULPI_SET(ULPI_FUNC_CTRL) << EHCI_INSNREG05_ULPI_REGADD_SHIFT) + /* Write */ + | (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) + /* PORTn */ + | ((port + 1) << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) + /* start ULPI access*/ + | (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT); + + ehci_omap_writel(omap->ehci_base, EHCI_INSNREG05_ULPI, reg); + + /* Wait for ULPI access completion */ + while ((ehci_omap_readl(omap->ehci_base, EHCI_INSNREG05_ULPI) + & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) { + cpu_relax(); + + if (time_after(jiffies, timeout)) { + dev_dbg(omap->dev, "phy reset operation timed out\n"); + break; + } + } +} + /* omap_start_ehc * - Start the TI USBHOST controller */ @@ -425,6 +455,12 @@ static int omap_start_ehc(struct ehci_hcd_omap *omap, struct usb_hcd *hcd) gpio_set_value(omap->reset_gpio_port[1], 1); } + /* Soft reset the PHY using PHY reset command over ULPI */ + if (omap->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) + omap_ehci_soft_phy_reset(omap, 0); + if (omap->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) + omap_ehci_soft_phy_reset(omap, 1); + return 0; err_sys_status: