usb: pd: Notify USB controller every time Rp changes

Allow USB controller to update its self-powered and bMaxPower
status whenever Rp changes dynamically. The source has a
responsiblity to reset the USB data connection in case Rp changes
to cause the sink to change its status, so make DWC3 driver
re-query for this each time it gets a connect done event.

Change-Id: If3b3ddc353d88599d70580c95175806f14e42096
Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
Jack Pham 2018-10-31 16:15:45 -07:00
parent d488c17c94
commit b8802df07e
2 changed files with 18 additions and 0 deletions

View File

@ -1785,6 +1785,7 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event,
{
struct dwc3_msm *mdwc = dev_get_drvdata(dwc->dev->parent);
struct dwc3_event_buffer *evt;
union extcon_property_value val;
u32 reg;
int i;
@ -1855,6 +1856,16 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event,
PWR_EVNT_LPM_OUT_L1_MASK, 1);
atomic_set(&dwc->in_lpm, 0);
if (mdwc->extcon &&
!extcon_get_property(mdwc->extcon[mdwc->ext_idx].edev,
EXTCON_USB,
EXTCON_PROP_USB_TYPEC_MED_HIGH_CURRENT,
&val))
dwc->gadget.is_selfpowered = val.intval;
else
dwc->gadget.is_selfpowered = 0;
break;
case DWC3_CONTROLLER_NOTIFY_OTG_EVENT:
dev_dbg(mdwc->dev, "DWC3_CONTROLLER_NOTIFY_OTG_EVENT received\n");

View File

@ -3537,6 +3537,8 @@ static inline const char *src_current(enum power_supply_typec_mode typec_mode)
static int usbpd_process_typec_mode(struct usbpd *pd,
enum power_supply_typec_mode typec_mode)
{
union extcon_property_value eval;
switch (typec_mode) {
/* Disconnect */
case POWER_SUPPLY_TYPEC_NONE:
@ -3575,6 +3577,11 @@ static int usbpd_process_typec_mode(struct usbpd *pd,
}
pd->current_pr = PR_SINK;
eval.intval = typec_mode > POWER_SUPPLY_TYPEC_SOURCE_DEFAULT ?
1 : 0;
extcon_set_property(pd->extcon, EXTCON_USB,
EXTCON_PROP_USB_TYPEC_MED_HIGH_CURRENT, eval);
break;
/* Source states */