Lines Matching refs:sw
238 * @sw: Switch the port belongs to
270 struct tb_switch *sw;
497 int (*runtime_suspend_switch)(struct tb_switch *sw);
498 int (*runtime_resume_switch)(struct tb_switch *sw);
503 int (*disapprove_switch)(struct tb *tb, struct tb_switch *sw);
504 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
505 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
506 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
515 int (*usb4_switch_op)(struct tb_switch *sw, u16 opcode, u32 *metadata,
518 int (*usb4_switch_nvm_authenticate_status)(struct tb_switch *sw,
541 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw)
543 return &sw->ports[sw->config.upstream_port_number];
555 const struct tb_port *upstream_port = tb_upstream_port(port->sw);
559 static inline u64 tb_route(const struct tb_switch *sw)
561 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo;
564 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw)
568 port = route >> (sw->config.depth * 8);
569 if (WARN_ON(port > sw->config.max_port_number))
571 return &sw->ports[port];
632 static inline int tb_sw_read(struct tb_switch *sw, void *buffer,
635 if (sw->is_unplugged)
637 return tb_cfg_read(sw->tb->ctl,
639 tb_route(sw),
646 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer,
649 if (sw->is_unplugged)
651 return tb_cfg_write(sw->tb->ctl,
653 tb_route(sw),
663 if (port->sw->is_unplugged)
665 return tb_cfg_read(port->sw->tb->ctl,
667 tb_route(port->sw),
677 if (port->sw->is_unplugged)
679 return tb_cfg_write(port->sw->tb->ctl,
681 tb_route(port->sw),
694 #define __TB_SW_PRINT(level, sw, fmt, arg...) \
696 const struct tb_switch *__sw = (sw); \
700 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg)
701 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg)
702 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg)
703 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg)
708 level(__port->sw->tb, "%llx:%u: " fmt, \
709 tb_route(__port->sw), __port->port, ## arg); \
744 int tb_domain_disapprove_switch(struct tb *tb, struct tb_switch *sw);
745 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
746 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
747 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
790 int tb_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
796 int tb_switch_configure(struct tb_switch *sw);
797 int tb_switch_configuration_valid(struct tb_switch *sw);
798 int tb_switch_add(struct tb_switch *sw);
799 void tb_switch_remove(struct tb_switch *sw);
800 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
801 int tb_switch_resume(struct tb_switch *sw);
802 int tb_switch_reset(struct tb_switch *sw);
803 int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
805 void tb_sw_set_unplugged(struct tb_switch *sw);
806 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
815 * @sw: Switch whose ports to iterate
820 #define tb_switch_for_each_port(sw, p) \
821 for ((p) = &(sw)->ports[1]; \
822 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
824 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw)
826 if (sw)
827 get_device(&sw->dev);
828 return sw;
831 static inline void tb_switch_put(struct tb_switch *sw)
833 put_device(&sw->dev);
848 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw)
850 return tb_to_switch(sw->dev.parent);
855 * @sw: Device router pointer
860 static inline struct tb_port *tb_switch_downstream_port(struct tb_switch *sw)
862 if (WARN_ON(!tb_route(sw)))
864 return tb_port_at(tb_route(sw), tb_switch_parent(sw));
867 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw)
869 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL &&
870 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE;
873 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw)
875 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL &&
876 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE;
879 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw)
881 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
882 switch (sw->config.device_id) {
891 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw)
893 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
894 switch (sw->config.device_id) {
903 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw)
905 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
906 switch (sw->config.device_id) {
918 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw)
920 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
921 switch (sw->config.device_id) {
931 static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw)
933 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
934 switch (sw->config.device_id) {
947 * @sw: Switch to check
950 * is handling @sw this function can be called. It is valid to call this
954 static inline bool tb_switch_is_icm(const struct tb_switch *sw)
956 return !sw->config.enabled;
959 int tb_switch_lane_bonding_enable(struct tb_switch *sw);
960 void tb_switch_lane_bonding_disable(struct tb_switch *sw);
961 int tb_switch_configure_link(struct tb_switch *sw);
962 void tb_switch_unconfigure_link(struct tb_switch *sw);
964 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
965 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
966 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
968 int tb_switch_tmu_init(struct tb_switch *sw);
969 int tb_switch_tmu_post_time(struct tb_switch *sw);
970 int tb_switch_tmu_disable(struct tb_switch *sw);
971 int tb_switch_tmu_enable(struct tb_switch *sw);
972 int tb_switch_tmu_configure(struct tb_switch *sw, enum tb_switch_tmu_mode mode);
976 * @sw: Router whose mode to check
982 static inline bool tb_switch_tmu_is_configured(const struct tb_switch *sw,
985 return sw->tmu.mode_request == mode;
990 * @sw: Router whose TMU mode to check
995 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw)
997 return sw->tmu.mode != TB_SWITCH_TMU_MODE_OFF &&
998 sw->tmu.mode == sw->tmu.mode_request;
1003 int tb_switch_clx_init(struct tb_switch *sw);
1004 bool tb_switch_clx_is_supported(const struct tb_switch *sw);
1005 int tb_switch_clx_enable(struct tb_switch *sw, unsigned int clx);
1006 int tb_switch_clx_disable(struct tb_switch *sw);
1010 * @sw: Router to check for the CLx
1018 static inline bool tb_switch_clx_is_enabled(const struct tb_switch *sw,
1021 return sw->clx & clx;
1024 int tb_switch_pcie_l1_enable(struct tb_switch *sw);
1026 int tb_switch_xhci_connect(struct tb_switch *sw);
1027 void tb_switch_xhci_disconnect(struct tb_switch *sw);
1045 return tb_port_is_null(port) && port->sw->credit_allocation;
1069 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
1070 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
1071 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
1114 int tb_drom_read(struct tb_switch *sw);
1115 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
1117 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
1128 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
1129 int tb_lc_set_sleep(struct tb_switch *sw);
1130 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
1131 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
1132 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
1133 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
1134 int tb_lc_force_power(struct tb_switch *sw);
1150 return tb_route(port->sw)
1151 | ((u64) port->port << (port->sw->config.depth * 8));
1200 * @sw: Router to check
1205 static inline unsigned int usb4_switch_version(const struct tb_switch *sw)
1207 return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version);
1212 * @sw: Switch to check
1214 * Returns true if the @sw is USB4 compliant router, false otherwise.
1216 static inline bool tb_switch_is_usb4(const struct tb_switch *sw)
1218 return usb4_switch_version(sw) > 0;
1221 int usb4_switch_setup(struct tb_switch *sw);
1222 int usb4_switch_configuration_valid(struct tb_switch *sw);
1223 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
1224 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
1226 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
1227 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
1228 int usb4_switch_set_sleep(struct tb_switch *sw);
1229 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
1230 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
1232 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address);
1233 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
1235 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
1236 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status);
1237 int usb4_switch_credits_init(struct tb_switch *sw);
1238 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1239 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1240 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1241 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
1243 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1245 int usb4_switch_add_ports(struct tb_switch *sw);
1246 void usb4_switch_remove_ports(struct tb_switch *sw);
1333 void tb_check_quirks(struct tb_switch *sw);
1366 void tb_switch_debugfs_init(struct tb_switch *sw);
1367 void tb_switch_debugfs_remove(struct tb_switch *sw);
1375 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { }
1376 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { }