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

Commit c860b6ac authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa Committed by Jack Pham
Browse files

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



It is required to notify device as selfpowered and bmaxpower as zero
even for non PD capable devices based on Type C current. Hence notify
as selfpowerer in bMattributes of configuation descriptor in case of
medium or high Type C current.

Change-Id: Ie552560d93a8195f4c69fdaf6086ef3a52b31d39
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 85596bb4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2718,6 +2718,13 @@ static void dwc3_resume_work(struct work_struct *w)
					ORIENTATION_CC2 : ORIENTATION_CC1;

		dbg_event(0xFF, "cc_state", mdwc->typec_orientation);

		ret = extcon_get_property(edev, extcon_id,
				EXTCON_PROP_USB_TYPEC_MED_HIGH_CURRENT, &val);
		if (!ret)
			dwc->gadget.is_selfpowered = val.intval;
		else
			dwc->gadget.is_selfpowered = 0;
	}

	/*
+4 −0
Original line number Diff line number Diff line
@@ -574,6 +574,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) {
+6 −0
Original line number Diff line number Diff line
@@ -550,6 +550,10 @@ static inline void start_usb_peripheral(struct usbpd *pd)
	val.intval = 1;
	extcon_set_property(pd->extcon, EXTCON_USB, EXTCON_PROP_USB_SS, val);

	val.intval = pd->typec_mode > POWER_SUPPLY_TYPEC_SOURCE_DEFAULT ? 1 : 0;
	extcon_set_property(pd->extcon, EXTCON_USB,
			EXTCON_PROP_USB_TYPEC_MED_HIGH_CURRENT, val);

	extcon_set_state_sync(pd->extcon, EXTCON_USB, 1);
}

@@ -4126,6 +4130,8 @@ struct usbpd *usbpd_create(struct device *parent)
			EXTCON_PROP_USB_TYPEC_POLARITY);
	extcon_set_property_capability(pd->extcon, EXTCON_USB,
			EXTCON_PROP_USB_SS);
	extcon_set_property_capability(pd->extcon, EXTCON_USB,
			EXTCON_PROP_USB_TYPEC_MED_HIGH_CURRENT);
	extcon_set_property_capability(pd->extcon, EXTCON_USB_HOST,
			EXTCON_PROP_USB_TYPEC_POLARITY);
	extcon_set_property_capability(pd->extcon, EXTCON_USB_HOST,
+6 −1
Original line number Diff line number Diff line
@@ -124,14 +124,19 @@
 * @type:       integer (intval)
 * @value:      0 (USB/USB2) or 1 (USB3)
 * @default:    0 (USB/USB2)
 * - EXTCON_PROP_USB_TYPEC_MED_HIGH_CURRENT
 * @type:       integer (intval)
 * @value:      0 (default current), 1 (medium or high current)
 * @default:    0 (default current)
 *
 */
#define EXTCON_PROP_USB_VBUS		0
#define EXTCON_PROP_USB_TYPEC_POLARITY	1
#define EXTCON_PROP_USB_SS		2
#define EXTCON_PROP_USB_TYPEC_MED_HIGH_CURRENT	3

#define EXTCON_PROP_USB_MIN		0
#define EXTCON_PROP_USB_MAX		2
#define EXTCON_PROP_USB_MAX		3
#define EXTCON_PROP_USB_CNT	(EXTCON_PROP_USB_MAX - EXTCON_PROP_USB_MIN + 1)

/* Properties of EXTCON_TYPE_CHG. */