summaryrefslogtreecommitdiffstats
path: root/include/linux/usb/typec_tbt.h
blob: fa97d7e00f5c7896ab23cd9b25a9e6acef309711 (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
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __USB_TYPEC_TBT_H
#define __USB_TYPEC_TBT_H

#include <linux/usb/typec_altmode.h>
#include <linux/bitfield.h>

#define USB_TYPEC_VENDOR_INTEL		0x8087
/* Alias for convenience */
#define USB_TYPEC_TBT_SID		USB_TYPEC_VENDOR_INTEL

/* Connector state for Thunderbolt3 */
#define TYPEC_TBT_MODE			TYPEC_STATE_MODAL

/**
 * struct typec_thunderbolt_data - Thundebolt3 Alt Mode specific data
 * @device_mode: Device Discover Mode VDO
 * @cable_mode: Cable Discover Mode VDO
 * @enter_vdo: Enter Mode VDO
 */
struct typec_thunderbolt_data {
	u32 device_mode;
	u32 cable_mode;
	u32 enter_vdo;
};

/* TBT3 Device Discover Mode VDO bits */
#define TBT_MODE			BIT(0)
#define TBT_ADAPTER(_vdo_)		FIELD_GET(BIT(16), _vdo_)
#define   TBT_ADAPTER_LEGACY		0
#define   TBT_ADAPTER_TBT3		1
#define TBT_INTEL_SPECIFIC_B0		BIT(26)
#define TBT_VENDOR_SPECIFIC_B0		BIT(30)
#define TBT_VENDOR_SPECIFIC_B1		BIT(31)

#define TBT_SET_ADAPTER(a)		(((a) & 1) << 16)

/* TBT3 Cable Discover Mode VDO bits */
#define TBT_CABLE_SPEED(_vdo_)		FIELD_GET(GENMASK(18, 16), _vdo_)
#define   TBT_CABLE_USB3_GEN1		1
#define   TBT_CABLE_USB3_PASSIVE	2
#define   TBT_CABLE_10_AND_20GBPS	3
#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) FIELD_GET(GENMASK(20, 19), _vdo_)

#define   TBT_GEN3_NON_ROUNDED                 0
#define   TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED    1
#define TBT_CABLE_OPTICAL		BIT(21)
#define TBT_CABLE_RETIMER		BIT(22)
#define TBT_CABLE_LINK_TRAINING		BIT(23)
#define TBT_CABLE_ACTIVE_PASSIVE	BIT(25)

#define TBT_SET_CABLE_SPEED(_s_)	(((_s_) & GENMASK(2, 0)) << 16)
#define TBT_SET_CABLE_ROUNDED(_g_)	(((_g_) & GENMASK(1, 0)) << 19)

/* TBT3 Device Enter Mode VDO bits */
#define TBT_ENTER_MODE_CABLE_SPEED(s)	TBT_SET_CABLE_SPEED(s)
#define TBT_ENTER_MODE_ACTIVE_CABLE	BIT(24)

#endif /* __USB_TYPEC_TBT_H */