Lines Matching full:sw

204  * @sw: Switch the port belongs to
231 struct tb_switch *sw; member
442 int (*runtime_suspend_switch)(struct tb_switch *sw);
443 int (*runtime_resume_switch)(struct tb_switch *sw);
448 int (*disapprove_switch)(struct tb *tb, struct tb_switch *sw);
449 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
450 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
451 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
460 int (*usb4_switch_op)(struct tb_switch *sw, u16 opcode, u32 *metadata,
463 int (*usb4_switch_nvm_authenticate_status)(struct tb_switch *sw,
486 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw) in tb_upstream_port() argument
488 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
500 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
504 static inline u64 tb_route(const struct tb_switch *sw) in tb_route() argument
506 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
509 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) in tb_port_at() argument
513 port = route >> (sw->config.depth * 8); in tb_port_at()
514 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
516 return &sw->ports[port]; in tb_port_at()
577 static inline int tb_sw_read(struct tb_switch *sw, void *buffer, in tb_sw_read() argument
580 if (sw->is_unplugged) in tb_sw_read()
582 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
584 tb_route(sw), in tb_sw_read()
591 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer, in tb_sw_write() argument
594 if (sw->is_unplugged) in tb_sw_write()
596 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
598 tb_route(sw), in tb_sw_write()
608 if (port->sw->is_unplugged) in tb_port_read()
610 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
612 tb_route(port->sw), in tb_port_read()
622 if (port->sw->is_unplugged) in tb_port_write()
624 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
626 tb_route(port->sw), in tb_port_write()
639 #define __TB_SW_PRINT(level, sw, fmt, arg...) \ argument
641 const struct tb_switch *__sw = (sw); \
645 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg) argument
646 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg) argument
647 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg) argument
648 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg) argument
653 level(__port->sw->tb, "%llx:%x: " fmt, \
654 tb_route(__port->sw), __port->port, ## arg); \
689 int tb_domain_disapprove_switch(struct tb *tb, struct tb_switch *sw);
690 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
691 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
692 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
737 int tb_switch_configure(struct tb_switch *sw);
738 int tb_switch_add(struct tb_switch *sw);
739 void tb_switch_remove(struct tb_switch *sw);
740 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
741 int tb_switch_resume(struct tb_switch *sw);
742 int tb_switch_reset(struct tb_switch *sw);
743 void tb_sw_set_unplugged(struct tb_switch *sw);
744 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
753 * @sw: Switch whose ports to iterate
758 #define tb_switch_for_each_port(sw, p) \ argument
759 for ((p) = &(sw)->ports[1]; \
760 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
762 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw) in tb_switch_get() argument
764 if (sw) in tb_switch_get()
765 get_device(&sw->dev); in tb_switch_get()
766 return sw; in tb_switch_get()
769 static inline void tb_switch_put(struct tb_switch *sw) in tb_switch_put() argument
771 put_device(&sw->dev); in tb_switch_put()
786 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw) in tb_switch_parent() argument
788 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
791 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw) in tb_switch_is_light_ridge() argument
793 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
794 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
797 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw) in tb_switch_is_eagle_ridge() argument
799 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
800 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
803 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw) in tb_switch_is_cactus_ridge() argument
805 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
806 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
815 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw) in tb_switch_is_falcon_ridge() argument
817 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
818 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
827 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw) in tb_switch_is_alpine_ridge() argument
829 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
830 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
841 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw) in tb_switch_is_titan_ridge() argument
843 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
844 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
856 * @sw: Switch to check
858 * Returns true if the @sw is USB4 compliant router, false otherwise.
860 static inline bool tb_switch_is_usb4(const struct tb_switch *sw) in tb_switch_is_usb4() argument
862 return sw->config.thunderbolt_version == USB4_VERSION_1_0; in tb_switch_is_usb4()
867 * @sw: Switch to check
869 * In case there is a need to differentiate whether ICM firmware or SW CM
870 * is handling @sw this function can be called. It is valid to call this
872 * (latter only for SW CM case).
874 static inline bool tb_switch_is_icm(const struct tb_switch *sw) in tb_switch_is_icm() argument
876 return !sw->config.enabled; in tb_switch_is_icm()
879 int tb_switch_lane_bonding_enable(struct tb_switch *sw);
880 void tb_switch_lane_bonding_disable(struct tb_switch *sw);
881 int tb_switch_configure_link(struct tb_switch *sw);
882 void tb_switch_unconfigure_link(struct tb_switch *sw);
884 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
885 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
886 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
888 int tb_switch_tmu_init(struct tb_switch *sw);
889 int tb_switch_tmu_post_time(struct tb_switch *sw);
890 int tb_switch_tmu_disable(struct tb_switch *sw);
891 int tb_switch_tmu_enable(struct tb_switch *sw);
893 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw) in tb_switch_tmu_is_enabled() argument
895 return sw->tmu.rate == TB_SWITCH_TMU_RATE_HIFI && in tb_switch_tmu_is_enabled()
896 !sw->tmu.unidirectional; in tb_switch_tmu_is_enabled()
914 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
938 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
939 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
940 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
982 int tb_drom_read(struct tb_switch *sw);
983 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
985 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
991 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
992 int tb_lc_set_sleep(struct tb_switch *sw);
993 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
994 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
995 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
996 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
997 int tb_lc_force_power(struct tb_switch *sw);
1013 return tb_route(port->sw) in tb_downstream_route()
1014 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1043 int usb4_switch_setup(struct tb_switch *sw);
1044 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
1045 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
1047 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
1048 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
1049 int usb4_switch_set_sleep(struct tb_switch *sw);
1050 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
1051 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
1053 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address);
1054 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
1056 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
1057 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status);
1058 int usb4_switch_credits_init(struct tb_switch *sw);
1059 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
1060 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1061 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
1062 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
1064 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1066 int usb4_switch_add_ports(struct tb_switch *sw);
1067 void usb4_switch_remove_ports(struct tb_switch *sw);
1124 void tb_check_quirks(struct tb_switch *sw);
1157 void tb_switch_debugfs_init(struct tb_switch *sw);
1158 void tb_switch_debugfs_remove(struct tb_switch *sw);
1164 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { } in tb_switch_debugfs_init() argument
1165 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { } in tb_switch_debugfs_remove() argument