Loading drivers/usb/dwc3/dwc3-msm.c +6 −0 Original line number Diff line number Diff line Loading @@ -2238,6 +2238,9 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy, { struct dwc3_msm *mdwc = container_of(psy, struct dwc3_msm, usb_psy); struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3); struct dwc3_otg *dotg = dwc->dotg; struct usb_phy *phy = dotg->otg.phy; switch (psp) { case POWER_SUPPLY_PROP_USB_OTG: Loading Loading @@ -2292,8 +2295,11 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy, mdwc->charger.chg_type = DWC3_SDP_CHARGER; break; case POWER_SUPPLY_TYPE_USB_DCP: mdwc->charger.chg_type = DWC3_DCP_CHARGER; break; case POWER_SUPPLY_TYPE_USB_HVDCP: mdwc->charger.chg_type = DWC3_DCP_CHARGER; usb_phy_set_power(phy, DWC3_HVDCP_CHG_MAX); break; case POWER_SUPPLY_TYPE_USB_CDP: mdwc->charger.chg_type = DWC3_CDP_CHARGER; Loading drivers/usb/dwc3/dwc3_otg.c +18 −10 Original line number Diff line number Diff line Loading @@ -395,7 +395,7 @@ static void dwc3_otg_notify_host_mode(struct usb_otg *otg, int host_mode) static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA) { static int power_supply_type; enum power_supply_property power_supply_type; struct dwc3_otg *dotg = container_of(phy->otg, struct dwc3_otg, otg); Loading @@ -407,6 +407,13 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA) if (dotg->charger->charging_disabled) return 0; if (dotg->charger->chg_type != DWC3_INVALID_CHARGER) { dev_dbg(phy->dev, "SKIP setting power supply type again,chg_type = %d\n", dotg->charger->chg_type); goto skip_psy_type; } if (dotg->charger->chg_type == DWC3_SDP_CHARGER) power_supply_type = POWER_SUPPLY_TYPE_USB; else if (dotg->charger->chg_type == DWC3_CDP_CHARGER) Loading @@ -419,6 +426,8 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA) power_supply_set_supply_type(dotg->psy, power_supply_type); skip_psy_type: if (dotg->charger->chg_type == DWC3_CDP_CHARGER) mA = DWC3_IDEV_CHG_MAX; Loading @@ -427,20 +436,19 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA) dev_info(phy->dev, "Avail curr from USB = %u\n", mA); if (dotg->charger->max_power <= 2 && mA > 2) { /* Enable charging */ if (power_supply_set_online(dotg->psy, true)) goto psy_error; if (power_supply_set_current_limit(dotg->psy, 1000*mA)) goto psy_error; } else if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) { if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) { /* Disable charging */ if (power_supply_set_online(dotg->psy, false)) goto psy_error; } else { /* Enable charging */ if (power_supply_set_online(dotg->psy, true)) goto psy_error; } /* Set max current limit in uA */ if (power_supply_set_current_limit(dotg->psy, 1000*mA)) goto psy_error; } power_supply_changed(dotg->psy); dotg->charger->max_power = mA; Loading drivers/usb/dwc3/dwc3_otg.h +1 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "power.h" #define DWC3_IDEV_CHG_MAX 1500 #define DWC3_HVDCP_CHG_MAX 1800 struct dwc3_charger; Loading Loading @@ -119,5 +120,4 @@ struct dwc3_ext_xceiv { /* for external transceiver driver */ extern int dwc3_set_ext_xceiv(struct usb_otg *otg, struct dwc3_ext_xceiv *ext_xceiv); #endif /* __LINUX_USB_DWC3_OTG_H */ Loading
drivers/usb/dwc3/dwc3-msm.c +6 −0 Original line number Diff line number Diff line Loading @@ -2238,6 +2238,9 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy, { struct dwc3_msm *mdwc = container_of(psy, struct dwc3_msm, usb_psy); struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3); struct dwc3_otg *dotg = dwc->dotg; struct usb_phy *phy = dotg->otg.phy; switch (psp) { case POWER_SUPPLY_PROP_USB_OTG: Loading Loading @@ -2292,8 +2295,11 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy, mdwc->charger.chg_type = DWC3_SDP_CHARGER; break; case POWER_SUPPLY_TYPE_USB_DCP: mdwc->charger.chg_type = DWC3_DCP_CHARGER; break; case POWER_SUPPLY_TYPE_USB_HVDCP: mdwc->charger.chg_type = DWC3_DCP_CHARGER; usb_phy_set_power(phy, DWC3_HVDCP_CHG_MAX); break; case POWER_SUPPLY_TYPE_USB_CDP: mdwc->charger.chg_type = DWC3_CDP_CHARGER; Loading
drivers/usb/dwc3/dwc3_otg.c +18 −10 Original line number Diff line number Diff line Loading @@ -395,7 +395,7 @@ static void dwc3_otg_notify_host_mode(struct usb_otg *otg, int host_mode) static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA) { static int power_supply_type; enum power_supply_property power_supply_type; struct dwc3_otg *dotg = container_of(phy->otg, struct dwc3_otg, otg); Loading @@ -407,6 +407,13 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA) if (dotg->charger->charging_disabled) return 0; if (dotg->charger->chg_type != DWC3_INVALID_CHARGER) { dev_dbg(phy->dev, "SKIP setting power supply type again,chg_type = %d\n", dotg->charger->chg_type); goto skip_psy_type; } if (dotg->charger->chg_type == DWC3_SDP_CHARGER) power_supply_type = POWER_SUPPLY_TYPE_USB; else if (dotg->charger->chg_type == DWC3_CDP_CHARGER) Loading @@ -419,6 +426,8 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA) power_supply_set_supply_type(dotg->psy, power_supply_type); skip_psy_type: if (dotg->charger->chg_type == DWC3_CDP_CHARGER) mA = DWC3_IDEV_CHG_MAX; Loading @@ -427,20 +436,19 @@ static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA) dev_info(phy->dev, "Avail curr from USB = %u\n", mA); if (dotg->charger->max_power <= 2 && mA > 2) { /* Enable charging */ if (power_supply_set_online(dotg->psy, true)) goto psy_error; if (power_supply_set_current_limit(dotg->psy, 1000*mA)) goto psy_error; } else if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) { if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) { /* Disable charging */ if (power_supply_set_online(dotg->psy, false)) goto psy_error; } else { /* Enable charging */ if (power_supply_set_online(dotg->psy, true)) goto psy_error; } /* Set max current limit in uA */ if (power_supply_set_current_limit(dotg->psy, 1000*mA)) goto psy_error; } power_supply_changed(dotg->psy); dotg->charger->max_power = mA; Loading
drivers/usb/dwc3/dwc3_otg.h +1 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "power.h" #define DWC3_IDEV_CHG_MAX 1500 #define DWC3_HVDCP_CHG_MAX 1800 struct dwc3_charger; Loading Loading @@ -119,5 +120,4 @@ struct dwc3_ext_xceiv { /* for external transceiver driver */ extern int dwc3_set_ext_xceiv(struct usb_otg *otg, struct dwc3_ext_xceiv *ext_xceiv); #endif /* __LINUX_USB_DWC3_OTG_H */