summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2017-06-06 08:25:06 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-06-09 05:42:42 -0400
commit32af9434f0b9fd31a68bf5be204667c1e17ddffe (patch)
tree4c0be5eaf2a818cf0fb3efc06594bde92b76c2e0 /drivers/thunderbolt
parent72ee33907b629355d8fd1980140a467041a9f519 (diff)
thunderbolt: Move control channel messages to tb_msgs.h
We will be forwarding notifications received from the control channel to the connection manager implementations. This way they can decide what to do if anything when a notification is received. To be able to use control channel messages from other files, move them to tb_msgs.h. No functional changes intended. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Yehezkel Bernat <yehezkel.bernat@intel.com> Reviewed-by: Michael Jamet <michael.jamet@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Andreas Noever <andreas.noever@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r--drivers/thunderbolt/ctl.c76
-rw-r--r--drivers/thunderbolt/ctl.h16
-rw-r--r--drivers/thunderbolt/tb_msgs.h108
3 files changed, 109 insertions, 91 deletions
diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index f8290a577b2b..24118c60b062 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -52,82 +52,6 @@ struct tb_ctl {
52#define tb_ctl_info(ctl, format, arg...) \ 52#define tb_ctl_info(ctl, format, arg...) \
53 dev_info(&(ctl)->nhi->pdev->dev, format, ## arg) 53 dev_info(&(ctl)->nhi->pdev->dev, format, ## arg)
54 54
55
56/* configuration packets definitions */
57
58enum tb_cfg_pkg_type {
59 TB_CFG_PKG_READ = 1,
60 TB_CFG_PKG_WRITE = 2,
61 TB_CFG_PKG_ERROR = 3,
62 TB_CFG_PKG_NOTIFY_ACK = 4,
63 TB_CFG_PKG_EVENT = 5,
64 TB_CFG_PKG_XDOMAIN_REQ = 6,
65 TB_CFG_PKG_XDOMAIN_RESP = 7,
66 TB_CFG_PKG_OVERRIDE = 8,
67 TB_CFG_PKG_RESET = 9,
68 TB_CFG_PKG_PREPARE_TO_SLEEP = 0xd,
69};
70
71/* common header */
72struct tb_cfg_header {
73 u32 route_hi:22;
74 u32 unknown:10; /* highest order bit is set on replies */
75 u32 route_lo;
76} __packed;
77
78/* additional header for read/write packets */
79struct tb_cfg_address {
80 u32 offset:13; /* in dwords */
81 u32 length:6; /* in dwords */
82 u32 port:6;
83 enum tb_cfg_space space:2;
84 u32 seq:2; /* sequence number */
85 u32 zero:3;
86} __packed;
87
88/* TB_CFG_PKG_READ, response for TB_CFG_PKG_WRITE */
89struct cfg_read_pkg {
90 struct tb_cfg_header header;
91 struct tb_cfg_address addr;
92} __packed;
93
94/* TB_CFG_PKG_WRITE, response for TB_CFG_PKG_READ */
95struct cfg_write_pkg {
96 struct tb_cfg_header header;
97 struct tb_cfg_address addr;
98 u32 data[64]; /* maximum size, tb_cfg_address.length has 6 bits */
99} __packed;
100
101/* TB_CFG_PKG_ERROR */
102struct cfg_error_pkg {
103 struct tb_cfg_header header;
104 enum tb_cfg_error error:4;
105 u32 zero1:4;
106 u32 port:6;
107 u32 zero2:2; /* Both should be zero, still they are different fields. */
108 u32 zero3:16;
109} __packed;
110
111/* TB_CFG_PKG_EVENT */
112struct cfg_event_pkg {
113 struct tb_cfg_header header;
114 u32 port:6;
115 u32 zero:25;
116 bool unplug:1;
117} __packed;
118
119/* TB_CFG_PKG_RESET */
120struct cfg_reset_pkg {
121 struct tb_cfg_header header;
122} __packed;
123
124/* TB_CFG_PKG_PREPARE_TO_SLEEP */
125struct cfg_pts_pkg {
126 struct tb_cfg_header header;
127 u32 data;
128} __packed;
129
130
131/* utility functions */ 55/* utility functions */
132 56
133static u64 get_route(struct tb_cfg_header header) 57static u64 get_route(struct tb_cfg_header header)
diff --git a/drivers/thunderbolt/ctl.h b/drivers/thunderbolt/ctl.h
index 83ae54947082..610980e3232f 100644
--- a/drivers/thunderbolt/ctl.h
+++ b/drivers/thunderbolt/ctl.h
@@ -8,6 +8,7 @@
8#define _TB_CFG 8#define _TB_CFG
9 9
10#include "nhi.h" 10#include "nhi.h"
11#include "tb_msgs.h"
11 12
12/* control channel */ 13/* control channel */
13struct tb_ctl; 14struct tb_ctl;
@@ -23,21 +24,6 @@ void tb_ctl_free(struct tb_ctl *ctl);
23 24
24#define TB_CFG_DEFAULT_TIMEOUT 5000 /* msec */ 25#define TB_CFG_DEFAULT_TIMEOUT 5000 /* msec */
25 26
26enum tb_cfg_space {
27 TB_CFG_HOPS = 0,
28 TB_CFG_PORT = 1,
29 TB_CFG_SWITCH = 2,
30 TB_CFG_COUNTERS = 3,
31};
32
33enum tb_cfg_error {
34 TB_CFG_ERROR_PORT_NOT_CONNECTED = 0,
35 TB_CFG_ERROR_INVALID_CONFIG_SPACE = 2,
36 TB_CFG_ERROR_NO_SUCH_PORT = 4,
37 TB_CFG_ERROR_ACK_PLUG_EVENT = 7, /* send as reply to TB_CFG_PKG_EVENT */
38 TB_CFG_ERROR_LOOP = 8,
39};
40
41struct tb_cfg_result { 27struct tb_cfg_result {
42 u64 response_route; 28 u64 response_route;
43 u32 response_port; /* 29 u32 response_port; /*
diff --git a/drivers/thunderbolt/tb_msgs.h b/drivers/thunderbolt/tb_msgs.h
new file mode 100644
index 000000000000..761d56287149
--- /dev/null
+++ b/drivers/thunderbolt/tb_msgs.h
@@ -0,0 +1,108 @@
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
17enum 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
31enum 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
38enum 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 */
50struct 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 */
57struct 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 */
67struct 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 */
73struct 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 */
80struct 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 */
90struct 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 */
98struct cfg_reset_pkg {
99 struct tb_cfg_header header;
100} __packed;
101
102/* TB_CFG_PKG_PREPARE_TO_SLEEP */
103struct cfg_pts_pkg {
104 struct tb_cfg_header header;
105 u32 data;
106} __packed;
107
108#endif