diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2017-06-06 14:25:01 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-06-09 11:42:42 +0200 |
commit | bfe778ac49826ced3dceb6416038e1cd887ce2bd (patch) | |
tree | 194b78bdbef54c49b4b98109414925550db383d3 /drivers/thunderbolt/tb.h | |
parent | thunderbolt: Introduce thunderbolt bus and connection manager (diff) | |
download | linux-bfe778ac49826ced3dceb6416038e1cd887ce2bd.tar.xz linux-bfe778ac49826ced3dceb6416038e1cd887ce2bd.zip |
thunderbolt: Convert switch to a device
Thunderbolt domain consists of switches that are connected to each
other, forming a bus. This will convert each switch into a real Linux
device structure and adds them to the domain. The advantage here is
that we get all the goodies from the driver core, like reference
counting and sysfs hierarchy for free.
Also expose device identification information to the userspace via new
sysfs attributes.
In order to support internal connection manager (ICM) we separate switch
configuration into its own function (tb_switch_configure()) which is
only called by the existing native connection manager implementation
used on Macs.
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/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 @@ #define TB_H_ #include <linux/pci.h> +#include <linux/uuid.h> #include "tb_regs.h" #include "ctl.h" /** * struct tb_switch - a thunderbolt switch + * @dev: Device for the switch + * @config: Switch configuration + * @ports: Ports in this switch + * @tb: Pointer to the domain the switch belongs to + * @uid: Unique ID of the switch + * @uuid: UUID of the switch (or %NULL if not supported) + * @vendor: Vendor ID of the switch + * @device: Device ID of the switch + * @cap_plug_events: Offset to the plug events capability (%0 if not found) + * @is_unplugged: The switch is going away + * @drom: DROM of the switch (%NULL if not found) */ struct tb_switch { + struct device dev; struct tb_regs_switch_header config; struct tb_port *ports; struct tb *tb; u64 uid; - int cap_plug_events; /* offset, zero if not found */ - bool is_unplugged; /* unplugged, will go away */ + uuid_be *uuid; + u16 vendor; + u16 device; + int cap_plug_events; + bool is_unplugged; u8 *drom; }; @@ -242,6 +258,7 @@ struct tb *tb_probe(struct tb_nhi *nhi); extern struct bus_type tb_bus_type; extern struct device_type tb_domain_type; +extern struct device_type tb_switch_type; int tb_domain_init(void); void tb_domain_exit(void); @@ -257,14 +274,34 @@ static inline void tb_domain_put(struct tb *tb) put_device(&tb->dev); } -struct tb_switch *tb_switch_alloc(struct tb *tb, u64 route); -void tb_switch_free(struct tb_switch *sw); +struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent, + u64 route); +int tb_switch_configure(struct tb_switch *sw); +int tb_switch_add(struct tb_switch *sw); +void tb_switch_remove(struct tb_switch *sw); void tb_switch_suspend(struct tb_switch *sw); int tb_switch_resume(struct tb_switch *sw); int tb_switch_reset(struct tb *tb, u64 route); void tb_sw_set_unplugged(struct tb_switch *sw); struct tb_switch *get_switch_at_route(struct tb_switch *sw, u64 route); +static inline void tb_switch_put(struct tb_switch *sw) +{ + put_device(&sw->dev); +} + +static inline bool tb_is_switch(const struct device *dev) +{ + return dev->type == &tb_switch_type; +} + +static inline struct tb_switch *tb_to_switch(struct device *dev) +{ + if (tb_is_switch(dev)) + return container_of(dev, struct tb_switch, dev); + return NULL; +} + int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged); int tb_port_add_nfc_credits(struct tb_port *port, int credits); int tb_port_clear_counter(struct tb_port *port, int counter); |