@@ -314,12 +314,16 @@ struct pd_data {
* @sink_wait_cap_time: Deadline (in ms) for tTypeCSinkWaitCap timer
* @ps_src_wait_off_time: Deadline (in ms) for tPSSourceOff timer
* @cc_debounce_time: Deadline (in ms) for tCCDebounce timer
+ * @pd2_sender_response_time: Deadline (in ms) for pd20 tSenderResponse timer
+ * @pd3_sender_response_time: Deadline (in ms) for pd30 tSenderResponse timer
*/
struct pd_timings {
u32 sink_wait_cap_time;
u32 ps_src_off_time;
u32 cc_debounce_time;
u32 snk_bc12_cmpletion_time;
+ u32 pd2_sender_response_time;
+ u32 pd3_sender_response_time;
};
struct tcpm_port {
@@ -3776,7 +3780,9 @@ static bool tcpm_send_queued_message(struct tcpm_port *port)
} else if (port->pwr_role == TYPEC_SOURCE) {
tcpm_ams_finish(port);
tcpm_set_state(port, HARD_RESET_SEND,
- PD_T_SENDER_RESPONSE);
+ port->negotiated_rev >= PD_REV30 ?
+ port->timings.pd3_sender_response_time :
+ port->timings.pd2_sender_response_time);
} else {
tcpm_ams_finish(port);
}
@@ -4619,6 +4625,9 @@ static void run_state_machine(struct tcpm_port *port)
enum typec_pwr_opmode opmode;
unsigned int msecs;
enum tcpm_state upcoming_state;
+ u32 sender_response_time = port->negotiated_rev >= PD_REV30 ?
+ port->timings.pd3_sender_response_time :
+ port->timings.pd2_sender_response_time;
if (port->tcpc->check_contaminant && port->state != CHECK_CONTAMINANT)
port->potential_contaminant = ((port->enter_state == SRC_ATTACH_WAIT &&
@@ -5113,7 +5122,7 @@ static void run_state_machine(struct tcpm_port *port)
tcpm_set_state(port, SNK_WAIT_CAPABILITIES, 0);
} else {
tcpm_set_state_cond(port, hard_reset_state(port),
- PD_T_SENDER_RESPONSE);
+ sender_response_time);
}
break;
case SNK_NEGOTIATE_PPS_CAPABILITIES:
@@ -5135,7 +5144,7 @@ static void run_state_machine(struct tcpm_port *port)
tcpm_set_state(port, SNK_READY, 0);
} else {
tcpm_set_state_cond(port, hard_reset_state(port),
- PD_T_SENDER_RESPONSE);
+ sender_response_time);
}
break;
case SNK_TRANSITION_SINK:
@@ -5387,7 +5396,7 @@ static void run_state_machine(struct tcpm_port *port)
port->message_id_prime = 0;
port->rx_msgid_prime = -1;
tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET, TCPC_TX_SOP_PRIME);
- tcpm_set_state_cond(port, ready_state(port), PD_T_SENDER_RESPONSE);
+ tcpm_set_state_cond(port, ready_state(port), sender_response_time);
} else {
port->message_id = 0;
port->rx_msgid = -1;
@@ -5398,7 +5407,7 @@ static void run_state_machine(struct tcpm_port *port)
tcpm_set_state_cond(port, hard_reset_state(port), 0);
else
tcpm_set_state_cond(port, hard_reset_state(port),
- PD_T_SENDER_RESPONSE);
+ sender_response_time);
}
break;
@@ -5409,8 +5418,7 @@ static void run_state_machine(struct tcpm_port *port)
port->send_discover = true;
port->send_discover_prime = false;
}
- tcpm_set_state_cond(port, DR_SWAP_SEND_TIMEOUT,
- PD_T_SENDER_RESPONSE);
+ tcpm_set_state_cond(port, DR_SWAP_SEND_TIMEOUT, sender_response_time);
break;
case DR_SWAP_ACCEPT:
tcpm_pd_send_control(port, PD_CTRL_ACCEPT, TCPC_TX_SOP);
@@ -5444,7 +5452,7 @@ static void run_state_machine(struct tcpm_port *port)
tcpm_set_state(port, ERROR_RECOVERY, 0);
break;
}
- tcpm_set_state_cond(port, FR_SWAP_SEND_TIMEOUT, PD_T_SENDER_RESPONSE);
+ tcpm_set_state_cond(port, FR_SWAP_SEND_TIMEOUT, sender_response_time);
break;
case FR_SWAP_SEND_TIMEOUT:
tcpm_set_state(port, ERROR_RECOVERY, 0);
@@ -5475,8 +5483,7 @@ static void run_state_machine(struct tcpm_port *port)
break;
case PR_SWAP_SEND:
tcpm_pd_send_control(port, PD_CTRL_PR_SWAP, TCPC_TX_SOP);
- tcpm_set_state_cond(port, PR_SWAP_SEND_TIMEOUT,
- PD_T_SENDER_RESPONSE);
+ tcpm_set_state_cond(port, PR_SWAP_SEND_TIMEOUT, sender_response_time);
break;
case PR_SWAP_SEND_TIMEOUT:
tcpm_swap_complete(port, -ETIMEDOUT);
@@ -5574,8 +5581,7 @@ static void run_state_machine(struct tcpm_port *port)
break;
case VCONN_SWAP_SEND:
tcpm_pd_send_control(port, PD_CTRL_VCONN_SWAP, TCPC_TX_SOP);
- tcpm_set_state(port, VCONN_SWAP_SEND_TIMEOUT,
- PD_T_SENDER_RESPONSE);
+ tcpm_set_state(port, VCONN_SWAP_SEND_TIMEOUT, sender_response_time);
break;
case VCONN_SWAP_SEND_TIMEOUT:
tcpm_swap_complete(port, -ETIMEDOUT);
@@ -5656,23 +5662,21 @@ static void run_state_machine(struct tcpm_port *port)
break;
case GET_STATUS_SEND:
tcpm_pd_send_control(port, PD_CTRL_GET_STATUS, TCPC_TX_SOP);
- tcpm_set_state(port, GET_STATUS_SEND_TIMEOUT,
- PD_T_SENDER_RESPONSE);
+ tcpm_set_state(port, GET_STATUS_SEND_TIMEOUT, sender_response_time);
break;
case GET_STATUS_SEND_TIMEOUT:
tcpm_set_state(port, ready_state(port), 0);
break;
case GET_PPS_STATUS_SEND:
tcpm_pd_send_control(port, PD_CTRL_GET_PPS_STATUS, TCPC_TX_SOP);
- tcpm_set_state(port, GET_PPS_STATUS_SEND_TIMEOUT,
- PD_T_SENDER_RESPONSE);
+ tcpm_set_state(port, GET_PPS_STATUS_SEND_TIMEOUT, sender_response_time);
break;
case GET_PPS_STATUS_SEND_TIMEOUT:
tcpm_set_state(port, ready_state(port), 0);
break;
case GET_SINK_CAP:
tcpm_pd_send_control(port, PD_CTRL_GET_SINK_CAP, TCPC_TX_SOP);
- tcpm_set_state(port, GET_SINK_CAP_TIMEOUT, PD_T_SENDER_RESPONSE);
+ tcpm_set_state(port, GET_SINK_CAP_TIMEOUT, sender_response_time);
break;
case GET_SINK_CAP_TIMEOUT:
port->sink_cap_done = true;
@@ -7109,6 +7113,18 @@ static void tcpm_fw_get_timings(struct tcpm_port *port, struct fwnode_handle *fw
ret = fwnode_property_read_u32(fwnode, "sink-bc12-completion-time-ms", &val);
if (!ret)
port->timings.snk_bc12_cmpletion_time = val;
+
+ ret = fwnode_property_read_u32(fwnode, "pd2-sender-response-time-ms", &val);
+ if (!ret)
+ port->timings.pd2_sender_response_time = val;
+ else
+ port->timings.pd2_sender_response_time = PD_T_PD2_SENDER_RESPONSE;
+
+ ret = fwnode_property_read_u32(fwnode, "pd3-sender-response-time-ms", &val);
+ if (!ret)
+ port->timings.pd3_sender_response_time = val;
+ else
+ port->timings.pd3_sender_response_time = PD_T_PD3_SENDER_RESPONSE;
}
static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode)
@@ -457,7 +457,6 @@ static inline unsigned int rdo_max_power(u32 rdo)
#define PD_T_NO_RESPONSE 5000 /* 4.5 - 5.5 seconds */
#define PD_T_DB_DETECT 10000 /* 10 - 15 seconds */
#define PD_T_SEND_SOURCE_CAP 150 /* 100 - 200 ms */
-#define PD_T_SENDER_RESPONSE 60 /* 24 - 30 ms, relaxed */
#define PD_T_RECEIVER_RESPONSE 15 /* 15ms max */
#define PD_T_SOURCE_ACTIVITY 45
#define PD_T_SINK_ACTIVITY 135
@@ -491,6 +490,8 @@ static inline unsigned int rdo_max_power(u32 rdo)
#define PD_T_CC_DEBOUNCE 200 /* 100 - 200 ms */
#define PD_T_PD_DEBOUNCE 20 /* 10 - 20 ms */
#define PD_T_TRY_CC_DEBOUNCE 15 /* 10 - 20 ms */
+#define PD_T_PD2_SENDER_RESPONSE 27 /* PD20 spec 24 - 30 ms */
+#define PD_T_PD3_SENDER_RESPONSE 30 /* PD30 spec 27 - 33 ms */
#define PD_N_CAPS_COUNT (PD_T_NO_RESPONSE / PD_T_SEND_SOURCE_CAP)
#define PD_N_HARD_RESET_COUNT 2