Lines Matching +full:use +full:- +full:sw +full:- +full:pm
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()
159 * usb4_switch_check_wakes() - Check for wakes and notify PM core about them
160 * @sw: Router whose wakes to check
162 * Checks wakes occurred during suspend and notify the PM core about them.
164 void usb4_switch_check_wakes(struct tb_switch *sw) in usb4_switch_check_wakes() argument
172 if (tb_route(sw)) { in usb4_switch_check_wakes()
173 if (tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1)) in usb4_switch_check_wakes()
176 tb_sw_dbg(sw, "PCIe wake: %s, USB3 wake: %s\n", in usb4_switch_check_wakes()
187 tb_switch_for_each_port(sw, port) { in usb4_switch_check_wakes()
188 if (!port->cap_usb4) in usb4_switch_check_wakes()
192 port->cap_usb4 + PORT_CS_18, 1)) in usb4_switch_check_wakes()
203 usb4 = port->usb4; in usb4_switch_check_wakes()
204 if (device_may_wakeup(&usb4->dev) && wakeup_usb4) in usb4_switch_check_wakes()
205 pm_wakeup_event(&usb4->dev, 0); in usb4_switch_check_wakes()
211 pm_wakeup_event(&sw->dev, 0); in usb4_switch_check_wakes()
218 if (!port->cap_usb4) in link_is_usb4()
222 port->cap_usb4 + PORT_CS_18, 1)) in link_is_usb4()
229 * usb4_switch_setup() - Additional setup for USB4 device
230 * @sw: USB4 router to setup
242 int usb4_switch_setup(struct tb_switch *sw) in usb4_switch_setup() argument
244 struct tb_switch *parent = tb_switch_parent(sw); in usb4_switch_setup()
250 if (!tb_route(sw)) in usb4_switch_setup()
253 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1); in usb4_switch_setup()
257 down = tb_switch_downstream_port(sw); in usb4_switch_setup()
258 sw->link_usb4 = link_is_usb4(down); in usb4_switch_setup()
259 tb_sw_dbg(sw, "link: %s\n", sw->link_usb4 ? "USB4" : "TBT"); in usb4_switch_setup()
264 tb_sw_dbg(sw, "TBT3 support: %s, xHCI: %s\n", in usb4_switch_setup()
267 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_setup()
271 if (tb_acpi_may_tunnel_usb3() && sw->link_usb4 && in usb4_switch_setup()
296 return tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_setup()
300 * usb4_switch_configuration_valid() - Set tunneling configuration to be valid
301 * @sw: USB4 router
310 int usb4_switch_configuration_valid(struct tb_switch *sw) in usb4_switch_configuration_valid() argument
315 if (!tb_route(sw)) in usb4_switch_configuration_valid()
318 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_configuration_valid()
324 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_configuration_valid()
328 return tb_switch_wait_for_bit(sw, ROUTER_CS_6, ROUTER_CS_6_CR, in usb4_switch_configuration_valid()
333 * usb4_switch_read_uid() - Read UID from USB4 router
334 * @sw: USB4 router
337 * Reads 64-bit UID from USB4 router config space.
339 int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid) in usb4_switch_read_uid() argument
341 return tb_sw_read(sw, uid, TB_CFG_SWITCH, ROUTER_CS_7, 2); in usb4_switch_read_uid()
348 struct tb_switch *sw = data; in usb4_switch_drom_read_block() local
357 ret = usb4_switch_op_data(sw, USB4_SWITCH_OP_DROM_READ, &metadata, in usb4_switch_drom_read_block()
362 return status ? -EIO : 0; in usb4_switch_drom_read_block()
366 * usb4_switch_drom_read() - Read arbitrary bytes from USB4 router DROM
367 * @sw: USB4 router
373 * should always work but for hosts it may return %-EOPNOTSUPP in which
376 int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf, in usb4_switch_drom_read() argument
380 usb4_switch_drom_read_block, sw); in usb4_switch_drom_read()
384 * usb4_switch_lane_bonding_possible() - Are conditions met for lane bonding
385 * @sw: USB4 router
390 bool usb4_switch_lane_bonding_possible(struct tb_switch *sw) in usb4_switch_lane_bonding_possible() argument
396 up = tb_upstream_port(sw); in usb4_switch_lane_bonding_possible()
397 ret = tb_port_read(up, &val, TB_CFG_PORT, up->cap_usb4 + PORT_CS_18, 1); in usb4_switch_lane_bonding_possible()
405 * usb4_switch_set_wake() - Enabled/disable wake
406 * @sw: USB4 router
411 int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags) in usb4_switch_set_wake() argument
415 u64 route = tb_route(sw); in usb4_switch_set_wake()
424 tb_switch_for_each_port(sw, port) { in usb4_switch_set_wake()
429 if (!port->cap_usb4) in usb4_switch_set_wake()
433 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
443 usb4 = port->usb4; in usb4_switch_set_wake()
446 device_may_wakeup(&usb4->dev)) && !configured) in usb4_switch_set_wake()
449 device_may_wakeup(&usb4->dev)) && configured) in usb4_switch_set_wake()
456 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
466 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_wake()
478 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_wake()
487 * usb4_switch_set_sleep() - Prepare the router to enter sleep
488 * @sw: USB4 router
493 int usb4_switch_set_sleep(struct tb_switch *sw) in usb4_switch_set_sleep() argument
499 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_sleep()
505 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_sleep()
509 return tb_switch_wait_for_bit(sw, ROUTER_CS_6, ROUTER_CS_6_SLPR, in usb4_switch_set_sleep()
514 * usb4_switch_nvm_sector_size() - Return router NVM sector size
515 * @sw: USB4 router
519 * %-EOPNOTSUPP.
521 int usb4_switch_nvm_sector_size(struct tb_switch *sw) in usb4_switch_nvm_sector_size() argument
527 ret = usb4_switch_op(sw, USB4_SWITCH_OP_NVM_SECTOR_SIZE, &metadata, in usb4_switch_nvm_sector_size()
533 return status == 0x2 ? -EOPNOTSUPP : -EIO; in usb4_switch_nvm_sector_size()
541 struct tb_switch *sw = data; in usb4_switch_nvm_read_block() local
551 ret = usb4_switch_op_data(sw, USB4_SWITCH_OP_NVM_READ, &metadata, in usb4_switch_nvm_read_block()
556 return status ? -EIO : 0; in usb4_switch_nvm_read_block()
560 * usb4_switch_nvm_read() - Read arbitrary bytes from router NVM
561 * @sw: USB4 router
567 * %-EOPNOTSUPP.
569 int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf, in usb4_switch_nvm_read() argument
573 usb4_switch_nvm_read_block, sw); in usb4_switch_nvm_read()
577 * usb4_switch_nvm_set_offset() - Set NVM write offset
578 * @sw: USB4 router
586 int usb4_switch_nvm_set_offset(struct tb_switch *sw, unsigned int address) in usb4_switch_nvm_set_offset() argument
596 ret = usb4_switch_op(sw, USB4_SWITCH_OP_NVM_SET_OFFSET, &metadata, in usb4_switch_nvm_set_offset()
601 return status ? -EIO : 0; in usb4_switch_nvm_set_offset()
607 struct tb_switch *sw = data; in usb4_switch_nvm_write_next_block() local
611 ret = usb4_switch_op_data(sw, USB4_SWITCH_OP_NVM_WRITE, NULL, &status, in usb4_switch_nvm_write_next_block()
616 return status ? -EIO : 0; in usb4_switch_nvm_write_next_block()
620 * usb4_switch_nvm_write() - Write to the router NVM
621 * @sw: USB4 router
627 * write is not supported returns %-EOPNOTSUPP.
629 int usb4_switch_nvm_write(struct tb_switch *sw, unsigned int address, in usb4_switch_nvm_write() argument
634 ret = usb4_switch_nvm_set_offset(sw, address); in usb4_switch_nvm_write()
639 usb4_switch_nvm_write_next_block, sw); in usb4_switch_nvm_write()
643 * usb4_switch_nvm_authenticate() - Authenticate new NVM
644 * @sw: USB4 router
655 int usb4_switch_nvm_authenticate(struct tb_switch *sw) in usb4_switch_nvm_authenticate() argument
659 ret = usb4_switch_op(sw, USB4_SWITCH_OP_NVM_AUTH, NULL, NULL); in usb4_switch_nvm_authenticate()
665 case -EACCES: in usb4_switch_nvm_authenticate()
666 case -ENOTCONN: in usb4_switch_nvm_authenticate()
667 case -ETIMEDOUT: in usb4_switch_nvm_authenticate()
676 * usb4_switch_nvm_authenticate_status() - Read status of last NVM authenticate
677 * @sw: USB4 router
687 int usb4_switch_nvm_authenticate_status(struct tb_switch *sw, u32 *status) in usb4_switch_nvm_authenticate_status() argument
689 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in usb4_switch_nvm_authenticate_status()
694 if (cm_ops->usb4_switch_nvm_authenticate_status) { in usb4_switch_nvm_authenticate_status()
695 ret = cm_ops->usb4_switch_nvm_authenticate_status(sw, status); in usb4_switch_nvm_authenticate_status()
696 if (ret != -EOPNOTSUPP) in usb4_switch_nvm_authenticate_status()
700 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); in usb4_switch_nvm_authenticate_status()
708 return -EBUSY; in usb4_switch_nvm_authenticate_status()
710 return -EOPNOTSUPP; in usb4_switch_nvm_authenticate_status()
722 * usb4_switch_credits_init() - Read buffer allocation parameters
723 * @sw: USB4 router
725 * Reads @sw buffer allocation parameters and initializes @sw buffer
726 * allocation fields accordingly. Specifically @sw->credits_allocation
731 int usb4_switch_credits_init(struct tb_switch *sw) in usb4_switch_credits_init() argument
741 ret = usb4_switch_op_data(sw, USB4_SWITCH_OP_BUFFER_ALLOC, &metadata, in usb4_switch_credits_init()
746 return -EIO; in usb4_switch_credits_init()
750 return -EMSGSIZE; in usb4_switch_credits_init()
752 max_usb3 = -1; in usb4_switch_credits_init()
753 min_dp_aux = -1; in usb4_switch_credits_init()
754 min_dp_main = -1; in usb4_switch_credits_init()
755 max_pcie = -1; in usb4_switch_credits_init()
756 max_dma = -1; in usb4_switch_credits_init()
758 tb_sw_dbg(sw, "credit allocation parameters:\n"); in usb4_switch_credits_init()
768 tb_sw_dbg(sw, " USB3: %u\n", value); in usb4_switch_credits_init()
772 tb_sw_dbg(sw, " DP AUX: %u\n", value); in usb4_switch_credits_init()
776 tb_sw_dbg(sw, " DP main: %u\n", value); in usb4_switch_credits_init()
780 tb_sw_dbg(sw, " PCIe: %u\n", value); in usb4_switch_credits_init()
784 tb_sw_dbg(sw, " DMA: %u\n", value); in usb4_switch_credits_init()
788 tb_sw_dbg(sw, " unknown credit allocation index %#x, skipping\n", in usb4_switch_credits_init()
796 * issues, log a warning and fall back using the hard-coded in usb4_switch_credits_init()
801 if (!tb_route(sw) && max_dma < 0) { in usb4_switch_credits_init()
802 tb_sw_warn(sw, "host router is missing baMaxHI\n"); in usb4_switch_credits_init()
807 tb_switch_for_each_port(sw, port) { in usb4_switch_credits_init()
814 tb_sw_warn(sw, "multiple USB4 ports require baMinDPaux/baMinDPmain\n"); in usb4_switch_credits_init()
818 tb_switch_for_each_port(sw, port) { in usb4_switch_credits_init()
820 tb_sw_warn(sw, "missing baMinDPmain"); in usb4_switch_credits_init()
825 tb_sw_warn(sw, "missing baMinDPaux"); in usb4_switch_credits_init()
830 tb_sw_warn(sw, "missing baMaxUSB3"); in usb4_switch_credits_init()
835 tb_sw_warn(sw, "missing baMaxPCIe"); in usb4_switch_credits_init()
841 * Buffer allocation passed the validation so we can use it in in usb4_switch_credits_init()
844 sw->credit_allocation = true; in usb4_switch_credits_init()
846 sw->max_usb3_credits = max_usb3; in usb4_switch_credits_init()
848 sw->min_dp_aux_credits = min_dp_aux; in usb4_switch_credits_init()
850 sw->min_dp_main_credits = min_dp_main; in usb4_switch_credits_init()
852 sw->max_pcie_credits = max_pcie; in usb4_switch_credits_init()
854 sw->max_dma_credits = max_dma; in usb4_switch_credits_init()
859 return -EINVAL; in usb4_switch_credits_init()
863 * usb4_switch_query_dp_resource() - Query availability of DP IN resource
864 * @sw: USB4 router
871 bool usb4_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in) in usb4_switch_query_dp_resource() argument
873 u32 metadata = in->port; in usb4_switch_query_dp_resource()
877 ret = usb4_switch_op(sw, USB4_SWITCH_OP_QUERY_DP_RESOURCE, &metadata, in usb4_switch_query_dp_resource()
883 if (ret == -EOPNOTSUPP) in usb4_switch_query_dp_resource()
892 * usb4_switch_alloc_dp_resource() - Allocate DP IN resource
893 * @sw: USB4 router
898 * returns negative errno, in particular %-EBUSY if the resource is
901 int usb4_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in) in usb4_switch_alloc_dp_resource() argument
903 u32 metadata = in->port; in usb4_switch_alloc_dp_resource()
907 ret = usb4_switch_op(sw, USB4_SWITCH_OP_ALLOC_DP_RESOURCE, &metadata, in usb4_switch_alloc_dp_resource()
909 if (ret == -EOPNOTSUPP) in usb4_switch_alloc_dp_resource()
914 return status ? -EBUSY : 0; in usb4_switch_alloc_dp_resource()
918 * usb4_switch_dealloc_dp_resource() - Releases allocated DP IN resource
919 * @sw: USB4 router
924 int usb4_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in) in usb4_switch_dealloc_dp_resource() argument
926 u32 metadata = in->port; in usb4_switch_dealloc_dp_resource()
930 ret = usb4_switch_op(sw, USB4_SWITCH_OP_DEALLOC_DP_RESOURCE, &metadata, in usb4_switch_dealloc_dp_resource()
932 if (ret == -EOPNOTSUPP) in usb4_switch_dealloc_dp_resource()
937 return status ? -EIO : 0; in usb4_switch_dealloc_dp_resource()
940 static int usb4_port_idx(const struct tb_switch *sw, const struct tb_port *port) in usb4_port_idx() argument
946 tb_switch_for_each_port(sw, p) { in usb4_port_idx()
951 if (!p->link_nr) { in usb4_port_idx()
962 * usb4_switch_map_pcie_down() - Map USB4 port to a PCIe downstream adapter
963 * @sw: USB4 router
971 struct tb_port *usb4_switch_map_pcie_down(struct tb_switch *sw, in usb4_switch_map_pcie_down() argument
974 int usb4_idx = usb4_port_idx(sw, port); in usb4_switch_map_pcie_down()
979 tb_switch_for_each_port(sw, p) { in usb4_switch_map_pcie_down()
993 * usb4_switch_map_usb3_down() - Map USB4 port to a USB3 downstream adapter
994 * @sw: USB4 router
1002 struct tb_port *usb4_switch_map_usb3_down(struct tb_switch *sw, in usb4_switch_map_usb3_down() argument
1005 int usb4_idx = usb4_port_idx(sw, port); in usb4_switch_map_usb3_down()
1010 tb_switch_for_each_port(sw, p) { in usb4_switch_map_usb3_down()
1024 * usb4_switch_add_ports() - Add USB4 ports for this router
1025 * @sw: USB4 router
1032 int usb4_switch_add_ports(struct tb_switch *sw) in usb4_switch_add_ports() argument
1036 if (tb_switch_is_icm(sw) || !tb_switch_is_usb4(sw)) in usb4_switch_add_ports()
1039 tb_switch_for_each_port(sw, port) { in usb4_switch_add_ports()
1044 if (!port->cap_usb4) in usb4_switch_add_ports()
1049 usb4_switch_remove_ports(sw); in usb4_switch_add_ports()
1053 port->usb4 = usb4; in usb4_switch_add_ports()
1060 * usb4_switch_remove_ports() - Removes USB4 ports from this router
1061 * @sw: USB4 router
1065 void usb4_switch_remove_ports(struct tb_switch *sw) in usb4_switch_remove_ports() argument
1069 tb_switch_for_each_port(sw, port) { in usb4_switch_remove_ports()
1070 if (port->usb4) { in usb4_switch_remove_ports()
1071 usb4_port_device_remove(port->usb4); in usb4_switch_remove_ports()
1072 port->usb4 = NULL; in usb4_switch_remove_ports()
1078 * usb4_port_unlock() - Unlock USB4 downstream port
1098 * usb4_port_hotplug_enable() - Enables hotplug for a port
1102 * to be used on lane, DP-IN, and DP-OUT adapters.
1118 * usb4_port_reset() - Issue downstream port reset
1128 if (!port->cap_usb4) in usb4_port_reset()
1129 return -EINVAL; in usb4_port_reset()
1132 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_reset()
1139 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_reset()
1146 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_reset()
1153 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_reset()
1161 if (!port->cap_usb4) in usb4_port_set_configured()
1162 return -EINVAL; in usb4_port_set_configured()
1165 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
1175 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
1179 * usb4_port_configure() - Set USB4 port configured
1190 * usb4_port_unconfigure() - Set USB4 port unconfigured
1205 if (!port->cap_usb4) in usb4_set_xdomain_configured()
1206 return -EINVAL; in usb4_set_xdomain_configured()
1209 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
1219 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
1223 * usb4_port_configure_xdomain() - Configure port for XDomain
1232 xd->link_usb4 = link_is_usb4(port); in usb4_port_configure_xdomain()
1237 * usb4_port_unconfigure_xdomain() - Unconfigure port for XDomain
1266 return -ETIMEDOUT; in usb4_port_wait_for_bit()
1272 return -EINVAL; in usb4_port_read_data()
1274 return tb_port_read(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_read_data()
1282 return -EINVAL; in usb4_port_write_data()
1284 return tb_port_write(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_write_data()
1295 if (!port->cap_usb4) in usb4_port_sb_read()
1296 return -EINVAL; in usb4_port_sb_read()
1306 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1310 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_read()
1316 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1321 return -ENODEV; in usb4_port_sb_read()
1323 return -EIO; in usb4_port_sb_read()
1335 if (!port->cap_usb4) in usb4_port_sb_write()
1336 return -EINVAL; in usb4_port_sb_write()
1353 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1357 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_write()
1363 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1368 return -ENODEV; in usb4_port_sb_write()
1370 return -EIO; in usb4_port_sb_write()
1381 return -EAGAIN; in usb4_port_sb_opcode_err_to_errno()
1383 return -EOPNOTSUPP; in usb4_port_sb_opcode_err_to_errno()
1385 return -EIO; in usb4_port_sb_opcode_err_to_errno()
1415 return -ETIMEDOUT; in usb4_port_sb_op()
1434 * usb4_port_router_offline() - Put the USB4 port to offline mode
1450 * usb4_port_router_online() - Put the USB4 port back to online
1461 * usb4_port_enumerate_retimers() - Send RT broadcast transaction
1478 * usb4_port_clx_supported() - Check if CLx is supported by the link
1490 port->cap_usb4 + PORT_CS_18, 1); in usb4_port_clx_supported()
1498 * usb4_port_asym_supported() - If the port supports asymmetric link
1508 if (!port->cap_usb4) in usb4_port_asym_supported()
1511 if (tb_port_read(port, &val, TB_CFG_PORT, port->cap_usb4 + PORT_CS_18, 1)) in usb4_port_asym_supported()
1518 * usb4_port_asym_set_link_width() - Set link width to asymmetric or symmetric
1530 if (!port->cap_phy) in usb4_port_asym_set_link_width()
1531 return -EINVAL; in usb4_port_asym_set_link_width()
1534 port->cap_phy + LANE_ADP_CS_1, 1); in usb4_port_asym_set_link_width()
1553 return -EINVAL; in usb4_port_asym_set_link_width()
1557 port->cap_phy + LANE_ADP_CS_1, 1); in usb4_port_asym_set_link_width()
1561 * usb4_port_asym_start() - Start symmetry change and wait for completion
1568 * Returns %0 in case of success, %-ETIMEDOUT if case of timeout or
1577 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_asym_start()
1585 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_asym_start()
1593 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_19, in usb4_port_asym_start()
1599 return usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_18, in usb4_port_asym_start()
1604 * usb4_port_margining_caps() - Read USB4 port marginig capabilities
1624 * usb4_port_hw_margin() - Run hardware lane margining on port
1630 * @right_high: Use Right/high margin instead of left/low
1667 * usb4_port_sw_margin() - Run software lane margining on port
1672 * @right_high: Use Right/high margin instead of left/low
1703 * usb4_port_sw_margin_errors() - Read the software margining error counters
1732 * usb4_port_retimer_set_inbound_sbtx() - Enable sideband channel transactions
1746 if (ret != -ENODEV) in usb4_port_retimer_set_inbound_sbtx()
1759 * usb4_port_retimer_unset_inbound_sbtx() - Disable sideband channel transactions
1773 * usb4_port_retimer_read() - Read from retimer sideband registers
1783 * present at given @index returns %-ENODEV. In any other failure
1794 * usb4_port_retimer_write() - Write to retimer sideband registers
1803 * is no retimer present at given @index returns %-ENODEV. In any other
1814 * usb4_port_retimer_is_last() - Is the retimer last on-board retimer
1819 * Type-C port) this function returns %1. If it is not returns %0. If
1820 * the retimer is not present returns %-ENODEV. Otherwise returns
1839 * usb4_port_retimer_nvm_sector_size() - Read retimer NVM sector size
1846 * in case of error. Specifically returns %-ENODEV if there is no
1865 * usb4_port_retimer_nvm_set_offset() - Set NVM write offset
1904 struct tb_port *port = info->port; in usb4_port_retimer_nvm_write_next_block()
1905 u8 index = info->index; in usb4_port_retimer_nvm_write_next_block()
1918 * usb4_port_retimer_nvm_write() - Write to retimer NVM
1927 * errno in case of failure. Specifically returns %-ENODEV if there is
1945 * usb4_port_retimer_nvm_authenticate() - Start retimer NVM upgrade
1960 * We need to use the raw operation here because once the in usb4_port_retimer_nvm_authenticate()
1970 * usb4_port_retimer_nvm_authenticate_status() - Read status of NVM upgrade
1999 case -EAGAIN: in usb4_port_retimer_nvm_authenticate_status()
2017 struct tb_port *port = info->port; in usb4_port_retimer_nvm_read_block()
2018 u8 index = info->index; in usb4_port_retimer_nvm_read_block()
2040 * usb4_port_retimer_nvm_read() - Read contents of retimer NVM
2049 * Specifically returns %-ENODEV if there is no retimer at @index.
2064 if (port->max_bw) in usb4_usb3_port_max_bandwidth()
2065 return min(bw, port->max_bw); in usb4_usb3_port_max_bandwidth()
2070 * usb4_usb3_port_max_link_rate() - Maximum support USB3 link rate
2082 return -EINVAL; in usb4_usb3_port_max_link_rate()
2085 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_max_link_rate()
2096 * usb4_usb3_port_actual_link_rate() - Established USB3 link rate
2108 return -EINVAL; in usb4_usb3_port_actual_link_rate()
2111 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_actual_link_rate()
2130 return -EINVAL; in usb4_usb3_port_cm_request()
2131 if (tb_route(port->sw)) in usb4_usb3_port_cm_request()
2132 return -EINVAL; in usb4_usb3_port_cm_request()
2135 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
2145 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
2150 * We can use val here directly as the CMR bit is in the same place in usb4_usb3_port_cm_request()
2154 return usb4_port_wait_for_bit(port, port->cap_adap + ADP_USB3_CS_1, in usb4_usb3_port_cm_request()
2180 /* 1 uframe is 1/8 ms (125 us) -> 1 / 8000 s */ in mbps_to_usb3_bw()
2193 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_read_allocated_bandwidth()
2198 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_allocated_bandwidth()
2214 * usb4_usb3_port_allocated_bandwidth() - Bandwidth allocated for USB3
2247 port->cap_adap + ADP_USB3_CS_1, 1); in usb4_usb3_port_read_consumed_bandwidth()
2252 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_consumed_bandwidth()
2284 return -EINVAL; in usb4_usb3_port_write_allocated_bandwidth()
2287 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_write_allocated_bandwidth()
2297 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
2306 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
2310 * usb4_usb3_port_allocate_bandwidth() - Allocate bandwidth for USB3
2358 * usb4_usb3_port_release_bandwidth() - Release allocated USB3 bandwidth
2408 if (!tb_switch_is_usb4(port->sw)) in is_usb4_dpin()
2414 * usb4_dp_port_set_cm_id() - Assign CM ID to the DP IN adapter
2419 * otherwise. Speficially returns %-EOPNOTSUPP if the @port does not
2428 return -EOPNOTSUPP; in usb4_dp_port_set_cm_id()
2431 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_cm_id()
2439 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_cm_id()
2443 * usb4_dp_port_bandwidth_mode_supported() - Is the bandwidth allocation mode
2459 port->cap_adap + DP_LOCAL_CAP, 1); in usb4_dp_port_bandwidth_mode_supported()
2467 * usb4_dp_port_bandwidth_mode_enabled() - Is the bandwidth allocation mode
2483 port->cap_adap + ADP_DP_CS_8, 1); in usb4_dp_port_bandwidth_mode_enabled()
2491 * usb4_dp_port_set_cm_bandwidth_mode_supported() - Set/clear CM support for
2498 * otherwise. Specifically returns %-OPNOTSUPP if the passed in adapter
2508 return -EOPNOTSUPP; in usb4_dp_port_set_cm_bandwidth_mode_supported()
2511 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_cm_bandwidth_mode_supported()
2521 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_cm_bandwidth_mode_supported()
2525 * usb4_dp_port_group_id() - Return Group ID assigned for the adapter
2530 * %-EOPNOTSUPP is returned.
2538 return -EOPNOTSUPP; in usb4_dp_port_group_id()
2541 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_group_id()
2549 * usb4_dp_port_set_group_id() - Set adapter Group ID
2555 * Specifically returns %-EOPNOTSUPP if the adapter does not support
2564 return -EOPNOTSUPP; in usb4_dp_port_set_group_id()
2567 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_group_id()
2575 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_group_id()
2579 * usb4_dp_port_nrd() - Read non-reduced rate and lanes
2581 * @rate: Non-reduced rate in Mb/s is placed here
2582 * @lanes: Non-reduced lanes are placed here
2584 * Reads the non-reduced rate and lanes from the DP IN adapter. Returns
2586 * %-EOPNOTSUPP if the adapter does not support this.
2594 return -EOPNOTSUPP; in usb4_dp_port_nrd()
2597 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_nrd()
2634 * usb4_dp_port_set_nrd() - Set non-reduced rate and lanes
2636 * @rate: Non-reduced rate in Mb/s
2637 * @lanes: Non-reduced lanes
2640 * the non-reduced values for the DP IN adapter. Returns %0 in success
2642 * %-EOPNOTSUPP is returned.
2650 return -EOPNOTSUPP; in usb4_dp_port_set_nrd()
2653 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_nrd()
2675 return -EINVAL; in usb4_dp_port_set_nrd()
2690 return -EINVAL; in usb4_dp_port_set_nrd()
2694 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_nrd()
2698 * usb4_dp_port_granularity() - Return granularity for the bandwidth values
2702 * not support bandwidth allocation mode returns %-EOPNOTSUPP and negative
2711 return -EOPNOTSUPP; in usb4_dp_port_granularity()
2714 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_granularity()
2730 return -EINVAL; in usb4_dp_port_granularity()
2734 * usb4_dp_port_set_granularity() - Set granularity for the bandwidth values
2740 * adapter does not support this %-EOPNOTSUPP is returned.
2748 return -EOPNOTSUPP; in usb4_dp_port_set_granularity()
2751 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_granularity()
2768 return -EINVAL; in usb4_dp_port_set_granularity()
2772 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_granularity()
2776 * usb4_dp_port_set_estimated_bandwidth() - Set estimated bandwidth
2783 * and negative errno otherwise. Specifically returns %-EOPNOTSUPP if
2792 return -EOPNOTSUPP; in usb4_dp_port_set_estimated_bandwidth()
2800 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_estimated_bandwidth()
2808 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_set_estimated_bandwidth()
2812 * usb4_dp_port_allocated_bandwidth() - Return allocated bandwidth
2825 return -EOPNOTSUPP; in usb4_dp_port_allocated_bandwidth()
2833 port->cap_adap + DP_STATUS, 1); in usb4_dp_port_allocated_bandwidth()
2849 port->cap_adap + ADP_DP_CS_2, 1); in __usb4_dp_port_set_cm_ack()
2859 port->cap_adap + ADP_DP_CS_2, 1); in __usb4_dp_port_set_cm_ack()
2881 port->cap_adap + ADP_DP_CS_8, 1); in usb4_dp_port_wait_and_clear_cm_ack()
2892 return -ETIMEDOUT; in usb4_dp_port_wait_and_clear_cm_ack()
2895 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_wait_and_clear_cm_ack()
2901 port->cap_adap + ADP_DP_CS_2, 1); in usb4_dp_port_wait_and_clear_cm_ack()
2905 * usb4_dp_port_allocate_bandwidth() - Set allocated bandwidth
2919 return -EOPNOTSUPP; in usb4_dp_port_allocate_bandwidth()
2927 port->cap_adap + DP_STATUS, 1); in usb4_dp_port_allocate_bandwidth()
2935 port->cap_adap + DP_STATUS, 1); in usb4_dp_port_allocate_bandwidth()
2947 * usb4_dp_port_requested_bandwidth() - Read requested bandwidth
2952 * error returns negative errno. Specifically returns %-EOPNOTSUPP if
2962 return -EOPNOTSUPP; in usb4_dp_port_requested_bandwidth()
2970 port->cap_adap + ADP_DP_CS_8, 1); in usb4_dp_port_requested_bandwidth()
2975 return -ENODATA; in usb4_dp_port_requested_bandwidth()
2981 * usb4_pci_port_set_ext_encapsulation() - Enable/disable extended encapsulation
2995 return -EINVAL; in usb4_pci_port_set_ext_encapsulation()
2998 port->cap_adap + ADP_PCIE_CS_1, 1); in usb4_pci_port_set_ext_encapsulation()
3008 port->cap_adap + ADP_PCIE_CS_1, 1); in usb4_pci_port_set_ext_encapsulation()