usb: typec: tcpm: add devicetree property faster-pd-negotiation to make pd negotiation faster

This commit is contained in:
amazingfate
2023-05-22 14:57:46 +08:00
committed by Mecid Urganci
parent 757191c243
commit 4e9d815ba4

View File

@@ -493,6 +493,7 @@ struct tcpm_port {
int logbuffer_tail;
u8 *logbuffer[LOG_BUFFER_ENTRIES];
#endif
bool faster_pd_negotiation;
};
struct pd_rx_event {
@@ -4296,10 +4297,10 @@ static void run_state_machine(struct tcpm_port *port)
(port->cc1 != TYPEC_CC_OPEN &&
port->cc2 == TYPEC_CC_OPEN))
tcpm_set_state(port, SNK_DEBOUNCED,
PD_T_CC_DEBOUNCE);
port->faster_pd_negotiation ? 100 : PD_T_CC_DEBOUNCE);
else if (tcpm_port_is_disconnected(port))
tcpm_set_state(port, SNK_UNATTACHED,
PD_T_PD_DEBOUNCE);
port->faster_pd_negotiation ? 100 : PD_T_CC_DEBOUNCE);
else if (tcpm_port_is_sink(port))
tcpm_set_state(port, SNK_DEBOUNCED, 0);
break;
@@ -4434,7 +4435,7 @@ static void run_state_machine(struct tcpm_port *port)
if (port->vbus_never_low) {
port->vbus_never_low = false;
tcpm_set_state(port, SNK_SOFT_RESET,
PD_T_SINK_WAIT_CAP);
port->faster_pd_negotiation ? 100 : PD_T_SINK_WAIT_CAP);
} else {
tcpm_set_state(port, hard_reset_state(port),
PD_T_SINK_WAIT_CAP);
@@ -4983,7 +4984,7 @@ static void run_state_machine(struct tcpm_port *port)
case PORT_RESET_WAIT_OFF:
tcpm_set_state(port,
tcpm_default_state(port),
port->vbus_present ? PD_T_PS_SOURCE_OFF : 0);
port->vbus_present ? port->faster_pd_negotiation ? 100 : PD_T_PS_SOURCE_OFF : 0);
break;
/* AMS intermediate state */
@@ -6309,6 +6310,8 @@ sink:
return -EINVAL;
port->operating_snk_mw = mw / 1000;
port->faster_pd_negotiation = fwnode_property_read_bool(fwnode, "faster-pd-negotiation");
/* FRS can only be supported by DRP ports */
if (port->port_type == TYPEC_PORT_DRP) {
ret = fwnode_property_read_u32(fwnode, "new-source-frs-typec-current",