Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0acf512

Browse files
amitsd2Treehugger Robot
authored andcommitted
UPSTREAM: 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. Signed-off-by: Amit Sunil Dhamne <[email protected]> Reviewed-by: Badhri Jagan Sridharan <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Bug: 296723174 Change-Id: I289a0c59c3a40d4470c666e6a92a8fb589eab340 Signed-off-by: Amit Sunil Dhamne <[email protected]> (cherry picked from commit 237d4e0)
1 parent 7585318 commit 0acf512

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ struct pd_timings {
314314
u32 sink_wait_cap_time;
315315
u32 ps_src_off_time;
316316
u32 cc_debounce_time;
317+
u32 snk_bc12_cmpletion_time;
317318
};
318319

319320
struct tcpm_port {
@@ -4292,7 +4293,16 @@ static void run_state_machine(struct tcpm_port *port)
42924293
if (ret < 0)
42934294
tcpm_set_state(port, SNK_UNATTACHED, 0);
42944295
else
4295-
tcpm_set_state(port, SNK_STARTUP, 0);
4296+
/*
4297+
* For Type C port controllers that use Battery Charging
4298+
* Detection (based on BCv1.2 spec) to detect USB
4299+
* charger type, add a delay of "snk_bc12_cmpletion_time"
4300+
* before transitioning to SNK_STARTUP to allow BC1.2
4301+
* detection to complete before PD is eventually enabled
4302+
* in later states.
4303+
*/
4304+
tcpm_set_state(port, SNK_STARTUP,
4305+
port->timings.snk_bc12_cmpletion_time);
42964306
break;
42974307
case SNK_STARTUP:
42984308
opmode = tcpm_get_pwr_opmode(port->polarity ?
@@ -6305,6 +6315,10 @@ static void tcpm_fw_get_timings(struct tcpm_port *port, struct fwnode_handle *fw
63056315
port->timings.cc_debounce_time = val;
63066316
else
63076317
port->timings.cc_debounce_time = PD_T_CC_DEBOUNCE;
6318+
6319+
ret = fwnode_property_read_u32(fwnode, "sink-bc12-completion-time-ms", &val);
6320+
if (!ret)
6321+
port->timings.snk_bc12_cmpletion_time = val;
63086322
}
63096323

63106324
static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode)

0 commit comments

Comments
 (0)