Lines Matching full:sw
229 * @sw: Switch the port belongs to
256 struct tb_switch *sw; member
475 int (*runtime_suspend_switch)(struct tb_switch *sw);
476 int (*runtime_resume_switch)(struct tb_switch *sw);
481 int (*disapprove_switch)(struct tb *tb, struct tb_switch *sw);
482 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
483 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
484 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
493 int (*usb4_switch_op)(struct tb_switch *sw, u16 opcode, u32 *metadata,
496 int (*usb4_switch_nvm_authenticate_status)(struct tb_switch *sw,
519 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw) in tb_upstream_port() argument
521 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
533 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
537 static inline u64 tb_route(const struct tb_switch *sw) in tb_route() argument
539 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
542 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) in tb_port_at() argument
546 port = route >> (sw->config.depth * 8); in tb_port_at()
547 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
549 return &sw->ports[port]; in tb_port_at()
610 static inline int tb_sw_read(struct tb_switch *sw, void *buffer, in tb_sw_read() argument
613 if (sw->is_unplugged) in tb_sw_read()
615 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
617 tb_route(sw), in tb_sw_read()
624 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer, in tb_sw_write() argument
627 if (sw->is_unplugged) in tb_sw_write()
629 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
631 tb_route(sw), in tb_sw_write()
641 if (port->sw->is_unplugged) in tb_port_read()
643 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
645 tb_route(port->sw), in tb_port_read()
655 if (port->sw->is_unplugged) in tb_port_write()
657 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
659 tb_route(port->sw), in tb_port_write()
672 #define __TB_SW_PRINT(level, sw, fmt, arg...) \ argument
674 const struct tb_switch *__sw = (sw); \
678 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg) argument
679 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg) argument
680 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg) argument
681 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg) argument
686 level(__port->sw->tb, "%llx:%u: " fmt, \
687 tb_route(__port->sw), __port->port, ## arg); \
722 int tb_domain_disapprove_switch(struct tb *tb, struct tb_switch *sw);
723 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
724 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
725 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
768 int tb_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
774 int tb_switch_configure(struct tb_switch *sw);
775 int tb_switch_add(struct tb_switch *sw);
776 void tb_switch_remove(struct tb_switch *sw);
777 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
778 int tb_switch_resume(struct tb_switch *sw);
779 int tb_switch_reset(struct tb_switch *sw);
780 int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
782 void tb_sw_set_unplugged(struct tb_switch *sw);
783 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
792 * @sw: Switch whose ports to iterate
797 #define tb_switch_for_each_port(sw, p) \ argument
798 for ((p) = &(sw)->ports[1]; \
799 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
801 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw) in tb_switch_get() argument
803 if (sw) in tb_switch_get()
804 get_device(&sw->dev); in tb_switch_get()
805 return sw; in tb_switch_get()
808 static inline void tb_switch_put(struct tb_switch *sw) in tb_switch_put() argument
810 put_device(&sw->dev); in tb_switch_put()
825 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw) in tb_switch_parent() argument
827 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
830 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw) in tb_switch_is_light_ridge() argument
832 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
833 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
836 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw) in tb_switch_is_eagle_ridge() argument
838 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
839 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
842 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw) in tb_switch_is_cactus_ridge() argument
844 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
845 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
854 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw) in tb_switch_is_falcon_ridge() argument
856 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
857 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
866 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw) in tb_switch_is_alpine_ridge() argument
868 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
869 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
881 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw) in tb_switch_is_titan_ridge() argument
883 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
884 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
894 static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw) in tb_switch_is_tiger_lake() argument
896 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
897 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
910 * @sw: Switch to check
912 * Returns true if the @sw is USB4 compliant router, false otherwise.
914 static inline bool tb_switch_is_usb4(const struct tb_switch *sw) in tb_switch_is_usb4() argument
916 return sw->config.thunderbolt_version == USB4_VERSION_1_0; in tb_switch_is_usb4()
921 * @sw: Switch to check
923 * In case there is a need to differentiate whether ICM firmware or SW CM
924 * is handling @sw this function can be called. It is valid to call this
926 * (latter only for SW CM case).
928 static inline bool tb_switch_is_icm(const struct tb_switch *sw) in tb_switch_is_icm() argument
930 return !sw->config.enabled; in tb_switch_is_icm()
933 int tb_switch_lane_bonding_enable(struct tb_switch *sw);
934 void tb_switch_lane_bonding_disable(struct tb_switch *sw);
935 int tb_switch_configure_link(struct tb_switch *sw);
936 void tb_switch_unconfigure_link(struct tb_switch *sw);
938 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
939 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
940 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
942 int tb_switch_tmu_init(struct tb_switch *sw);
943 int tb_switch_tmu_post_time(struct tb_switch *sw);
944 int tb_switch_tmu_disable(struct tb_switch *sw);
945 int tb_switch_tmu_enable(struct tb_switch *sw);
946 void tb_switch_tmu_configure(struct tb_switch *sw,
949 void tb_switch_enable_tmu_1st_child(struct tb_switch *sw,
953 * @sw: Router whose TMU mode to check
959 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw, in tb_switch_tmu_is_enabled() argument
962 return sw->tmu.rate == sw->tmu.rate_request && in tb_switch_tmu_is_enabled()
963 sw->tmu.unidirectional == unidirectional; in tb_switch_tmu_is_enabled()
977 int tb_switch_enable_clx(struct tb_switch *sw, enum tb_clx clx);
978 int tb_switch_disable_clx(struct tb_switch *sw, enum tb_clx clx);
982 * @sw: Router to check for the CLx
988 static inline bool tb_switch_is_clx_enabled(const struct tb_switch *sw, in tb_switch_is_clx_enabled() argument
991 return sw->clx == clx; in tb_switch_is_clx_enabled()
996 * @sw: The router to check CLx support for
998 static inline bool tb_switch_is_clx_supported(const struct tb_switch *sw) in tb_switch_is_clx_supported() argument
1000 return tb_switch_is_usb4(sw) || tb_switch_is_titan_ridge(sw); in tb_switch_is_clx_supported()
1003 int tb_switch_mask_clx_objections(struct tb_switch *sw);
1005 int tb_switch_pcie_l1_enable(struct tb_switch *sw);
1007 int tb_switch_xhci_connect(struct tb_switch *sw);
1008 void tb_switch_xhci_disconnect(struct tb_switch *sw);
1026 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
1052 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
1053 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
1054 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
1097 int tb_drom_read(struct tb_switch *sw);
1098 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
1100 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
1111 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
1112 int tb_lc_set_sleep(struct tb_switch *sw);
1113 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
1114 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
1115 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
1116 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
1117 int tb_lc_force_power(struct tb_switch *sw);
1133 return tb_route(port->sw) in tb_downstream_route()
1134 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1170 int usb4_switch_setup(struct tb_switch *sw);
1171 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
1172 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
1174 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
1175 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
1176 int usb4_switch_set_sleep(struct tb_switch *sw);
1177 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
1178 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
1180 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address);
1181 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
1183 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
1184 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status);
1185 int usb4_switch_credits_init(struct tb_switch *sw);
1186 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1187 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1188 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1189 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
1191 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1193 int usb4_switch_add_ports(struct tb_switch *sw);
1194 void usb4_switch_remove_ports(struct tb_switch *sw);
1260 void tb_check_quirks(struct tb_switch *sw);
1293 void tb_switch_debugfs_init(struct tb_switch *sw);
1294 void tb_switch_debugfs_remove(struct tb_switch *sw);
1302 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { } in tb_switch_debugfs_init() argument
1303 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { } in tb_switch_debugfs_remove() argument