diff options
Diffstat (limited to 'drivers/thunderbolt/tb.h')
-rw-r--r-- | drivers/thunderbolt/tb.h | 45 |
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 | */ |
18 | struct tb_switch { | 30 | struct 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 | ||
243 | extern struct bus_type tb_bus_type; | 259 | extern struct bus_type tb_bus_type; |
244 | extern struct device_type tb_domain_type; | 260 | extern struct device_type tb_domain_type; |
261 | extern struct device_type tb_switch_type; | ||
245 | 262 | ||
246 | int tb_domain_init(void); | 263 | int tb_domain_init(void); |
247 | void tb_domain_exit(void); | 264 | void 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 | ||
260 | struct tb_switch *tb_switch_alloc(struct tb *tb, u64 route); | 277 | struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent, |
261 | void tb_switch_free(struct tb_switch *sw); | 278 | u64 route); |
279 | int tb_switch_configure(struct tb_switch *sw); | ||
280 | int tb_switch_add(struct tb_switch *sw); | ||
281 | void tb_switch_remove(struct tb_switch *sw); | ||
262 | void tb_switch_suspend(struct tb_switch *sw); | 282 | void tb_switch_suspend(struct tb_switch *sw); |
263 | int tb_switch_resume(struct tb_switch *sw); | 283 | int tb_switch_resume(struct tb_switch *sw); |
264 | int tb_switch_reset(struct tb *tb, u64 route); | 284 | int tb_switch_reset(struct tb *tb, u64 route); |
265 | void tb_sw_set_unplugged(struct tb_switch *sw); | 285 | void tb_sw_set_unplugged(struct tb_switch *sw); |
266 | struct tb_switch *get_switch_at_route(struct tb_switch *sw, u64 route); | 286 | struct tb_switch *get_switch_at_route(struct tb_switch *sw, u64 route); |
267 | 287 | ||
288 | static inline void tb_switch_put(struct tb_switch *sw) | ||
289 | { | ||
290 | put_device(&sw->dev); | ||
291 | } | ||
292 | |||
293 | static inline bool tb_is_switch(const struct device *dev) | ||
294 | { | ||
295 | return dev->type == &tb_switch_type; | ||
296 | } | ||
297 | |||
298 | static 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 | |||
268 | int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged); | 305 | int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged); |
269 | int tb_port_add_nfc_credits(struct tb_port *port, int credits); | 306 | int tb_port_add_nfc_credits(struct tb_port *port, int credits); |
270 | int tb_port_clear_counter(struct tb_port *port, int counter); | 307 | int tb_port_clear_counter(struct tb_port *port, int counter); |