diff options
| author | Jibben Nee <ziddey@ijib.com> | 2013-10-16 22:54:54 -0400 |
|---|---|---|
| committer | Toni Toivanen <tonitoivanen95@gmail.com> | 2014-05-11 16:19:43 +0300 |
| commit | 5b3d457e132569dee15997f9fcfe1001c57810de (patch) | |
| tree | 9b79a068484709c00d106090303f883ef69c957b | |
| parent | 10af1ed7a993714fcd775aca469ced708f639e2b (diff) | |
msm_otg: hack to allow automatic usb host mode (externally powered)
Force ID_A (host mode + charging) on detection of proprietary charger (Apple-compatible charger with voltage on D+/D-).
Unforce ID_A on PMIC: BSV clear (detection of loss of charger).
Use charger type ACA_DOCK and allow up to 1.5A charge rate in host mode.
Change-Id: I227b6278d16d530d518c501335824c4b19ebe866
| -rw-r--r-- | drivers/usb/otg/msm_otg.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c index 50d2209753e..68ecce4f1e9 100644 --- a/drivers/usb/otg/msm_otg.c +++ b/drivers/usb/otg/msm_otg.c @@ -1133,7 +1133,8 @@ static void msm_otg_notify_charger(struct msm_otg *motg, unsigned mA) if (g && g->is_a_peripheral) return; - if ((motg->chg_type == USB_ACA_DOCK_CHARGER || + // charge limit should not be imposed for dock charger -ziddey + if ((//motg->chg_type == USB_ACA_DOCK_CHARGER || motg->chg_type == USB_ACA_A_CHARGER || motg->chg_type == USB_ACA_B_CHARGER || motg->chg_type == USB_ACA_C_CHARGER) && @@ -1232,9 +1233,12 @@ static int msm_otg_usbdev_notify(struct notifier_block *self, * ACA dock can supply IDEV_CHG irrespective devices connected * on the accessory port. */ - if (!udev->parent || udev->parent->parent || + + // do not cause required code to be skipped -ziddey + // will not switch to a_host / charge otherwise + /*if (!udev->parent || udev->parent->parent || motg->chg_type == USB_ACA_DOCK_CHARGER) - goto out; + goto out;*/ switch (action) { case USB_DEVICE_ADD: @@ -2154,8 +2158,13 @@ static void msm_chg_detect_work(struct work_struct *w) break; } - if (line_state) /* DP > VLGC or/and DM > VLGC */ - motg->chg_type = USB_PROPRIETARY_CHARGER; + if (line_state) /* DP > VLGC or/and DM > VLGC */ { + // simulate ID_A to force host mode with charging -ziddey + pr_info("*** FORCING USB HOST MODE WITH CHARGING ***\n"); + set_bit(ID_A, &motg->inputs); + motg->chg_type = USB_ACA_DOCK_CHARGER; + //motg->chg_type = USB_PROPRIETARY_CHARGER; + } else motg->chg_type = USB_SDP_CHARGER; @@ -3011,11 +3020,13 @@ static void msm_otg_set_vbus_state(int online) { static bool init; struct msm_otg *motg = the_msm_otg; - struct usb_otg *otg = motg->phy.otg; + + // need BSV interrupt in A Host Mode to detect cable unplug -ziddey + //struct usb_otg *otg = motg->phy.otg; /* In A Host Mode, ignore received BSV interrupts */ - if (otg->phy->state >= OTG_STATE_A_IDLE) - return; + /*if (otg->phy->state >= OTG_STATE_A_IDLE) + return;*/ if (online) { pr_debug("PMIC: BSV set\n"); @@ -3023,6 +3034,10 @@ static void msm_otg_set_vbus_state(int online) } else { pr_debug("PMIC: BSV clear\n"); clear_bit(B_SESS_VLD, &motg->inputs); + + // disable host mode (if enabled) -ziddey + if (test_and_clear_bit(ID_A, &motg->inputs)) + pr_info("*** UNFORCING USB HOST MODE ***\n"); } if (!init) { |
