]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
usb: gadget: tegra: Support charging in LP0
authorRohith Seelaboyina <rseelaboyina@nvidia.com>
Mon, 9 Dec 2013 09:15:32 +0000 (14:45 +0530)
committerRohith Seelaboyina <rseelaboyina@nvidia.com>
Wed, 18 Dec 2013 09:46:49 +0000 (01:46 -0800)
Add Support to allow device to charge in LP0
when vbus detection happens through pmic.

Bug 1406615

Change-Id: I2df45587c8d610746ca054439b71878d5391aae7
Signed-off-by: Rohith Seelaboyina <rseelaboyina@nvidia.com>
Reviewed-on: http://git-master/r/344709
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
drivers/usb/gadget/tegra_udc.c
drivers/usb/gadget/tegra_udc.h

index 78499ea4355d2846f87a27c2b47f38026c9c58d0..83ab6ee8831e98eb892f142b02a2f0fe58e4657a 100644 (file)
@@ -2963,6 +2963,10 @@ static int __init tegra_udc_probe(struct platform_device *pdev)
                kfree(udc->edev);
                udc->edev = NULL;
        }
+
+       if (udc->support_pmu_vbus && pdata->vbus_extcon_dev_name)
+               udc->vbus_extcon_dev =
+                       extcon_get_extcon_dev(pdata->vbus_extcon_dev_name);
 #endif
 
        /* Create work for controlling clocks to the phy if otg is disabled */
@@ -3086,14 +3090,21 @@ static int tegra_udc_suspend(struct platform_device *pdev, pm_message_t state)
 
        DBG("%s(%d) BEGIN\n", __func__, __LINE__);
 
-       temp = udc_readl(udc, VBUS_WAKEUP_REG_OFFSET);
-       if (temp & USB_SYS_VBUS_STATUS)
-               udc->vbus_in_lp0 = true;
+       if (udc->support_pmu_vbus) {
+#ifdef CONFIG_EXTCON
+               if (extcon_get_cable_state(udc->vbus_extcon_dev, "USB"))
+                       udc->vbus_in_lp0 = true;
+#endif
+       } else {
+               temp = udc_readl(udc, VBUS_WAKEUP_REG_OFFSET);
+               if (temp & USB_SYS_VBUS_STATUS)
+                       udc->vbus_in_lp0 = true;
+       }
        udc->connect_type_lp0 = udc->connect_type;
 
        /* If the controller is in otg mode, return */
        if (udc->transceiver)
-                       return 0;
+               return 0;
 
        if (udc->vbus_active) {
                spin_lock_irqsave(&udc->lock, flags);
@@ -3105,8 +3116,6 @@ static int tegra_udc_suspend(struct platform_device *pdev, pm_message_t state)
        }
        /* Stop the controller and turn off the clocks */
        dr_controller_stop(udc);
-       if (udc->transceiver)
-               udc->transceiver->state = OTG_STATE_UNDEFINED;
 
        tegra_usb_phy_power_off(udc->phy);
 
@@ -3124,12 +3133,25 @@ static int tegra_udc_resume(struct platform_device *pdev)
        udc->vbus_in_lp0 = false;
 
        /* Set Current limit to 0 if charger is disconnected in LP0 */
-       temp = udc_readl(udc, VBUS_WAKEUP_REG_OFFSET);
-       if ((udc->connect_type_lp0 != CONNECT_TYPE_NONE)
-                       && !(temp & USB_SYS_VBUS_STATUS)) {
-               udc->connect_type_lp0 = CONNECT_TYPE_NONE;
-               if (udc->vbus_reg != NULL)
-                       regulator_set_current_limit(udc->vbus_reg, 0, 0);
+       if (udc->vbus_reg != NULL) {
+               if (udc->support_pmu_vbus) {
+#ifdef CONFIG_EXTCON
+                       if ((udc->connect_type_lp0 != CONNECT_TYPE_NONE) &&
+                       !extcon_get_cable_state(udc->vbus_extcon_dev, "USB")) {
+                               udc->connect_type_lp0 = CONNECT_TYPE_NONE;
+                               regulator_set_current_limit(udc->vbus_reg,
+                                                                        0, 0);
+                       }
+#endif
+               } else {
+                       temp = udc_readl(udc, VBUS_WAKEUP_REG_OFFSET);
+                       if ((udc->connect_type_lp0 != CONNECT_TYPE_NONE) &&
+                                       !(temp & USB_SYS_VBUS_STATUS)) {
+                               udc->connect_type_lp0 = CONNECT_TYPE_NONE;
+                               regulator_set_current_limit(udc->vbus_reg,
+                                                                        0, 0);
+                       }
+               }
        }
 
        if (udc->transceiver)
index b1860f44c38ff3f9e42eff8329ff152a177230d1..bae8dd413c8bc3f790a86b918d995c87d161cf3a 100644 (file)
@@ -476,6 +476,7 @@ struct tegra_udc {
        bool vbus_in_lp0;
 #ifdef CONFIG_EXTCON
        struct extcon_dev *edev;
+       struct extcon_dev *vbus_extcon_dev;
 #endif
 };