Merge "USB: pd: Notify selfpowered state based on type C current"
This commit is contained in:
commit
d6d8c10244
4 changed files with 18 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue