summaryrefslogtreecommitdiff
path: root/include/usb_pd_tbt.h
blob: 7cf6cd9c7a98ee3aa82bf5c0adeffb74fb6e1426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/* Copyright 2020 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * Thunderbolt-compatible mode header.
 */

#ifndef __CROS_EC_USB_PD_TBT_COMPAT_H
#define __CROS_EC_USB_PD_TBT_COMPAT_H

#include "usb_pd_vdo.h"

/*
 * NOTE: Throughout the file, some of the bit fields in the structures are for
 * information purpose, they might not be actually used in the current code.
 * When appropriate, replace the bit fields in the structures with appropriate
 * enums.
 */

/*
 * Reference: USB Type-C cable and connector specification, Release 2.0
 */

/*****************************************************************************/
/*
 * TBT3 Device Discover Identity Responses
 */

/*
 * Table F-8 TBT3 Device Discover Identity VDO Responses
 * -------------------------------------------------------------
 * <31>    : USB Communications Capable as USB Host
 *           0b = No
 *           1b = Yes
 * <30>    : USB Communications Capable as a USB Device
 *           0b = No
 *           1b = Yes
 * <29:27> : Product Type (UFP)
 *           001b = PDUSB Hub
 *           010b = PDUSB Peripheral
 *           101b = Alternate Mode Adapter (AMA)
 *           110b = VCONN-Powered USB Device (VPD)
 * <26>    : Modal Operation Supported Modal Operation Supported
 *           0b = No
 *           1b = Yes
 * <25:23> : Product Type (DFP)
 *           001b = PDUSB Hub
 *           010b = PDUSB Host
 *           100b = Alternate Mode Controller (AMC)
 * <22:16> : 0 Reserved
 * <15:0>  : Per vendor USB Vendor ID
 */

/*****************************************************************************/
/*
 * TBT3 Discover SVID Responses
 */

/*
 * Table F-9 TBT3 Discover SVID VDO Responses
 * -------------------------------------------------------------
 * Note: These SVID can be in any order
 * <31:16> : 0x8087 = Intel/TBT3 SVID 0
 * <B15:0> : 0xFF01 = VESA DP (if supported) SVID 1
 */

/*****************************************************************************/
/*
 * TBT3 Device Discover Mode Responses
 */

/*
 * Table F-10 TBT3 Device Discover Mode VDO Responses
 * -------------------------------------------------------------
 * <31>    : Vendor specific B1
 *           0b = Not supported
 *           1b = Supported
 * <30>    : Vendor specific B0
 *           0b = Not supported
 *           1b = Supported
 * <29:27> : Reserved
 * <26>    : Intel specific B0
 *           0b = Not supported
 *           1b = Supported
 * <25:17> : Reserved
 * <16>    : TBT Adapter
 *           Errata: TBT Adapter bits are swapped in the document
 *           Refer USB Type-C ENGINEERING CHANGE NOTICE (ECN)
 *           "USB Type-C ECN Thunderbolt 3 Compatibility Updates.pdf"
 *           with Title: Thunderbolt 3 Compatibility Updates
 *           for the document fix published by USB-IF.
 *           0b = TBT3 Adapter
 *           1b = TBT2 Legacy Adapter
 * <15:0>  : TBT Alternate Mode
 *           0x0001 = TBT Mode
 */
enum tbt_adapter_type {
	TBT_ADAPTER_TBT3,
	TBT_ADAPTER_TBT2_LEGACY,
};

enum vendor_specific_support {
	VENDOR_SPECIFIC_NOT_SUPPORTED,
	VENDOR_SPECIFIC_SUPPORTED,
};

/* TBT Alternate Mode */
#define TBT_ALTERNATE_MODE 0x0001
#define PD_VDO_RESP_MODE_INTEL_TBT(x)	(((x) & 0xff) == TBT_ALTERNATE_MODE)

union tbt_mode_resp_device {
	struct {
		uint16_t tbt_alt_mode : 16;
		enum tbt_adapter_type tbt_adapter : 1;
		uint16_t reserved0 : 9;
		enum vendor_specific_support intel_spec_b0 : 1;
		uint8_t reserved1 : 3;
		enum vendor_specific_support vendor_spec_b0 : 1;
		enum vendor_specific_support vendor_spec_b1 : 1;
	};
	uint32_t raw_value;
};

/*
 * Table F-11 TBT3 Cable Discover Mode VDO Responses
 * -------------------------------------------------------------
 * <31:26> : Reserved
 * <25>    : Active Passive
 *           Errata: Reserved B25 has been changed to Active passive bit
 *           Refer USB Type-C ENGINEERING CHANGE NOTICE (ECN)
 *           "USB Type-C ECN Thunderbolt 3 Compatibility Updates.pdf"
 *           with Title: Thunderbolt 3 Compatibility Updates
 *           for the document fix published by USB-IF.
 *           0b = Passive cable
 *           1b = Active cable
 *           NOTE: This change is only applicable to rev 3 cables
 * <24>    : Reserved
 * <23>    : Active Cable Plug Link Training
 *           0 = Active with bi-directional LSRX1 communication or when Passive
 *           1 = Active with uni-directional LSRX1 communication
 * <22>    : Re-timer
 *           0 = Not re-timer
 *           1 = Re-timer
 * <21>    : Cable Type
 *           0b = Non-Optical
 *           1b = Optical
 * <20:19> : TBT_Rounded_Support
 *           00b = 3rd Gen Non-Rounded TBT
 *           01b = 3rd & 4th Gen Rounded and Non-Rounded TBT
 *           10b..11b = Reserved
 * <18:16> : Cable Speed
 *           000b = Reserved
 *           001b = USB3.1 Gen1 Cable (10 Gbps TBT support)
 *           010b = 10 Gbps (USB 3.2 Gen1 and Gen2 passive cables)
 *           011b = 10 Gbps and 20 Gbps (TBT 3rd Gen active cables and
 *                  20 Gbps passive cables)
 *           100b..111b = Reserved
 * <15:0>  : TBT Alternate Mode
 *           0x0001 = TBT Mode
 */
enum tbt_active_passive_cable {
	TBT_CABLE_PASSIVE,
	TBT_CABLE_ACTIVE,
};

enum tbt_compat_cable_speed {
	TBT_SS_RES_0,
	TBT_SS_U31_GEN1,
	TBT_SS_U32_GEN1_GEN2,
	TBT_SS_TBT_GEN3,
	TBT_SS_RES_4,
	TBT_SS_RES_5,
	TBT_SS_RES_6,
	TBT_SS_RES_7,
};

enum tbt_cable_type {
	TBT_CABLE_NON_OPTICAL,
	TBT_CABLE_OPTICAL,
};

enum tbt_compat_rounded_support {
	TBT_GEN3_NON_ROUNDED,
	TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED,
	TBT_ROUND_SUP_RES_2,
	TBT_ROUND_SUP_RES_3,
};

enum usb_retimer_type {
	USB_NOT_RETIMER,
	USB_RETIMER,
};

enum link_lsrx_comm {
	BIDIR_LSRX_COMM,
	UNIDIR_LSRX_COMM,
};

union tbt_mode_resp_cable {
	struct {
		uint16_t tbt_alt_mode : 16;
		enum tbt_compat_cable_speed tbt_cable_speed : 3;
		enum tbt_compat_rounded_support tbt_rounded : 2;
		enum tbt_cable_type tbt_cable : 1;
		enum usb_retimer_type retimer_type : 1;
		enum link_lsrx_comm lsrx_comm : 1;
		uint8_t reserved1 : 1;
		enum tbt_active_passive_cable tbt_active_passive : 1;
		uint8_t reserved0 : 6;
	};
	uint32_t raw_value;
};

/*****************************************************************************/
/*
 * TBT3 Enter Mode Command
 */

/*
 * Table F-13 TBT3 Device Enter Mode Command SOP
 * -------------------------------------------------------------
 * <31>    : Vendor specific B1
 *           0b = Not supported
 *           1b = Supported
 * <30>    : Vendor specific B0
 *           0b = Not supported
 *           1b = Supported
 * <29:27> : 000b Reserved
 * <26>    : Intel specific B0
 *           0b = Not supported
 *           1b = Supported
 * <25>    : Active_Passive
 *           Errata: Active_Passive bit is changed to B25
 *           Refer USB Type-C ENGINEERING CHANGE NOTICE (ECN)
 *           "USB Type-C ECN Thunderbolt 3 Compatibility Updates.pdf"
 *           with Title: Thunderbolt 3 Compatibility Updates
 *           for the document fix published by USB-IF.
 *           0b = Passive cable
 *           1b = Active cable
 * <24>    : TBT adapter
 *           Errata: B24 represents Thunderbolt Adapter type
 *           Refer USB Type-C ENGINEERING CHANGE NOTICE (ECN)
 *           "USB Type-C ECN Thunderbolt 3 Compatibility Updates.pdf"
 *           with Title: Thunderbolt 3 Compatibility Updates
 *           for the document fix published by USB-IF.
 *           0b = TBT3 Adapter
 *           1b = TBT2 Legacy Adapter
 * <23>    : Active Cable Link Training
 *           0b = Active with bi-directional LSRX1 communication or when Passive
 *           1b = Active with uni-directional LSRX1 communication
 * <22>    : Re-timer
 *           0b = Not re-timer
 *           1b = Re-timer
 * <21>    : Cable Type
 *           0b = Non-Optical
 *           1b = Optical
 * <20:19> : TBT_Rounded_Support
 *           00b = 3rd Gen Non-Rounded TBT
 *           01b = 3rd & 4th Gen Rounded and Non-Rounded TBT
 *           10b..11b = Reserved
 * <18:16> : Cable Speed
 *           000b = Reserved
 *           001b = USB3.1 Gen1 Cable (10 Gbps TBT support)
 *           010b = 10 Gbps (USB 3.2 Gen1 and Gen2 passive cables)
 *           011b = 10 Gbps and 20 Gbps (TBT 3rd Gen active cables and
 *                  20 Gbps passive cables)
 *           100b..111b = Reserved
 * <15:0>  : TBT Alternate Mode
 *           0x0001 = TBT Mode
 */
enum tbt_enter_cable_type {
	TBT_ENTER_PASSIVE_CABLE,
	TBT_ENTER_ACTIVE_CABLE,
};

union tbt_dev_mode_enter_cmd {
	struct {
		uint16_t tbt_alt_mode : 16;
		enum tbt_compat_cable_speed tbt_cable_speed : 3;
		enum tbt_compat_rounded_support tbt_rounded : 2;
		enum tbt_cable_type tbt_cable : 1;
		enum usb_retimer_type retimer_type : 1;
		enum link_lsrx_comm lsrx_comm : 1;
		enum tbt_adapter_type tbt_adapter : 1;
		enum tbt_enter_cable_type cable : 1;
		enum vendor_specific_support intel_spec_b0 : 1;
		uint8_t reserved1 : 3;
		enum vendor_specific_support vendor_spec_b0 : 1;
		enum vendor_specific_support vendor_spec_b1 : 1;
	};
	uint32_t raw_value;
};

#endif /* __CROS_EC_USB_PD_TBT_COMPAT_H */