Permalink
Browse files

mako OTG patch

  • Loading branch information...
1 parent 25607bc commit d148585787ea35a65f049533a77854450445f3c2 Binky Bear committed with binkybear Oct 22, 2014
Showing with 43 additions and 22 deletions.
  1. +43 −22 drivers/usb/otg/msm_otg.c
View
@@ -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 or 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,18 +3020,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) {
@@ -3144,39 +3159,43 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
goto out;
}
+ // always force req_mode, and use ID_A instead of ID for host mode -ziddey
switch (req_mode) {
case USB_NONE:
- switch (phy->state) {
+ /*switch (phy->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_B_PERIPHERAL:
- set_bit(ID, &motg->inputs);
+ set_bit(ID, &motg->inputs);*/
+ clear_bit(ID_A, &motg->inputs);
clear_bit(B_SESS_VLD, &motg->inputs);
break;
- default:
+ /*default:
goto out;
}
- break;
+ break;*/
case USB_PERIPHERAL:
- switch (phy->state) {
+ /*switch (phy->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_A_HOST:
- set_bit(ID, &motg->inputs);
+ set_bit(ID, &motg->inputs);*/
+ clear_bit(ID_A, &motg->inputs);
set_bit(B_SESS_VLD, &motg->inputs);
break;
- default:
+ /*default:
goto out;
}
- break;
+ break;*/
case USB_HOST:
- switch (phy->state) {
+ /*switch (phy->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_B_PERIPHERAL:
- clear_bit(ID, &motg->inputs);
+ clear_bit(ID, &motg->inputs);*/
+ set_bit(ID_A, &motg->inputs);
break;
- default:
+ /*default:
goto out;
}
- break;
+ break;*/
default:
goto out;
}
@@ -3341,8 +3360,9 @@ static int msm_otg_debugfs_init(struct msm_otg *motg)
if (!msm_otg_dbg_root || IS_ERR(msm_otg_dbg_root))
return -ENODEV;
- if (motg->pdata->mode == USB_OTG &&
- motg->pdata->otg_control == OTG_USER_CONTROL) {
+ // enable /sys/kernel/debug/msm_otg/host -ziddey
+ if (motg->pdata->mode == USB_OTG /*&&
+ motg->pdata->otg_control == OTG_USER_CONTROL*/) {
msm_otg_dentry = debugfs_create_file("mode", S_IRUGO |
S_IWUSR, msm_otg_dbg_root, motg,
@@ -4058,3 +4078,4 @@ module_exit(msm_otg_exit);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MSM USB transceiver driver");
+

0 comments on commit d148585

Please sign in to comment.