diff options
author | Gil Fine <gil.fine@intel.com> | 2022-09-23 01:30:43 +0300 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2023-06-16 09:53:27 +0300 |
commit | 6e21007d0f7e6723bb67e79aa3d0081419c403e8 (patch) | |
tree | 7e04b5cacc8c13815a91cc1e38b7bac09c838469 /drivers/thunderbolt/tb.h | |
parent | 2ad3e1314cafad9a8edbefed2b19d2a101cdb4fc (diff) | |
download | lwn-6e21007d0f7e6723bb67e79aa3d0081419c403e8.tar.gz lwn-6e21007d0f7e6723bb67e79aa3d0081419c403e8.zip |
thunderbolt: Identify USB4 v2 routers
Add a new function usb4_switch_version() that can be used to figure out
the spec version of the router and make tb_switch_is_usb4() to use it as
well. Update the uevent accordingly.
Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt/tb.h')
-rw-r--r-- | drivers/thunderbolt/tb.h | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 58df106aaa5e..bc91fcf5f430 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -948,17 +948,6 @@ static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw) } /** - * tb_switch_is_usb4() - Is the switch USB4 compliant - * @sw: Switch to check - * - * Returns true if the @sw is USB4 compliant router, false otherwise. - */ -static inline bool tb_switch_is_usb4(const struct tb_switch *sw) -{ - return sw->config.thunderbolt_version == USB4_VERSION_1_0; -} - -/** * tb_switch_is_icm() - Is the switch handled by ICM firmware * @sw: Switch to check * @@ -1198,6 +1187,29 @@ static inline struct tb_retimer *tb_to_retimer(struct device *dev) return NULL; } +/** + * usb4_switch_version() - Returns USB4 version of the router + * @sw: Router to check + * + * Returns major version of USB4 router (%1 for v1, %2 for v2 and so + * on). Can be called to pre-USB4 router too and in that case returns %0. + */ +static inline unsigned int usb4_switch_version(const struct tb_switch *sw) +{ + return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version); +} + +/** + * tb_switch_is_usb4() - Is the switch USB4 compliant + * @sw: Switch to check + * + * Returns true if the @sw is USB4 compliant router, false otherwise. + */ +static inline bool tb_switch_is_usb4(const struct tb_switch *sw) +{ + return usb4_switch_version(sw) > 0; +} + int usb4_switch_setup(struct tb_switch *sw); int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid); int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf, |