]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
usb: gadget: tegra: conditionally update LP0 connect type
authorRakesh Bodla <rbodla@nvidia.com>
Tue, 15 Jul 2014 15:26:07 +0000 (20:56 +0530)
committerDhiren Parmar <dparmar@nvidia.com>
Wed, 16 Jul 2014 10:11:38 +0000 (03:11 -0700)
After driver resume sometimes connect_type_lp0 is not
set to NONE, due some tasks didn't get scheduled.
In this case retain the value, so that correct
value will be preserved.

Bug 200017175

Change-Id: I8f2400675a8ced063a182c1069c586dfb9cc756f
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/438218
GVS: Gerrit_Virtual_Submit
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
drivers/usb/gadget/tegra_udc.c

index 0a006bfe4018544e6825fd732cbfab0c1afcb4b9..ed0c91f8514f0e0ee956c84273f33b84b07cc374 100644 (file)
@@ -3098,6 +3098,7 @@ static int __exit tegra_udc_remove(struct platform_device *pdev)
 static int tegra_udc_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct tegra_udc *udc = platform_get_drvdata(pdev);
+       struct device *dev = &udc->pdev->dev;
        unsigned long flags;
        u32 temp;
 
@@ -3112,8 +3113,15 @@ static int tegra_udc_suspend(struct platform_device *pdev, pm_message_t state)
                if (temp & USB_SYS_VBUS_STATUS)
                        udc->vbus_in_lp0 = true;
        }
-       udc->connect_type_lp0 = udc->connect_type;
 
+       /* After driver resume sometimes connect_type_lp0 is not
+          set to NONE, which means task is finished incomplete,
+          in this case retain the value */
+       if (udc->connect_type_lp0 == CONNECT_TYPE_NONE)
+               udc->connect_type_lp0 = udc->connect_type;
+
+       dev_info(dev, "tegra_udc_suspend: lp0_connect_type = %d\n",
+                                              udc->connect_type_lp0);
        /* If the controller is in otg mode, return */
        if (udc->transceiver)
                return 0;
@@ -3146,6 +3154,7 @@ static int tegra_udc_suspend(struct platform_device *pdev, pm_message_t state)
 static int tegra_udc_resume(struct platform_device *pdev)
 {
        struct tegra_udc *udc = platform_get_drvdata(pdev);
+       struct device *dev = &udc->pdev->dev;
        u32 temp;
 
        int err = 0;
@@ -3156,6 +3165,9 @@ static int tegra_udc_resume(struct platform_device *pdev)
        /* Set Current limit to 0 if charger is disconnected in LP0 */
        if (udc->vbus_reg != NULL) {
                if (udc->support_pmu_vbus) {
+                       dev_info(dev, "tegra_udc_resume: state (%d, %d)\n",
+                              udc->connect_type_lp0, extcon_get_cable_state(
+                                      udc->vbus_extcon_dev, "USB"));
                        if ((udc->connect_type_lp0 != CONNECT_TYPE_NONE) &&
                        !extcon_get_cable_state(udc->vbus_extcon_dev, "USB")) {
                                tegra_udc_set_extcon_state(udc);