Lines Matching full:sw

249  * @sw: Switch the port belongs to
282 struct tb_switch *sw; member
519 int (*runtime_suspend_switch)(struct tb_switch *sw);
520 int (*runtime_resume_switch)(struct tb_switch *sw);
525 int (*disapprove_switch)(struct tb *tb, struct tb_switch *sw);
526 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
527 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
528 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
537 int (*usb4_switch_op)(struct tb_switch *sw, u16 opcode, u32 *metadata,
540 int (*usb4_switch_nvm_authenticate_status)(struct tb_switch *sw,
563 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw) in tb_upstream_port() argument
565 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
577 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
581 static inline u64 tb_route(const struct tb_switch *sw) in tb_route() argument
583 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
586 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) in tb_port_at() argument
590 port = route >> (sw->config.depth * 8); in tb_port_at()
591 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
593 return &sw->ports[port]; in tb_port_at()
670 static inline int tb_sw_read(struct tb_switch *sw, void *buffer, in tb_sw_read() argument
673 if (sw->is_unplugged) in tb_sw_read()
675 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
677 tb_route(sw), in tb_sw_read()
684 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer, in tb_sw_write() argument
687 if (sw->is_unplugged) in tb_sw_write()
689 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
691 tb_route(sw), in tb_sw_write()
701 if (port->sw->is_unplugged) in tb_port_read()
703 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
705 tb_route(port->sw), in tb_port_read()
715 if (port->sw->is_unplugged) in tb_port_write()
717 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
719 tb_route(port->sw), in tb_port_write()
732 #define __TB_SW_PRINT(level, sw, fmt, arg...) \ argument
734 const struct tb_switch *__sw = (sw); \
738 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg) argument
739 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg) argument
740 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg) argument
741 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg) argument
746 level(__port->sw->tb, "%llx:%u: " fmt, \
747 tb_route(__port->sw), __port->port, ## arg); \
782 int tb_domain_disapprove_switch(struct tb *tb, struct tb_switch *sw);
783 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
784 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
785 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
828 int tb_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
834 int tb_switch_configure(struct tb_switch *sw);
835 int tb_switch_configuration_valid(struct tb_switch *sw);
836 int tb_switch_add(struct tb_switch *sw);
837 void tb_switch_remove(struct tb_switch *sw);
838 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
839 int tb_switch_resume(struct tb_switch *sw, bool runtime);
840 int tb_switch_reset(struct tb_switch *sw);
841 int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
843 void tb_sw_set_unplugged(struct tb_switch *sw);
844 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
853 * @sw: Switch whose ports to iterate
858 #define tb_switch_for_each_port(sw, p) \ argument
859 for ((p) = &(sw)->ports[1]; \
860 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
862 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw) in tb_switch_get() argument
864 if (sw) in tb_switch_get()
865 get_device(&sw->dev); in tb_switch_get()
866 return sw; in tb_switch_get()
869 static inline void tb_switch_put(struct tb_switch *sw) in tb_switch_put() argument
871 put_device(&sw->dev); in tb_switch_put()
886 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw) in tb_switch_parent() argument
888 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
893 * @sw: Device router pointer
898 static inline struct tb_port *tb_switch_downstream_port(struct tb_switch *sw) in tb_switch_downstream_port() argument
900 if (WARN_ON(!tb_route(sw))) in tb_switch_downstream_port()
902 return tb_port_at(tb_route(sw), tb_switch_parent(sw)); in tb_switch_downstream_port()
907 * @sw: Router
909 static inline int tb_switch_depth(const struct tb_switch *sw) in tb_switch_depth() argument
911 return sw->config.depth; in tb_switch_depth()
914 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw) in tb_switch_is_light_ridge() argument
916 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
917 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
920 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw) in tb_switch_is_eagle_ridge() argument
922 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
923 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
926 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw) in tb_switch_is_cactus_ridge() argument
928 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
929 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
938 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw) in tb_switch_is_falcon_ridge() argument
940 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
941 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
950 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw) in tb_switch_is_alpine_ridge() argument
952 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
953 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
965 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw) in tb_switch_is_titan_ridge() argument
967 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
968 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
978 static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw) in tb_switch_is_tiger_lake() argument
980 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
981 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
994 * @sw: Switch to check
996 * In case there is a need to differentiate whether ICM firmware or SW CM
997 * is handling @sw this function can be called. It is valid to call this
999 * (latter only for SW CM case).
1001 static inline bool tb_switch_is_icm(const struct tb_switch *sw) in tb_switch_is_icm() argument
1003 return !sw->config.enabled; in tb_switch_is_icm()
1006 int tb_switch_set_link_width(struct tb_switch *sw, enum tb_link_width width);
1007 int tb_switch_configure_link(struct tb_switch *sw);
1008 void tb_switch_unconfigure_link(struct tb_switch *sw);
1010 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1011 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1012 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1014 int tb_switch_tmu_init(struct tb_switch *sw);
1015 int tb_switch_tmu_post_time(struct tb_switch *sw);
1016 int tb_switch_tmu_disable(struct tb_switch *sw);
1017 int tb_switch_tmu_enable(struct tb_switch *sw);
1018 int tb_switch_tmu_configure(struct tb_switch *sw, enum tb_switch_tmu_mode mode);
1022 * @sw: Router whose mode to check
1028 static inline bool tb_switch_tmu_is_configured(const struct tb_switch *sw, in tb_switch_tmu_is_configured() argument
1031 return sw->tmu.mode_request == mode; in tb_switch_tmu_is_configured()
1036 * @sw: Router whose TMU mode to check
1041 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw) in tb_switch_tmu_is_enabled() argument
1043 return sw->tmu.mode != TB_SWITCH_TMU_MODE_OFF && in tb_switch_tmu_is_enabled()
1044 sw->tmu.mode == sw->tmu.mode_request; in tb_switch_tmu_is_enabled()
1049 int tb_switch_clx_init(struct tb_switch *sw);
1050 int tb_switch_clx_enable(struct tb_switch *sw, unsigned int clx);
1051 int tb_switch_clx_disable(struct tb_switch *sw);
1055 * @sw: Router to check for the CLx
1063 static inline bool tb_switch_clx_is_enabled(const struct tb_switch *sw, in tb_switch_clx_is_enabled() argument
1066 return sw->clx & clx; in tb_switch_clx_is_enabled()
1069 int tb_switch_pcie_l1_enable(struct tb_switch *sw);
1071 int tb_switch_xhci_connect(struct tb_switch *sw);
1072 void tb_switch_xhci_disconnect(struct tb_switch *sw);
1100 return src->sw->config.depth < dst->sw->config.depth; in tb_port_path_direction_downstream()
1105 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
1146 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
1147 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
1148 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
1192 int tb_drom_read(struct tb_switch *sw);
1193 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
1195 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
1207 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
1208 int tb_lc_set_sleep(struct tb_switch *sw);
1209 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
1210 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
1211 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
1212 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
1213 int tb_lc_force_power(struct tb_switch *sw);
1229 return tb_route(port->sw) in tb_downstream_route()
1230 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1279 * @sw: Router to check
1284 static inline unsigned int usb4_switch_version(const struct tb_switch *sw) in usb4_switch_version() argument
1286 return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version); in usb4_switch_version()
1291 * @sw: Switch to check
1293 * Returns true if the @sw is USB4 compliant router, false otherwise.
1295 static inline bool tb_switch_is_usb4(const struct tb_switch *sw) in tb_switch_is_usb4() argument
1297 return usb4_switch_version(sw) > 0; in tb_switch_is_usb4()
1300 void usb4_switch_check_wakes(struct tb_switch *sw);
1301 int usb4_switch_setup(struct tb_switch *sw);
1302 int usb4_switch_configuration_valid(struct tb_switch *sw);
1303 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
1304 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
1306 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
1307 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
1308 int usb4_switch_set_sleep(struct tb_switch *sw);
1309 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
1310 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
1312 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address);
1313 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
1315 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
1316 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status);
1317 int usb4_switch_credits_init(struct tb_switch *sw);
1318 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1319 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1320 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1321 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
1323 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1325 int usb4_switch_add_ports(struct tb_switch *sw);
1326 void usb4_switch_remove_ports(struct tb_switch *sw);
1477 void tb_check_quirks(struct tb_switch *sw);
1510 void tb_switch_debugfs_init(struct tb_switch *sw);
1511 void tb_switch_debugfs_remove(struct tb_switch *sw);
1521 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { } in tb_switch_debugfs_init() argument
1522 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { } in tb_switch_debugfs_remove() argument