[PATCH RESEND] OMAP: USB : Fix the EHCI enumeration and core retention issue

2012-07-20 Thread Keshava Munegowda
This commit 354ab8567ae3107a8cbe7228c3181990ba598aac titled
Fix OMAP EHCI suspend/resume failure (i693) is causing
the usb hub and device detection fails in beagle XM
causeing NFS not functional. This affects the core retention too.
The same commit logic needs to be revisted adhering to hwmod and
device tree framework.
for now, this commit id 354ab8567ae3107a8cbe7228c3181990ba598aac
titled Fix OMAP EHCI suspend/resume failure (i693) reverted.

This patch is validated on BeagleXM with NFS support over
usb ethernet and USB mass storage and other device detection.

Signed-off-by: Keshava Munegowda keshava_mgo...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/host/ehci-omap.c |  167 +-
 1 file changed, 1 insertion(+), 166 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index ec21f4a..3ee5ed3 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -56,15 +56,6 @@
 #defineEHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8
 #defineEHCI_INSNREG05_ULPI_WRDATA_SHIFT0
 
-/* Errata i693 */
-static struct clk  *utmi_p1_fck;
-static struct clk  *utmi_p2_fck;
-static struct clk  *xclk60mhsp1_ck;
-static struct clk  *xclk60mhsp2_ck;
-static struct clk  *usbhost_p1_fck;
-static struct clk  *usbhost_p2_fck;
-static struct clk  *init_60m_fclk;
-
 /*-*/
 
 static const struct hc_driver ehci_omap_hc_driver;
@@ -80,40 +71,6 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
return __raw_readl(base + reg);
 }
 
-/* Erratum i693 workaround sequence */
-static void omap_ehci_erratum_i693(struct ehci_hcd *ehci)
-{
-   int ret = 0;
-
-   /* Switch to the internal 60 MHz clock */
-   ret = clk_set_parent(utmi_p1_fck, init_60m_fclk);
-   if (ret != 0)
-   ehci_err(ehci, init_60m_fclk set parent
-   failed error:%d\n, ret);
-
-   ret = clk_set_parent(utmi_p2_fck, init_60m_fclk);
-   if (ret != 0)
-   ehci_err(ehci, init_60m_fclk set parent
-   failed error:%d\n, ret);
-
-   clk_enable(usbhost_p1_fck);
-   clk_enable(usbhost_p2_fck);
-
-   /* Wait 1ms and switch back to the external clock */
-   mdelay(1);
-   ret = clk_set_parent(utmi_p1_fck, xclk60mhsp1_ck);
-   if (ret != 0)
-   ehci_err(ehci, xclk60mhsp1_ck set parent
-   failed error:%d\n, ret);
-
-   ret = clk_set_parent(utmi_p2_fck, xclk60mhsp2_ck);
-   if (ret != 0)
-   ehci_err(ehci, xclk60mhsp2_ck set parent
-   failed error:%d\n, ret);
-
-   clk_disable(usbhost_p1_fck);
-   clk_disable(usbhost_p2_fck);
-}
 
 static void omap_ehci_soft_phy_reset(struct usb_hcd *hcd, u8 port)
 {
@@ -195,50 +152,6 @@ static int omap_ehci_init(struct usb_hcd *hcd)
return rc;
 }
 
-static int omap_ehci_hub_control(
-   struct usb_hcd  *hcd,
-   u16 typeReq,
-   u16 wValue,
-   u16 wIndex,
-   char*buf,
-   u16 wLength
-)
-{
-   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-   u32 __iomem *status_reg = ehci-regs-port_status[
-   (wIndex  0xff) - 1];
-   u32 temp;
-   unsigned long   flags;
-   int retval = 0;
-
-   spin_lock_irqsave(ehci-lock, flags);
-
-   if (typeReq == SetPortFeature  wValue == USB_PORT_FEAT_SUSPEND) {
-   temp = ehci_readl(ehci, status_reg);
-   if ((temp  PORT_PE) == 0 || (temp  PORT_RESET) != 0) {
-   retval = -EPIPE;
-   goto done;
-   }
-
-   temp = ~PORT_WKCONN_E;
-   temp |= PORT_WKDISC_E | PORT_WKOC_E;
-   ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
-
-   omap_ehci_erratum_i693(ehci);
-
-   set_bit((wIndex  0xff) - 1, ehci-suspended_ports);
-   goto done;
-   }
-
-   spin_unlock_irqrestore(ehci-lock, flags);
-
-   /* Handle the hub control events here */
-   return ehci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
-done:
-   spin_unlock_irqrestore(ehci-lock, flags);
-   return retval;
-}
-
 static void disable_put_regulator(
struct ehci_hcd_omap_platform_data *pdata)
 {
@@ -351,79 +264,9 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
goto err_pm_runtime;
}
 
-   /* get clocks */
-   utmi_p1_fck = clk_get(dev, utmi_p1_gfclk);
-   if (IS_ERR(utmi_p1_fck)) {
-   ret = PTR_ERR(utmi_p1_fck);
-   dev_err(dev, utmi_p1_gfclk failed error:%d\n, ret);
-   goto err_add_hcd;
-   }
-
-   xclk60mhsp1_ck = clk_get(dev, xclk60mhsp1_ck);
-   if (IS_ERR(xclk60mhsp1_ck)) 

Re: [PATCH RESEND] OMAP: USB : Fix the EHCI enumeration and core retention issue

2012-07-20 Thread Munegowda, Keshava
On Fri, Jul 20, 2012 at 3:13 PM, Keshava Munegowda
keshava_mgo...@ti.com wrote:
 This commit 354ab8567ae3107a8cbe7228c3181990ba598aac titled
 Fix OMAP EHCI suspend/resume failure (i693) is causing
 the usb hub and device detection fails in beagle XM
 causeing NFS not functional. This affects the core retention too.
 The same commit logic needs to be revisted adhering to hwmod and
 device tree framework.
 for now, this commit id 354ab8567ae3107a8cbe7228c3181990ba598aac
 titled Fix OMAP EHCI suspend/resume failure (i693) reverted.

 This patch is validated on BeagleXM with NFS support over
 usb ethernet and USB mass storage and other device detection.

 Signed-off-by: Keshava Munegowda keshava_mgo...@ti.com
 Acked-by: Felipe Balbi ba...@ti.com
 ---
  drivers/usb/host/ehci-omap.c |  167 
 +-
  1 file changed, 1 insertion(+), 166 deletions(-)

 diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
 index ec21f4a..3ee5ed3 100644
 --- a/drivers/usb/host/ehci-omap.c
 +++ b/drivers/usb/host/ehci-omap.c
 @@ -56,15 +56,6 @@
  #defineEHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8
  #defineEHCI_INSNREG05_ULPI_WRDATA_SHIFT0

 -/* Errata i693 */
 -static struct clk  *utmi_p1_fck;
 -static struct clk  *utmi_p2_fck;
 -static struct clk  *xclk60mhsp1_ck;
 -static struct clk  *xclk60mhsp2_ck;
 -static struct clk  *usbhost_p1_fck;
 -static struct clk  *usbhost_p2_fck;
 -static struct clk  *init_60m_fclk;
 -
  /*-*/

  static const struct hc_driver ehci_omap_hc_driver;
 @@ -80,40 +71,6 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
 return __raw_readl(base + reg);
  }

 -/* Erratum i693 workaround sequence */
 -static void omap_ehci_erratum_i693(struct ehci_hcd *ehci)
 -{
 -   int ret = 0;
 -
 -   /* Switch to the internal 60 MHz clock */
 -   ret = clk_set_parent(utmi_p1_fck, init_60m_fclk);
 -   if (ret != 0)
 -   ehci_err(ehci, init_60m_fclk set parent
 -   failed error:%d\n, ret);
 -
 -   ret = clk_set_parent(utmi_p2_fck, init_60m_fclk);
 -   if (ret != 0)
 -   ehci_err(ehci, init_60m_fclk set parent
 -   failed error:%d\n, ret);
 -
 -   clk_enable(usbhost_p1_fck);
 -   clk_enable(usbhost_p2_fck);
 -
 -   /* Wait 1ms and switch back to the external clock */
 -   mdelay(1);
 -   ret = clk_set_parent(utmi_p1_fck, xclk60mhsp1_ck);
 -   if (ret != 0)
 -   ehci_err(ehci, xclk60mhsp1_ck set parent
 -   failed error:%d\n, ret);
 -
 -   ret = clk_set_parent(utmi_p2_fck, xclk60mhsp2_ck);
 -   if (ret != 0)
 -   ehci_err(ehci, xclk60mhsp2_ck set parent
 -   failed error:%d\n, ret);
 -
 -   clk_disable(usbhost_p1_fck);
 -   clk_disable(usbhost_p2_fck);
 -}

  static void omap_ehci_soft_phy_reset(struct usb_hcd *hcd, u8 port)
  {
 @@ -195,50 +152,6 @@ static int omap_ehci_init(struct usb_hcd *hcd)
 return rc;
  }

 -static int omap_ehci_hub_control(
 -   struct usb_hcd  *hcd,
 -   u16 typeReq,
 -   u16 wValue,
 -   u16 wIndex,
 -   char*buf,
 -   u16 wLength
 -)
 -{
 -   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
 -   u32 __iomem *status_reg = ehci-regs-port_status[
 -   (wIndex  0xff) - 1];
 -   u32 temp;
 -   unsigned long   flags;
 -   int retval = 0;
 -
 -   spin_lock_irqsave(ehci-lock, flags);
 -
 -   if (typeReq == SetPortFeature  wValue == USB_PORT_FEAT_SUSPEND) {
 -   temp = ehci_readl(ehci, status_reg);
 -   if ((temp  PORT_PE) == 0 || (temp  PORT_RESET) != 0) {
 -   retval = -EPIPE;
 -   goto done;
 -   }
 -
 -   temp = ~PORT_WKCONN_E;
 -   temp |= PORT_WKDISC_E | PORT_WKOC_E;
 -   ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
 -
 -   omap_ehci_erratum_i693(ehci);
 -
 -   set_bit((wIndex  0xff) - 1, ehci-suspended_ports);
 -   goto done;
 -   }
 -
 -   spin_unlock_irqrestore(ehci-lock, flags);
 -
 -   /* Handle the hub control events here */
 -   return ehci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
 -done:
 -   spin_unlock_irqrestore(ehci-lock, flags);
 -   return retval;
 -}
 -
  static void disable_put_regulator(
 struct ehci_hcd_omap_platform_data *pdata)
  {
 @@ -351,79 +264,9 @@ static int ehci_hcd_omap_probe(struct platform_device 
 *pdev)
 goto err_pm_runtime;
 }

 -   /* get clocks */
 -   utmi_p1_fck = clk_get(dev, utmi_p1_gfclk);
 -   if (IS_ERR(utmi_p1_fck)) {
 -   ret = PTR_ERR(utmi_p1_fck);