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,
555 * @sw: Router
564 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw) in tb_upstream_port() argument
566 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
578 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
582 static inline u64 tb_route(const struct tb_switch *sw) in tb_route() argument
584 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
587 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) in tb_port_at() argument
591 port = route >> (sw->config.depth * 8); in tb_port_at()
592 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
594 return &sw->ports[port]; in tb_port_at()
671 static inline int tb_sw_read(struct tb_switch *sw, void *buffer, in tb_sw_read() argument
674 if (sw->is_unplugged) in tb_sw_read()
676 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
678 tb_route(sw), in tb_sw_read()
685 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer, in tb_sw_write() argument
688 if (sw->is_unplugged) in tb_sw_write()
690 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
692 tb_route(sw), in tb_sw_write()
702 if (port->sw->is_unplugged) in tb_port_read()
704 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
706 tb_route(port->sw), in tb_port_read()
716 if (port->sw->is_unplugged) in tb_port_write()
718 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
720 tb_route(port->sw), in tb_port_write()
733 #define __TB_SW_PRINT(level, sw, fmt, arg...) \ argument
735 const struct tb_switch *__sw = (sw); \
739 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg) argument
740 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg) argument
741 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg) argument
742 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg) argument
747 level(__port->sw->tb, "%llx:%u: " fmt, \
748 tb_route(__port->sw), __port->port, ## arg); \
783 int tb_domain_disapprove_switch(struct tb *tb, struct tb_switch *sw);
784 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
785 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
786 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
842 int tb_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
848 int tb_switch_configure(struct tb_switch *sw);
849 int tb_switch_configuration_valid(struct tb_switch *sw);
850 int tb_switch_add(struct tb_switch *sw);
851 void tb_switch_remove(struct tb_switch *sw);
852 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
853 int tb_switch_resume(struct tb_switch *sw, bool runtime);
854 int tb_switch_reset(struct tb_switch *sw);
855 int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
857 void tb_sw_set_unplugged(struct tb_switch *sw);
858 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
867 * @sw: Switch whose ports to iterate
872 #define tb_switch_for_each_port(sw, p) \ argument
873 for ((p) = &(sw)->ports[1]; \
874 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
876 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw) in tb_switch_get() argument
878 if (sw) in tb_switch_get()
879 get_device(&sw->dev); in tb_switch_get()
880 return sw; in tb_switch_get()
883 static inline void tb_switch_put(struct tb_switch *sw) in tb_switch_put() argument
885 put_device(&sw->dev); in tb_switch_put()
900 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw) in tb_switch_parent() argument
902 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
907 * @sw: Device router pointer
913 static inline struct tb_port *tb_switch_downstream_port(struct tb_switch *sw) in tb_switch_downstream_port() argument
915 if (WARN_ON(!tb_route(sw))) in tb_switch_downstream_port()
917 return tb_port_at(tb_route(sw), tb_switch_parent(sw)); in tb_switch_downstream_port()
922 * @sw: Router
926 static inline int tb_switch_depth(const struct tb_switch *sw) in tb_switch_depth() argument
928 return sw->config.depth; in tb_switch_depth()
931 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw) in tb_switch_is_light_ridge() argument
933 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
934 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
937 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw) in tb_switch_is_eagle_ridge() argument
939 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
940 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
943 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw) in tb_switch_is_cactus_ridge() argument
945 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
946 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
955 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw) in tb_switch_is_falcon_ridge() argument
957 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
958 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
967 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw) in tb_switch_is_alpine_ridge() argument
969 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
970 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
982 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw) in tb_switch_is_titan_ridge() argument
984 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
985 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
995 static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw) in tb_switch_is_tiger_lake() argument
997 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
998 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
1011 * @sw: Switch to check
1013 * In case there is a need to differentiate whether ICM firmware or SW CM
1014 * is handling @sw this function can be called. It is valid to call this
1016 * (latter only for SW CM case).
1021 static inline bool tb_switch_is_icm(const struct tb_switch *sw) in tb_switch_is_icm() argument
1023 return !sw->config.enabled; in tb_switch_is_icm()
1026 int tb_switch_set_link_width(struct tb_switch *sw, enum tb_link_width width);
1027 int tb_switch_configure_link(struct tb_switch *sw);
1028 void tb_switch_unconfigure_link(struct tb_switch *sw);
1030 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1031 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1032 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1034 int tb_switch_tmu_init(struct tb_switch *sw);
1035 int tb_switch_tmu_post_time(struct tb_switch *sw);
1036 int tb_switch_tmu_disable(struct tb_switch *sw);
1037 int tb_switch_tmu_enable(struct tb_switch *sw);
1038 int tb_switch_tmu_configure(struct tb_switch *sw, enum tb_switch_tmu_mode mode);
1042 * @sw: Router whose mode to check
1050 static inline bool tb_switch_tmu_is_configured(const struct tb_switch *sw, in tb_switch_tmu_is_configured() argument
1053 return sw->tmu.mode_request == mode; in tb_switch_tmu_is_configured()
1058 * @sw: Router whose TMU mode to check
1063 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw) in tb_switch_tmu_is_enabled() argument
1065 return sw->tmu.mode != TB_SWITCH_TMU_MODE_OFF && in tb_switch_tmu_is_enabled()
1066 sw->tmu.mode == sw->tmu.mode_request; in tb_switch_tmu_is_enabled()
1071 int tb_switch_clx_init(struct tb_switch *sw);
1072 int tb_switch_clx_enable(struct tb_switch *sw, unsigned int clx);
1073 int tb_switch_clx_disable(struct tb_switch *sw);
1077 * @sw: Router to check for the CLx
1086 static inline bool tb_switch_clx_is_enabled(const struct tb_switch *sw, in tb_switch_clx_is_enabled() argument
1089 return sw->clx & clx; in tb_switch_clx_is_enabled()
1092 int tb_switch_pcie_l1_enable(struct tb_switch *sw);
1094 int tb_switch_xhci_connect(struct tb_switch *sw);
1095 void tb_switch_xhci_disconnect(struct tb_switch *sw);
1123 return src->sw->config.depth < dst->sw->config.depth; in tb_port_path_direction_downstream()
1128 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
1169 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
1170 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
1171 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
1215 int tb_drom_read(struct tb_switch *sw);
1216 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
1218 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
1230 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
1231 int tb_lc_set_sleep(struct tb_switch *sw);
1232 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
1233 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
1234 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
1235 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
1236 int tb_lc_force_power(struct tb_switch *sw);
1253 return tb_route(port->sw) in tb_downstream_route()
1254 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1303 * @sw: Router to check
1308 static inline unsigned int usb4_switch_version(const struct tb_switch *sw) in usb4_switch_version() argument
1310 return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version); in usb4_switch_version()
1315 * @sw: Switch to check
1317 * Return: %true if the @sw is USB4 compliant router, %false otherwise.
1319 static inline bool tb_switch_is_usb4(const struct tb_switch *sw) in tb_switch_is_usb4() argument
1321 return usb4_switch_version(sw) > 0; in tb_switch_is_usb4()
1324 void usb4_switch_check_wakes(struct tb_switch *sw);
1325 int usb4_switch_setup(struct tb_switch *sw);
1326 int usb4_switch_configuration_valid(struct tb_switch *sw);
1327 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
1328 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
1330 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
1331 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags, bool runtime);
1332 int usb4_switch_set_sleep(struct tb_switch *sw);
1333 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
1334 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
1336 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address);
1337 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
1339 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
1340 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status);
1341 int usb4_switch_credits_init(struct tb_switch *sw);
1342 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1343 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1344 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1345 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
1347 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1349 int usb4_switch_add_ports(struct tb_switch *sw);
1350 void usb4_switch_remove_ports(struct tb_switch *sw);
1497 int usb4_port_index(const struct tb_switch *sw, const struct tb_port *port);
1504 void tb_check_quirks(struct tb_switch *sw);
1537 void tb_switch_debugfs_init(struct tb_switch *sw);
1538 void tb_switch_debugfs_remove(struct tb_switch *sw);
1548 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { } in tb_switch_debugfs_init() argument
1549 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { } in tb_switch_debugfs_remove() argument