Lines Matching refs:sw

277 	struct tb_switch *sw;  member
514 int (*runtime_suspend_switch)(struct tb_switch *sw);
515 int (*runtime_resume_switch)(struct tb_switch *sw);
520 int (*disapprove_switch)(struct tb *tb, struct tb_switch *sw);
521 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
522 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
523 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
532 int (*usb4_switch_op)(struct tb_switch *sw, u16 opcode, u32 *metadata,
535 int (*usb4_switch_nvm_authenticate_status)(struct tb_switch *sw,
558 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw) in tb_upstream_port() argument
560 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
572 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
576 static inline u64 tb_route(const struct tb_switch *sw) in tb_route() argument
578 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
581 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) in tb_port_at() argument
585 port = route >> (sw->config.depth * 8); in tb_port_at()
586 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
588 return &sw->ports[port]; in tb_port_at()
665 static inline int tb_sw_read(struct tb_switch *sw, void *buffer, in tb_sw_read() argument
668 if (sw->is_unplugged) in tb_sw_read()
670 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
672 tb_route(sw), in tb_sw_read()
679 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer, in tb_sw_write() argument
682 if (sw->is_unplugged) in tb_sw_write()
684 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
686 tb_route(sw), in tb_sw_write()
696 if (port->sw->is_unplugged) in tb_port_read()
698 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
700 tb_route(port->sw), in tb_port_read()
710 if (port->sw->is_unplugged) in tb_port_write()
712 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
714 tb_route(port->sw), in tb_port_write()
727 #define __TB_SW_PRINT(level, sw, fmt, arg...) \ argument
729 const struct tb_switch *__sw = (sw); \
733 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg) argument
734 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg) argument
735 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg) argument
736 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg) argument
741 level(__port->sw->tb, "%llx:%u: " fmt, \
742 tb_route(__port->sw), __port->port, ## arg); \
777 int tb_domain_disapprove_switch(struct tb *tb, struct tb_switch *sw);
778 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
779 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
780 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
823 int tb_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
829 int tb_switch_configure(struct tb_switch *sw);
830 int tb_switch_configuration_valid(struct tb_switch *sw);
831 int tb_switch_add(struct tb_switch *sw);
832 void tb_switch_remove(struct tb_switch *sw);
833 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
834 int tb_switch_resume(struct tb_switch *sw, bool runtime);
835 int tb_switch_reset(struct tb_switch *sw);
836 int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
838 void tb_sw_set_unplugged(struct tb_switch *sw);
839 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
853 #define tb_switch_for_each_port(sw, p) \ argument
854 for ((p) = &(sw)->ports[1]; \
855 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
857 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw) in tb_switch_get() argument
859 if (sw) in tb_switch_get()
860 get_device(&sw->dev); in tb_switch_get()
861 return sw; in tb_switch_get()
864 static inline void tb_switch_put(struct tb_switch *sw) in tb_switch_put() argument
866 put_device(&sw->dev); in tb_switch_put()
881 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw) in tb_switch_parent() argument
883 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
893 static inline struct tb_port *tb_switch_downstream_port(struct tb_switch *sw) in tb_switch_downstream_port() argument
895 if (WARN_ON(!tb_route(sw))) in tb_switch_downstream_port()
897 return tb_port_at(tb_route(sw), tb_switch_parent(sw)); in tb_switch_downstream_port()
904 static inline int tb_switch_depth(const struct tb_switch *sw) in tb_switch_depth() argument
906 return sw->config.depth; in tb_switch_depth()
909 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw) in tb_switch_is_light_ridge() argument
911 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
912 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
915 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw) in tb_switch_is_eagle_ridge() argument
917 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
918 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
921 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw) in tb_switch_is_cactus_ridge() argument
923 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
924 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
933 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw) in tb_switch_is_falcon_ridge() argument
935 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
936 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
945 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw) in tb_switch_is_alpine_ridge() argument
947 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
948 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
960 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw) in tb_switch_is_titan_ridge() argument
962 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
963 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
973 static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw) in tb_switch_is_tiger_lake() argument
975 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
976 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
996 static inline bool tb_switch_is_icm(const struct tb_switch *sw) in tb_switch_is_icm() argument
998 return !sw->config.enabled; in tb_switch_is_icm()
1001 int tb_switch_set_link_width(struct tb_switch *sw, enum tb_link_width width);
1002 int tb_switch_configure_link(struct tb_switch *sw);
1003 void tb_switch_unconfigure_link(struct tb_switch *sw);
1005 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1006 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1007 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1009 int tb_switch_tmu_init(struct tb_switch *sw);
1010 int tb_switch_tmu_post_time(struct tb_switch *sw);
1011 int tb_switch_tmu_disable(struct tb_switch *sw);
1012 int tb_switch_tmu_enable(struct tb_switch *sw);
1013 int tb_switch_tmu_configure(struct tb_switch *sw, enum tb_switch_tmu_mode mode);
1023 static inline bool tb_switch_tmu_is_configured(const struct tb_switch *sw, in tb_switch_tmu_is_configured() argument
1026 return sw->tmu.mode_request == mode; in tb_switch_tmu_is_configured()
1036 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw) in tb_switch_tmu_is_enabled() argument
1038 return sw->tmu.mode != TB_SWITCH_TMU_MODE_OFF && in tb_switch_tmu_is_enabled()
1039 sw->tmu.mode == sw->tmu.mode_request; in tb_switch_tmu_is_enabled()
1044 int tb_switch_clx_init(struct tb_switch *sw);
1045 int tb_switch_clx_enable(struct tb_switch *sw, unsigned int clx);
1046 int tb_switch_clx_disable(struct tb_switch *sw);
1058 static inline bool tb_switch_clx_is_enabled(const struct tb_switch *sw, in tb_switch_clx_is_enabled() argument
1061 return sw->clx & clx; in tb_switch_clx_is_enabled()
1064 int tb_switch_pcie_l1_enable(struct tb_switch *sw);
1066 int tb_switch_xhci_connect(struct tb_switch *sw);
1067 void tb_switch_xhci_disconnect(struct tb_switch *sw);
1095 return src->sw->config.depth < dst->sw->config.depth; in tb_port_path_direction_downstream()
1100 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
1141 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
1142 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
1143 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
1187 int tb_drom_read(struct tb_switch *sw);
1188 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
1190 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
1202 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
1203 int tb_lc_set_sleep(struct tb_switch *sw);
1204 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
1205 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
1206 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
1207 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
1208 int tb_lc_force_power(struct tb_switch *sw);
1224 return tb_route(port->sw) in tb_downstream_route()
1225 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1279 static inline unsigned int usb4_switch_version(const struct tb_switch *sw) in usb4_switch_version() argument
1281 return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version); in usb4_switch_version()
1290 static inline bool tb_switch_is_usb4(const struct tb_switch *sw) in tb_switch_is_usb4() argument
1292 return usb4_switch_version(sw) > 0; in tb_switch_is_usb4()
1295 void usb4_switch_check_wakes(struct tb_switch *sw);
1296 int usb4_switch_setup(struct tb_switch *sw);
1297 int usb4_switch_configuration_valid(struct tb_switch *sw);
1298 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
1299 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
1301 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
1302 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
1303 int usb4_switch_set_sleep(struct tb_switch *sw);
1304 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
1305 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
1307 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address);
1308 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
1310 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
1311 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status);
1312 int usb4_switch_credits_init(struct tb_switch *sw);
1313 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1314 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1315 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1316 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
1318 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1320 int usb4_switch_add_ports(struct tb_switch *sw);
1321 void usb4_switch_remove_ports(struct tb_switch *sw);
1464 void tb_check_quirks(struct tb_switch *sw);
1497 void tb_switch_debugfs_init(struct tb_switch *sw);
1498 void tb_switch_debugfs_remove(struct tb_switch *sw);
1508 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { } in tb_switch_debugfs_init() argument
1509 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { } in tb_switch_debugfs_remove() argument