Lines Matching +full:port +full:- +full:specific
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Thunderbolt driver - bus logic (NHI independent)
12 #include <linux/nvmem-provider.h>
27 * struct tb_nvm - Structure holding NVM information
34 * @non_active: Non-active portion NVMem device
43 * @vops: Router vendor specific NVM operations (optional)
75 * enum tb_switch_tmu_rate - TMU refresh rate
91 * struct tb_switch_tmu - Structure holding switch TMU configuration
93 * @has_ucap: Does the switch support uni-directional mode
96 * @unidirectional: Is the TMU in uni-directional or bi-directional mode
99 * @unidirectional_request: Is the new TMU mode: uni-directional or bi-directional
123 * struct tb_switch - a thunderbolt switch
127 * @dma_port: If the switch has port supporting DMA configuration based
144 * @cap_vsec_tmu: Offset to the TMU vendor specific capability (%0 if not found)
151 * @safe_mode: The switch is in safe-mode
227 * struct tb_port - a thunderbolt port, part of a tb_switch
228 * @config: Cached port configuration read from registers
229 * @sw: Switch the port belongs to
230 * @remote: Remote port (%NULL if not connected)
233 * @cap_tmu: Offset of the adapter specific TMU capability (%0 if not present)
234 * @cap_adap: Offset of the adapter specific capability (%0 if not present)
235 * @cap_usb4: Offset to the USB4 port capability (%0 if not present)
236 * @usb4: Pointer to the USB4 port structure (only if @cap_usb4 is != %0)
237 * @port: Port number on switch
239 * @bonded: true if the port is bonded (two lanes combined as one)
241 * to the other port.
242 * @link_nr: Is this primary or secondary port on the dual_link.
246 * @total_credits: Total number of buffers available for this port
249 * DMA paths through this port.
264 u8 port; member
278 * struct usb4_port - USB4 port device
279 * @dev: Device for the port
280 * @port: Pointer to the lane 0 adapter
281 * @can_offline: Does the port have necessary platform support to moved
283 * @offline: The port is currently in offline mode
288 struct tb_port *port; member
300 * @index: Retimer index facing the router USB4 port
303 * @port: Pointer to the lane 0 adapter
314 struct tb_port *port; member
321 * struct tb_path_hop - routing information for a tb_path
322 * @in_port: Ingress port of a switch
323 * @out_port: Egress port of a switch where the packet is routed out
328 * currently, %-1 to disable)
332 * @nfc_credits: Number of non-flow controlled buffers allocated for the
335 * Hop configuration is always done on the IN port of a switch.
338 * next hop to take (on out_port->remote) is determined by
339 * next_hop_index. When routing packet to another switch (out->remote is
344 * port.
357 * enum tb_path_port - path options mask
373 * struct tb_path - a unidirectional path between two ports
388 * @alloc_hopid: Does this path consume port HopID
412 /* HopIDs 0-7 are reserved by the Thunderbolt protocol */
429 * struct tb_cm_ops - Connection manager specific operations vector
434 * @suspend_noirq: Connection manager specific suspend_noirq
435 * @resume_noirq: Connection manager specific resume_noirq
436 * @suspend: Connection manager specific suspend
437 * @freeze_noirq: Connection manager specific freeze_noirq
438 * @thaw_noirq: Connection manager specific thaw_noirq
439 * @complete: Connection manager specific complete
440 * @runtime_suspend: Connection manager specific runtime_suspend
441 * @runtime_resume: Connection manager specific runtime_resume
456 * performed. If this returns %-EOPNOTSUPP then the
502 return (void *)tb->privdata; in tb_priv()
510 * tb_upstream_port() - return the upstream port of a switch
512 * Every switch has an upstream port (for the root switch it is the NHI).
514 * During switch alloc/init tb_upstream_port()->remote may be NULL, even for
515 * non root switches (on the NHI port remote is always NULL).
517 * Return: Returns the upstream port of the switch.
521 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
525 * tb_is_upstream_port() - Is the port upstream facing
526 * @port: Port to check
528 * Returns true if @port is upstream facing port. In case of dual link
531 static inline bool tb_is_upstream_port(const struct tb_port *port) in tb_is_upstream_port() argument
533 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
534 return port == upstream_port || port->dual_link_port == upstream_port; in tb_is_upstream_port()
539 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
544 u8 port; in tb_port_at() local
546 port = route >> (sw->config.depth * 8); in tb_port_at()
547 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
549 return &sw->ports[port]; in tb_port_at()
553 * tb_port_has_remote() - Does the port have switch connected downstream
554 * @port: Port to check
556 * Returns true only when the port is primary port and has remote set.
558 static inline bool tb_port_has_remote(const struct tb_port *port) in tb_port_has_remote() argument
560 if (tb_is_upstream_port(port)) in tb_port_has_remote()
562 if (!port->remote) in tb_port_has_remote()
564 if (port->dual_link_port && port->link_nr) in tb_port_has_remote()
570 static inline bool tb_port_is_null(const struct tb_port *port) in tb_port_is_null() argument
572 return port && port->port && port->config.type == TB_TYPE_PORT; in tb_port_is_null()
575 static inline bool tb_port_is_nhi(const struct tb_port *port) in tb_port_is_nhi() argument
577 return port && port->config.type == TB_TYPE_NHI; in tb_port_is_nhi()
580 static inline bool tb_port_is_pcie_down(const struct tb_port *port) in tb_port_is_pcie_down() argument
582 return port && port->config.type == TB_TYPE_PCIE_DOWN; in tb_port_is_pcie_down()
585 static inline bool tb_port_is_pcie_up(const struct tb_port *port) in tb_port_is_pcie_up() argument
587 return port && port->config.type == TB_TYPE_PCIE_UP; in tb_port_is_pcie_up()
590 static inline bool tb_port_is_dpin(const struct tb_port *port) in tb_port_is_dpin() argument
592 return port && port->config.type == TB_TYPE_DP_HDMI_IN; in tb_port_is_dpin()
595 static inline bool tb_port_is_dpout(const struct tb_port *port) in tb_port_is_dpout() argument
597 return port && port->config.type == TB_TYPE_DP_HDMI_OUT; in tb_port_is_dpout()
600 static inline bool tb_port_is_usb3_down(const struct tb_port *port) in tb_port_is_usb3_down() argument
602 return port && port->config.type == TB_TYPE_USB3_DOWN; in tb_port_is_usb3_down()
605 static inline bool tb_port_is_usb3_up(const struct tb_port *port) in tb_port_is_usb3_up() argument
607 return port && port->config.type == TB_TYPE_USB3_UP; in tb_port_is_usb3_up()
613 if (sw->is_unplugged) in tb_sw_read()
614 return -ENODEV; in tb_sw_read()
615 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
627 if (sw->is_unplugged) in tb_sw_write()
628 return -ENODEV; in tb_sw_write()
629 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
638 static inline int tb_port_read(struct tb_port *port, void *buffer, in tb_port_read() argument
641 if (port->sw->is_unplugged) in tb_port_read()
642 return -ENODEV; in tb_port_read()
643 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
645 tb_route(port->sw), in tb_port_read()
646 port->port, in tb_port_read()
652 static inline int tb_port_write(struct tb_port *port, const void *buffer, in tb_port_write() argument
655 if (port->sw->is_unplugged) in tb_port_write()
656 return -ENODEV; in tb_port_write()
657 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
659 tb_route(port->sw), in tb_port_write()
660 port->port, in tb_port_write()
666 #define tb_err(tb, fmt, arg...) dev_err(&(tb)->nhi->pdev->dev, fmt, ## arg)
667 #define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg)
668 #define tb_warn(tb, fmt, arg...) dev_warn(&(tb)->nhi->pdev->dev, fmt, ## arg)
669 #define tb_info(tb, fmt, arg...) dev_info(&(tb)->nhi->pdev->dev, fmt, ## arg)
670 #define tb_dbg(tb, fmt, arg...) dev_dbg(&(tb)->nhi->pdev->dev, fmt, ## arg)
675 level(__sw->tb, "%llx: " fmt, \
686 level(__port->sw->tb, "%llx:%u: " fmt, \
687 tb_route(__port->sw), __port->port, ## arg); \
689 #define tb_port_WARN(port, fmt, arg...) \ argument
690 __TB_PORT_PRINT(tb_WARN, port, fmt, ##arg)
691 #define tb_port_warn(port, fmt, arg...) \ argument
692 __TB_PORT_PRINT(tb_warn, port, fmt, ##arg)
693 #define tb_port_info(port, fmt, arg...) \ argument
694 __TB_PORT_PRINT(tb_info, port, fmt, ##arg)
695 #define tb_port_dbg(port, fmt, arg...) \ argument
696 __TB_PORT_PRINT(tb_dbg, port, fmt, ##arg)
738 get_device(&tb->dev); in tb_domain_get()
744 put_device(&tb->dev); in tb_domain_put()
791 * tb_switch_for_each_port() - Iterate over each switch port
793 * @p: Port used as iterator
795 * Iterates over each switch port skipping the control port (port %0).
798 for ((p) = &(sw)->ports[1]; \
799 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
804 get_device(&sw->dev); in tb_switch_get()
810 put_device(&sw->dev); in tb_switch_put()
815 return dev->type == &tb_switch_type; in tb_is_switch()
827 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
832 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
833 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
838 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
839 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
844 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
845 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
856 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
857 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
868 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
869 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
883 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
884 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
896 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
897 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
909 * tb_switch_is_usb4() - Is the switch USB4 compliant
916 return sw->config.thunderbolt_version == USB4_VERSION_1_0; in tb_switch_is_usb4()
920 * tb_switch_is_icm() - Is the switch handled by ICM firmware
930 return !sw->config.enabled; in tb_switch_is_icm()
952 * tb_switch_tmu_is_enabled() - Checks if the specified TMU mode is enabled
954 * @unidirectional: If uni-directional (bi-directional otherwise)
957 * as parameter. That is HiFi/Normal and either uni-directional or bi-directional.
962 return sw->tmu.rate == sw->tmu.rate_request && in tb_switch_tmu_is_enabled()
963 sw->tmu.unidirectional == unidirectional; in tb_switch_tmu_is_enabled()
981 * tb_switch_is_clx_enabled() - Checks if the CLx is enabled
991 return sw->clx == clx; in tb_switch_is_clx_enabled()
995 * tb_switch_is_clx_supported() - Is CLx supported on this type of router
1010 int tb_port_state(struct tb_port *port);
1011 int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged);
1012 int tb_port_add_nfc_credits(struct tb_port *port, int credits);
1013 int tb_port_clear_counter(struct tb_port *port, int counter);
1014 int tb_port_unlock(struct tb_port *port);
1015 int tb_port_enable(struct tb_port *port);
1016 int tb_port_disable(struct tb_port *port);
1017 int tb_port_alloc_in_hopid(struct tb_port *port, int hopid, int max_hopid);
1018 void tb_port_release_in_hopid(struct tb_port *port, int hopid);
1019 int tb_port_alloc_out_hopid(struct tb_port *port, int hopid, int max_hopid);
1020 void tb_port_release_out_hopid(struct tb_port *port, int hopid);
1024 static inline bool tb_port_use_credit_allocation(const struct tb_port *port) in tb_port_use_credit_allocation() argument
1026 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
1030 * tb_for_each_port_on_path() - Iterate over each port on path
1031 * @src: Source port
1032 * @dst: Destination port
1033 * @p: Port used as iterator
1035 * Walks over each port on path from @src to @dst.
1041 int tb_port_get_link_speed(struct tb_port *port);
1042 int tb_port_get_link_width(struct tb_port *port);
1043 int tb_port_set_link_width(struct tb_port *port, unsigned int width);
1044 int tb_port_set_lane_bonding(struct tb_port *port, bool bonding);
1045 int tb_port_lane_bonding_enable(struct tb_port *port);
1046 void tb_port_lane_bonding_disable(struct tb_port *port);
1047 int tb_port_wait_for_link_width(struct tb_port *port, int width,
1049 int tb_port_update_credits(struct tb_port *port);
1050 bool tb_port_is_clx_enabled(struct tb_port *port, enum tb_clx clx);
1055 int tb_port_find_cap(struct tb_port *port, enum tb_port_cap cap);
1056 int tb_port_next_cap(struct tb_port *port, unsigned int offset);
1057 bool tb_port_is_enabled(struct tb_port *port);
1059 bool tb_usb3_port_is_enabled(struct tb_port *port);
1060 int tb_usb3_port_enable(struct tb_port *port, bool enable);
1062 bool tb_pci_port_is_enabled(struct tb_port *port);
1063 int tb_pci_port_enable(struct tb_port *port, bool enable);
1065 int tb_dp_port_hpd_is_active(struct tb_port *port);
1066 int tb_dp_port_hpd_clear(struct tb_port *port);
1067 int tb_dp_port_set_hops(struct tb_port *port, unsigned int video,
1069 bool tb_dp_port_is_enabled(struct tb_port *port);
1070 int tb_dp_port_enable(struct tb_port *port, bool enable);
1084 const struct tb_port *port);
1087 * tb_path_for_each_hop() - Iterate over each hop on path
1094 for ((hop) = &(path)->hops[0]; \
1095 (hop) <= &(path)->hops[(path)->path_length - 1]; (hop)++)
1101 int tb_lc_configure_port(struct tb_port *port);
1102 void tb_lc_unconfigure_port(struct tb_port *port);
1103 int tb_lc_configure_xdomain(struct tb_port *port);
1104 void tb_lc_unconfigure_xdomain(struct tb_port *port);
1105 int tb_lc_start_lane_initialization(struct tb_port *port);
1106 bool tb_lc_is_clx_supported(struct tb_port *port);
1107 bool tb_lc_is_usb_plugged(struct tb_port *port);
1108 bool tb_lc_is_xhci_connected(struct tb_port *port);
1109 int tb_lc_xhci_connect(struct tb_port *port);
1110 void tb_lc_xhci_disconnect(struct tb_port *port);
1121 return (fls64(route) + TB_ROUTE_SHIFT - 1) / TB_ROUTE_SHIFT; in tb_route_length()
1125 * tb_downstream_route() - get route to downstream switch
1127 * Port must not be the upstream port (otherwise a loop is created).
1129 * Return: Returns a route to the switch behind @port.
1131 static inline u64 tb_downstream_route(struct tb_port *port) in tb_downstream_route() argument
1133 return tb_route(port->sw) in tb_downstream_route()
1134 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1150 return tb_to_switch(xd->dev.parent); in tb_xdomain_parent()
1155 int tb_retimer_scan(struct tb_port *port, bool add);
1156 void tb_retimer_remove_all(struct tb_port *port);
1160 return dev->type == &tb_retimer_type; in tb_is_retimer()
1190 const struct tb_port *port);
1192 const struct tb_port *port);
1196 int usb4_port_unlock(struct tb_port *port);
1197 int usb4_port_hotplug_enable(struct tb_port *port);
1198 int usb4_port_configure(struct tb_port *port);
1199 void usb4_port_unconfigure(struct tb_port *port);
1200 int usb4_port_configure_xdomain(struct tb_port *port, struct tb_xdomain *xd);
1201 void usb4_port_unconfigure_xdomain(struct tb_port *port);
1202 int usb4_port_router_offline(struct tb_port *port);
1203 int usb4_port_router_online(struct tb_port *port);
1204 int usb4_port_enumerate_retimers(struct tb_port *port);
1205 bool usb4_port_clx_supported(struct tb_port *port);
1206 int usb4_port_margining_caps(struct tb_port *port, u32 *caps);
1207 int usb4_port_hw_margin(struct tb_port *port, unsigned int lanes,
1210 int usb4_port_sw_margin(struct tb_port *port, unsigned int lanes, bool timing,
1212 int usb4_port_sw_margin_errors(struct tb_port *port, u32 *errors);
1214 int usb4_port_retimer_set_inbound_sbtx(struct tb_port *port, u8 index);
1215 int usb4_port_retimer_read(struct tb_port *port, u8 index, u8 reg, void *buf,
1217 int usb4_port_retimer_write(struct tb_port *port, u8 index, u8 reg,
1219 int usb4_port_retimer_is_last(struct tb_port *port, u8 index);
1220 int usb4_port_retimer_nvm_sector_size(struct tb_port *port, u8 index);
1221 int usb4_port_retimer_nvm_set_offset(struct tb_port *port, u8 index,
1223 int usb4_port_retimer_nvm_write(struct tb_port *port, u8 index,
1226 int usb4_port_retimer_nvm_authenticate(struct tb_port *port, u8 index);
1227 int usb4_port_retimer_nvm_authenticate_status(struct tb_port *port, u8 index,
1229 int usb4_port_retimer_nvm_read(struct tb_port *port, u8 index,
1232 int usb4_usb3_port_max_link_rate(struct tb_port *port);
1233 int usb4_usb3_port_actual_link_rate(struct tb_port *port);
1234 int usb4_usb3_port_allocated_bandwidth(struct tb_port *port, int *upstream_bw,
1236 int usb4_usb3_port_allocate_bandwidth(struct tb_port *port, int *upstream_bw,
1238 int usb4_usb3_port_release_bandwidth(struct tb_port *port, int *upstream_bw,
1243 return dev->type == &usb4_port_device_type; in tb_is_usb4_port_device()
1253 struct usb4_port *usb4_port_device_add(struct tb_port *port);
1273 int tb_acpi_power_on_retimers(struct tb_port *port);
1274 int tb_acpi_power_off_retimers(struct tb_port *port);
1286 static inline int tb_acpi_power_on_retimers(struct tb_port *port) { return 0; } in tb_acpi_power_on_retimers() argument
1287 static inline int tb_acpi_power_off_retimers(struct tb_port *port) { return 0; } in tb_acpi_power_off_retimers() argument