Line data Source code
1 1 : /*
2 : * Copyright 2022 The Chromium OS Authors
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : /**
7 : * @file
8 : * @brief USB Type-C Cable and Connector API used for USB-C drivers
9 : *
10 : * The information in this file was taken from the USB Type-C
11 : * Cable and Connector Specification Release 2.1
12 : */
13 :
14 : #ifndef ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_TC_H_
15 : #define ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_TC_H_
16 :
17 : /**
18 : * @brief Support for USB Type-C cables and connectors
19 : * @defgroup usb_type_c USB Type-C
20 : * @ingroup usb_interfaces
21 : * @{
22 : */
23 :
24 : #include <zephyr/types.h>
25 :
26 : #ifdef __cplusplus
27 : extern "C" {
28 : #endif
29 :
30 : /**
31 : * @brief VBUS minimum for a sink disconnect detection.
32 : * See Table 4-3 VBUS Sink Characteristics
33 : */
34 1 : #define TC_V_SINK_DISCONNECT_MIN_MV 800
35 :
36 : /**
37 : * @brief VBUS maximum for a sink disconnect detection.
38 : * See Table 4-3 VBUS Sink Characteristics
39 : */
40 1 : #define TC_V_SINK_DISCONNECT_MAX_MV 3670
41 :
42 : /**
43 : * @brief From entry to Attached.SRC until VBUS reaches the minimum vSafe5V threshold as
44 : * measured at the source’s receptacle
45 : * See Table 4-29 VBUS and VCONN Timing Parameters
46 : */
47 1 : #define TC_T_VBUS_ON_MAX_MS 275
48 :
49 : /**
50 : * @brief From the time the Sink is detached until the Source removes VBUS and reaches
51 : * vSafe0V (See USB PD).
52 : * See Table 4-29 VBUS and VCONN Timing Parameters
53 : */
54 1 : #define TC_T_VBUS_OFF_MAX_MS 650
55 :
56 : /**
57 : * @brief From the time the Source supplied VBUS in the Attached.SRC state.
58 : * See Table 4-29 VBUS and VCONN Timing Parameters
59 : */
60 1 : #define TC_T_VCONN_ON_MAX_MS 2
61 :
62 : /**
63 : * @brief From the time a Sink with accessory support enters the PoweredAccessory state
64 : * until the Sink sources minimum VCONN voltage (see Table 4-5)
65 : * See Table 4-29 VBUS and VCONN Timing Parameters
66 : */
67 1 : #define TC_T_VCONN_ON_PA_MAX_MS 100
68 :
69 : /**
70 : * @brief From the time that a Sink is detached or as directed until the VCONN supply is
71 : * disconnected.
72 : * See Table 4-29 VBUS and VCONN Timing Parameters
73 : */
74 1 : #define TC_T_VCONN_OFF_MAX_MS 35
75 :
76 : /**
77 : * @brief Response time for a Sink to adjust its current consumption to be in the specified
78 : * range due to a change in USB Type-C Current advertisement
79 : * See Table 4-29 VBUS and VCONN Timing Parameters
80 : */
81 1 : #define TC_T_SINK_ADJ_MAX_MS 60
82 :
83 : /**
84 : * @brief The minimum period a DRP shall complete a Source to Sink and back advertisement
85 : * See Table 4-30 DRP Timing Parameters
86 : */
87 1 : #define TC_T_DRP_MIN_MS 50
88 :
89 : /**
90 : * @brief The maximum period a DRP shall complete a Source to Sink and back advertisement
91 : * See Table 4-30 DRP Timing Parameters
92 : */
93 1 : #define TC_T_DRP_MAX_MS 100
94 :
95 : /**
96 : * @brief The minimum time a DRP shall complete transitions between Source and Sink roles
97 : * during role resolution
98 : * See Table 4-30 DRP Timing Parameters
99 : */
100 1 : #define TC_T_DRP_TRANSITION_MIN_MS 0
101 :
102 : /**
103 : * @brief The maximum time a DRP shall complete transitions between Source and Sink roles
104 : * during role resolution
105 : * See Table 4-30 DRP Timing Parameters
106 : */
107 1 : #define TC_T_DRP_TRANSITION_MAX_MS 1
108 :
109 : /**
110 : * @brief Minimum wait time associated with the Try.SRC state.
111 : * See Table 4-30 DRP Timing Parameters
112 : */
113 1 : #define TC_T_DRP_TRY_MIN_MS 75
114 :
115 : /**
116 : * @brief Maximum wait time associated with the Try.SRC state.
117 : * See Table 4-30 DRP Timing Parameters
118 : */
119 1 : #define TC_T_DRP_TRY_MAX_MS 150
120 :
121 : /**
122 : * @brief Minimum wait time associated with the Try.SNK state.
123 : * See Table 4-30 DRP Timing Parameters
124 : */
125 1 : #define TC_T_DRP_TRY_WAIT_MIN_MS 400
126 :
127 : /**
128 : * @brief Maximum wait time associated with the Try.SNK state.
129 : * See Table 4-30 DRP Timing Parameters
130 : */
131 1 : #define TC_T_DRP_TRY_WAIT_MAX_MS 800
132 :
133 : /**
134 : * @brief Minimum timeout for transition from Try.SRC to TryWait.SNK.
135 : * See Table 4-30 DRP Timing Parameters
136 : */
137 1 : #define TC_T_TRY_TIMEOUT_MIN_MS 550
138 :
139 : /**
140 : * @brief Maximum timeout for transition from Try.SRC to TryWait.SNK.
141 : * See Table 4-30 DRP Timing Parameters
142 : */
143 1 : #define TC_T_TRY_TIMEOUT_MAX_MS 1100
144 :
145 : /**
146 : * @brief Minimum Time for a DRP to detect that the connected Charge-Through VCONNPowered
147 : * USB Device has been detached, after VBUS has been removed.
148 : * See Table 4-30 DRP Timing Parameters
149 : */
150 1 : #define TC_T_VPD_DETACH_MIN_MS 10
151 :
152 : /**
153 : * @brief Maximum Time for a DRP to detect that the connected Charge-Through VCONNPowered
154 : * USB Device has been detached, after VBUS has been removed.
155 : * See Table 4-30 DRP Timing Parameters
156 : */
157 1 : #define TC_T_VPD_DETACH_MAX_MS 20
158 :
159 : /**
160 : * @brief Minimum time a port shall wait before it can determine it is attached
161 : * See Table 4-31 CC Timing
162 : */
163 1 : #define TC_T_CC_DEBOUNCE_MIN_MS 100
164 :
165 : /**
166 : * @brief Maximum time a port shall wait before it can determine it is attached
167 : * See Table 4-31 CC Timing
168 : */
169 1 : #define TC_T_CC_DEBOUNCE_MAX_MS 200
170 :
171 : /**
172 : * @brief Minimum time a Sink port shall wait before it can determine it is detached due to
173 : * the potential for USB PD signaling on CC as described in the state definitions.
174 : * See Table 4-31 CC Timing
175 : */
176 1 : #define TC_T_PD_DEBOUNCE_MIN_MS 10
177 :
178 : /**
179 : * @brief Maximum time a Sink port shall wait before it can determine it is detached due to
180 : * the potential for USB PD signaling on CC as described in the state definitions.
181 : * See Table 4-31 CC Timing
182 : */
183 1 : #define TC_T_PD_DEBOUNCE_MAX_MS 20
184 :
185 : /**
186 : * @brief Minimum Time a port shall wait before it can determine it is re-attached during
187 : * the try-wait process.
188 : * See Table 4-31 CC Timing
189 : */
190 1 : #define TC_T_TRY_CC_DEBOUNCE_MIN_MS 10
191 :
192 : /**
193 : * @brief Maximum Time a port shall wait before it can determine it is re-attached during
194 : * the try-wait process.
195 : * See Table 4-31 CC Timing
196 : */
197 1 : #define TC_T_TRY_CC_DEBOUNCE_MAX_MS 10
198 :
199 : /**
200 : * @brief Minimum time a self-powered port shall remain in the ErrorRecovery state.
201 : * See Table 4-31 CC Timing
202 : */
203 1 : #define TC_T_ERROR_RECOVERY_SELF_POWERED_MIN_MS 25
204 :
205 : /**
206 : * @brief Minimum time a source shall remain in the ErrorRecovery state if it was sourcing
207 : * VCONN in the previous state.
208 : * See Table 4-31 CC Timing
209 : */
210 1 : #define TC_T_ERROR_RECOVERY_SOURCE_MIN_MS 240
211 :
212 : /**
213 : * @brief Minimum time a Sink port shall wait before it can determine there has been a change
214 : * in Rp where CC is not BMC Idle or the port is unable to detect BMC Idle.
215 : * See Table 4-31 CC Timing
216 : */
217 1 : #define TC_T_RP_VALUE_CHANGE_MIN_MS 10
218 :
219 : /**
220 : * @brief Maximum time a Sink port shall wait before it can determine there has been a change
221 : * in Rp where CC is not BMC Idle or the port is unable to detect BMC Idle.
222 : * See Table 4-31 CC Timing
223 : */
224 1 : #define TC_T_RP_VALUE_CHANGE_MAX_MS 20
225 :
226 : /**
227 : * @brief Minimum time a Source shall detect the SRC.Open state. The Source should detect the
228 : * SRC.Open state as quickly as practical.
229 : * See Table 4-31 CC Timing
230 : */
231 1 : #define TC_T_SRC_DISCONNECT_MIN_MS 0
232 :
233 : /**
234 : * @brief Maximum time a Source shall detect the SRC.Open state. The Source should detect the
235 : * SRC.Open state as quickly as practical.
236 : * See Table 4-31 CC Timing
237 : */
238 1 : #define TC_T_SRC_DISCONNECT_MAX_MS 20
239 :
240 : /**
241 : * @brief Minimum time to detect connection when neither Port Partner is toggling.
242 : * See Table 4-31 CC Timing
243 : */
244 1 : #define TC_T_NO_TOGGLE_CONNECT_MIN_MS 0
245 :
246 : /**
247 : * @brief Maximum time to detect connection when neither Port Partner is toggling.
248 : * See Table 4-31 CC Timing
249 : */
250 1 : #define TC_T_NO_TOGGLE_CONNECT_MAX_MS 5
251 :
252 : /**
253 : * @brief Minimum time to detect connection when one Port Partner is toggling
254 : * 0ms … dcSRC.DRP max * tDRP max + 2 * tNoToggleConnect).
255 : * See Table 4-31 CC Timing
256 : */
257 1 : #define TC_T_ONE_PORT_TOGGLE_CONNECT_MIN_MS 0
258 :
259 : /**
260 : * @brief Maximum time to detect connection when one Port Partner is toggling
261 : * 0ms … dcSRC.DRP max * tDRP max + 2 * tNoToggleConnect).
262 : * See Table 4-31 CC Timing
263 : */
264 1 : #define TC_T_ONE_PORT_TOGGLE_CONNECT_MAX_MS 80
265 :
266 : /**
267 : * @brief Minimum time to detect connection when both Port Partners are toggling
268 : * (0ms … 5 * tDRP max + 2 * tNoToggleConnect).
269 : * See Table 4-31 CC Timing
270 : */
271 1 : #define TC_T_TWO_PORT_TOGGLE_CONNECT_MIN_MS 0
272 :
273 : /**
274 : * @brief Maximum time to detect connection when both Port Partners are toggling
275 : * (0ms … 5 * tDRP max + 2 * tNoToggleConnect).
276 : * See Table 4-31 CC Timing
277 : */
278 1 : #define TC_T_TWO_PORT_TOGGLE_CONNECT_MAX_MS 510
279 :
280 : /**
281 : * @brief Minimum time for a Charge-Through VCONN-Powered USB Device to detect that the
282 : * Charge-Through source has disconnected from CC after VBUS has been removed,
283 : * transition to CTUnattached.VPD, and re-apply its Rp termination advertising
284 : * 3.0 A on the host port CC.
285 : * See Table 4-31 CC Timing
286 : */
287 1 : #define TC_T_VPDCTDD_MIN_US 30
288 :
289 : /**
290 : * @brief Maximum time for a Charge-Through VCONN-Powered USB Device to detect that the
291 : * Charge-Through source has disconnected from CC after VBUS has been removed,
292 : * transition to CTUnattached.VPD, and re-apply its Rp termination advertising
293 : * 3.0 A on the host port CC.
294 : * See Table 4-31 CC Timing
295 : */
296 1 : #define TC_T_VPDCTDD_MAX_MS 5
297 :
298 : /**
299 : * @brief Minimum time for a Charge-Through VCONN-Powered USB Device shall remain
300 : * in CTDisabled.VPD state.
301 : * See Table 4-31 CC Timing
302 : */
303 1 : #define TC_T_VPDDISABLE_MIN_MS 25
304 :
305 : /**
306 : * @brief CC Voltage status
307 : */
308 0 : enum tc_cc_voltage_state {
309 : /** No port partner connection */
310 : TC_CC_VOLT_OPEN = 0,
311 : /** Port partner is applying Ra */
312 : TC_CC_VOLT_RA = 1,
313 : /** Port partner is applying Rd */
314 : TC_CC_VOLT_RD = 2,
315 : /** Port partner is applying Rp (0.5A) */
316 : TC_CC_VOLT_RP_DEF = 5,
317 : /*8 Port partner is applying Rp (1.5A) */
318 : TC_CC_VOLT_RP_1A5 = 6,
319 : /** Port partner is applying Rp (3.0A) */
320 : TC_CC_VOLT_RP_3A0 = 7,
321 : };
322 :
323 : /**
324 : * @brief VBUS level voltages
325 : */
326 1 : enum tc_vbus_level {
327 : /** VBUS is less than vSafe0V max */
328 : TC_VBUS_SAFE0V = 0,
329 : /** VBUS is at least vSafe5V min */
330 : TC_VBUS_PRESENT = 1,
331 : /** VBUS is less than vSinkDisconnect max */
332 : TC_VBUS_REMOVED = 2
333 : };
334 :
335 : /**
336 : * @brief Pull-Up resistor values
337 : */
338 1 : enum tc_rp_value {
339 : /** Pull-Up resistor for a current of 900mA */
340 : TC_RP_USB = 0,
341 : /** Pull-Up resistor for a current of 1.5A */
342 : TC_RP_1A5 = 1,
343 : /** Pull-Up resistor for a current of 3.0A */
344 : TC_RP_3A0 = 2,
345 : /** No Pull-Up resistor is applied */
346 : TC_RP_RESERVED = 3
347 : };
348 :
349 : /**
350 : * @brief CC pull resistors
351 : */
352 1 : enum tc_cc_pull {
353 : /** Ra Pull-Down resistor */
354 : TC_CC_RA = 0,
355 : /** Rp Pull-Up resistor */
356 : TC_CC_RP = 1,
357 : /** Rd Pull-Down resistor */
358 : TC_CC_RD = 2,
359 : /** No CC resistor */
360 : TC_CC_OPEN = 3,
361 : /** Ra and Rd Pull-Down resistor */
362 : TC_RA_RD = 4
363 : };
364 :
365 : /**
366 : * @brief Cable plug. See 6.2.1.1.7 Cable Plug. Only applies to SOP' and SOP".
367 : * Replaced by pd_power_role for SOP packets.
368 : */
369 0 : enum tc_cable_plug {
370 : /* Message originated from a DFP or UFP */
371 : PD_PLUG_FROM_DFP_UFP = 0,
372 : /* Message originated from a Cable Plug or VPD */
373 : PD_PLUG_FROM_CABLE_VPD = 1
374 : };
375 :
376 : /**
377 : * @brief Power Delivery Power Role
378 : */
379 1 : enum tc_power_role {
380 : /** Power role is a sink */
381 : TC_ROLE_SINK = 0,
382 : /** Power role is a source */
383 : TC_ROLE_SOURCE = 1
384 : };
385 :
386 : /**
387 : * @brief Power Delivery Data Role
388 : */
389 1 : enum tc_data_role {
390 : /** Data role is an Upstream Facing Port */
391 : TC_ROLE_UFP = 0,
392 : /** Data role is a Downstream Facing Port */
393 : TC_ROLE_DFP = 1,
394 : /** Port is disconnected */
395 : TC_ROLE_DISCONNECTED = 2
396 : };
397 :
398 : /**
399 : * @brief Polarity of the CC lines
400 : */
401 1 : enum tc_cc_polarity {
402 : /** Use CC1 IO for Power Delivery communication */
403 : TC_POLARITY_CC1 = 0,
404 : /** Use CC2 IO for Power Delivery communication */
405 : TC_POLARITY_CC2 = 1
406 : };
407 :
408 : /**
409 : * @brief Possible port partner connections based on CC line states
410 : */
411 1 : enum tc_cc_states {
412 : /** No port partner attached */
413 : TC_CC_NONE = 0,
414 :
415 : /** From DFP perspective */
416 :
417 : /** No UFP accessory connected */
418 : TC_CC_UFP_NONE = 1,
419 : /** UFP Audio accessory connected */
420 : TC_CC_UFP_AUDIO_ACC = 2,
421 : /** UFP Debug accessory connected */
422 : TC_CC_UFP_DEBUG_ACC = 3,
423 : /** Plain UFP attached */
424 : TC_CC_UFP_ATTACHED = 4,
425 :
426 : /** From UFP perspective */
427 :
428 : /** Plain DFP attached */
429 : TC_CC_DFP_ATTACHED = 5,
430 : /** DFP debug accessory connected */
431 : TC_CC_DFP_DEBUG_ACC = 6
432 : };
433 :
434 : /**
435 : * @}
436 : */
437 :
438 : #ifdef __cplusplus
439 : }
440 : #endif
441 :
442 : #endif /* ZEPHYR_INCLUDE_DRIVERS_USBC_USBC_TC_H_ */
|