Lines Matching full:sw

183  * @sw: Switch the port belongs to
202 struct tb_switch *sw; member
383 int (*runtime_suspend_switch)(struct tb_switch *sw);
384 int (*runtime_resume_switch)(struct tb_switch *sw);
389 int (*approve_switch)(struct tb *tb, struct tb_switch *sw);
390 int (*add_switch_key)(struct tb *tb, struct tb_switch *sw);
391 int (*challenge_switch_key)(struct tb *tb, struct tb_switch *sw,
417 static inline struct tb_port *tb_upstream_port(struct tb_switch *sw) in tb_upstream_port() argument
419 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
431 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
435 static inline u64 tb_route(const struct tb_switch *sw) in tb_route() argument
437 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
440 static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) in tb_port_at() argument
444 port = route >> (sw->config.depth * 8); in tb_port_at()
445 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
447 return &sw->ports[port]; in tb_port_at()
508 static inline int tb_sw_read(struct tb_switch *sw, void *buffer, in tb_sw_read() argument
511 if (sw->is_unplugged) in tb_sw_read()
513 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
515 tb_route(sw), in tb_sw_read()
522 static inline int tb_sw_write(struct tb_switch *sw, const void *buffer, in tb_sw_write() argument
525 if (sw->is_unplugged) in tb_sw_write()
527 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
529 tb_route(sw), in tb_sw_write()
539 if (port->sw->is_unplugged) in tb_port_read()
541 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
543 tb_route(port->sw), in tb_port_read()
553 if (port->sw->is_unplugged) in tb_port_write()
555 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
557 tb_route(port->sw), in tb_port_write()
570 #define __TB_SW_PRINT(level, sw, fmt, arg...) \ argument
572 const struct tb_switch *__sw = (sw); \
576 #define tb_sw_WARN(sw, fmt, arg...) __TB_SW_PRINT(tb_WARN, sw, fmt, ##arg) argument
577 #define tb_sw_warn(sw, fmt, arg...) __TB_SW_PRINT(tb_warn, sw, fmt, ##arg) argument
578 #define tb_sw_info(sw, fmt, arg...) __TB_SW_PRINT(tb_info, sw, fmt, ##arg) argument
579 #define tb_sw_dbg(sw, fmt, arg...) __TB_SW_PRINT(tb_dbg, sw, fmt, ##arg) argument
584 level(__port->sw->tb, "%llx:%x: " fmt, \
585 tb_route(__port->sw), __port->port, ## arg); \
619 int tb_domain_approve_switch(struct tb *tb, struct tb_switch *sw);
620 int tb_domain_approve_switch_key(struct tb *tb, struct tb_switch *sw);
621 int tb_domain_challenge_switch_key(struct tb *tb, struct tb_switch *sw);
652 int tb_switch_configure(struct tb_switch *sw);
653 int tb_switch_add(struct tb_switch *sw);
654 void tb_switch_remove(struct tb_switch *sw);
655 void tb_switch_suspend(struct tb_switch *sw, bool runtime);
656 int tb_switch_resume(struct tb_switch *sw);
657 int tb_switch_reset(struct tb_switch *sw);
658 void tb_sw_set_unplugged(struct tb_switch *sw);
659 struct tb_port *tb_switch_find_port(struct tb_switch *sw,
668 * @sw: Switch whose ports to iterate
673 #define tb_switch_for_each_port(sw, p) \ argument
674 for ((p) = &(sw)->ports[1]; \
675 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
677 static inline struct tb_switch *tb_switch_get(struct tb_switch *sw) in tb_switch_get() argument
679 if (sw) in tb_switch_get()
680 get_device(&sw->dev); in tb_switch_get()
681 return sw; in tb_switch_get()
684 static inline void tb_switch_put(struct tb_switch *sw) in tb_switch_put() argument
686 put_device(&sw->dev); in tb_switch_put()
701 static inline struct tb_switch *tb_switch_parent(struct tb_switch *sw) in tb_switch_parent() argument
703 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
706 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw) in tb_switch_is_light_ridge() argument
708 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
709 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
712 static inline bool tb_switch_is_eagle_ridge(const struct tb_switch *sw) in tb_switch_is_eagle_ridge() argument
714 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
715 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
718 static inline bool tb_switch_is_cactus_ridge(const struct tb_switch *sw) in tb_switch_is_cactus_ridge() argument
720 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
721 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
730 static inline bool tb_switch_is_falcon_ridge(const struct tb_switch *sw) in tb_switch_is_falcon_ridge() argument
732 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
733 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
742 static inline bool tb_switch_is_alpine_ridge(const struct tb_switch *sw) in tb_switch_is_alpine_ridge() argument
744 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
745 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
756 static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw) in tb_switch_is_titan_ridge() argument
758 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
759 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
769 static inline bool tb_switch_is_ice_lake(const struct tb_switch *sw) in tb_switch_is_ice_lake() argument
771 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_ice_lake()
772 switch (sw->config.device_id) { in tb_switch_is_ice_lake()
781 static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw) in tb_switch_is_tiger_lake() argument
783 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
784 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
797 * @sw: Switch to check
799 * Returns true if the @sw is USB4 compliant router, false otherwise.
801 static inline bool tb_switch_is_usb4(const struct tb_switch *sw) in tb_switch_is_usb4() argument
803 return sw->config.thunderbolt_version == USB4_VERSION_1_0; in tb_switch_is_usb4()
808 * @sw: Switch to check
810 * In case there is a need to differentiate whether ICM firmware or SW CM
811 * is handling @sw this function can be called. It is valid to call this
813 * (latter only for SW CM case).
815 static inline bool tb_switch_is_icm(const struct tb_switch *sw) in tb_switch_is_icm() argument
817 return !sw->config.enabled; in tb_switch_is_icm()
820 int tb_switch_lane_bonding_enable(struct tb_switch *sw);
821 void tb_switch_lane_bonding_disable(struct tb_switch *sw);
822 int tb_switch_configure_link(struct tb_switch *sw);
823 void tb_switch_unconfigure_link(struct tb_switch *sw);
825 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
826 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
827 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
829 int tb_switch_tmu_init(struct tb_switch *sw);
830 int tb_switch_tmu_post_time(struct tb_switch *sw);
831 int tb_switch_tmu_disable(struct tb_switch *sw);
832 int tb_switch_tmu_enable(struct tb_switch *sw);
834 static inline bool tb_switch_tmu_is_enabled(const struct tb_switch *sw) in tb_switch_tmu_is_enabled() argument
836 return sw->tmu.rate == TB_SWITCH_TMU_RATE_HIFI && in tb_switch_tmu_is_enabled()
837 !sw->tmu.unidirectional; in tb_switch_tmu_is_enabled()
868 int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);
869 int tb_switch_find_cap(struct tb_switch *sw, enum tb_switch_cap cap);
870 int tb_switch_next_cap(struct tb_switch *sw, unsigned int offset);
901 int tb_drom_read(struct tb_switch *sw);
902 int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid);
904 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid);
909 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags);
910 int tb_lc_set_sleep(struct tb_switch *sw);
911 bool tb_lc_lane_bonding_possible(struct tb_switch *sw);
912 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in);
913 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in);
914 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in);
915 int tb_lc_force_power(struct tb_switch *sw);
931 return tb_route(port->sw) in tb_downstream_route()
932 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
960 int usb4_switch_setup(struct tb_switch *sw);
961 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
962 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
964 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
965 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
966 int usb4_switch_set_sleep(struct tb_switch *sw);
967 int usb4_switch_nvm_sector_size(struct tb_switch *sw);
968 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,
970 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address,
972 int usb4_switch_nvm_authenticate(struct tb_switch *sw);
973 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in);
974 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
975 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in);
976 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw,
978 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw,
1015 void tb_check_quirks(struct tb_switch *sw);
1026 void tb_switch_debugfs_init(struct tb_switch *sw);
1027 void tb_switch_debugfs_remove(struct tb_switch *sw);
1031 static inline void tb_switch_debugfs_init(struct tb_switch *sw) { } in tb_switch_debugfs_init() argument
1032 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { } in tb_switch_debugfs_remove() argument