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
319319 u32 sink_wait_cap_time;
320320 u32 ps_src_off_time;
321321 u32 cc_debounce_time;
322+ u32 snk_bc12_cmpletion_time;
322323 };
323324
324325 struct tcpm_port {
@@ -4979,7 +4980,16 @@ static void run_state_machine(struct tcpm_port *port) · 4654 unmodified lines
49794980 if (ret < 0)
49804981 tcpm_set_state(port, SNK_UNATTACHED, 0);
49814982 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);
49834993 break;
49844994 case SNK_STARTUP:
49854995 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
70957105 port->timings.cc_debounce_time = val;
70967106 else
70977107 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;
70987112 }
70997113
71007114 static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode)