thunderbolt: Move control channel messages to tb_msgs.h
[platform/kernel/linux-rpi.git] / drivers / thunderbolt / tb_msgs.h
1 /*
2  * Thunderbolt control channel messages
3  *
4  * Copyright (C) 2014 Andreas Noever <andreas.noever@gmail.com>
5  * Copyright (C) 2017, Intel Corporation
6  *
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.
10  */
11
12 #ifndef _TB_MSGS
13 #define _TB_MSGS
14
15 #include <linux/types.h>
16
17 enum tb_cfg_pkg_type {
18         TB_CFG_PKG_READ = 1,
19         TB_CFG_PKG_WRITE = 2,
20         TB_CFG_PKG_ERROR = 3,
21         TB_CFG_PKG_NOTIFY_ACK = 4,
22         TB_CFG_PKG_EVENT = 5,
23         TB_CFG_PKG_XDOMAIN_REQ = 6,
24         TB_CFG_PKG_XDOMAIN_RESP = 7,
25         TB_CFG_PKG_OVERRIDE = 8,
26         TB_CFG_PKG_RESET = 9,
27         TB_CFG_PKG_PREPARE_TO_SLEEP = 0xd,
28
29 };
30
31 enum tb_cfg_space {
32         TB_CFG_HOPS = 0,
33         TB_CFG_PORT = 1,
34         TB_CFG_SWITCH = 2,
35         TB_CFG_COUNTERS = 3,
36 };
37
38 enum tb_cfg_error {
39         TB_CFG_ERROR_PORT_NOT_CONNECTED = 0,
40         TB_CFG_ERROR_LINK_ERROR = 1,
41         TB_CFG_ERROR_INVALID_CONFIG_SPACE = 2,
42         TB_CFG_ERROR_NO_SUCH_PORT = 4,
43         TB_CFG_ERROR_ACK_PLUG_EVENT = 7, /* send as reply to TB_CFG_PKG_EVENT */
44         TB_CFG_ERROR_LOOP = 8,
45         TB_CFG_ERROR_HEC_ERROR_DETECTED = 12,
46         TB_CFG_ERROR_FLOW_CONTROL_ERROR = 13,
47 };
48
49 /* common header */
50 struct tb_cfg_header {
51         u32 route_hi:22;
52         u32 unknown:10; /* highest order bit is set on replies */
53         u32 route_lo;
54 } __packed;
55
56 /* additional header for read/write packets */
57 struct tb_cfg_address {
58         u32 offset:13; /* in dwords */
59         u32 length:6; /* in dwords */
60         u32 port:6;
61         enum tb_cfg_space space:2;
62         u32 seq:2; /* sequence number  */
63         u32 zero:3;
64 } __packed;
65
66 /* TB_CFG_PKG_READ, response for TB_CFG_PKG_WRITE */
67 struct cfg_read_pkg {
68         struct tb_cfg_header header;
69         struct tb_cfg_address addr;
70 } __packed;
71
72 /* TB_CFG_PKG_WRITE, response for TB_CFG_PKG_READ */
73 struct cfg_write_pkg {
74         struct tb_cfg_header header;
75         struct tb_cfg_address addr;
76         u32 data[64]; /* maximum size, tb_cfg_address.length has 6 bits */
77 } __packed;
78
79 /* TB_CFG_PKG_ERROR */
80 struct cfg_error_pkg {
81         struct tb_cfg_header header;
82         enum tb_cfg_error error:4;
83         u32 zero1:4;
84         u32 port:6;
85         u32 zero2:2; /* Both should be zero, still they are different fields. */
86         u32 zero3:16;
87 } __packed;
88
89 /* TB_CFG_PKG_EVENT */
90 struct cfg_event_pkg {
91         struct tb_cfg_header header;
92         u32 port:6;
93         u32 zero:25;
94         bool unplug:1;
95 } __packed;
96
97 /* TB_CFG_PKG_RESET */
98 struct cfg_reset_pkg {
99         struct tb_cfg_header header;
100 } __packed;
101
102 /* TB_CFG_PKG_PREPARE_TO_SLEEP */
103 struct cfg_pts_pkg {
104         struct tb_cfg_header header;
105         u32 data;
106 } __packed;
107
108 #endif