Lines Matching full:sw
235 * @sw: Switch the port belongs to
267 struct tb_switch *sw; member
496 int (*runtime_suspend_switch)(struct tb_switch *sw);
497 int (*runtime_resume_switch)(struct tb_switch *sw);
502 int (*disapprove_switch)(struct tb *tb, struct tb_switch *sw);
503 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
504 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
505 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
514 int (*usb4_switch_op)(struct tb_switch *sw, u16 opcode, u32 *metadata,
517 int (*usb4_switch_nvm_authenticate_status)(struct tb_switch *sw,
540 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw) in tb_upstream_port() argument
542 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
554 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
558 static inline u64 tb_route(const struct tb_switch *sw) in tb_route() argument
560 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
563 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) in tb_port_at() argument
567 port = route >> (sw->config.depth * 8); in tb_port_at()
568 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
570 return &sw->ports[port]; in tb_port_at()
647 static inline int tb_sw_read(struct tb_switch *sw, void *buffer, in tb_sw_read() argument
650 if (sw->is_unplugged) in tb_sw_read()
652 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
654 tb_route(sw), in tb_sw_read()
661 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer, in tb_sw_write() argument
664 if (sw->is_unplugged) in tb_sw_write()
666 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
668 tb_route(sw), in tb_sw_write()
678 if (port->sw->is_unplugged) in tb_port_read()
680 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
682 tb_route(port->sw), in tb_port_read()
692 if (port->sw->is_unplugged) in tb_port_write()
694 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
696 tb_route(port->sw), in tb_port_write()
709 #define __TB_SW_PRINT(level, sw, fmt, arg...) \ argument
711 const struct tb_switch *__sw = (sw); \
715 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg) argument
716 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg) argument
717 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg) argument
718 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg) argument
723 level(__port->sw->tb, "%llx:%u: " fmt, \
724 tb_route(__port->sw), __port->port, ## arg); \
759 int tb_domain_disapprove_switch(struct tb *tb, struct tb_switch *sw);
760 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
761 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
762 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
805 int tb_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
811 int tb_switch_configure(struct tb_switch *sw);
812 int tb_switch_configuration_valid(struct tb_switch *sw);
813 int tb_switch_add(struct tb_switch *sw);
814 void tb_switch_remove(struct tb_switch *sw);
815 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
816 int tb_switch_resume(struct tb_switch *sw);
817 int tb_switch_reset(struct tb_switch *sw);
818 int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
820 void tb_sw_set_unplugged(struct tb_switch *sw);
821 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
830 * @sw: Switch whose ports to iterate
835 #define tb_switch_for_each_port(sw, p) \ argument
836 for ((p) = &(sw)->ports[1]; \
837 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
839 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw) in tb_switch_get() argument
841 if (sw) in tb_switch_get()
842 get_device(&sw->dev); in tb_switch_get()
843 return sw; in tb_switch_get()
846 static inline void tb_switch_put(struct tb_switch *sw) in tb_switch_put() argument
848 put_device(&sw->dev); in tb_switch_put()
863 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw) in tb_switch_parent() argument
865 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
870 * @sw: Device router pointer
875 static inline struct tb_port *tb_switch_downstream_port(struct tb_switch *sw) in tb_switch_downstream_port() argument
877 if (WARN_ON(!tb_route(sw))) in tb_switch_downstream_port()
879 return tb_port_at(tb_route(sw), tb_switch_parent(sw)); in tb_switch_downstream_port()
884 * @sw: Router
886 static inline int tb_switch_depth(const struct tb_switch *sw) in tb_switch_depth() argument
888 return sw->config.depth; in tb_switch_depth()
891 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw) in tb_switch_is_light_ridge() argument
893 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
894 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
897 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw) in tb_switch_is_eagle_ridge() argument
899 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
900 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
903 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw) in tb_switch_is_cactus_ridge() argument
905 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
906 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
915 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw) in tb_switch_is_falcon_ridge() argument
917 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
918 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
927 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw) in tb_switch_is_alpine_ridge() argument
929 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
930 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
942 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw) in tb_switch_is_titan_ridge() argument
944 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
945 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
955 static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw) in tb_switch_is_tiger_lake() argument
957 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
958 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
971 * @sw: Switch to check
973 * In case there is a need to differentiate whether ICM firmware or SW CM
974 * is handling @sw this function can be called. It is valid to call this
976 * (latter only for SW CM case).
978 static inline bool tb_switch_is_icm(const struct tb_switch *sw) in tb_switch_is_icm() argument
980 return !sw->config.enabled; in tb_switch_is_icm()
983 int tb_switch_set_link_width(struct tb_switch *sw, enum tb_link_width width);
984 int tb_switch_configure_link(struct tb_switch *sw);
985 void tb_switch_unconfigure_link(struct tb_switch *sw);
987 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
988 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
989 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
991 int tb_switch_tmu_init(struct tb_switch *sw);
992 int tb_switch_tmu_post_time(struct tb_switch *sw);
993 int tb_switch_tmu_disable(struct tb_switch *sw);
994 int tb_switch_tmu_enable(struct tb_switch *sw);
995 int tb_switch_tmu_configure(struct tb_switch *sw, enum tb_switch_tmu_mode mode);
999 * @sw: Router whose mode to check
1005 static inline bool tb_switch_tmu_is_configured(const struct tb_switch *sw, in tb_switch_tmu_is_configured() argument
1008 return sw->tmu.mode_request == mode; in tb_switch_tmu_is_configured()
1013 * @sw: Router whose TMU mode to check
1018 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw) in tb_switch_tmu_is_enabled() argument
1020 return sw->tmu.mode != TB_SWITCH_TMU_MODE_OFF && in tb_switch_tmu_is_enabled()
1021 sw->tmu.mode == sw->tmu.mode_request; in tb_switch_tmu_is_enabled()
1026 int tb_switch_clx_init(struct tb_switch *sw);
1027 int tb_switch_clx_enable(struct tb_switch *sw, unsigned int clx);
1028 int tb_switch_clx_disable(struct tb_switch *sw);
1032 * @sw: Router to check for the CLx
1040 static inline bool tb_switch_clx_is_enabled(const struct tb_switch *sw, in tb_switch_clx_is_enabled() argument
1043 return sw->clx & clx; in tb_switch_clx_is_enabled()
1046 int tb_switch_pcie_l1_enable(struct tb_switch *sw);
1048 int tb_switch_xhci_connect(struct tb_switch *sw);
1049 void tb_switch_xhci_disconnect(struct tb_switch *sw);
1077 return src->sw->config.depth < dst->sw->config.depth; in tb_port_path_direction_downstream()
1082 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
1123 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
1124 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
1125 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
1168 int tb_drom_read(struct tb_switch *sw);
1169 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
1171 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
1182 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
1183 int tb_lc_set_sleep(struct tb_switch *sw);
1184 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
1185 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
1186 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
1187 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
1188 int tb_lc_force_power(struct tb_switch *sw);
1204 return tb_route(port->sw) in tb_downstream_route()
1205 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1254 * @sw: Router to check
1259 static inline unsigned int usb4_switch_version(const struct tb_switch *sw) in usb4_switch_version() argument
1261 return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version); in usb4_switch_version()
1266 * @sw: Switch to check
1268 * Returns true if the @sw is USB4 compliant router, false otherwise.
1270 static inline bool tb_switch_is_usb4(const struct tb_switch *sw) in tb_switch_is_usb4() argument
1272 return usb4_switch_version(sw) > 0; in tb_switch_is_usb4()
1275 int usb4_switch_setup(struct tb_switch *sw);
1276 int usb4_switch_configuration_valid(struct tb_switch *sw);
1277 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
1278 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
1280 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
1281 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
1282 int usb4_switch_set_sleep(struct tb_switch *sw);
1283 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
1284 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
1286 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address);
1287 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
1289 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
1290 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status);
1291 int usb4_switch_credits_init(struct tb_switch *sw);
1292 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1293 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1294 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1295 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
1297 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1299 int usb4_switch_add_ports(struct tb_switch *sw);
1300 void usb4_switch_remove_ports(struct tb_switch *sw);
1391 void tb_check_quirks(struct tb_switch *sw);
1424 void tb_switch_debugfs_init(struct tb_switch *sw);
1425 void tb_switch_debugfs_remove(struct tb_switch *sw);
1433 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { } in tb_switch_debugfs_init() argument
1434 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { } in tb_switch_debugfs_remove() argument