usb: pd: Use new power_supply PD_IN_HARD_RESET property
Set the POWER_SUPPLY_PROP_PD_IN_HARD_RESET when hard reset has been issued and clear it when completed. This replaces the previous use of PD_ACTIVE which is now used to indicate assertively whether the port partner is PD capable or not. As such, since charger driver now definitively knows, it is also not necessary to explicitly change PROP_TYPE to USB_PD. Change-Id: I4d8c9fcdf553d1cf1ae79c66932773834804d1a9 Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
parent
9ed824e16b
commit
5b100713ec
1 changed files with 37 additions and 13 deletions
|
@ -658,10 +658,6 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)
|
|||
pd->pd_phy_opened = true;
|
||||
}
|
||||
|
||||
val.intval = 1;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_ACTIVE, &val);
|
||||
|
||||
pd->current_state = PE_SRC_SEND_CAPABILITIES;
|
||||
if (pd->in_pr_swap) {
|
||||
pd->in_pr_swap = false;
|
||||
|
@ -776,6 +772,10 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)
|
|||
}
|
||||
}
|
||||
|
||||
val.intval = 0;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET, &val);
|
||||
|
||||
usbpd_set_state(pd, PE_SRC_STARTUP);
|
||||
break;
|
||||
|
||||
|
@ -1396,6 +1396,9 @@ static void usbpd_sm(struct work_struct *w)
|
|||
memset(&pd->received_pdos, 0, sizeof(pd->received_pdos));
|
||||
|
||||
val.intval = 0;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET, &val);
|
||||
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_ACTIVE, &val);
|
||||
|
||||
|
@ -1434,6 +1437,10 @@ static void usbpd_sm(struct work_struct *w)
|
|||
|
||||
/* Hard reset? */
|
||||
if (pd->hard_reset) {
|
||||
val.intval = 1;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET, &val);
|
||||
|
||||
reset_vdm_state(pd);
|
||||
|
||||
if (pd->current_pr == PR_SINK)
|
||||
|
@ -1506,15 +1513,15 @@ static void usbpd_sm(struct work_struct *w)
|
|||
break;
|
||||
}
|
||||
|
||||
val.intval = 1;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_ACTIVE, &val);
|
||||
|
||||
/* transmit was successful if GoodCRC was received */
|
||||
pd->caps_count = 0;
|
||||
pd->hard_reset_count = 0;
|
||||
pd->pd_connected = true; /* we know peer is PD capable */
|
||||
|
||||
val.intval = pd->psy_type = POWER_SUPPLY_TYPE_USB_PD;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_TYPE, &val);
|
||||
|
||||
/* wait for REQUEST */
|
||||
pd->current_state = PE_SRC_SEND_CAPABILITIES_WAIT;
|
||||
kick_sm(pd, SENDER_RESPONSE_TIME);
|
||||
|
@ -1601,6 +1608,10 @@ static void usbpd_sm(struct work_struct *w)
|
|||
break;
|
||||
|
||||
case PE_SRC_HARD_RESET:
|
||||
val.intval = 1;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET, &val);
|
||||
|
||||
pd_send_hard_reset(pd);
|
||||
pd->in_explicit_contract = false;
|
||||
reset_vdm_state(pd);
|
||||
|
@ -1612,22 +1623,35 @@ static void usbpd_sm(struct work_struct *w)
|
|||
|
||||
case PE_SNK_WAIT_FOR_CAPABILITIES:
|
||||
if (data_recvd == MSG_SOURCE_CAPABILITIES) {
|
||||
val.intval = 0;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET,
|
||||
&val);
|
||||
|
||||
val.intval = 1;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_ACTIVE, &val);
|
||||
|
||||
val.intval = pd->psy_type = POWER_SUPPLY_TYPE_USB_PD;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_TYPE, &val);
|
||||
|
||||
usbpd_set_state(pd, PE_SNK_EVALUATE_CAPABILITY);
|
||||
} else if (pd->hard_reset_count < 3) {
|
||||
usbpd_set_state(pd, PE_SNK_HARD_RESET);
|
||||
} else if (pd->pd_connected) {
|
||||
usbpd_info(&pd->dev, "Sink hard reset count exceeded, forcing reconnect\n");
|
||||
|
||||
val.intval = 0;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET,
|
||||
&val);
|
||||
|
||||
usbpd_set_state(pd, PE_ERROR_RECOVERY);
|
||||
} else {
|
||||
usbpd_dbg(&pd->dev, "Sink hard reset count exceeded, disabling PD\n");
|
||||
|
||||
val.intval = 0;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET,
|
||||
&val);
|
||||
|
||||
val.intval = 0;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_ACTIVE, &val);
|
||||
|
@ -1822,7 +1846,7 @@ static void usbpd_sm(struct work_struct *w)
|
|||
/* prepare charger for VBUS change */
|
||||
val.intval = 1;
|
||||
power_supply_set_property(pd->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_ACTIVE, &val);
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET, &val);
|
||||
|
||||
pd->requested_voltage = 5000000;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue