Skip to content

Commit

Permalink
msm_otg: hack to allow automatic usb host mode (externally powered)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ziddey committed Oct 17, 2013
1 parent 84ad865 commit a78f598
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions drivers/usb/otg/msm_otg.c
Expand Up @@ -1138,7 +1138,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) &&
Expand Down Expand Up @@ -1244,9 +1245,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:
Expand Down Expand Up @@ -2166,8 +2170,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;

Expand Down Expand Up @@ -3023,18 +3032,24 @@ 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");
set_bit(B_SESS_VLD, &motg->inputs);
} 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) {
Expand Down

0 comments on commit a78f598

Please sign in to comment.