summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorRohith Seelaboyina <rseelaboyina@nvidia.com>2014-05-07 17:00:57 +0530
committerMandar Padmawar <mpadmawar@nvidia.com>2014-05-19 07:45:51 -0700
commit5286ad5b728ceea157c5a96c06466b0013c958de (patch)
treea8c53d41920367005cd9a46be9e66210d47fa19d /drivers/usb
parent3a9518a72a249b2106d91b7ba93f4617fed5311f (diff)
usb: gadget: tegra: Update extcon state properly
If USB cable is disconnected when the device is in LP0, after resuming current limit is set to 0 and accordingly extcon state must be updated with which charger icon also gets updated. Bug 1502977 Change-Id: I171df607d3190191cf821a5b03f93d52cfa25e93 Signed-off-by: Rohith Seelaboyina <rseelaboyina@nvidia.com> Reviewed-on: http://git-master/r/406423 (cherry picked from commit 370c32eae5d11419bb48f6ce2f6d8a37a7d7b8b6) Reviewed-on: http://git-master/r/409576 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/tegra_udc.c14
-rw-r--r--drivers/usb/gadget/tegra_udc.h2
2 files changed, 2 insertions, 14 deletions
diff --git a/drivers/usb/gadget/tegra_udc.c b/drivers/usb/gadget/tegra_udc.c
index 3b0a710d6cda..46bed8cbd9cf 100644
--- a/drivers/usb/gadget/tegra_udc.c
+++ b/drivers/usb/gadget/tegra_udc.c
@@ -1358,7 +1358,6 @@ static void tegra_udc_set_charger_type(struct tegra_udc *udc,
udc->connect_type = type;
}
-#ifdef CONFIG_EXTCON
static void tegra_udc_set_extcon_state(struct tegra_udc *udc)
{
const char **cables;
@@ -1375,7 +1374,6 @@ static void tegra_udc_set_extcon_state(struct tegra_udc *udc)
if (udc->connect_type != udc->connect_type_lp0)
extcon_set_cable_state(edev, cables[udc->connect_type], true);
}
-#endif
static void tegra_udc_notify_event(struct tegra_udc *udc, int event)
{
@@ -1474,9 +1472,7 @@ static int tegra_usb_set_charging_current(struct tegra_udc *udc)
0, max_ua);
}
if (!udc->vbus_in_lp0) {
-#ifdef CONFIG_EXTCON
tegra_udc_set_extcon_state(udc);
-#endif
udc->connect_type_lp0 = CONNECT_TYPE_NONE;
}
return ret;
@@ -2950,7 +2946,6 @@ static int __init tegra_udc_probe(struct platform_device *pdev)
setup_timer(&boost_timer, tegra_udc_set_cpu_freq_normal, 0);
#endif
-#ifdef CONFIG_EXTCON
/* External connector */
udc->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL);
if (!udc->edev) {
@@ -2971,7 +2966,6 @@ static int __init tegra_udc_probe(struct platform_device *pdev)
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 */
INIT_WORK(&udc->irq_work, tegra_udc_irq_work);
@@ -3043,12 +3037,10 @@ static int __exit tegra_udc_remove(struct platform_device *pdev)
return -ENODEV;
}
-#ifdef CONFIG_EXTCON
if (udc->edev != NULL) {
extcon_dev_unregister(udc->edev);
kfree(udc->edev);
}
-#endif
usb_del_gadget_udc(&udc->gadget);
udc->done = &done;
@@ -3096,10 +3088,8 @@ static int tegra_udc_suspend(struct platform_device *pdev, pm_message_t state)
DBG("%s(%d) BEGIN\n", __func__, __LINE__);
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)
@@ -3149,18 +3139,18 @@ 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) {
-#ifdef CONFIG_EXTCON
if ((udc->connect_type_lp0 != CONNECT_TYPE_NONE) &&
!extcon_get_cable_state(udc->vbus_extcon_dev, "USB")) {
+ tegra_udc_set_extcon_state(udc);
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)) {
+ tegra_udc_set_extcon_state(udc);
udc->connect_type_lp0 = CONNECT_TYPE_NONE;
regulator_set_current_limit(udc->vbus_reg,
0, 0);
diff --git a/drivers/usb/gadget/tegra_udc.h b/drivers/usb/gadget/tegra_udc.h
index 44d0a08fa8e2..fe1f5bb7505e 100644
--- a/drivers/usb/gadget/tegra_udc.h
+++ b/drivers/usb/gadget/tegra_udc.h
@@ -478,10 +478,8 @@ struct tegra_udc {
bool fence_read;
bool vbus_in_lp0;
bool charging_supported;
-#ifdef CONFIG_EXTCON
struct extcon_dev *edev;
struct extcon_dev *vbus_extcon_dev;
-#endif
};