]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
arm: tegra: phy: enable wakeup event for usb phy
authorRakesh Bodla <rbodla@nvidia.com>
Fri, 7 Sep 2012 10:24:55 +0000 (15:54 +0530)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 19:33:41 +0000 (12:33 -0700)
If usb device already connected, should disable WKCN
in USB2D_PORTSC1, and enable WKDS in USB2D_PORTSC1,
during utmi phy power off. All the wakeup resource
should be cleared after the event happened.

Bug 1020021
Bug 1028429

Reviewed-on: http://git-master/r/128547
(cherry picked from commit 65ce999d1b22b01f6a2e6b3516be47e83d6d2584)

Change-Id: I0c4f704cd0517f0195053a5835ddf5c2956a2fa9
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/130601
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
Rebase-Id: Rb7338395f8a9d46506479c43f9fffa36b0eacb3e

arch/arm/mach-tegra/tegra2_usb_phy.c
arch/arm/mach-tegra/tegra3_usb_phy.c

index ddab299bd3dfb4133eef76a192d879d1ec2f0a6c..1befe2b0d0f626ef2e9db5218255775bbfd2ef0a 100644 (file)
@@ -616,13 +616,19 @@ static int utmi_phy_irq(struct tegra_usb_phy *phy)
                        val &= ~USB_PHY_CLK_VALID_INT_ENB |
                                        USB_PHY_CLK_VALID_INT_STS;
                        writel(val , (base + USB_SUSP_CTRL));
-                       pr_info("%s: usb device plugged-in\n", __func__);
+
                        val = readl(base + USB_USBSTS);
                        if (!(val  & USB_USBSTS_PCI))
                                return IRQ_NONE;
+
                        val = readl(base + USB_PORTSC);
-                       val &= ~(USB_PORTSC_WKCN | USB_PORTSC_RWC_BITS);
+                       if (val & USB_PORTSC_CCS)
+                               val &= ~USB_PORTSC_WKCN;
+                       else
+                               val &= ~USB_PORTSC_WKDS;
+                       val &= ~USB_PORTSC_RWC_BITS;
                        writel(val , (base + USB_PORTSC));
+
                } else if (!phy->phy_clk_on) {
                        return IRQ_NONE;
                }
@@ -721,8 +727,12 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy)
                        enable_hotplug = (val & USB_ID_STATUS) ? false : true;
                }
                if (enable_hotplug) {
+                       /* Enable wakeup event of device plug-in/plug-out */
                        val = readl(base + USB_PORTSC);
-                       val |= USB_PORTSC_WKCN;
+                       if (val & USB_PORTSC_CCS)
+                               val |= USB_PORTSC_WKDS;
+                       else
+                               val |= USB_PORTSC_WKCN;
                        writel(val, base + USB_PORTSC);
 
                        val = readl(base + USB_SUSP_CTRL);
@@ -737,6 +747,7 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy)
                }
        }
 
+       /* Disable PHY clock */
        if (phy->inst == 2) {
                val = readl(base + USB_PORTSC);
                val |= USB_PORTSC_PHCD;
index dbdf7e9e1e37f1e7a5bf9f681f70128490ec606a..156ecc603a241f5c1f3159b91c0bc1caba40d612 100644 (file)
@@ -1247,15 +1247,26 @@ static int utmi_phy_irq(struct tegra_usb_phy *phy)
                        val &= ~USB_PHY_CLK_VALID_INT_ENB |
                                        USB_PHY_CLK_VALID_INT_STS;
                        writel(val , (base + USB_SUSP_CTRL));
-                       pr_info("%s: usb device plugged-in\n", __func__);
-                       val = readl(base + USB_USBSTS);
-                       if (!(val  & USB_USBSTS_PCI)) {
-                               irq_status = IRQ_NONE;
-                               goto exit;
+
+                       /* In case of remote wakeup PHY clock will not up
+                          immediately, so should not access any controller
+                          register but normal plug-in/plug-out should be
+                          executed */
+                       if (!remote_wakeup) {
+                               val = readl(base + USB_USBSTS);
+                               if (!(val  & USB_USBSTS_PCI)) {
+                                       irq_status = IRQ_NONE;
+                                       goto exit;
+                               }
+
+                               val = readl(base + USB_PORTSC);
+                               if (val & USB_PORTSC_CCS)
+                                       val &= ~USB_PORTSC_WKCN;
+                               else
+                                       val &= ~USB_PORTSC_WKDS;
+                               val &= ~USB_PORTSC_RWC_BITS;
+                               writel(val , (base + USB_PORTSC));
                        }
-                       val = readl(base + USB_PORTSC);
-                       val &= ~(USB_PORTSC_WKCN | USB_PORTSC_RWC_BITS);
-                       writel(val , (base + USB_PORTSC));
                } else if (!phy->phy_clk_on) {
                        if (remote_wakeup)
                                irq_status = IRQ_HANDLED;
@@ -1488,8 +1499,12 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy)
                        enable_hotplug = (val & USB_ID_STATUS) ? false : true;
                }
                if (enable_hotplug) {
+                       /* Enable wakeup event of device plug-in/plug-out */
                        val = readl(base + USB_PORTSC);
-                       val |= USB_PORTSC_WKCN;
+                       if (val & USB_PORTSC_CCS)
+                               val |= USB_PORTSC_WKDS;
+                       else
+                               val |= USB_PORTSC_WKCN;
                        writel(val, base + USB_PORTSC);
 
                        val = readl(base + USB_SUSP_CTRL);
@@ -1503,6 +1518,7 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy)
                }
        }
 
+       /* Disable PHY clock */
        val = readl(base + HOSTPC1_DEVLC);
        val |= HOSTPC1_DEVLC_PHCD;
        writel(val, base + HOSTPC1_DEVLC);
@@ -1691,7 +1707,8 @@ static void utmi_phy_restore_end(struct tegra_usb_phy *phy)
                        val = readl(base + USB_PORTSC);
                        udelay(1);
                        if (wait_time_us == 0) {
-                               PHY_DBG("%s PMC REMOTE WAKEUP FPR timeout val = 0x%x instance = %d\n", __func__, val, phy->inst);
+                               PHY_DBG("%s PMC FPR timeout val = 0x%lx ",
+                                                       __func__, val);
                                utmip_phy_disable_pmc_bus_ctrl(phy);
                                utmi_phy_post_resume(phy);
                                return;