summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRohith Seelaboyina <rseelaboyina@nvidia.com>2013-07-19 16:13:29 +0530
committerHarshada Kale <hkale@nvidia.com>2013-07-25 02:02:09 -0700
commit9e6bb042d649c77b4eeec43c471a8d0f51f61baa (patch)
tree089999a8e3af9da8e61f682d84e63f8fe5fb0339 /drivers
parentcf52b3f15c946348e0e196278be6039288c79902 (diff)
usb: gadget: tegra: fix schedule work for non-std charger
Work is scheduled to detect non-standard charger whenever can_pullup is successful. Bug 1316950 Change-Id: I8c8b7eb381d311273a77f039964601d5b2535bb2 Signed-off-by: Rohith Seelaboyina <rseelaboyina@nvidia.com> Reviewed-on: http://git-master/r/251164 (cherry picked from commit 7d9bf6522525659f68559c077c817e0305765da7) Reviewed-on: http://git-master/r/252724 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/gadget/tegra_udc.c32
-rw-r--r--drivers/usb/gadget/tegra_udc.h4
2 files changed, 21 insertions, 15 deletions
diff --git a/drivers/usb/gadget/tegra_udc.c b/drivers/usb/gadget/tegra_udc.c
index e8b0e1b7c3ed..a78bed337190 100644
--- a/drivers/usb/gadget/tegra_udc.c
+++ b/drivers/usb/gadget/tegra_udc.c
@@ -376,8 +376,12 @@ static void dr_controller_run(struct tegra_udc *udc)
temp = udc_readl(udc, USB_CMD_REG_OFFSET);
temp &= ~USB_CMD_ITC;
temp |= USB_CMD_ITC_1_MICRO_FRM;
- if (can_pullup(udc))
+ if (can_pullup(udc)) {
temp |= USB_CMD_RUN_STOP;
+ if (udc->connect_type == CONNECT_TYPE_SDP)
+ schedule_delayed_work(&udc->non_std_charger_work,
+ msecs_to_jiffies(NON_STD_CHARGER_DET_TIME_MS));
+ }
else
temp &= ~USB_CMD_RUN_STOP;
udc_writel(udc, temp, USB_CMD_REG_OFFSET);
@@ -1438,16 +1442,6 @@ static int tegra_vbus_session(struct usb_gadget *gadget, int is_active)
if ((udc->connect_type == CONNECT_TYPE_SDP) ||
(udc->connect_type == CONNECT_TYPE_CDP))
dr_controller_run(udc);
-
- /*
- * We cannot tell difference between a SDP and non-standard
- * charger (which has D+/D- line floating) based on line status.
- * Schedule a 7sec delayed work and verify it is an
- * non-standard charger if no setup packet is received.
- */
- if (udc->connect_type == CONNECT_TYPE_SDP)
- schedule_delayed_work(&udc->non_std_charger_work,
- msecs_to_jiffies(NON_STD_CHARGER_DET_TIME_MS));
}
return 0;
@@ -1495,9 +1489,21 @@ static int tegra_pullup(struct usb_gadget *gadget, int is_on)
tmp = udc_readl(udc, USB_CMD_REG_OFFSET);
tmp &= ~USB_CMD_ITC;
tmp |= USB_CMD_ITC_1_MICRO_FRM;
- if (can_pullup(udc))
+ if (can_pullup(udc)) {
udc_writel(udc, tmp | USB_CMD_RUN_STOP, USB_CMD_REG_OFFSET);
- else
+ /*
+ * We cannot tell difference between a SDP and non-standard
+ * charger (which has D+/D- line floating) based on line status
+ * at the time VBUS is detected.
+ *
+ * We can schedule a 4s delayed work and verify it is an
+ * non-standard charger if no setup packet is received after
+ * enumeration started.
+ */
+ if (udc->connect_type == CONNECT_TYPE_SDP)
+ schedule_delayed_work(&udc->non_std_charger_work,
+ msecs_to_jiffies(NON_STD_CHARGER_DET_TIME_MS));
+ } else
udc_writel(udc, (tmp & ~USB_CMD_RUN_STOP), USB_CMD_REG_OFFSET);
DBG("%s(%d) END\n", __func__, __LINE__);
diff --git a/drivers/usb/gadget/tegra_udc.h b/drivers/usb/gadget/tegra_udc.h
index 8a764a801b90..48e5eee1401f 100644
--- a/drivers/usb/gadget/tegra_udc.h
+++ b/drivers/usb/gadget/tegra_udc.h
@@ -44,8 +44,8 @@
#define USB_CHARGING_NV_CHARGER_CURRENT_LIMIT_UA 2000000u
#define USB_CHARGING_NON_STANDARD_CHARGER_CURRENT_LIMIT_UA 500000u
- /* 7 sec wait time for non-std charger detection after vbus is detected */
-#define NON_STD_CHARGER_DET_TIME_MS 7000
+ /* 1 sec wait time for non-std charger detection after vbus is detected */
+#define NON_STD_CHARGER_DET_TIME_MS 1000
#define BOOST_TRIGGER_SIZE 4096
#define UDC_RESET_TIMEOUT_MS 1000