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

Commit d6d8c102 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "USB: pd: Notify selfpowered state based on type C current"

parents 83a0df57 6494e9ee
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2689,6 +2689,7 @@ static int dwc3_msm_vbus_notifier(struct notifier_block *nb,
	struct extcon_dev *edev = ptr;
	int cc_state;
	int speed;
	int self_powered;

	if (!edev) {
		dev_err(mdwc->dev, "%s: edev null\n", __func__);
@@ -2714,6 +2715,13 @@ static int dwc3_msm_vbus_notifier(struct notifier_block *nb,
	if (dwc->maximum_speed > dwc->max_hw_supp_speed)
		dwc->maximum_speed = dwc->max_hw_supp_speed;

	self_powered = extcon_get_cable_state_(edev,
					EXTCON_USB_TYPEC_MED_HIGH_CURRENT);
	if (self_powered < 0)
		dwc->gadget.is_selfpowered = 0;
	else
		dwc->gadget.is_selfpowered = self_powered;

	mdwc->vbus_active = event;
	if (dwc->is_drd && !mdwc->in_restart) {
		dbg_event(0xFF, "Q RW (vbus)", mdwc->vbus_active);
+4 −0
Original line number Diff line number Diff line
@@ -518,6 +518,10 @@ static int config_buf(struct usb_configuration *config,
	c->iConfiguration = config->iConfiguration;
	c->bmAttributes = USB_CONFIG_ATT_ONE | config->bmAttributes;
	c->bMaxPower = encode_bMaxPower(speed, config);
	if (config->cdev->gadget->is_selfpowered) {
		c->bmAttributes |= USB_CONFIG_ATT_SELFPOWER;
		c->bMaxPower = 0;
	}

	/* There may be e.g. OTG descriptors */
	if (config->descriptors) {
+3 −0
Original line number Diff line number Diff line
@@ -456,6 +456,7 @@ static const unsigned int usbpd_extcon_cable[] = {
	EXTCON_USB_HOST,
	EXTCON_USB_CC,
	EXTCON_USB_SPEED,
	EXTCON_USB_TYPEC_MED_HIGH_CURRENT,
	EXTCON_NONE,
};

@@ -503,6 +504,8 @@ static inline void start_usb_peripheral(struct usbpd *pd)
	extcon_set_cable_state_(pd->extcon, EXTCON_USB_CC,
			cc == ORIENTATION_CC2);
	extcon_set_cable_state_(pd->extcon, EXTCON_USB_SPEED, 1);
	extcon_set_cable_state_(pd->extcon, EXTCON_USB_TYPEC_MED_HIGH_CURRENT,
		pd->typec_mode > POWER_SUPPLY_TYPEC_SOURCE_DEFAULT ? 1 : 0);
	extcon_set_cable_state_(pd->extcon, EXTCON_USB, 1);
}

+3 −0
Original line number Diff line number Diff line
@@ -61,6 +61,9 @@
/* connector speed 0 - High Speed, 1 - super speed */
#define EXTCON_USB_SPEED	29

/* connector type C current 0 - default current, 1 - medium or high current */
#define EXTCON_USB_TYPEC_MED_HIGH_CURRENT	30

/* Display external connector */
#define EXTCON_DISP_HDMI	40	/* High-Definition Multimedia Interface */
#define EXTCON_DISP_MHL		41	/* Mobile High-Definition Link */