2 * Thunderbolt control channel messages
5 * Copyright (C) 2017, Intel Corporation
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
15 #include <linux/types.h>
16 #include <linux/uuid.h>
26 TB_CFG_ERROR_PORT_NOT_CONNECTED = 0,
27 TB_CFG_ERROR_LINK_ERROR = 1,
28 TB_CFG_ERROR_INVALID_CONFIG_SPACE = 2,
29 TB_CFG_ERROR_NO_SUCH_PORT = 4,
30 TB_CFG_ERROR_ACK_PLUG_EVENT = 7, /* send as reply to TB_CFG_PKG_EVENT */
31 TB_CFG_ERROR_LOOP = 8,
32 TB_CFG_ERROR_HEC_ERROR_DETECTED = 12,
33 TB_CFG_ERROR_FLOW_CONTROL_ERROR = 13,
37 struct tb_cfg_header {
39 u32 unknown:10; /* highest order bit is set on replies */
43 /* additional header for read/write packets */
44 struct tb_cfg_address {
45 u32 offset:13; /* in dwords */
46 u32 length:6; /* in dwords */
48 enum tb_cfg_space space:2;
49 u32 seq:2; /* sequence number */
53 /* TB_CFG_PKG_READ, response for TB_CFG_PKG_WRITE */
55 struct tb_cfg_header header;
56 struct tb_cfg_address addr;
59 /* TB_CFG_PKG_WRITE, response for TB_CFG_PKG_READ */
60 struct cfg_write_pkg {
61 struct tb_cfg_header header;
62 struct tb_cfg_address addr;
63 u32 data[64]; /* maximum size, tb_cfg_address.length has 6 bits */
66 /* TB_CFG_PKG_ERROR */
67 struct cfg_error_pkg {
68 struct tb_cfg_header header;
69 enum tb_cfg_error error:4;
72 u32 zero2:2; /* Both should be zero, still they are different fields. */
76 /* TB_CFG_PKG_EVENT */
77 struct cfg_event_pkg {
78 struct tb_cfg_header header;
84 /* TB_CFG_PKG_RESET */
85 struct cfg_reset_pkg {
86 struct tb_cfg_header header;
89 /* TB_CFG_PKG_PREPARE_TO_SLEEP */
91 struct tb_cfg_header header;
98 ICM_GET_TOPOLOGY = 0x1,
99 ICM_DRIVER_READY = 0x3,
100 ICM_APPROVE_DEVICE = 0x4,
101 ICM_CHALLENGE_DEVICE = 0x5,
102 ICM_ADD_DEVICE_KEY = 0x6,
104 ICM_APPROVE_XDOMAIN = 0x10,
107 enum icm_event_code {
108 ICM_EVENT_DEVICE_CONNECTED = 3,
109 ICM_EVENT_DEVICE_DISCONNECTED = 4,
110 ICM_EVENT_XDOMAIN_CONNECTED = 6,
111 ICM_EVENT_XDOMAIN_DISCONNECTED = 7,
114 struct icm_pkg_header {
121 #define ICM_FLAGS_ERROR BIT(0)
122 #define ICM_FLAGS_NO_KEY BIT(1)
123 #define ICM_FLAGS_SLEVEL_SHIFT 3
124 #define ICM_FLAGS_SLEVEL_MASK GENMASK(4, 3)
126 struct icm_pkg_driver_ready {
127 struct icm_pkg_header hdr;
130 struct icm_pkg_driver_ready_response {
131 struct icm_pkg_header hdr;
137 /* Falcon Ridge & Alpine Ridge common messages */
139 struct icm_fr_pkg_get_topology {
140 struct icm_pkg_header hdr;
143 #define ICM_GET_TOPOLOGY_PACKETS 14
145 struct icm_fr_pkg_get_topology_response {
146 struct icm_pkg_header hdr;
151 u8 drom_i2c_address_index;
155 u32 port_hop_info[16];
158 #define ICM_SWITCH_USED BIT(0)
159 #define ICM_SWITCH_UPSTREAM_PORT_MASK GENMASK(7, 1)
160 #define ICM_SWITCH_UPSTREAM_PORT_SHIFT 1
162 #define ICM_PORT_TYPE_MASK GENMASK(23, 0)
163 #define ICM_PORT_INDEX_SHIFT 24
164 #define ICM_PORT_INDEX_MASK GENMASK(31, 24)
166 struct icm_fr_event_device_connected {
167 struct icm_pkg_header hdr;
175 #define ICM_LINK_INFO_LINK_MASK 0x7
176 #define ICM_LINK_INFO_DEPTH_SHIFT 4
177 #define ICM_LINK_INFO_DEPTH_MASK GENMASK(7, 4)
178 #define ICM_LINK_INFO_APPROVED BIT(8)
180 struct icm_fr_pkg_approve_device {
181 struct icm_pkg_header hdr;
188 struct icm_fr_event_device_disconnected {
189 struct icm_pkg_header hdr;
194 struct icm_fr_event_xdomain_connected {
195 struct icm_pkg_header hdr;
206 struct icm_fr_event_xdomain_disconnected {
207 struct icm_pkg_header hdr;
213 struct icm_fr_pkg_add_device_key {
214 struct icm_pkg_header hdr;
222 struct icm_fr_pkg_add_device_key_response {
223 struct icm_pkg_header hdr;
230 struct icm_fr_pkg_challenge_device {
231 struct icm_pkg_header hdr;
239 struct icm_fr_pkg_challenge_device_response {
240 struct icm_pkg_header hdr;
249 struct icm_fr_pkg_approve_xdomain {
250 struct icm_pkg_header hdr;
260 struct icm_fr_pkg_approve_xdomain_response {
261 struct icm_pkg_header hdr;
271 /* Alpine Ridge only messages */
273 struct icm_ar_pkg_get_route {
274 struct icm_pkg_header hdr;
279 struct icm_ar_pkg_get_route_response {
280 struct icm_pkg_header hdr;
287 /* XDomain messages */
289 struct tb_xdomain_header {
295 #define TB_XDOMAIN_LENGTH_MASK GENMASK(5, 0)
296 #define TB_XDOMAIN_SN_MASK GENMASK(28, 27)
297 #define TB_XDOMAIN_SN_SHIFT 27
300 UUID_REQUEST_OLD = 1,
304 PROPERTIES_CHANGED_REQUEST,
305 PROPERTIES_CHANGED_RESPONSE,
310 struct tb_xdp_header {
311 struct tb_xdomain_header xd_hdr;
316 struct tb_xdp_properties {
317 struct tb_xdp_header hdr;
324 struct tb_xdp_properties_response {
325 struct tb_xdp_header hdr;
335 * Max length of data array single XDomain property response is allowed
338 #define TB_XDP_PROPERTIES_MAX_DATA_LENGTH \
339 (((256 - 4 - sizeof(struct tb_xdp_properties_response))) / 4)
341 /* Maximum size of the total property block in dwords we allow */
342 #define TB_XDP_PROPERTIES_MAX_LENGTH 500
344 struct tb_xdp_properties_changed {
345 struct tb_xdp_header hdr;
349 struct tb_xdp_properties_changed_response {
350 struct tb_xdp_header hdr;
355 ERROR_UNKNOWN_PACKET,
356 ERROR_UNKNOWN_DOMAIN,
361 struct tb_xdp_error_response {
362 struct tb_xdp_header hdr;