162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Thunderbolt driver - Port/Switch config area registers
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Every thunderbolt device consists (logically) of a switch with multiple
662306a36Sopenharmony_ci * ports. Every port contains up to four config regions (HOPS, PORT, SWITCH,
762306a36Sopenharmony_ci * COUNTERS) which are used to configure the device.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
1062306a36Sopenharmony_ci * Copyright (C) 2018, Intel Corporation
1162306a36Sopenharmony_ci */
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifndef _TB_REGS
1462306a36Sopenharmony_ci#define _TB_REGS
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include <linux/types.h>
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define TB_ROUTE_SHIFT 8  /* number of bits in a port entry of a route */
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/*
2362306a36Sopenharmony_ci * TODO: should be 63? But we do not know how to receive frames larger than 256
2462306a36Sopenharmony_ci * bytes at the frame level. (header + checksum = 16, 60*4 = 240)
2562306a36Sopenharmony_ci */
2662306a36Sopenharmony_ci#define TB_MAX_CONFIG_RW_LENGTH 60
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cienum tb_switch_cap {
2962306a36Sopenharmony_ci	TB_SWITCH_CAP_TMU		= 0x03,
3062306a36Sopenharmony_ci	TB_SWITCH_CAP_VSE		= 0x05,
3162306a36Sopenharmony_ci};
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_cienum tb_switch_vse_cap {
3462306a36Sopenharmony_ci	TB_VSE_CAP_PLUG_EVENTS		= 0x01, /* also EEPROM */
3562306a36Sopenharmony_ci	TB_VSE_CAP_TIME2		= 0x03,
3662306a36Sopenharmony_ci	TB_VSE_CAP_CP_LP		= 0x04,
3762306a36Sopenharmony_ci	TB_VSE_CAP_LINK_CONTROLLER	= 0x06, /* also IECS */
3862306a36Sopenharmony_ci};
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cienum tb_port_cap {
4162306a36Sopenharmony_ci	TB_PORT_CAP_PHY			= 0x01,
4262306a36Sopenharmony_ci	TB_PORT_CAP_POWER		= 0x02,
4362306a36Sopenharmony_ci	TB_PORT_CAP_TIME1		= 0x03,
4462306a36Sopenharmony_ci	TB_PORT_CAP_ADAP		= 0x04,
4562306a36Sopenharmony_ci	TB_PORT_CAP_VSE			= 0x05,
4662306a36Sopenharmony_ci	TB_PORT_CAP_USB4		= 0x06,
4762306a36Sopenharmony_ci};
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_cienum tb_port_state {
5062306a36Sopenharmony_ci	TB_PORT_DISABLED	= 0, /* tb_cap_phy.disable == 1 */
5162306a36Sopenharmony_ci	TB_PORT_CONNECTING	= 1, /* retry */
5262306a36Sopenharmony_ci	TB_PORT_UP		= 2,
5362306a36Sopenharmony_ci	TB_PORT_TX_CL0S		= 3,
5462306a36Sopenharmony_ci	TB_PORT_RX_CL0S		= 4,
5562306a36Sopenharmony_ci	TB_PORT_CL1		= 5,
5662306a36Sopenharmony_ci	TB_PORT_CL2		= 6,
5762306a36Sopenharmony_ci	TB_PORT_UNPLUGGED	= 7,
5862306a36Sopenharmony_ci};
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci/* capability headers */
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistruct tb_cap_basic {
6362306a36Sopenharmony_ci	u8 next;
6462306a36Sopenharmony_ci	/* enum tb_cap cap:8; prevent "narrower than values of its type" */
6562306a36Sopenharmony_ci	u8 cap; /* if cap == 0x05 then we have a extended capability */
6662306a36Sopenharmony_ci} __packed;
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci/**
6962306a36Sopenharmony_ci * struct tb_cap_extended_short - Switch extended short capability
7062306a36Sopenharmony_ci * @next: Pointer to the next capability. If @next and @length are zero
7162306a36Sopenharmony_ci *	  then we have a long cap.
7262306a36Sopenharmony_ci * @cap: Base capability ID (see &enum tb_switch_cap)
7362306a36Sopenharmony_ci * @vsec_id: Vendor specific capability ID (see &enum switch_vse_cap)
7462306a36Sopenharmony_ci * @length: Length of this capability
7562306a36Sopenharmony_ci */
7662306a36Sopenharmony_cistruct tb_cap_extended_short {
7762306a36Sopenharmony_ci	u8 next;
7862306a36Sopenharmony_ci	u8 cap;
7962306a36Sopenharmony_ci	u8 vsec_id;
8062306a36Sopenharmony_ci	u8 length;
8162306a36Sopenharmony_ci} __packed;
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci/**
8462306a36Sopenharmony_ci * struct tb_cap_extended_long - Switch extended long capability
8562306a36Sopenharmony_ci * @zero1: This field should be zero
8662306a36Sopenharmony_ci * @cap: Base capability ID (see &enum tb_switch_cap)
8762306a36Sopenharmony_ci * @vsec_id: Vendor specific capability ID (see &enum switch_vse_cap)
8862306a36Sopenharmony_ci * @zero2: This field should be zero
8962306a36Sopenharmony_ci * @next: Pointer to the next capability
9062306a36Sopenharmony_ci * @length: Length of this capability
9162306a36Sopenharmony_ci */
9262306a36Sopenharmony_cistruct tb_cap_extended_long {
9362306a36Sopenharmony_ci	u8 zero1;
9462306a36Sopenharmony_ci	u8 cap;
9562306a36Sopenharmony_ci	u8 vsec_id;
9662306a36Sopenharmony_ci	u8 zero2;
9762306a36Sopenharmony_ci	u16 next;
9862306a36Sopenharmony_ci	u16 length;
9962306a36Sopenharmony_ci} __packed;
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci/**
10262306a36Sopenharmony_ci * struct tb_cap_any - Structure capable of hold every capability
10362306a36Sopenharmony_ci * @basic: Basic capability
10462306a36Sopenharmony_ci * @extended_short: Vendor specific capability
10562306a36Sopenharmony_ci * @extended_long: Vendor specific extended capability
10662306a36Sopenharmony_ci */
10762306a36Sopenharmony_cistruct tb_cap_any {
10862306a36Sopenharmony_ci	union {
10962306a36Sopenharmony_ci		struct tb_cap_basic basic;
11062306a36Sopenharmony_ci		struct tb_cap_extended_short extended_short;
11162306a36Sopenharmony_ci		struct tb_cap_extended_long extended_long;
11262306a36Sopenharmony_ci	};
11362306a36Sopenharmony_ci} __packed;
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/* capabilities */
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_cistruct tb_cap_link_controller {
11862306a36Sopenharmony_ci	struct tb_cap_extended_long cap_header;
11962306a36Sopenharmony_ci	u32 count:4; /* number of link controllers */
12062306a36Sopenharmony_ci	u32 unknown1:4;
12162306a36Sopenharmony_ci	u32 base_offset:8; /*
12262306a36Sopenharmony_ci			    * offset (into this capability) of the configuration
12362306a36Sopenharmony_ci			    * area of the first link controller
12462306a36Sopenharmony_ci			    */
12562306a36Sopenharmony_ci	u32 length:12; /* link controller configuration area length */
12662306a36Sopenharmony_ci	u32 unknown2:4; /* TODO check that length is correct */
12762306a36Sopenharmony_ci} __packed;
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_cistruct tb_cap_phy {
13062306a36Sopenharmony_ci	struct tb_cap_basic cap_header;
13162306a36Sopenharmony_ci	u32 unknown1:16;
13262306a36Sopenharmony_ci	u32 unknown2:14;
13362306a36Sopenharmony_ci	bool disable:1;
13462306a36Sopenharmony_ci	u32 unknown3:11;
13562306a36Sopenharmony_ci	enum tb_port_state state:4;
13662306a36Sopenharmony_ci	u32 unknown4:2;
13762306a36Sopenharmony_ci} __packed;
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_cistruct tb_eeprom_ctl {
14062306a36Sopenharmony_ci	bool fl_sk:1; /* send pulse to transfer one bit */
14162306a36Sopenharmony_ci	bool fl_cs:1; /* set to 0 before access */
14262306a36Sopenharmony_ci	bool fl_di:1; /* to eeprom */
14362306a36Sopenharmony_ci	bool fl_do:1; /* from eeprom */
14462306a36Sopenharmony_ci	bool bit_banging_enable:1; /* set to 1 before access */
14562306a36Sopenharmony_ci	bool not_present:1; /* should be 0 */
14662306a36Sopenharmony_ci	bool unknown1:1;
14762306a36Sopenharmony_ci	bool present:1; /* should be 1 */
14862306a36Sopenharmony_ci	u32 unknown2:24;
14962306a36Sopenharmony_ci} __packed;
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_cistruct tb_cap_plug_events {
15262306a36Sopenharmony_ci	struct tb_cap_extended_short cap_header;
15362306a36Sopenharmony_ci	u32 __unknown1:2; /* VSC_CS_1 */
15462306a36Sopenharmony_ci	u32 plug_events:5; /* VSC_CS_1 */
15562306a36Sopenharmony_ci	u32 __unknown2:25; /* VSC_CS_1 */
15662306a36Sopenharmony_ci	u32 vsc_cs_2;
15762306a36Sopenharmony_ci	u32 vsc_cs_3;
15862306a36Sopenharmony_ci	struct tb_eeprom_ctl eeprom_ctl;
15962306a36Sopenharmony_ci	u32 __unknown5[7]; /* VSC_CS_5 -> VSC_CS_11 */
16062306a36Sopenharmony_ci	u32 drom_offset; /* VSC_CS_12: 32 bit register, but eeprom addresses are 16 bit */
16162306a36Sopenharmony_ci} __packed;
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci/* device headers */
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci/* Present on port 0 in TB_CFG_SWITCH at address zero. */
16662306a36Sopenharmony_cistruct tb_regs_switch_header {
16762306a36Sopenharmony_ci	/* DWORD 0 */
16862306a36Sopenharmony_ci	u16 vendor_id;
16962306a36Sopenharmony_ci	u16 device_id;
17062306a36Sopenharmony_ci	/* DWORD 1 */
17162306a36Sopenharmony_ci	u32 first_cap_offset:8;
17262306a36Sopenharmony_ci	u32 upstream_port_number:6;
17362306a36Sopenharmony_ci	u32 max_port_number:6;
17462306a36Sopenharmony_ci	u32 depth:3;
17562306a36Sopenharmony_ci	u32 __unknown1:1;
17662306a36Sopenharmony_ci	u32 revision:8;
17762306a36Sopenharmony_ci	/* DWORD 2 */
17862306a36Sopenharmony_ci	u32 route_lo;
17962306a36Sopenharmony_ci	/* DWORD 3 */
18062306a36Sopenharmony_ci	u32 route_hi:31;
18162306a36Sopenharmony_ci	bool enabled:1;
18262306a36Sopenharmony_ci	/* DWORD 4 */
18362306a36Sopenharmony_ci	u32 plug_events_delay:8; /*
18462306a36Sopenharmony_ci				  * RW, pause between plug events in
18562306a36Sopenharmony_ci				  * milliseconds. Writing 0x00 is interpreted
18662306a36Sopenharmony_ci				  * as 255ms.
18762306a36Sopenharmony_ci				  */
18862306a36Sopenharmony_ci	u32 cmuv:8;
18962306a36Sopenharmony_ci	u32 __unknown4:8;
19062306a36Sopenharmony_ci	u32 thunderbolt_version:8;
19162306a36Sopenharmony_ci} __packed;
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci/* Used with the router thunderbolt_version */
19462306a36Sopenharmony_ci#define USB4_VERSION_MAJOR_MASK			GENMASK(7, 5)
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci#define ROUTER_CS_1				0x01
19762306a36Sopenharmony_ci#define ROUTER_CS_4				0x04
19862306a36Sopenharmony_ci/* Used with the router cmuv field */
19962306a36Sopenharmony_ci#define ROUTER_CS_4_CMUV_V1			0x10
20062306a36Sopenharmony_ci#define ROUTER_CS_4_CMUV_V2			0x20
20162306a36Sopenharmony_ci#define ROUTER_CS_5				0x05
20262306a36Sopenharmony_ci#define ROUTER_CS_5_SLP				BIT(0)
20362306a36Sopenharmony_ci#define ROUTER_CS_5_WOP				BIT(1)
20462306a36Sopenharmony_ci#define ROUTER_CS_5_WOU				BIT(2)
20562306a36Sopenharmony_ci#define ROUTER_CS_5_WOD				BIT(3)
20662306a36Sopenharmony_ci#define ROUTER_CS_5_CNS				BIT(23)
20762306a36Sopenharmony_ci#define ROUTER_CS_5_PTO				BIT(24)
20862306a36Sopenharmony_ci#define ROUTER_CS_5_UTO				BIT(25)
20962306a36Sopenharmony_ci#define ROUTER_CS_5_HCO				BIT(26)
21062306a36Sopenharmony_ci#define ROUTER_CS_5_CV				BIT(31)
21162306a36Sopenharmony_ci#define ROUTER_CS_6				0x06
21262306a36Sopenharmony_ci#define ROUTER_CS_6_SLPR			BIT(0)
21362306a36Sopenharmony_ci#define ROUTER_CS_6_TNS				BIT(1)
21462306a36Sopenharmony_ci#define ROUTER_CS_6_WOPS			BIT(2)
21562306a36Sopenharmony_ci#define ROUTER_CS_6_WOUS			BIT(3)
21662306a36Sopenharmony_ci#define ROUTER_CS_6_HCI				BIT(18)
21762306a36Sopenharmony_ci#define ROUTER_CS_6_CR				BIT(25)
21862306a36Sopenharmony_ci#define ROUTER_CS_7				0x07
21962306a36Sopenharmony_ci#define ROUTER_CS_9				0x09
22062306a36Sopenharmony_ci#define ROUTER_CS_25				0x19
22162306a36Sopenharmony_ci#define ROUTER_CS_26				0x1a
22262306a36Sopenharmony_ci#define ROUTER_CS_26_OPCODE_MASK		GENMASK(15, 0)
22362306a36Sopenharmony_ci#define ROUTER_CS_26_STATUS_MASK		GENMASK(29, 24)
22462306a36Sopenharmony_ci#define ROUTER_CS_26_STATUS_SHIFT		24
22562306a36Sopenharmony_ci#define ROUTER_CS_26_ONS			BIT(30)
22662306a36Sopenharmony_ci#define ROUTER_CS_26_OV				BIT(31)
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci/* USB4 router operations opcodes */
22962306a36Sopenharmony_cienum usb4_switch_op {
23062306a36Sopenharmony_ci	USB4_SWITCH_OP_QUERY_DP_RESOURCE = 0x10,
23162306a36Sopenharmony_ci	USB4_SWITCH_OP_ALLOC_DP_RESOURCE = 0x11,
23262306a36Sopenharmony_ci	USB4_SWITCH_OP_DEALLOC_DP_RESOURCE = 0x12,
23362306a36Sopenharmony_ci	USB4_SWITCH_OP_NVM_WRITE = 0x20,
23462306a36Sopenharmony_ci	USB4_SWITCH_OP_NVM_AUTH = 0x21,
23562306a36Sopenharmony_ci	USB4_SWITCH_OP_NVM_READ = 0x22,
23662306a36Sopenharmony_ci	USB4_SWITCH_OP_NVM_SET_OFFSET = 0x23,
23762306a36Sopenharmony_ci	USB4_SWITCH_OP_DROM_READ = 0x24,
23862306a36Sopenharmony_ci	USB4_SWITCH_OP_NVM_SECTOR_SIZE = 0x25,
23962306a36Sopenharmony_ci	USB4_SWITCH_OP_BUFFER_ALLOC = 0x33,
24062306a36Sopenharmony_ci};
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci/* Router TMU configuration */
24362306a36Sopenharmony_ci#define TMU_RTR_CS_0				0x00
24462306a36Sopenharmony_ci#define TMU_RTR_CS_0_FREQ_WIND_MASK		GENMASK(26, 16)
24562306a36Sopenharmony_ci#define TMU_RTR_CS_0_TD				BIT(27)
24662306a36Sopenharmony_ci#define TMU_RTR_CS_0_UCAP			BIT(30)
24762306a36Sopenharmony_ci#define TMU_RTR_CS_1				0x01
24862306a36Sopenharmony_ci#define TMU_RTR_CS_1_LOCAL_TIME_NS_MASK		GENMASK(31, 16)
24962306a36Sopenharmony_ci#define TMU_RTR_CS_1_LOCAL_TIME_NS_SHIFT	16
25062306a36Sopenharmony_ci#define TMU_RTR_CS_2				0x02
25162306a36Sopenharmony_ci#define TMU_RTR_CS_3				0x03
25262306a36Sopenharmony_ci#define TMU_RTR_CS_3_LOCAL_TIME_NS_MASK		GENMASK(15, 0)
25362306a36Sopenharmony_ci#define TMU_RTR_CS_3_TS_PACKET_INTERVAL_MASK	GENMASK(31, 16)
25462306a36Sopenharmony_ci#define TMU_RTR_CS_3_TS_PACKET_INTERVAL_SHIFT	16
25562306a36Sopenharmony_ci#define TMU_RTR_CS_15				0x0f
25662306a36Sopenharmony_ci#define TMU_RTR_CS_15_FREQ_AVG_MASK		GENMASK(5, 0)
25762306a36Sopenharmony_ci#define TMU_RTR_CS_15_DELAY_AVG_MASK		GENMASK(11, 6)
25862306a36Sopenharmony_ci#define TMU_RTR_CS_15_OFFSET_AVG_MASK		GENMASK(17, 12)
25962306a36Sopenharmony_ci#define TMU_RTR_CS_15_ERROR_AVG_MASK		GENMASK(23, 18)
26062306a36Sopenharmony_ci#define TMU_RTR_CS_18				0x12
26162306a36Sopenharmony_ci#define TMU_RTR_CS_18_DELTA_AVG_CONST_MASK	GENMASK(23, 16)
26262306a36Sopenharmony_ci#define TMU_RTR_CS_22				0x16
26362306a36Sopenharmony_ci#define TMU_RTR_CS_24				0x18
26462306a36Sopenharmony_ci#define TMU_RTR_CS_25				0x19
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_cienum tb_port_type {
26762306a36Sopenharmony_ci	TB_TYPE_INACTIVE	= 0x000000,
26862306a36Sopenharmony_ci	TB_TYPE_PORT		= 0x000001,
26962306a36Sopenharmony_ci	TB_TYPE_NHI		= 0x000002,
27062306a36Sopenharmony_ci	/* TB_TYPE_ETHERNET	= 0x020000, lower order bits are not known */
27162306a36Sopenharmony_ci	/* TB_TYPE_SATA		= 0x080000, lower order bits are not known */
27262306a36Sopenharmony_ci	TB_TYPE_DP_HDMI_IN	= 0x0e0101,
27362306a36Sopenharmony_ci	TB_TYPE_DP_HDMI_OUT	= 0x0e0102,
27462306a36Sopenharmony_ci	TB_TYPE_PCIE_DOWN	= 0x100101,
27562306a36Sopenharmony_ci	TB_TYPE_PCIE_UP		= 0x100102,
27662306a36Sopenharmony_ci	TB_TYPE_USB3_DOWN	= 0x200101,
27762306a36Sopenharmony_ci	TB_TYPE_USB3_UP		= 0x200102,
27862306a36Sopenharmony_ci};
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci/* Present on every port in TB_CF_PORT at address zero. */
28162306a36Sopenharmony_cistruct tb_regs_port_header {
28262306a36Sopenharmony_ci	/* DWORD 0 */
28362306a36Sopenharmony_ci	u16 vendor_id;
28462306a36Sopenharmony_ci	u16 device_id;
28562306a36Sopenharmony_ci	/* DWORD 1 */
28662306a36Sopenharmony_ci	u32 first_cap_offset:8;
28762306a36Sopenharmony_ci	u32 max_counters:11;
28862306a36Sopenharmony_ci	u32 counters_support:1;
28962306a36Sopenharmony_ci	u32 __unknown1:4;
29062306a36Sopenharmony_ci	u32 revision:8;
29162306a36Sopenharmony_ci	/* DWORD 2 */
29262306a36Sopenharmony_ci	enum tb_port_type type:24;
29362306a36Sopenharmony_ci	u32 thunderbolt_version:8;
29462306a36Sopenharmony_ci	/* DWORD 3 */
29562306a36Sopenharmony_ci	u32 __unknown2:20;
29662306a36Sopenharmony_ci	u32 port_number:6;
29762306a36Sopenharmony_ci	u32 __unknown3:6;
29862306a36Sopenharmony_ci	/* DWORD 4 */
29962306a36Sopenharmony_ci	u32 nfc_credits;
30062306a36Sopenharmony_ci	/* DWORD 5 */
30162306a36Sopenharmony_ci	u32 max_in_hop_id:11;
30262306a36Sopenharmony_ci	u32 max_out_hop_id:11;
30362306a36Sopenharmony_ci	u32 __unknown4:10;
30462306a36Sopenharmony_ci	/* DWORD 6 */
30562306a36Sopenharmony_ci	u32 __unknown5;
30662306a36Sopenharmony_ci	/* DWORD 7 */
30762306a36Sopenharmony_ci	u32 __unknown6;
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci} __packed;
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_ci/* Basic adapter configuration registers */
31262306a36Sopenharmony_ci#define ADP_CS_4				0x04
31362306a36Sopenharmony_ci#define ADP_CS_4_NFC_BUFFERS_MASK		GENMASK(9, 0)
31462306a36Sopenharmony_ci#define ADP_CS_4_TOTAL_BUFFERS_MASK		GENMASK(29, 20)
31562306a36Sopenharmony_ci#define ADP_CS_4_TOTAL_BUFFERS_SHIFT		20
31662306a36Sopenharmony_ci#define ADP_CS_4_LCK				BIT(31)
31762306a36Sopenharmony_ci#define ADP_CS_5				0x05
31862306a36Sopenharmony_ci#define ADP_CS_5_LCA_MASK			GENMASK(28, 22)
31962306a36Sopenharmony_ci#define ADP_CS_5_LCA_SHIFT			22
32062306a36Sopenharmony_ci#define ADP_CS_5_DHP				BIT(31)
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ci/* TMU adapter registers */
32362306a36Sopenharmony_ci#define TMU_ADP_CS_3				0x03
32462306a36Sopenharmony_ci#define TMU_ADP_CS_3_UDM			BIT(29)
32562306a36Sopenharmony_ci#define TMU_ADP_CS_6				0x06
32662306a36Sopenharmony_ci#define TMU_ADP_CS_6_DTS			BIT(1)
32762306a36Sopenharmony_ci#define TMU_ADP_CS_8				0x08
32862306a36Sopenharmony_ci#define TMU_ADP_CS_8_REPL_TIMEOUT_MASK		GENMASK(14, 0)
32962306a36Sopenharmony_ci#define TMU_ADP_CS_8_EUDM			BIT(15)
33062306a36Sopenharmony_ci#define TMU_ADP_CS_8_REPL_THRESHOLD_MASK	GENMASK(25, 16)
33162306a36Sopenharmony_ci#define TMU_ADP_CS_9				0x09
33262306a36Sopenharmony_ci#define TMU_ADP_CS_9_REPL_N_MASK		GENMASK(7, 0)
33362306a36Sopenharmony_ci#define TMU_ADP_CS_9_DIRSWITCH_N_MASK		GENMASK(15, 8)
33462306a36Sopenharmony_ci#define TMU_ADP_CS_9_ADP_TS_INTERVAL_MASK	GENMASK(31, 16)
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_ci/* Lane adapter registers */
33762306a36Sopenharmony_ci#define LANE_ADP_CS_0				0x00
33862306a36Sopenharmony_ci#define LANE_ADP_CS_0_SUPPORTED_SPEED_MASK	GENMASK(19, 16)
33962306a36Sopenharmony_ci#define LANE_ADP_CS_0_SUPPORTED_SPEED_SHIFT	16
34062306a36Sopenharmony_ci#define LANE_ADP_CS_0_SUPPORTED_WIDTH_MASK	GENMASK(25, 20)
34162306a36Sopenharmony_ci#define LANE_ADP_CS_0_SUPPORTED_WIDTH_SHIFT	20
34262306a36Sopenharmony_ci#define LANE_ADP_CS_0_SUPPORTED_WIDTH_DUAL	0x2
34362306a36Sopenharmony_ci#define LANE_ADP_CS_0_CL0S_SUPPORT		BIT(26)
34462306a36Sopenharmony_ci#define LANE_ADP_CS_0_CL1_SUPPORT		BIT(27)
34562306a36Sopenharmony_ci#define LANE_ADP_CS_0_CL2_SUPPORT		BIT(28)
34662306a36Sopenharmony_ci#define LANE_ADP_CS_1				0x01
34762306a36Sopenharmony_ci#define LANE_ADP_CS_1_TARGET_SPEED_MASK		GENMASK(3, 0)
34862306a36Sopenharmony_ci#define LANE_ADP_CS_1_TARGET_SPEED_GEN3		0xc
34962306a36Sopenharmony_ci#define LANE_ADP_CS_1_TARGET_WIDTH_MASK		GENMASK(9, 4)
35062306a36Sopenharmony_ci#define LANE_ADP_CS_1_TARGET_WIDTH_SHIFT	4
35162306a36Sopenharmony_ci#define LANE_ADP_CS_1_TARGET_WIDTH_SINGLE	0x1
35262306a36Sopenharmony_ci#define LANE_ADP_CS_1_TARGET_WIDTH_DUAL		0x3
35362306a36Sopenharmony_ci#define LANE_ADP_CS_1_CL0S_ENABLE		BIT(10)
35462306a36Sopenharmony_ci#define LANE_ADP_CS_1_CL1_ENABLE		BIT(11)
35562306a36Sopenharmony_ci#define LANE_ADP_CS_1_CL2_ENABLE		BIT(12)
35662306a36Sopenharmony_ci#define LANE_ADP_CS_1_LD			BIT(14)
35762306a36Sopenharmony_ci#define LANE_ADP_CS_1_LB			BIT(15)
35862306a36Sopenharmony_ci#define LANE_ADP_CS_1_CURRENT_SPEED_MASK	GENMASK(19, 16)
35962306a36Sopenharmony_ci#define LANE_ADP_CS_1_CURRENT_SPEED_SHIFT	16
36062306a36Sopenharmony_ci#define LANE_ADP_CS_1_CURRENT_SPEED_GEN2	0x8
36162306a36Sopenharmony_ci#define LANE_ADP_CS_1_CURRENT_SPEED_GEN3	0x4
36262306a36Sopenharmony_ci#define LANE_ADP_CS_1_CURRENT_SPEED_GEN4	0x2
36362306a36Sopenharmony_ci#define LANE_ADP_CS_1_CURRENT_WIDTH_MASK	GENMASK(25, 20)
36462306a36Sopenharmony_ci#define LANE_ADP_CS_1_CURRENT_WIDTH_SHIFT	20
36562306a36Sopenharmony_ci#define LANE_ADP_CS_1_PMS			BIT(30)
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ci/* USB4 port registers */
36862306a36Sopenharmony_ci#define PORT_CS_1				0x01
36962306a36Sopenharmony_ci#define PORT_CS_1_LENGTH_SHIFT			8
37062306a36Sopenharmony_ci#define PORT_CS_1_TARGET_MASK			GENMASK(18, 16)
37162306a36Sopenharmony_ci#define PORT_CS_1_TARGET_SHIFT			16
37262306a36Sopenharmony_ci#define PORT_CS_1_RETIMER_INDEX_SHIFT		20
37362306a36Sopenharmony_ci#define PORT_CS_1_WNR_WRITE			BIT(24)
37462306a36Sopenharmony_ci#define PORT_CS_1_NR				BIT(25)
37562306a36Sopenharmony_ci#define PORT_CS_1_RC				BIT(26)
37662306a36Sopenharmony_ci#define PORT_CS_1_PND				BIT(31)
37762306a36Sopenharmony_ci#define PORT_CS_2				0x02
37862306a36Sopenharmony_ci#define PORT_CS_18				0x12
37962306a36Sopenharmony_ci#define PORT_CS_18_BE				BIT(8)
38062306a36Sopenharmony_ci#define PORT_CS_18_TCM				BIT(9)
38162306a36Sopenharmony_ci#define PORT_CS_18_CPS				BIT(10)
38262306a36Sopenharmony_ci#define PORT_CS_18_WOCS				BIT(16)
38362306a36Sopenharmony_ci#define PORT_CS_18_WODS				BIT(17)
38462306a36Sopenharmony_ci#define PORT_CS_18_WOU4S			BIT(18)
38562306a36Sopenharmony_ci#define PORT_CS_19				0x13
38662306a36Sopenharmony_ci#define PORT_CS_19_PC				BIT(3)
38762306a36Sopenharmony_ci#define PORT_CS_19_PID				BIT(4)
38862306a36Sopenharmony_ci#define PORT_CS_19_WOC				BIT(16)
38962306a36Sopenharmony_ci#define PORT_CS_19_WOD				BIT(17)
39062306a36Sopenharmony_ci#define PORT_CS_19_WOU4				BIT(18)
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_ci/* Display Port adapter registers */
39362306a36Sopenharmony_ci#define ADP_DP_CS_0				0x00
39462306a36Sopenharmony_ci#define ADP_DP_CS_0_VIDEO_HOPID_MASK		GENMASK(26, 16)
39562306a36Sopenharmony_ci#define ADP_DP_CS_0_VIDEO_HOPID_SHIFT		16
39662306a36Sopenharmony_ci#define ADP_DP_CS_0_AE				BIT(30)
39762306a36Sopenharmony_ci#define ADP_DP_CS_0_VE				BIT(31)
39862306a36Sopenharmony_ci#define ADP_DP_CS_1_AUX_TX_HOPID_MASK		GENMASK(10, 0)
39962306a36Sopenharmony_ci#define ADP_DP_CS_1_AUX_RX_HOPID_MASK		GENMASK(21, 11)
40062306a36Sopenharmony_ci#define ADP_DP_CS_1_AUX_RX_HOPID_SHIFT		11
40162306a36Sopenharmony_ci#define ADP_DP_CS_2				0x02
40262306a36Sopenharmony_ci#define ADP_DP_CS_2_NRD_MLC_MASK		GENMASK(2, 0)
40362306a36Sopenharmony_ci#define ADP_DP_CS_2_HDP				BIT(6)
40462306a36Sopenharmony_ci#define ADP_DP_CS_2_NRD_MLR_MASK		GENMASK(9, 7)
40562306a36Sopenharmony_ci#define ADP_DP_CS_2_NRD_MLR_SHIFT		7
40662306a36Sopenharmony_ci#define ADP_DP_CS_2_CA				BIT(10)
40762306a36Sopenharmony_ci#define ADP_DP_CS_2_GR_MASK			GENMASK(12, 11)
40862306a36Sopenharmony_ci#define ADP_DP_CS_2_GR_SHIFT			11
40962306a36Sopenharmony_ci#define ADP_DP_CS_2_GR_0_25G			0x0
41062306a36Sopenharmony_ci#define ADP_DP_CS_2_GR_0_5G			0x1
41162306a36Sopenharmony_ci#define ADP_DP_CS_2_GR_1G			0x2
41262306a36Sopenharmony_ci#define ADP_DP_CS_2_GROUP_ID_MASK		GENMASK(15, 13)
41362306a36Sopenharmony_ci#define ADP_DP_CS_2_GROUP_ID_SHIFT		13
41462306a36Sopenharmony_ci#define ADP_DP_CS_2_CM_ID_MASK			GENMASK(19, 16)
41562306a36Sopenharmony_ci#define ADP_DP_CS_2_CM_ID_SHIFT			16
41662306a36Sopenharmony_ci#define ADP_DP_CS_2_CMMS			BIT(20)
41762306a36Sopenharmony_ci#define ADP_DP_CS_2_ESTIMATED_BW_MASK		GENMASK(31, 24)
41862306a36Sopenharmony_ci#define ADP_DP_CS_2_ESTIMATED_BW_SHIFT		24
41962306a36Sopenharmony_ci#define ADP_DP_CS_3				0x03
42062306a36Sopenharmony_ci#define ADP_DP_CS_3_HDPC			BIT(9)
42162306a36Sopenharmony_ci#define DP_LOCAL_CAP				0x04
42262306a36Sopenharmony_ci#define DP_REMOTE_CAP				0x05
42362306a36Sopenharmony_ci/* For DP IN adapter */
42462306a36Sopenharmony_ci#define DP_STATUS				0x06
42562306a36Sopenharmony_ci#define DP_STATUS_ALLOCATED_BW_MASK		GENMASK(31, 24)
42662306a36Sopenharmony_ci#define DP_STATUS_ALLOCATED_BW_SHIFT		24
42762306a36Sopenharmony_ci/* For DP OUT adapter */
42862306a36Sopenharmony_ci#define DP_STATUS_CTRL				0x06
42962306a36Sopenharmony_ci#define DP_STATUS_CTRL_CMHS			BIT(25)
43062306a36Sopenharmony_ci#define DP_STATUS_CTRL_UF			BIT(26)
43162306a36Sopenharmony_ci#define DP_COMMON_CAP				0x07
43262306a36Sopenharmony_ci/* Only if DP IN supports BW allocation mode */
43362306a36Sopenharmony_ci#define ADP_DP_CS_8				0x08
43462306a36Sopenharmony_ci#define ADP_DP_CS_8_REQUESTED_BW_MASK		GENMASK(7, 0)
43562306a36Sopenharmony_ci#define ADP_DP_CS_8_DPME			BIT(30)
43662306a36Sopenharmony_ci#define ADP_DP_CS_8_DR				BIT(31)
43762306a36Sopenharmony_ci
43862306a36Sopenharmony_ci/*
43962306a36Sopenharmony_ci * DP_COMMON_CAP offsets work also for DP_LOCAL_CAP and DP_REMOTE_CAP
44062306a36Sopenharmony_ci * with exception of DPRX done.
44162306a36Sopenharmony_ci */
44262306a36Sopenharmony_ci#define DP_COMMON_CAP_RATE_MASK			GENMASK(11, 8)
44362306a36Sopenharmony_ci#define DP_COMMON_CAP_RATE_SHIFT		8
44462306a36Sopenharmony_ci#define DP_COMMON_CAP_RATE_RBR			0x0
44562306a36Sopenharmony_ci#define DP_COMMON_CAP_RATE_HBR			0x1
44662306a36Sopenharmony_ci#define DP_COMMON_CAP_RATE_HBR2			0x2
44762306a36Sopenharmony_ci#define DP_COMMON_CAP_RATE_HBR3			0x3
44862306a36Sopenharmony_ci#define DP_COMMON_CAP_LANES_MASK		GENMASK(14, 12)
44962306a36Sopenharmony_ci#define DP_COMMON_CAP_LANES_SHIFT		12
45062306a36Sopenharmony_ci#define DP_COMMON_CAP_1_LANE			0x0
45162306a36Sopenharmony_ci#define DP_COMMON_CAP_2_LANES			0x1
45262306a36Sopenharmony_ci#define DP_COMMON_CAP_4_LANES			0x2
45362306a36Sopenharmony_ci#define DP_COMMON_CAP_UHBR10			BIT(17)
45462306a36Sopenharmony_ci#define DP_COMMON_CAP_UHBR20			BIT(18)
45562306a36Sopenharmony_ci#define DP_COMMON_CAP_UHBR13_5			BIT(19)
45662306a36Sopenharmony_ci#define DP_COMMON_CAP_LTTPR_NS			BIT(27)
45762306a36Sopenharmony_ci#define DP_COMMON_CAP_BW_MODE			BIT(28)
45862306a36Sopenharmony_ci#define DP_COMMON_CAP_DPRX_DONE			BIT(31)
45962306a36Sopenharmony_ci/* Only present if DP IN supports BW allocation mode */
46062306a36Sopenharmony_ci#define ADP_DP_CS_8				0x08
46162306a36Sopenharmony_ci#define ADP_DP_CS_8_DPME			BIT(30)
46262306a36Sopenharmony_ci#define ADP_DP_CS_8_DR				BIT(31)
46362306a36Sopenharmony_ci
46462306a36Sopenharmony_ci/* PCIe adapter registers */
46562306a36Sopenharmony_ci#define ADP_PCIE_CS_0				0x00
46662306a36Sopenharmony_ci#define ADP_PCIE_CS_0_PE			BIT(31)
46762306a36Sopenharmony_ci#define ADP_PCIE_CS_1				0x01
46862306a36Sopenharmony_ci#define ADP_PCIE_CS_1_EE			BIT(0)
46962306a36Sopenharmony_ci
47062306a36Sopenharmony_ci/* USB adapter registers */
47162306a36Sopenharmony_ci#define ADP_USB3_CS_0				0x00
47262306a36Sopenharmony_ci#define ADP_USB3_CS_0_V				BIT(30)
47362306a36Sopenharmony_ci#define ADP_USB3_CS_0_PE			BIT(31)
47462306a36Sopenharmony_ci#define ADP_USB3_CS_1				0x01
47562306a36Sopenharmony_ci#define ADP_USB3_CS_1_CUBW_MASK			GENMASK(11, 0)
47662306a36Sopenharmony_ci#define ADP_USB3_CS_1_CDBW_MASK			GENMASK(23, 12)
47762306a36Sopenharmony_ci#define ADP_USB3_CS_1_CDBW_SHIFT		12
47862306a36Sopenharmony_ci#define ADP_USB3_CS_1_HCA			BIT(31)
47962306a36Sopenharmony_ci#define ADP_USB3_CS_2				0x02
48062306a36Sopenharmony_ci#define ADP_USB3_CS_2_AUBW_MASK			GENMASK(11, 0)
48162306a36Sopenharmony_ci#define ADP_USB3_CS_2_ADBW_MASK			GENMASK(23, 12)
48262306a36Sopenharmony_ci#define ADP_USB3_CS_2_ADBW_SHIFT		12
48362306a36Sopenharmony_ci#define ADP_USB3_CS_2_CMR			BIT(31)
48462306a36Sopenharmony_ci#define ADP_USB3_CS_3				0x03
48562306a36Sopenharmony_ci#define ADP_USB3_CS_3_SCALE_MASK		GENMASK(5, 0)
48662306a36Sopenharmony_ci#define ADP_USB3_CS_4				0x04
48762306a36Sopenharmony_ci#define ADP_USB3_CS_4_ALR_MASK			GENMASK(6, 0)
48862306a36Sopenharmony_ci#define ADP_USB3_CS_4_ALR_20G			0x1
48962306a36Sopenharmony_ci#define ADP_USB3_CS_4_ULV			BIT(7)
49062306a36Sopenharmony_ci#define ADP_USB3_CS_4_MSLR_MASK			GENMASK(18, 12)
49162306a36Sopenharmony_ci#define ADP_USB3_CS_4_MSLR_SHIFT		12
49262306a36Sopenharmony_ci#define ADP_USB3_CS_4_MSLR_20G			0x1
49362306a36Sopenharmony_ci
49462306a36Sopenharmony_ci/* Hop register from TB_CFG_HOPS. 8 byte per entry. */
49562306a36Sopenharmony_cistruct tb_regs_hop {
49662306a36Sopenharmony_ci	/* DWORD 0 */
49762306a36Sopenharmony_ci	u32 next_hop:11; /*
49862306a36Sopenharmony_ci			  * hop to take after sending the packet through
49962306a36Sopenharmony_ci			  * out_port (on the incoming port of the next switch)
50062306a36Sopenharmony_ci			  */
50162306a36Sopenharmony_ci	u32 out_port:6; /* next port of the path (on the same switch) */
50262306a36Sopenharmony_ci	u32 initial_credits:8;
50362306a36Sopenharmony_ci	u32 unknown1:6; /* set to zero */
50462306a36Sopenharmony_ci	bool enable:1;
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_ci	/* DWORD 1 */
50762306a36Sopenharmony_ci	u32 weight:4;
50862306a36Sopenharmony_ci	u32 unknown2:4; /* set to zero */
50962306a36Sopenharmony_ci	u32 priority:3;
51062306a36Sopenharmony_ci	bool drop_packages:1;
51162306a36Sopenharmony_ci	u32 counter:11; /* index into TB_CFG_COUNTERS on this port */
51262306a36Sopenharmony_ci	bool counter_enable:1;
51362306a36Sopenharmony_ci	bool ingress_fc:1;
51462306a36Sopenharmony_ci	bool egress_fc:1;
51562306a36Sopenharmony_ci	bool ingress_shared_buffer:1;
51662306a36Sopenharmony_ci	bool egress_shared_buffer:1;
51762306a36Sopenharmony_ci	bool pending:1;
51862306a36Sopenharmony_ci	u32 unknown3:3; /* set to zero */
51962306a36Sopenharmony_ci} __packed;
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ci/* TMU Thunderbolt 3 registers */
52262306a36Sopenharmony_ci#define TB_TIME_VSEC_3_CS_9			0x9
52362306a36Sopenharmony_ci#define TB_TIME_VSEC_3_CS_9_TMU_OBJ_MASK	GENMASK(17, 16)
52462306a36Sopenharmony_ci#define TB_TIME_VSEC_3_CS_26			0x1a
52562306a36Sopenharmony_ci#define TB_TIME_VSEC_3_CS_26_TD			BIT(22)
52662306a36Sopenharmony_ci
52762306a36Sopenharmony_ci/*
52862306a36Sopenharmony_ci * Used for Titan Ridge only. Bits are part of the same register: TMU_ADP_CS_6
52962306a36Sopenharmony_ci * (see above) as in USB4 spec, but these specific bits used for Titan Ridge
53062306a36Sopenharmony_ci * only and reserved in USB4 spec.
53162306a36Sopenharmony_ci */
53262306a36Sopenharmony_ci#define TMU_ADP_CS_6_DISABLE_TMU_OBJ_MASK	GENMASK(3, 2)
53362306a36Sopenharmony_ci#define TMU_ADP_CS_6_DISABLE_TMU_OBJ_CL1	BIT(2)
53462306a36Sopenharmony_ci#define TMU_ADP_CS_6_DISABLE_TMU_OBJ_CL2	BIT(3)
53562306a36Sopenharmony_ci
53662306a36Sopenharmony_ci/* Plug Events registers */
53762306a36Sopenharmony_ci#define TB_PLUG_EVENTS_USB_DISABLE		BIT(2)
53862306a36Sopenharmony_ci#define TB_PLUG_EVENTS_CS_1_LANE_DISABLE	BIT(3)
53962306a36Sopenharmony_ci#define TB_PLUG_EVENTS_CS_1_DPOUT_DISABLE	BIT(4)
54062306a36Sopenharmony_ci#define TB_PLUG_EVENTS_CS_1_LOW_DPIN_DISABLE	BIT(5)
54162306a36Sopenharmony_ci#define TB_PLUG_EVENTS_CS_1_HIGH_DPIN_DISABLE	BIT(6)
54262306a36Sopenharmony_ci
54362306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_WR_DATA		0x1b
54462306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD			0x1c
54562306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_DW_OFFSET_MASK	GENMASK(9, 0)
54662306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_BR_SHIFT	10
54762306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_BR_MASK		GENMASK(17, 10)
54862306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_RD_WR_MASK	BIT(21)
54962306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_WR		0x1
55062306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_COMMAND_SHIFT	22
55162306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_COMMAND_MASK	GENMASK(24, 22)
55262306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_COMMAND_VAL	0x2
55362306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_REQ_ACK_MASK	BIT(30)
55462306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_TIMEOUT_MASK	BIT(31)
55562306a36Sopenharmony_ci#define TB_PLUG_EVENTS_PCIE_CMD_RD_DATA		0x1d
55662306a36Sopenharmony_ci
55762306a36Sopenharmony_ci/* CP Low Power registers */
55862306a36Sopenharmony_ci#define TB_LOW_PWR_C1_CL1			0x1
55962306a36Sopenharmony_ci#define TB_LOW_PWR_C1_CL1_OBJ_MASK		GENMASK(4, 1)
56062306a36Sopenharmony_ci#define TB_LOW_PWR_C1_CL2_OBJ_MASK		GENMASK(4, 1)
56162306a36Sopenharmony_ci#define TB_LOW_PWR_C1_PORT_A_MASK		GENMASK(2, 1)
56262306a36Sopenharmony_ci#define TB_LOW_PWR_C0_PORT_B_MASK		GENMASK(4, 3)
56362306a36Sopenharmony_ci#define TB_LOW_PWR_C3_CL1			0x3
56462306a36Sopenharmony_ci
56562306a36Sopenharmony_ci/* Common link controller registers */
56662306a36Sopenharmony_ci#define TB_LC_DESC				0x02
56762306a36Sopenharmony_ci#define TB_LC_DESC_NLC_MASK			GENMASK(3, 0)
56862306a36Sopenharmony_ci#define TB_LC_DESC_SIZE_SHIFT			8
56962306a36Sopenharmony_ci#define TB_LC_DESC_SIZE_MASK			GENMASK(15, 8)
57062306a36Sopenharmony_ci#define TB_LC_DESC_PORT_SIZE_SHIFT		16
57162306a36Sopenharmony_ci#define TB_LC_DESC_PORT_SIZE_MASK		GENMASK(27, 16)
57262306a36Sopenharmony_ci#define TB_LC_FUSE				0x03
57362306a36Sopenharmony_ci#define TB_LC_SNK_ALLOCATION			0x10
57462306a36Sopenharmony_ci#define TB_LC_SNK_ALLOCATION_SNK0_MASK		GENMASK(3, 0)
57562306a36Sopenharmony_ci#define TB_LC_SNK_ALLOCATION_SNK0_CM		0x1
57662306a36Sopenharmony_ci#define TB_LC_SNK_ALLOCATION_SNK1_SHIFT		4
57762306a36Sopenharmony_ci#define TB_LC_SNK_ALLOCATION_SNK1_MASK		GENMASK(7, 4)
57862306a36Sopenharmony_ci#define TB_LC_SNK_ALLOCATION_SNK1_CM		0x1
57962306a36Sopenharmony_ci#define TB_LC_POWER				0x740
58062306a36Sopenharmony_ci
58162306a36Sopenharmony_ci/* Link controller registers */
58262306a36Sopenharmony_ci#define TB_LC_CS_42				0x2a
58362306a36Sopenharmony_ci#define TB_LC_CS_42_USB_PLUGGED			BIT(31)
58462306a36Sopenharmony_ci
58562306a36Sopenharmony_ci#define TB_LC_PORT_ATTR				0x8d
58662306a36Sopenharmony_ci#define TB_LC_PORT_ATTR_BE			BIT(12)
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_ci#define TB_LC_SX_CTRL				0x96
58962306a36Sopenharmony_ci#define TB_LC_SX_CTRL_WOC			BIT(1)
59062306a36Sopenharmony_ci#define TB_LC_SX_CTRL_WOD			BIT(2)
59162306a36Sopenharmony_ci#define TB_LC_SX_CTRL_WODPC			BIT(3)
59262306a36Sopenharmony_ci#define TB_LC_SX_CTRL_WODPD			BIT(4)
59362306a36Sopenharmony_ci#define TB_LC_SX_CTRL_WOU4			BIT(5)
59462306a36Sopenharmony_ci#define TB_LC_SX_CTRL_WOP			BIT(6)
59562306a36Sopenharmony_ci#define TB_LC_SX_CTRL_L1C			BIT(16)
59662306a36Sopenharmony_ci#define TB_LC_SX_CTRL_L1D			BIT(17)
59762306a36Sopenharmony_ci#define TB_LC_SX_CTRL_L2C			BIT(20)
59862306a36Sopenharmony_ci#define TB_LC_SX_CTRL_L2D			BIT(21)
59962306a36Sopenharmony_ci#define TB_LC_SX_CTRL_SLI			BIT(29)
60062306a36Sopenharmony_ci#define TB_LC_SX_CTRL_UPSTREAM			BIT(30)
60162306a36Sopenharmony_ci#define TB_LC_SX_CTRL_SLP			BIT(31)
60262306a36Sopenharmony_ci#define TB_LC_LINK_ATTR				0x97
60362306a36Sopenharmony_ci#define TB_LC_LINK_ATTR_CPS			BIT(18)
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_ci#define TB_LC_LINK_REQ				0xad
60662306a36Sopenharmony_ci#define TB_LC_LINK_REQ_XHCI_CONNECT		BIT(31)
60762306a36Sopenharmony_ci
60862306a36Sopenharmony_ci#endif
609