usb: tegra: conditionally set wake enable
Preetham Chandru R [Thu, 29 Nov 2012 11:38:50 +0000 (16:38 +0530)]
Set wake enable only if remote wakeup is supported
by the platform

Bug 1039143

Signed-off-by: Preetham Chandru R <pchandru@nvidia.com>
Change-Id: I805dd773cdbb5639f59b2f5ba4bcb2e14be74d5b
Reviewed-on: http://git-master/r/147462
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Suresh Mangipudi <smangipudi@nvidia.com>
Reviewed-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>

drivers/usb/gadget/tegra_udc.c
drivers/usb/host/ehci-tegra.c
drivers/usb/otg/tegra-otg.c

index ddf9c60..9af22eb 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/pm_qos_params.h>
+#include <linux/platform_data/tegra_usb.h>
 
 #include <asm/byteorder.h>
 #include <asm/io.h>
@@ -2565,6 +2566,7 @@ static int __init tegra_udc_probe(struct platform_device *pdev)
 {
        struct tegra_udc *udc;
        struct resource *res;
+       struct tegra_usb_platform_data *pdata = dev_get_platdata(&pdev->dev);
        int err = -ENODEV;
        DBG("%s(%d) BEGIN\n", __func__, __LINE__);
 
@@ -2615,12 +2617,14 @@ static int __init tegra_udc_probe(struct platform_device *pdev)
                goto err_iounmap;
        }
 
-       err = enable_irq_wake(udc->irq);
-       if (err < 0) {
-               dev_warn(&pdev->dev,
-                       "Couldn't enable USB udc mode wakeup, irq=%d, error=%d\n",
-                       udc->irq, err);
-               err = 0;
+       if (pdata->u_data.dev.remote_wakeup_supported) {
+               err = enable_irq_wake(udc->irq);
+               if (err < 0) {
+                       dev_warn(&pdev->dev,
+                               "Couldn't enable USB udc mode wakeup, irq=%d,"
+                               " error=%d\n", udc->irq, err);
+                       err = 0;
+               }
        }
 
        udc->phy = tegra_usb_phy_open(pdev);
index af6fa87..4ddb279 100644 (file)
@@ -407,6 +407,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
        struct resource *res;
        struct usb_hcd *hcd;
        struct tegra_ehci_hcd *tegra;
+       struct tegra_usb_platform_data *pdata = dev_get_platdata(&pdev->dev);
        int err = 0;
        int irq;
 
@@ -477,13 +478,15 @@ static int tegra_ehci_probe(struct platform_device *pdev)
                goto fail_phy;
        }
 
-       err = enable_irq_wake(tegra->irq);
-       if (err < 0) {
-               dev_warn(&pdev->dev,
-                               "Couldn't enable USB host mode wakeup, irq=%d, "
-                               "error=%d\n", irq, err);
-               err = 0;
-               tegra->irq = 0;
+       if (pdata->u_data.host.remote_wakeup_supported) {
+               err = enable_irq_wake(tegra->irq);
+               if (err < 0) {
+                       dev_warn(&pdev->dev,
+                                       "Couldn't enable USB host mode wakeup,"
+                                       " irq=%d error=%d\n", irq, err);
+                       err = 0;
+                       tegra->irq = 0;
+               }
        }
 
        tegra->ehci = hcd_to_ehci(hcd);
@@ -531,6 +534,7 @@ static int tegra_ehci_suspend(struct platform_device *pdev, pm_message_t state)
 static int tegra_ehci_remove(struct platform_device *pdev)
 {
        struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
+       struct tegra_usb_platform_data *pdata = dev_get_platdata(&pdev->dev);
        struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
 
        if (tegra == NULL || hcd == NULL)
@@ -543,7 +547,7 @@ static int tegra_ehci_remove(struct platform_device *pdev)
        }
 #endif
 
-       if (tegra->irq)
+       if (tegra->irq && pdata->u_data.host.remote_wakeup_supported)
                disable_irq_wake(tegra->irq);
 
        /* Make sure phy is powered ON to access USB register */
index 22e303e..ce19f77 100644 (file)
@@ -472,12 +472,14 @@ static int tegra_otg_probe(struct platform_device *pdev)
                goto err_irq;
        }
 
-       err = enable_irq_wake(tegra->irq);
-       if (err < 0) {
-               dev_warn(&pdev->dev,
-                       "Couldn't enable USB otg mode wakeup, irq=%d, error=%d\n",
-                       tegra->irq, err);
-               err = 0;
+       if (pdata->ehci_pdata->u_data.host.remote_wakeup_supported) {
+               err = enable_irq_wake(tegra->irq);
+               if (err < 0) {
+                       dev_warn(&pdev->dev,
+                               "Couldn't enable USB otg mode wakeup,"
+                               " irq=%d, error=%d\n", tegra->irq, err);
+                       err = 0;
+               }
        }
 
        INIT_WORK(&tegra->work, irq_work);