Lines Matching refs:sw

183  * @sw: Switch the port belongs to
202 struct tb_switch *sw;
383 int (*runtime_suspend_switch)(struct tb_switch *sw);
384 int (*runtime_resume_switch)(struct tb_switch *sw);
389 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
390 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
391 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
417 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw)
419 return &sw->ports[sw->config.upstream_port_number];
431 const struct tb_port *upstream_port = tb_upstream_port(port->sw);
435 static inline u64 tb_route(const struct tb_switch *sw)
437 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo;
440 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw)
444 port = route >> (sw->config.depth * 8);
445 if (WARN_ON(port > sw->config.max_port_number))
447 return &sw->ports[port];
508 static inline int tb_sw_read(struct tb_switch *sw, void *buffer,
511 if (sw->is_unplugged)
513 return tb_cfg_read(sw->tb->ctl,
515 tb_route(sw),
522 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer,
525 if (sw->is_unplugged)
527 return tb_cfg_write(sw->tb->ctl,
529 tb_route(sw),
539 if (port->sw->is_unplugged)
541 return tb_cfg_read(port->sw->tb->ctl,
543 tb_route(port->sw),
553 if (port->sw->is_unplugged)
555 return tb_cfg_write(port->sw->tb->ctl,
557 tb_route(port->sw),
570 #define __TB_SW_PRINT(level, sw, fmt, arg...) \
572 const struct tb_switch *__sw = (sw); \
576 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg)
577 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg)
578 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg)
579 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg)
584 level(__port->sw->tb, "%llx:%x: " fmt, \
585 tb_route(__port->sw), __port->port, ## arg); \
619 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
620 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
621 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
652 int tb_switch_configure(struct tb_switch *sw);
653 int tb_switch_add(struct tb_switch *sw);
654 void tb_switch_remove(struct tb_switch *sw);
655 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
656 int tb_switch_resume(struct tb_switch *sw);
657 int tb_switch_reset(struct tb_switch *sw);
658 void tb_sw_set_unplugged(struct tb_switch *sw);
659 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
668 * @sw: Switch whose ports to iterate
673 #define tb_switch_for_each_port(sw, p) \
674 for ((p) = &(sw)->ports[1]; \
675 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
677 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw)
679 if (sw)
680 get_device(&sw->dev);
681 return sw;
684 static inline void tb_switch_put(struct tb_switch *sw)
686 put_device(&sw->dev);
701 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw)
703 return tb_to_switch(sw->dev.parent);
706 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw)
708 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL &&
709 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE;
712 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw)
714 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL &&
715 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE;
718 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw)
720 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
721 switch (sw->config.device_id) {
730 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw)
732 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
733 switch (sw->config.device_id) {
742 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw)
744 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
745 switch (sw->config.device_id) {
756 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw)
758 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
759 switch (sw->config.device_id) {
769 static inline bool tb_switch_is_ice_lake(const struct tb_switch *sw)
771 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
772 switch (sw->config.device_id) {
781 static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw)
783 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
784 switch (sw->config.device_id) {
797 * @sw: Switch to check
799 * Returns true if the @sw is USB4 compliant router, false otherwise.
801 static inline bool tb_switch_is_usb4(const struct tb_switch *sw)
803 return sw->config.thunderbolt_version == USB4_VERSION_1_0;
808 * @sw: Switch to check
811 * is handling @sw this function can be called. It is valid to call this
815 static inline bool tb_switch_is_icm(const struct tb_switch *sw)
817 return !sw->config.enabled;
820 int tb_switch_lane_bonding_enable(struct tb_switch *sw);
821 void tb_switch_lane_bonding_disable(struct tb_switch *sw);
822 int tb_switch_configure_link(struct tb_switch *sw);
823 void tb_switch_unconfigure_link(struct tb_switch *sw);
825 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
826 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
827 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
829 int tb_switch_tmu_init(struct tb_switch *sw);
830 int tb_switch_tmu_post_time(struct tb_switch *sw);
831 int tb_switch_tmu_disable(struct tb_switch *sw);
832 int tb_switch_tmu_enable(struct tb_switch *sw);
834 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw)
836 return sw->tmu.rate == TB_SWITCH_TMU_RATE_HIFI &&
837 !sw->tmu.unidirectional;
868 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
869 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
870 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
901 int tb_drom_read(struct tb_switch *sw);
902 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
904 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
909 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
910 int tb_lc_set_sleep(struct tb_switch *sw);
911 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
912 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
913 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
914 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
915 int tb_lc_force_power(struct tb_switch *sw);
931 return tb_route(port->sw)
932 | ((u64) port->port << (port->sw->config.depth * 8));
960 int usb4_switch_setup(struct tb_switch *sw);
961 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
962 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
964 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
965 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
966 int usb4_switch_set_sleep(struct tb_switch *sw);
967 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
968 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
970 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
972 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
973 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
974 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
975 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
976 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
978 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1016 void tb_check_quirks(struct tb_switch *sw);
1027 void tb_switch_debugfs_init(struct tb_switch *sw);
1028 void tb_switch_debugfs_remove(struct tb_switch *sw);
1032 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { }
1033 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { }