• Home
  • Raw
  • Download

Lines Matching +full:retimer +full:- +full:switch

1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Thunderbolt driver - bus logic (NHI independent)
12 #include <linux/nvmem-provider.h>
30 * struct tb_nvm - Structure holding NVM information
36 * @non_active: Non-active portion NVMem device
65 * enum tb_switch_tmu_rate - TMU refresh rate
81 * struct tb_switch_tmu - Structure holding switch TMU configuration
83 * @has_ucap: Does the switch support uni-directional mode
84 * @rate: TMU refresh rate related to upstream switch. In case of root
85 * switch this holds the domain rate.
86 * @unidirectional: Is the TMU in uni-directional or bi-directional mode
87 * related to upstream switch. Don't case for root switch.
97 * struct tb_switch - a thunderbolt switch
98 * @dev: Device for the switch
99 * @config: Switch configuration
100 * @ports: Ports in this switch
101 * @dma_port: If the switch has port supporting DMA configuration based
103 * otherwise). If set it also means the switch has
105 * @tmu: The switch TMU configuration
106 * @tb: Pointer to the domain the switch belongs to
107 * @uid: Unique ID of the switch
108 * @uuid: UUID of the switch (or %NULL if not supported)
109 * @vendor: Vendor ID of the switch
110 * @device: Device ID of the switch
116 * @generation: Switch Thunderbolt generation
119 * @is_unplugged: The switch is going away
120 * @drom: DROM of the switch (%NULL if not found)
121 * @nvm: Pointer to the NVM if the switch has one (%NULL otherwise)
122 * @no_nvm_upgrade: Prevent NVM upgrade of this switch
123 * @safe_mode: The switch is in safe-mode
124 * @boot: Whether the switch was already authorized on boot or not
125 * @rpm: The switch supports runtime PM
126 * @authorized: Whether the switch is authorized by user or policy
127 * @security_level: Switch supported security level
133 * @link: Root switch link this switch is connected (ICM only)
134 * @depth: Depth in the chain this switch is connected (ICM only)
137 * @quirks: Quirks used for this Thunderbolt switch
139 * When the switch is being added or removed to the domain (other
181 * struct tb_port - a thunderbolt port, part of a tb_switch
183 * @sw: Switch the port belongs to
190 * @port: Port number on switch
193 * @dual_link_port: If the switch is connected using two ports, points
220 * tb_retimer: Thunderbolt retimer
221 * @dev: Device for the retimer
222 * @tb: Pointer to the domain the retimer belongs to
223 * @index: Retimer index facing the router USB4 port
224 * @vendor: Vendor ID of the retimer
225 * @device: Device ID of the retimer
227 * @nvm: Pointer to the NVM if the retimer has one (%NULL otherwise)
242 * struct tb_path_hop - routing information for a tb_path
243 * @in_port: Ingress port of a switch
244 * @out_port: Egress port of a switch where the packet is routed out
245 * (must be on the same switch than @in_port)
249 * currently, %-1 to disable)
254 * Hop configuration is always done on the IN port of a switch.
255 * in_port and out_port have to be on the same switch. Packets arriving on
257 * next hop to take (on out_port->remote) is determined by
258 * next_hop_index. When routing packet to another switch (out->remote is
275 * enum tb_path_port - path options mask
291 * struct tb_path - a unidirectional path between two ports
330 /* HopIDs 0-7 are reserved by the Thunderbolt protocol */
346 * struct tb_cm_ops - Connection manager specific operations vector
359 * @runtime_suspend_switch: Runtime suspend a switch
360 * @runtime_resume_switch: Runtime resume a switch
364 * @approve_switch: Approve switch
365 * @add_switch_key: Add key to switch
366 * @challenge_switch_key: Challenge switch using key
400 return (void *)tb->privdata; in tb_priv()
408 * tb_upstream_port() - return the upstream port of a switch
410 * Every switch has an upstream port (for the root switch it is the NHI).
412 * During switch alloc/init tb_upstream_port()->remote may be NULL, even for
415 * Return: Returns the upstream port of the switch.
419 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
423 * tb_is_upstream_port() - Is the port upstream facing
431 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
432 return port == upstream_port || port->dual_link_port == upstream_port; in tb_is_upstream_port()
437 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
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()
451 * tb_port_has_remote() - Does the port have switch connected downstream
460 if (!port->remote) in tb_port_has_remote()
462 if (port->dual_link_port && port->link_nr) in tb_port_has_remote()
470 return port && port->port && port->config.type == TB_TYPE_PORT; in tb_port_is_null()
475 return port && port->config.type == TB_TYPE_NHI; in tb_port_is_nhi()
480 return port && port->config.type == TB_TYPE_PCIE_DOWN; in tb_port_is_pcie_down()
485 return port && port->config.type == TB_TYPE_PCIE_UP; in tb_port_is_pcie_up()
490 return port && port->config.type == TB_TYPE_DP_HDMI_IN; in tb_port_is_dpin()
495 return port && port->config.type == TB_TYPE_DP_HDMI_OUT; in tb_port_is_dpout()
500 return port && port->config.type == TB_TYPE_USB3_DOWN; in tb_port_is_usb3_down()
505 return port && port->config.type == TB_TYPE_USB3_UP; in tb_port_is_usb3_up()
511 if (sw->is_unplugged) in tb_sw_read()
512 return -ENODEV; in tb_sw_read()
513 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
525 if (sw->is_unplugged) in tb_sw_write()
526 return -ENODEV; in tb_sw_write()
527 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
539 if (port->sw->is_unplugged) in tb_port_read()
540 return -ENODEV; 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()
544 port->port, in tb_port_read()
553 if (port->sw->is_unplugged) in tb_port_write()
554 return -ENODEV; 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()
558 port->port, in tb_port_write()
564 #define tb_err(tb, fmt, arg...) dev_err(&(tb)->nhi->pdev->dev, fmt, ## arg)
565 #define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg)
566 #define tb_warn(tb, fmt, arg...) dev_warn(&(tb)->nhi->pdev->dev, fmt, ## arg)
567 #define tb_info(tb, fmt, arg...) dev_info(&(tb)->nhi->pdev->dev, fmt, ## arg)
568 #define tb_dbg(tb, fmt, arg...) dev_dbg(&(tb)->nhi->pdev->dev, fmt, ## arg)
573 level(__sw->tb, "%llx: " fmt, \
584 level(__port->sw->tb, "%llx:%x: " fmt, \
585 tb_route(__port->sw), __port->port, ## arg); \
630 get_device(&tb->dev); in tb_domain_get()
636 put_device(&tb->dev); in tb_domain_put()
667 * tb_switch_for_each_port() - Iterate over each switch port
668 * @sw: Switch whose ports to iterate
671 * Iterates over each switch port skipping the control port (port %0).
674 for ((p) = &(sw)->ports[1]; \
675 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
680 get_device(&sw->dev); in tb_switch_get()
686 put_device(&sw->dev); in tb_switch_put()
691 return dev->type == &tb_switch_type; in tb_is_switch()
703 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
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()
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()
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()
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()
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()
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()
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()
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()
796 * tb_switch_is_usb4() - Is the switch USB4 compliant
797 * @sw: Switch to check
803 return sw->config.thunderbolt_version == USB4_VERSION_1_0; in tb_switch_is_usb4()
807 * tb_switch_is_icm() - Is the switch handled by ICM firmware
808 * @sw: Switch to check
817 return !sw->config.enabled; in tb_switch_is_icm()
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()
855 * tb_for_each_port_on_path() - Iterate over each port on path
919 return (fls64(route) + TB_ROUTE_SHIFT - 1) / TB_ROUTE_SHIFT; in tb_route_length()
923 * tb_downstream_route() - get route to downstream switch
927 * Return: Returns a route to the switch behind @port.
931 return tb_route(port->sw) in tb_downstream_route()
932 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
950 return dev->type == &tb_retimer_type; in tb_is_retimer()