Loading drivers/usb/phy/phy-msm-usb.c +13 −11 Original line number Diff line number Diff line Loading @@ -2433,6 +2433,11 @@ static void msm_chg_detect_work(struct work_struct *w) * Notify the charger type to power supply * owner as soon as we determine the charger. */ if (motg->chg_type == USB_DCP_CHARGER && motg->ext_chg_opened) { init_completion(&motg->ext_chg_wait); motg->ext_chg_active = DEFAULT; } msm_otg_notify_chg_type(motg); msm_chg_block_off(motg); msm_chg_enable_aca_det(motg); Loading Loading @@ -2562,7 +2567,7 @@ static void msm_otg_wait_for_ext_chg_done(struct msm_otg *motg) * detection is completed. */ if (motg->ext_chg_active) { if (motg->ext_chg_active == ACTIVE) { do_wait: pr_debug("before msm_otg ext chg wait\n"); Loading @@ -2571,7 +2576,7 @@ do_wait: msecs_to_jiffies(3000)); if (!t) pr_err("msm_otg ext chg wait timeout\n"); else if (motg->ext_chg_active) else if (motg->ext_chg_active == ACTIVE) goto do_wait; else pr_debug("msm_otg ext chg wait done\n"); Loading Loading @@ -2648,11 +2653,6 @@ static void msm_otg_sm_work(struct work_struct *w) case USB_DCP_CHARGER: /* Enable VDP_SRC */ ulpi_write(otg->phy, 0x2, 0x85); if (motg->ext_chg_opened) { init_completion( &motg->ext_chg_wait); motg->ext_chg_active = true; } /* fall through */ case USB_PROPRIETARY_CHARGER: msm_otg_notify_charger(motg, Loading Loading @@ -2722,6 +2722,8 @@ static void msm_otg_sm_work(struct work_struct *w) motg->chg_type = USB_INVALID_CHARGER; msm_otg_notify_charger(motg, 0); if (dcp) { if (motg->ext_chg_active == DEFAULT) motg->ext_chg_active = INACTIVE; msm_otg_wait_for_ext_chg_done(motg); /* Turn off VDP_SRC */ ulpi_write(otg->phy, 0x2, 0x86); Loading Loading @@ -4119,7 +4121,7 @@ msm_otg_ext_chg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) pr_debug("%s: LPM block request %d\n", __func__, val); if (val) { /* block LPM */ if (motg->chg_type == USB_DCP_CHARGER) { motg->ext_chg_active = true; motg->ext_chg_active = ACTIVE; /* * If device is already suspended, resume it. * The PM usage counter is incremented in Loading @@ -4132,12 +4134,12 @@ msm_otg_ext_chg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) else pm_runtime_get_sync(motg->phy.dev); } else { motg->ext_chg_active = false; motg->ext_chg_active = INACTIVE; complete(&motg->ext_chg_wait); ret = -ENODEV; } } else { motg->ext_chg_active = false; motg->ext_chg_active = INACTIVE; complete(&motg->ext_chg_wait); /* * If usb cable is disconnected and then userspace Loading Loading @@ -5078,7 +5080,7 @@ static int msm_otg_runtime_idle(struct device *dev) if (phy->state == OTG_STATE_UNDEFINED) return -EAGAIN; if (motg->ext_chg_active) { if (motg->ext_chg_active == DEFAULT) { dev_dbg(dev, "Deferring LPM\n"); /* * Charger detection may happen in user space. Loading include/linux/usb/msm_hsusb.h +14 −1 Original line number Diff line number Diff line Loading @@ -190,6 +190,19 @@ enum usb_vdd_value { VDD_VAL_MAX, }; /** * Maintain state for hvdcp external charger status * DEFAULT This is used when DCP is detected * ACTIVE This is used when ioctl is called to block LPM * INACTIVE This is used when ioctl is called to unblock LPM */ enum usb_ext_chg_status { DEFAULT = 1, ACTIVE, INACTIVE, }; /** * Supported USB controllers */ Loading Loading @@ -495,7 +508,7 @@ struct msm_otg { struct class *ext_chg_class; struct device *ext_chg_device; bool ext_chg_opened; bool ext_chg_active; enum usb_ext_chg_status ext_chg_active; struct completion ext_chg_wait; struct pinctrl *phy_pinctrl; int ui_enabled; Loading Loading
drivers/usb/phy/phy-msm-usb.c +13 −11 Original line number Diff line number Diff line Loading @@ -2433,6 +2433,11 @@ static void msm_chg_detect_work(struct work_struct *w) * Notify the charger type to power supply * owner as soon as we determine the charger. */ if (motg->chg_type == USB_DCP_CHARGER && motg->ext_chg_opened) { init_completion(&motg->ext_chg_wait); motg->ext_chg_active = DEFAULT; } msm_otg_notify_chg_type(motg); msm_chg_block_off(motg); msm_chg_enable_aca_det(motg); Loading Loading @@ -2562,7 +2567,7 @@ static void msm_otg_wait_for_ext_chg_done(struct msm_otg *motg) * detection is completed. */ if (motg->ext_chg_active) { if (motg->ext_chg_active == ACTIVE) { do_wait: pr_debug("before msm_otg ext chg wait\n"); Loading @@ -2571,7 +2576,7 @@ do_wait: msecs_to_jiffies(3000)); if (!t) pr_err("msm_otg ext chg wait timeout\n"); else if (motg->ext_chg_active) else if (motg->ext_chg_active == ACTIVE) goto do_wait; else pr_debug("msm_otg ext chg wait done\n"); Loading Loading @@ -2648,11 +2653,6 @@ static void msm_otg_sm_work(struct work_struct *w) case USB_DCP_CHARGER: /* Enable VDP_SRC */ ulpi_write(otg->phy, 0x2, 0x85); if (motg->ext_chg_opened) { init_completion( &motg->ext_chg_wait); motg->ext_chg_active = true; } /* fall through */ case USB_PROPRIETARY_CHARGER: msm_otg_notify_charger(motg, Loading Loading @@ -2722,6 +2722,8 @@ static void msm_otg_sm_work(struct work_struct *w) motg->chg_type = USB_INVALID_CHARGER; msm_otg_notify_charger(motg, 0); if (dcp) { if (motg->ext_chg_active == DEFAULT) motg->ext_chg_active = INACTIVE; msm_otg_wait_for_ext_chg_done(motg); /* Turn off VDP_SRC */ ulpi_write(otg->phy, 0x2, 0x86); Loading Loading @@ -4119,7 +4121,7 @@ msm_otg_ext_chg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) pr_debug("%s: LPM block request %d\n", __func__, val); if (val) { /* block LPM */ if (motg->chg_type == USB_DCP_CHARGER) { motg->ext_chg_active = true; motg->ext_chg_active = ACTIVE; /* * If device is already suspended, resume it. * The PM usage counter is incremented in Loading @@ -4132,12 +4134,12 @@ msm_otg_ext_chg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) else pm_runtime_get_sync(motg->phy.dev); } else { motg->ext_chg_active = false; motg->ext_chg_active = INACTIVE; complete(&motg->ext_chg_wait); ret = -ENODEV; } } else { motg->ext_chg_active = false; motg->ext_chg_active = INACTIVE; complete(&motg->ext_chg_wait); /* * If usb cable is disconnected and then userspace Loading Loading @@ -5078,7 +5080,7 @@ static int msm_otg_runtime_idle(struct device *dev) if (phy->state == OTG_STATE_UNDEFINED) return -EAGAIN; if (motg->ext_chg_active) { if (motg->ext_chg_active == DEFAULT) { dev_dbg(dev, "Deferring LPM\n"); /* * Charger detection may happen in user space. Loading
include/linux/usb/msm_hsusb.h +14 −1 Original line number Diff line number Diff line Loading @@ -190,6 +190,19 @@ enum usb_vdd_value { VDD_VAL_MAX, }; /** * Maintain state for hvdcp external charger status * DEFAULT This is used when DCP is detected * ACTIVE This is used when ioctl is called to block LPM * INACTIVE This is used when ioctl is called to unblock LPM */ enum usb_ext_chg_status { DEFAULT = 1, ACTIVE, INACTIVE, }; /** * Supported USB controllers */ Loading Loading @@ -495,7 +508,7 @@ struct msm_otg { struct class *ext_chg_class; struct device *ext_chg_device; bool ext_chg_opened; bool ext_chg_active; enum usb_ext_chg_status ext_chg_active; struct completion ext_chg_wait; struct pinctrl *phy_pinctrl; int ui_enabled; Loading