Lines Matching +full:sw +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
55 static int usb4_native_switch_op(struct tb_switch *sw, u16 opcode, in usb4_native_switch_op() argument
64 ret = tb_sw_write(sw, metadata, TB_CFG_SWITCH, ROUTER_CS_25, 1); in usb4_native_switch_op()
69 ret = tb_sw_write(sw, tx_data, TB_CFG_SWITCH, ROUTER_CS_9, in usb4_native_switch_op()
76 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); in usb4_native_switch_op()
80 ret = tb_switch_wait_for_bit(sw, ROUTER_CS_26, ROUTER_CS_26_OV, 0, 500); in usb4_native_switch_op()
84 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); in usb4_native_switch_op()
89 return -EOPNOTSUPP; in usb4_native_switch_op()
96 ret = tb_sw_read(sw, metadata, TB_CFG_SWITCH, ROUTER_CS_25, 1); in usb4_native_switch_op()
101 ret = tb_sw_read(sw, rx_data, TB_CFG_SWITCH, ROUTER_CS_9, in usb4_native_switch_op()
110 static int __usb4_switch_op(struct tb_switch *sw, u16 opcode, u32 *metadata, in __usb4_switch_op() argument
114 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in __usb4_switch_op()
117 return -EINVAL; in __usb4_switch_op()
124 if (cm_ops->usb4_switch_op) { in __usb4_switch_op()
127 ret = cm_ops->usb4_switch_op(sw, opcode, metadata, status, in __usb4_switch_op()
130 if (ret != -EOPNOTSUPP) in __usb4_switch_op()
139 return usb4_native_switch_op(sw, opcode, metadata, status, tx_data, in __usb4_switch_op()
143 static inline int usb4_switch_op(struct tb_switch *sw, u16 opcode, in usb4_switch_op() argument
146 return __usb4_switch_op(sw, opcode, metadata, status, NULL, 0, NULL, 0); in usb4_switch_op()
149 static inline int usb4_switch_op_data(struct tb_switch *sw, u16 opcode, in usb4_switch_op_data() argument
154 return __usb4_switch_op(sw, opcode, metadata, status, tx_data, in usb4_switch_op_data()
158 static void usb4_switch_check_wakes(struct tb_switch *sw) in usb4_switch_check_wakes() argument
166 if (!device_may_wakeup(&sw->dev)) in usb4_switch_check_wakes()
169 if (tb_route(sw)) { in usb4_switch_check_wakes()
170 if (tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1)) in usb4_switch_check_wakes()
173 tb_sw_dbg(sw, "PCIe wake: %s, USB3 wake: %s\n", in usb4_switch_check_wakes()
184 tb_switch_for_each_port(sw, port) { in usb4_switch_check_wakes()
185 if (!port->cap_usb4) in usb4_switch_check_wakes()
189 port->cap_usb4 + PORT_CS_18, 1)) in usb4_switch_check_wakes()
200 usb4 = port->usb4; in usb4_switch_check_wakes()
201 if (device_may_wakeup(&usb4->dev) && wakeup_usb4) in usb4_switch_check_wakes()
202 pm_wakeup_event(&usb4->dev, 0); in usb4_switch_check_wakes()
208 pm_wakeup_event(&sw->dev, 0); in usb4_switch_check_wakes()
215 if (!port->cap_usb4) in link_is_usb4()
219 port->cap_usb4 + PORT_CS_18, 1)) in link_is_usb4()
226 * usb4_switch_setup() - Additional setup for USB4 device
227 * @sw: USB4 router to setup
239 int usb4_switch_setup(struct tb_switch *sw) in usb4_switch_setup() argument
241 struct tb_switch *parent = tb_switch_parent(sw); in usb4_switch_setup()
247 usb4_switch_check_wakes(sw); in usb4_switch_setup()
249 if (!tb_route(sw)) in usb4_switch_setup()
252 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1); in usb4_switch_setup()
256 down = tb_switch_downstream_port(sw); in usb4_switch_setup()
257 sw->link_usb4 = link_is_usb4(down); in usb4_switch_setup()
258 tb_sw_dbg(sw, "link: %s\n", sw->link_usb4 ? "USB4" : "TBT"); in usb4_switch_setup()
263 tb_sw_dbg(sw, "TBT3 support: %s, xHCI: %s\n", in usb4_switch_setup()
266 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_setup()
270 if (tb_acpi_may_tunnel_usb3() && sw->link_usb4 && in usb4_switch_setup()
295 return tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_setup()
299 * usb4_switch_configuration_valid() - Set tunneling configuration to be valid
300 * @sw: USB4 router
309 int usb4_switch_configuration_valid(struct tb_switch *sw) in usb4_switch_configuration_valid() argument
314 if (!tb_route(sw)) in usb4_switch_configuration_valid()
317 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_configuration_valid()
323 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_configuration_valid()
327 return tb_switch_wait_for_bit(sw, ROUTER_CS_6, ROUTER_CS_6_CR, in usb4_switch_configuration_valid()
332 * usb4_switch_read_uid() - Read UID from USB4 router
333 * @sw: USB4 router
336 * Reads 64-bit UID from USB4 router config space.
338 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid) in usb4_switch_read_uid() argument
340 return tb_sw_read(sw, uid, TB_CFG_SWITCH, ROUTER_CS_7, 2); in usb4_switch_read_uid()
347 struct tb_switch *sw = data; in usb4_switch_drom_read_block() local
356 ret = usb4_switch_op_data(sw, USB4_SWITCH_OP_DROM_READ, &metadata, in usb4_switch_drom_read_block()
361 return status ? -EIO : 0; in usb4_switch_drom_read_block()
365 * usb4_switch_drom_read() - Read arbitrary bytes from USB4 router DROM
366 * @sw: USB4 router
372 * should always work but for hosts it may return %-EOPNOTSUPP in which
375 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf, in usb4_switch_drom_read() argument
379 usb4_switch_drom_read_block, sw); in usb4_switch_drom_read()
383 * usb4_switch_lane_bonding_possible() - Are conditions met for lane bonding
384 * @sw: USB4 router
389 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw) in usb4_switch_lane_bonding_possible() argument
395 up = tb_upstream_port(sw); in usb4_switch_lane_bonding_possible()
396 ret = tb_port_read(up, &val, TB_CFG_PORT, up->cap_usb4 + PORT_CS_18, 1); in usb4_switch_lane_bonding_possible()
404 * usb4_switch_set_wake() - Enabled/disable wake
405 * @sw: USB4 router
410 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags) in usb4_switch_set_wake() argument
414 u64 route = tb_route(sw); in usb4_switch_set_wake()
423 tb_switch_for_each_port(sw, port) { in usb4_switch_set_wake()
428 if (!port->cap_usb4) in usb4_switch_set_wake()
432 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
442 usb4 = port->usb4; in usb4_switch_set_wake()
445 device_may_wakeup(&usb4->dev)) && !configured) in usb4_switch_set_wake()
448 device_may_wakeup(&usb4->dev)) && configured) in usb4_switch_set_wake()
455 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
465 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_wake()
477 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_wake()
486 * usb4_switch_set_sleep() - Prepare the router to enter sleep
487 * @sw: USB4 router
492 int usb4_switch_set_sleep(struct tb_switch *sw) in usb4_switch_set_sleep() argument
498 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_sleep()
504 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_sleep()
508 return tb_switch_wait_for_bit(sw, ROUTER_CS_6, ROUTER_CS_6_SLPR, in usb4_switch_set_sleep()
513 * usb4_switch_nvm_sector_size() - Return router NVM sector size
514 * @sw: USB4 router
518 * %-EOPNOTSUPP.
520 int usb4_switch_nvm_sector_size(struct tb_switch *sw) in usb4_switch_nvm_sector_size() argument
526 ret = usb4_switch_op(sw, USB4_SWITCH_OP_NVM_SECTOR_SIZE, &metadata, in usb4_switch_nvm_sector_size()
532 return status == 0x2 ? -EOPNOTSUPP : -EIO; in usb4_switch_nvm_sector_size()
540 struct tb_switch *sw = data; in usb4_switch_nvm_read_block() local
550 ret = usb4_switch_op_data(sw, USB4_SWITCH_OP_NVM_READ, &metadata, in usb4_switch_nvm_read_block()
555 return status ? -EIO : 0; in usb4_switch_nvm_read_block()
559 * usb4_switch_nvm_read() - Read arbitrary bytes from router NVM
560 * @sw: USB4 router
566 * %-EOPNOTSUPP.
568 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf, in usb4_switch_nvm_read() argument
572 usb4_switch_nvm_read_block, sw); in usb4_switch_nvm_read()
576 * usb4_switch_nvm_set_offset() - Set NVM write offset
577 * @sw: USB4 router
585 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address) in usb4_switch_nvm_set_offset() argument
595 ret = usb4_switch_op(sw, USB4_SWITCH_OP_NVM_SET_OFFSET, &metadata, in usb4_switch_nvm_set_offset()
600 return status ? -EIO : 0; in usb4_switch_nvm_set_offset()
606 struct tb_switch *sw = data; in usb4_switch_nvm_write_next_block() local
610 ret = usb4_switch_op_data(sw, USB4_SWITCH_OP_NVM_WRITE, NULL, &status, in usb4_switch_nvm_write_next_block()
615 return status ? -EIO : 0; in usb4_switch_nvm_write_next_block()
619 * usb4_switch_nvm_write() - Write to the router NVM
620 * @sw: USB4 router
626 * write is not supported returns %-EOPNOTSUPP.
628 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address, in usb4_switch_nvm_write() argument
633 ret = usb4_switch_nvm_set_offset(sw, address); in usb4_switch_nvm_write()
638 usb4_switch_nvm_write_next_block, sw); in usb4_switch_nvm_write()
642 * usb4_switch_nvm_authenticate() - Authenticate new NVM
643 * @sw: USB4 router
654 int usb4_switch_nvm_authenticate(struct tb_switch *sw) in usb4_switch_nvm_authenticate() argument
658 ret = usb4_switch_op(sw, USB4_SWITCH_OP_NVM_AUTH, NULL, NULL); in usb4_switch_nvm_authenticate()
664 case -EACCES: in usb4_switch_nvm_authenticate()
665 case -ENOTCONN: in usb4_switch_nvm_authenticate()
666 case -ETIMEDOUT: in usb4_switch_nvm_authenticate()
675 * usb4_switch_nvm_authenticate_status() - Read status of last NVM authenticate
676 * @sw: USB4 router
686 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status) in usb4_switch_nvm_authenticate_status() argument
688 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in usb4_switch_nvm_authenticate_status()
693 if (cm_ops->usb4_switch_nvm_authenticate_status) { in usb4_switch_nvm_authenticate_status()
694 ret = cm_ops->usb4_switch_nvm_authenticate_status(sw, status); in usb4_switch_nvm_authenticate_status()
695 if (ret != -EOPNOTSUPP) in usb4_switch_nvm_authenticate_status()
699 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); in usb4_switch_nvm_authenticate_status()
707 return -EBUSY; in usb4_switch_nvm_authenticate_status()
709 return -EOPNOTSUPP; in usb4_switch_nvm_authenticate_status()
721 * usb4_switch_credits_init() - Read buffer allocation parameters
722 * @sw: USB4 router
724 * Reads @sw buffer allocation parameters and initializes @sw buffer
725 * allocation fields accordingly. Specifically @sw->credits_allocation
730 int usb4_switch_credits_init(struct tb_switch *sw) in usb4_switch_credits_init() argument
740 ret = usb4_switch_op_data(sw, USB4_SWITCH_OP_BUFFER_ALLOC, &metadata, in usb4_switch_credits_init()
745 return -EIO; in usb4_switch_credits_init()
749 return -EMSGSIZE; in usb4_switch_credits_init()
751 max_usb3 = -1; in usb4_switch_credits_init()
752 min_dp_aux = -1; in usb4_switch_credits_init()
753 min_dp_main = -1; in usb4_switch_credits_init()
754 max_pcie = -1; in usb4_switch_credits_init()
755 max_dma = -1; in usb4_switch_credits_init()
757 tb_sw_dbg(sw, "credit allocation parameters:\n"); in usb4_switch_credits_init()
767 tb_sw_dbg(sw, " USB3: %u\n", value); in usb4_switch_credits_init()
771 tb_sw_dbg(sw, " DP AUX: %u\n", value); in usb4_switch_credits_init()
775 tb_sw_dbg(sw, " DP main: %u\n", value); in usb4_switch_credits_init()
779 tb_sw_dbg(sw, " PCIe: %u\n", value); in usb4_switch_credits_init()
783 tb_sw_dbg(sw, " DMA: %u\n", value); in usb4_switch_credits_init()
787 tb_sw_dbg(sw, " unknown credit allocation index %#x, skipping\n", in usb4_switch_credits_init()
795 * issues, log a warning and fall back using the hard-coded in usb4_switch_credits_init()
800 if (!tb_route(sw) && max_dma < 0) { in usb4_switch_credits_init()
801 tb_sw_warn(sw, "host router is missing baMaxHI\n"); in usb4_switch_credits_init()
806 tb_switch_for_each_port(sw, port) { in usb4_switch_credits_init()
813 tb_sw_warn(sw, "multiple USB4 ports require baMinDPaux/baMinDPmain\n"); in usb4_switch_credits_init()
817 tb_switch_for_each_port(sw, port) { in usb4_switch_credits_init()
819 tb_sw_warn(sw, "missing baMinDPmain"); in usb4_switch_credits_init()
824 tb_sw_warn(sw, "missing baMinDPaux"); in usb4_switch_credits_init()
829 tb_sw_warn(sw, "missing baMaxUSB3"); in usb4_switch_credits_init()
834 tb_sw_warn(sw, "missing baMaxPCIe"); in usb4_switch_credits_init()
843 sw->credit_allocation = true; in usb4_switch_credits_init()
845 sw->max_usb3_credits = max_usb3; in usb4_switch_credits_init()
847 sw->min_dp_aux_credits = min_dp_aux; in usb4_switch_credits_init()
849 sw->min_dp_main_credits = min_dp_main; in usb4_switch_credits_init()
851 sw->max_pcie_credits = max_pcie; in usb4_switch_credits_init()
853 sw->max_dma_credits = max_dma; in usb4_switch_credits_init()
858 return -EINVAL; in usb4_switch_credits_init()
862 * usb4_switch_query_dp_resource() - Query availability of DP IN resource
863 * @sw: USB4 router
870 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in) in usb4_switch_query_dp_resource() argument
872 u32 metadata = in->port; in usb4_switch_query_dp_resource()
876 ret = usb4_switch_op(sw, USB4_SWITCH_OP_QUERY_DP_RESOURCE, &metadata, in usb4_switch_query_dp_resource()
882 if (ret == -EOPNOTSUPP) in usb4_switch_query_dp_resource()
891 * usb4_switch_alloc_dp_resource() - Allocate DP IN resource
892 * @sw: USB4 router
897 * returns negative errno, in particular %-EBUSY if the resource is
900 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in) in usb4_switch_alloc_dp_resource() argument
902 u32 metadata = in->port; in usb4_switch_alloc_dp_resource()
906 ret = usb4_switch_op(sw, USB4_SWITCH_OP_ALLOC_DP_RESOURCE, &metadata, in usb4_switch_alloc_dp_resource()
908 if (ret == -EOPNOTSUPP) in usb4_switch_alloc_dp_resource()
913 return status ? -EBUSY : 0; in usb4_switch_alloc_dp_resource()
917 * usb4_switch_dealloc_dp_resource() - Releases allocated DP IN resource
918 * @sw: USB4 router
923 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in) in usb4_switch_dealloc_dp_resource() argument
925 u32 metadata = in->port; in usb4_switch_dealloc_dp_resource()
929 ret = usb4_switch_op(sw, USB4_SWITCH_OP_DEALLOC_DP_RESOURCE, &metadata, in usb4_switch_dealloc_dp_resource()
931 if (ret == -EOPNOTSUPP) in usb4_switch_dealloc_dp_resource()
936 return status ? -EIO : 0; in usb4_switch_dealloc_dp_resource()
939 static int usb4_port_idx(const struct tb_switch *sw, const struct tb_port *port) in usb4_port_idx() argument
945 tb_switch_for_each_port(sw, p) { in usb4_port_idx()
950 if (!p->link_nr) { in usb4_port_idx()
961 * usb4_switch_map_pcie_down() - Map USB4 port to a PCIe downstream adapter
962 * @sw: USB4 router
970 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw, in usb4_switch_map_pcie_down() argument
973 int usb4_idx = usb4_port_idx(sw, port); in usb4_switch_map_pcie_down()
978 tb_switch_for_each_port(sw, p) { in usb4_switch_map_pcie_down()
992 * usb4_switch_map_usb3_down() - Map USB4 port to a USB3 downstream adapter
993 * @sw: USB4 router
1001 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw, in usb4_switch_map_usb3_down() argument
1004 int usb4_idx = usb4_port_idx(sw, port); in usb4_switch_map_usb3_down()
1009 tb_switch_for_each_port(sw, p) { in usb4_switch_map_usb3_down()
1023 * usb4_switch_add_ports() - Add USB4 ports for this router
1024 * @sw: USB4 router
1031 int usb4_switch_add_ports(struct tb_switch *sw) in usb4_switch_add_ports() argument
1035 if (tb_switch_is_icm(sw) || !tb_switch_is_usb4(sw)) in usb4_switch_add_ports()
1038 tb_switch_for_each_port(sw, port) { in usb4_switch_add_ports()
1043 if (!port->cap_usb4) in usb4_switch_add_ports()
1048 usb4_switch_remove_ports(sw); in usb4_switch_add_ports()
1052 port->usb4 = usb4; in usb4_switch_add_ports()
1059 * usb4_switch_remove_ports() - Removes USB4 ports from this router
1060 * @sw: USB4 router
1064 void usb4_switch_remove_ports(struct tb_switch *sw) in usb4_switch_remove_ports() argument
1068 tb_switch_for_each_port(sw, port) { in usb4_switch_remove_ports()
1069 if (port->usb4) { in usb4_switch_remove_ports()
1070 usb4_port_device_remove(port->usb4); in usb4_switch_remove_ports()
1071 port->usb4 = NULL; in usb4_switch_remove_ports()
1077 * usb4_port_unlock() - Unlock USB4 downstream port
1097 * usb4_port_hotplug_enable() - Enables hotplug for a port
1101 * to be used on lane, DP-IN, and DP-OUT adapters.
1121 if (!port->cap_usb4) in usb4_port_set_configured()
1122 return -EINVAL; in usb4_port_set_configured()
1125 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
1135 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
1139 * usb4_port_configure() - Set USB4 port configured
1150 * usb4_port_unconfigure() - Set USB4 port unconfigured
1165 if (!port->cap_usb4) in usb4_set_xdomain_configured()
1166 return -EINVAL; in usb4_set_xdomain_configured()
1169 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
1179 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
1183 * usb4_port_configure_xdomain() - Configure port for XDomain
1192 xd->link_usb4 = link_is_usb4(port); in usb4_port_configure_xdomain()
1197 * usb4_port_unconfigure_xdomain() - Unconfigure port for XDomain
1226 return -ETIMEDOUT; in usb4_port_wait_for_bit()
1232 return -EINVAL; in usb4_port_read_data()
1234 return tb_port_read(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_read_data()
1242 return -EINVAL; in usb4_port_write_data()
1244 return tb_port_write(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_write_data()
1255 if (!port->cap_usb4) in usb4_port_sb_read()
1256 return -EINVAL; in usb4_port_sb_read()
1266 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1270 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_read()
1276 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1281 return -ENODEV; in usb4_port_sb_read()
1283 return -EIO; in usb4_port_sb_read()
1295 if (!port->cap_usb4) in usb4_port_sb_write()
1296 return -EINVAL; in usb4_port_sb_write()
1313 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1317 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_write()
1323 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1328 return -ENODEV; in usb4_port_sb_write()
1330 return -EIO; in usb4_port_sb_write()
1341 return -EAGAIN; in usb4_port_sb_opcode_err_to_errno()
1343 return -EOPNOTSUPP; in usb4_port_sb_opcode_err_to_errno()
1345 return -EIO; in usb4_port_sb_opcode_err_to_errno()
1375 return -ETIMEDOUT; in usb4_port_sb_op()
1394 * usb4_port_router_offline() - Put the USB4 port to offline mode
1397 * This function puts the USB4 port into offline mode. In this mode the
1410 * usb4_port_router_online() - Put the USB4 port back to online
1421 * usb4_port_enumerate_retimers() - Send RT broadcast transaction
1438 * usb4_port_clx_supported() - Check if CLx is supported by the link
1450 port->cap_usb4 + PORT_CS_18, 1); in usb4_port_clx_supported()
1458 * usb4_port_margining_caps() - Read USB4 port marginig capabilities
1478 * usb4_port_hw_margin() - Run hardware lane margining on port
1521 * usb4_port_sw_margin() - Run software lane margining on port
1557 * usb4_port_sw_margin_errors() - Read the software margining error counters
1586 * usb4_port_retimer_set_inbound_sbtx() - Enable sideband channel transactions
1600 if (ret != -ENODEV) in usb4_port_retimer_set_inbound_sbtx()
1613 * usb4_port_retimer_unset_inbound_sbtx() - Disable sideband channel transactions
1627 * usb4_port_retimer_read() - Read from retimer sideband registers
1637 * present at given @index returns %-ENODEV. In any other failure
1648 * usb4_port_retimer_write() - Write to retimer sideband registers
1657 * is no retimer present at given @index returns %-ENODEV. In any other
1668 * usb4_port_retimer_is_last() - Is the retimer last on-board retimer
1673 * Type-C port) this function returns %1. If it is not returns %0. If
1674 * the retimer is not present returns %-ENODEV. Otherwise returns
1693 * usb4_port_retimer_nvm_sector_size() - Read retimer NVM sector size
1700 * in case of error. Specifically returns %-ENODEV if there is no
1719 * usb4_port_retimer_nvm_set_offset() - Set NVM write offset
1758 struct tb_port *port = info->port; in usb4_port_retimer_nvm_write_next_block()
1759 u8 index = info->index; in usb4_port_retimer_nvm_write_next_block()
1772 * usb4_port_retimer_nvm_write() - Write to retimer NVM
1781 * errno in case of failure. Specifically returns %-ENODEV if there is
1799 * usb4_port_retimer_nvm_authenticate() - Start retimer NVM upgrade
1824 * usb4_port_retimer_nvm_authenticate_status() - Read status of NVM upgrade
1853 case -EAGAIN: in usb4_port_retimer_nvm_authenticate_status()
1871 struct tb_port *port = info->port; in usb4_port_retimer_nvm_read_block()
1872 u8 index = info->index; in usb4_port_retimer_nvm_read_block()
1894 * usb4_port_retimer_nvm_read() - Read contents of retimer NVM
1903 * Specifically returns %-ENODEV if there is no retimer at @index.
1918 if (port->max_bw) in usb4_usb3_port_max_bandwidth()
1919 return min(bw, port->max_bw); in usb4_usb3_port_max_bandwidth()
1924 * usb4_usb3_port_max_link_rate() - Maximum support USB3 link rate
1936 return -EINVAL; in usb4_usb3_port_max_link_rate()
1939 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_max_link_rate()
1950 * usb4_usb3_port_actual_link_rate() - Established USB3 link rate
1962 return -EINVAL; in usb4_usb3_port_actual_link_rate()
1965 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_actual_link_rate()
1984 return -EINVAL; in usb4_usb3_port_cm_request()
1985 if (tb_route(port->sw)) in usb4_usb3_port_cm_request()
1986 return -EINVAL; in usb4_usb3_port_cm_request()
1989 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
1999 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
2008 return usb4_port_wait_for_bit(port, port->cap_adap + ADP_USB3_CS_1, in usb4_usb3_port_cm_request()
2034 /* 1 uframe is 1/8 ms (125 us) -> 1 / 8000 s */ in mbps_to_usb3_bw()
2047 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_read_allocated_bandwidth()
2052 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_allocated_bandwidth()
2068 * usb4_usb3_port_allocated_bandwidth() - Bandwidth allocated for USB3
2101 port->cap_adap + ADP_USB3_CS_1, 1); in usb4_usb3_port_read_consumed_bandwidth()
2106 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_consumed_bandwidth()
2138 return -EINVAL; in usb4_usb3_port_write_allocated_bandwidth()
2141 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_write_allocated_bandwidth()
2151 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
2160 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
2164 * usb4_usb3_port_allocate_bandwidth() - Allocate bandwidth for USB3
2212 * usb4_usb3_port_release_bandwidth() - Release allocated USB3 bandwidth
2262 if (!tb_switch_is_usb4(port->sw)) in is_usb4_dpin()
2268 * usb4_dp_port_set_cm_id() - Assign CM ID to the DP IN adapter
2273 * otherwise. Speficially returns %-EOPNOTSUPP if the @port does not
2282 return -EOPNOTSUPP; in usb4_dp_port_set_cm_id()
2285 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_cm_id()
2293 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_cm_id()
2297 * usb4_dp_port_bandwidth_mode_supported() - Is the bandwidth allocation mode
2302 * supports USB4 bandwidth allocation mode, false otherwise.
2313 port->cap_adap + DP_LOCAL_CAP, 1); in usb4_dp_port_bandwidth_mode_supported()
2321 * usb4_dp_port_bandwidth_mode_enabled() - Is the bandwidth allocation mode
2326 * allocation mode has been enabled, false otherwise.
2337 port->cap_adap + ADP_DP_CS_8, 1); in usb4_dp_port_bandwidth_mode_enabled()
2345 * usb4_dp_port_set_cm_bandwidth_mode_supported() - Set/clear CM support for
2346 * bandwidth allocation mode
2348 * @supported: Does the CM support bandwidth allocation mode
2352 * otherwise. Specifically returns %-OPNOTSUPP if the passed in adapter
2362 return -EOPNOTSUPP; in usb4_dp_port_set_cm_bandwidth_mode_supported()
2365 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_cm_bandwidth_mode_supported()
2375 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_cm_bandwidth_mode_supported()
2379 * usb4_dp_port_group_id() - Return Group ID assigned for the adapter
2384 * %-EOPNOTSUPP is returned.
2392 return -EOPNOTSUPP; in usb4_dp_port_group_id()
2395 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_group_id()
2403 * usb4_dp_port_set_group_id() - Set adapter Group ID
2407 * Sets bandwidth allocation mode Group ID for the DP IN adapter.
2409 * Specifically returns %-EOPNOTSUPP if the adapter does not support
2418 return -EOPNOTSUPP; in usb4_dp_port_set_group_id()
2421 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_group_id()
2429 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_group_id()
2433 * usb4_dp_port_nrd() - Read non-reduced rate and lanes
2435 * @rate: Non-reduced rate in Mb/s is placed here
2436 * @lanes: Non-reduced lanes are placed here
2438 * Reads the non-reduced rate and lanes from the DP IN adapter. Returns
2440 * %-EOPNOTSUPP if the adapter does not support this.
2448 return -EOPNOTSUPP; in usb4_dp_port_nrd()
2451 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_nrd()
2488 * usb4_dp_port_set_nrd() - Set non-reduced rate and lanes
2490 * @rate: Non-reduced rate in Mb/s
2491 * @lanes: Non-reduced lanes
2494 * the non-reduced values for the DP IN adapter. Returns %0 in success
2496 * %-EOPNOTSUPP is returned.
2504 return -EOPNOTSUPP; in usb4_dp_port_set_nrd()
2507 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_nrd()
2529 return -EINVAL; in usb4_dp_port_set_nrd()
2544 return -EINVAL; in usb4_dp_port_set_nrd()
2548 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_nrd()
2552 * usb4_dp_port_granularity() - Return granularity for the bandwidth values
2556 * not support bandwidth allocation mode returns %-EOPNOTSUPP and negative
2565 return -EOPNOTSUPP; in usb4_dp_port_granularity()
2568 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_granularity()
2584 return -EINVAL; in usb4_dp_port_granularity()
2588 * usb4_dp_port_set_granularity() - Set granularity for the bandwidth values
2594 * adapter does not support this %-EOPNOTSUPP is returned.
2602 return -EOPNOTSUPP; in usb4_dp_port_set_granularity()
2605 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_granularity()
2622 return -EINVAL; in usb4_dp_port_set_granularity()
2626 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_granularity()
2630 * usb4_dp_port_set_estimated_bandwidth() - Set estimated bandwidth
2637 * and negative errno otherwise. Specifically returns %-EOPNOTSUPP if
2646 return -EOPNOTSUPP; in usb4_dp_port_set_estimated_bandwidth()
2654 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_estimated_bandwidth()
2662 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_estimated_bandwidth()
2666 * usb4_dp_port_allocated_bandwidth() - Return allocated bandwidth
2679 return -EOPNOTSUPP; in usb4_dp_port_allocated_bandwidth()
2687 port->cap_adap + DP_STATUS, 1); in usb4_dp_port_allocated_bandwidth()
2703 port->cap_adap + ADP_DP_CS_2, 1); in __usb4_dp_port_set_cm_ack()
2713 port->cap_adap + ADP_DP_CS_2, 1); in __usb4_dp_port_set_cm_ack()
2735 port->cap_adap + ADP_DP_CS_8, 1); in usb4_dp_port_wait_and_clear_cm_ack()
2746 return -ETIMEDOUT; in usb4_dp_port_wait_and_clear_cm_ack()
2749 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_wait_and_clear_cm_ack()
2755 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_wait_and_clear_cm_ack()
2759 * usb4_dp_port_allocate_bandwidth() - Set allocated bandwidth
2773 return -EOPNOTSUPP; in usb4_dp_port_allocate_bandwidth()
2781 port->cap_adap + DP_STATUS, 1); in usb4_dp_port_allocate_bandwidth()
2789 port->cap_adap + DP_STATUS, 1); in usb4_dp_port_allocate_bandwidth()
2801 * usb4_dp_port_requested_bandwidth() - Read requested bandwidth
2806 * error returns negative errno. Specifically returns %-EOPNOTSUPP if
2807 * the adapter does not support bandwidth allocation mode, and %ENODATA
2816 return -EOPNOTSUPP; in usb4_dp_port_requested_bandwidth()
2824 port->cap_adap + ADP_DP_CS_8, 1); in usb4_dp_port_requested_bandwidth()
2829 return -ENODATA; in usb4_dp_port_requested_bandwidth()
2835 * usb4_pci_port_set_ext_encapsulation() - Enable/disable extended encapsulation
2849 return -EINVAL; in usb4_pci_port_set_ext_encapsulation()
2852 port->cap_adap + ADP_PCIE_CS_1, 1); in usb4_pci_port_set_ext_encapsulation()
2862 port->cap_adap + ADP_PCIE_CS_1, 1); in usb4_pci_port_set_ext_encapsulation()