summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt/tb.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thunderbolt/tb.h')
-rw-r--r--drivers/thunderbolt/tb.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 5fab4c44f124..f7dfe733d71a 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -8,20 +8,36 @@
8#define TB_H_ 8#define TB_H_
9 9
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/uuid.h>
11 12
12#include "tb_regs.h" 13#include "tb_regs.h"
13#include "ctl.h" 14#include "ctl.h"
14 15
15/** 16/**
16 * struct tb_switch - a thunderbolt switch 17 * struct tb_switch - a thunderbolt switch
18 * @dev: Device for the switch
19 * @config: Switch configuration
20 * @ports: Ports in this switch
21 * @tb: Pointer to the domain the switch belongs to
22 * @uid: Unique ID of the switch
23 * @uuid: UUID of the switch (or %NULL if not supported)
24 * @vendor: Vendor ID of the switch
25 * @device: Device ID of the switch
26 * @cap_plug_events: Offset to the plug events capability (%0 if not found)
27 * @is_unplugged: The switch is going away
28 * @drom: DROM of the switch (%NULL if not found)
17 */ 29 */
18struct tb_switch { 30struct tb_switch {
31 struct device dev;
19 struct tb_regs_switch_header config; 32 struct tb_regs_switch_header config;
20 struct tb_port *ports; 33 struct tb_port *ports;
21 struct tb *tb; 34 struct tb *tb;
22 u64 uid; 35 u64 uid;
23 int cap_plug_events; /* offset, zero if not found */ 36 uuid_be *uuid;
24 bool is_unplugged; /* unplugged, will go away */ 37 u16 vendor;
38 u16 device;
39 int cap_plug_events;
40 bool is_unplugged;
25 u8 *drom; 41 u8 *drom;
26}; 42};
27 43
@@ -242,6 +258,7 @@ struct tb *tb_probe(struct tb_nhi *nhi);
242 258
243extern struct bus_type tb_bus_type; 259extern struct bus_type tb_bus_type;
244extern struct device_type tb_domain_type; 260extern struct device_type tb_domain_type;
261extern struct device_type tb_switch_type;
245 262
246int tb_domain_init(void); 263int tb_domain_init(void);
247void tb_domain_exit(void); 264void tb_domain_exit(void);
@@ -257,14 +274,34 @@ static inline void tb_domain_put(struct tb *tb)
257 put_device(&tb->dev); 274 put_device(&tb->dev);
258} 275}
259 276
260struct tb_switch *tb_switch_alloc(struct tb *tb, u64 route); 277struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,
261void tb_switch_free(struct tb_switch *sw); 278 u64 route);
279int tb_switch_configure(struct tb_switch *sw);
280int tb_switch_add(struct tb_switch *sw);
281void tb_switch_remove(struct tb_switch *sw);
262void tb_switch_suspend(struct tb_switch *sw); 282void tb_switch_suspend(struct tb_switch *sw);
263int tb_switch_resume(struct tb_switch *sw); 283int tb_switch_resume(struct tb_switch *sw);
264int tb_switch_reset(struct tb *tb, u64 route); 284int tb_switch_reset(struct tb *tb, u64 route);
265void tb_sw_set_unplugged(struct tb_switch *sw); 285void tb_sw_set_unplugged(struct tb_switch *sw);
266struct tb_switch *get_switch_at_route(struct tb_switch *sw, u64 route); 286struct tb_switch *get_switch_at_route(struct tb_switch *sw, u64 route);
267 287
288static inline void tb_switch_put(struct tb_switch *sw)
289{
290 put_device(&sw->dev);
291}
292
293static inline bool tb_is_switch(const struct device *dev)
294{
295 return dev->type == &tb_switch_type;
296}
297
298static inline struct tb_switch *tb_to_switch(struct device *dev)
299{
300 if (tb_is_switch(dev))
301 return container_of(dev, struct tb_switch, dev);
302 return NULL;
303}
304
268int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged); 305int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged);
269int tb_port_add_nfc_credits(struct tb_port *port, int credits); 306int tb_port_add_nfc_credits(struct tb_port *port, int credits);
270int tb_port_clear_counter(struct tb_port *port, int counter); 307int tb_port_clear_counter(struct tb_port *port, int counter);