History

usb: typec: tcpm: Add support for sink-bc12-completion-time-ms DT property

Add support for parsing DT time property "sink-bc12-completion-time-ms". This timer is used to relax the PD state machine during Sink attach to allow completion of Battery Charging (BC1.2) charger type detection in TCPC before PD negotiations. BC1.2 detection is a hardware mechanism to detect charger port type that is run by some controllers (such as "maxim,max33359") in parallel to Type-C connection state machines. This is to ensure that BC1.2 completes before PD is enabled as running BC1.2 in parallel with PD negotiation results in delays violating timer constraints in PD spec. This is an optional timer and will not add any delay unless explicitly set.

Amit Sunil Dhamne committed 2 years ago

Commit 237d4e01 parent 3b9d67e1 file · +15 −1Browse files

Unified · Split

drivers/usb/typec/tcpm/tcpm.c+15−1
@@ -319,6 +319,7 @@ struct pd_timings { · 318 unmodified lines
319 u32 sink_wait_cap_time;319 u32 sink_wait_cap_time;
320 u32 ps_src_off_time;320 u32 ps_src_off_time;
321 u32 cc_debounce_time;321 u32 cc_debounce_time;
322 u32 snk_bc12_cmpletion_time;
322};323};
323 324
324struct tcpm_port {325struct tcpm_port {
@@ -4979,7 +4980,16 @@ static void run_state_machine(struct tcpm_port *port) · 4654 unmodified lines
4979 if (ret < 0)4980 if (ret < 0)
4980 tcpm_set_state(port, SNK_UNATTACHED, 0);4981 tcpm_set_state(port, SNK_UNATTACHED, 0);
4981 else4982 else
4982 tcpm_set_state(port, SNK_STARTUP, 0);4983 /*
4984 * For Type C port controllers that use Battery Charging
4985 * Detection (based on BCv1.2 spec) to detect USB
4986 * charger type, add a delay of "snk_bc12_cmpletion_time"
4987 * before transitioning to SNK_STARTUP to allow BC1.2
4988 * detection to complete before PD is eventually enabled
4989 * in later states.
4990 */
4991 tcpm_set_state(port, SNK_STARTUP,
4992 port->timings.snk_bc12_cmpletion_time);
4983 break;4993 break;
4984 case SNK_STARTUP:4994 case SNK_STARTUP:
4985 opmode = tcpm_get_pwr_opmode(port->polarity ?4995 opmode = tcpm_get_pwr_opmode(port->polarity ?
@@ -7095,6 +7105,10 @@ static void tcpm_fw_get_timings(struct tcpm_port *port, struct fwnode_handle *fw · 2109 unmodified lines
7095 port->timings.cc_debounce_time = val;7105 port->timings.cc_debounce_time = val;
7096 else7106 else
7097 port->timings.cc_debounce_time = PD_T_CC_DEBOUNCE;7107 port->timings.cc_debounce_time = PD_T_CC_DEBOUNCE;
7108
7109 ret = fwnode_property_read_u32(fwnode, "sink-bc12-completion-time-ms", &val);
7110 if (!ret)
7111 port->timings.snk_bc12_cmpletion_time = val;
7098}7112}
7099 7113
7100static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode)7114static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode)