Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8802df0 authored by Jack Pham's avatar Jack Pham
Browse files

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: default avatarJack Pham <jackp@codeaurora.org>
parent d488c17c
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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");
+7 −0
Original line number Diff line number Diff line
@@ -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 */