Lines Matching +full:retimer +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0
74 return -ETIMEDOUT; in usb4_switch_wait_for_bit()
81 return -EINVAL; in usb4_switch_op_read_data()
90 return -EINVAL; in usb4_switch_op_write_data()
125 if (ret != -ENODEV && retries--) in usb4_do_read_data()
130 nbytes -= offset; in usb4_do_read_data()
133 size -= nbytes; in usb4_do_read_data()
159 if (ret == -ETIMEDOUT) { in usb4_do_write_data()
160 if (retries--) in usb4_do_write_data()
162 ret = -EIO; in usb4_do_write_data()
167 size -= nbytes; in usb4_do_write_data()
194 return -EOPNOTSUPP; in usb4_switch_op()
206 if (!device_may_wakeup(&sw->dev)) in usb4_switch_check_wakes()
226 port->cap_usb4 + PORT_CS_18, 1)) in usb4_switch_check_wakes()
237 pm_wakeup_event(&sw->dev, 0); in usb4_switch_check_wakes()
244 if (!port->cap_usb4) in link_is_usb4()
248 port->cap_usb4 + PORT_CS_18, 1)) in link_is_usb4()
255 * usb4_switch_setup() - Additional setup for USB4 device
260 * enabled (e.g the parent switch also supports them). If USB tunneling
262 * switch upstream) then the internal xHCI controller is enabled
284 sw->link_usb4 = link_is_usb4(downstream_port); in usb4_switch_setup()
285 tb_sw_dbg(sw, "link: %s\n", sw->link_usb4 ? "USB4" : "TBT3"); in usb4_switch_setup()
297 if (sw->link_usb4 && tb_switch_find_port(parent, TB_TYPE_USB3_DOWN)) { in usb4_switch_setup()
328 * usb4_switch_read_uid() - Read UID from USB4 router
332 * Reads 64-bit UID from USB4 router config space.
361 return -EIO; in usb4_switch_drom_read_block()
367 * usb4_switch_drom_read() - Read arbitrary bytes from USB4 router DROM
374 * should always work but for hosts it may return %-EOPNOTSUPP in which
385 * usb4_switch_lane_bonding_possible() - Are conditions met for lane bonding
398 ret = tb_port_read(up, &val, TB_CFG_PORT, up->cap_usb4 + PORT_CS_18, 1); in usb4_switch_lane_bonding_possible()
406 * usb4_switch_set_wake() - Enabled/disable wake
429 if (!port->cap_usb4) in usb4_switch_set_wake()
433 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
447 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
476 * usb4_switch_set_sleep() - Prepare the router to enter sleep
503 * usb4_switch_nvm_sector_size() - Return router NVM sector size
508 * %-EOPNOTSUPP.
521 return status == 0x2 ? -EOPNOTSUPP : -EIO; in usb4_switch_nvm_sector_size()
552 return -EIO; in usb4_switch_nvm_read_block()
558 * usb4_switch_nvm_read() - Read arbitrary bytes from router NVM
565 * %-EOPNOTSUPP.
593 return status ? -EIO : 0; in usb4_switch_nvm_set_offset()
611 return status ? -EIO : 0; in usb4_switch_nvm_write_next_block()
615 * usb4_switch_nvm_write() - Write to the router NVM
622 * write is not supported returns %-EOPNOTSUPP.
638 * usb4_switch_nvm_authenticate() - Authenticate new NVM
655 switch (status) { in usb4_switch_nvm_authenticate()
660 return -EINVAL; in usb4_switch_nvm_authenticate()
662 return -EAGAIN; in usb4_switch_nvm_authenticate()
664 return -EOPNOTSUPP; in usb4_switch_nvm_authenticate()
666 return -EIO; in usb4_switch_nvm_authenticate()
671 * usb4_switch_query_dp_resource() - Query availability of DP IN resource
684 ret = usb4_switch_op_write_metadata(sw, in->port); in usb4_switch_query_dp_resource()
693 if (ret == -EOPNOTSUPP) in usb4_switch_query_dp_resource()
702 * usb4_switch_alloc_dp_resource() - Allocate DP IN resource
708 * returns negative errno, in particular %-EBUSY if the resource is
716 ret = usb4_switch_op_write_metadata(sw, in->port); in usb4_switch_alloc_dp_resource()
721 if (ret == -EOPNOTSUPP) in usb4_switch_alloc_dp_resource()
726 return status ? -EBUSY : 0; in usb4_switch_alloc_dp_resource()
730 * usb4_switch_dealloc_dp_resource() - Releases allocated DP IN resource
741 ret = usb4_switch_op_write_metadata(sw, in->port); in usb4_switch_dealloc_dp_resource()
746 if (ret == -EOPNOTSUPP) in usb4_switch_dealloc_dp_resource()
751 return status ? -EIO : 0; in usb4_switch_dealloc_dp_resource()
765 if (!p->link_nr) { in usb4_port_idx()
776 * usb4_switch_map_pcie_down() - Map USB4 port to a PCIe downstream adapter
807 * usb4_switch_map_usb3_down() - Map USB4 port to a USB3 downstream adapter
838 * usb4_port_unlock() - Unlock USB4 downstream port
858 * usb4_port_hotplug_enable() - Enables hotplug for a port
862 * to be used on lane, DP-IN, and DP-OUT adapters.
882 if (!port->cap_usb4) in usb4_port_set_configured()
883 return -EINVAL; in usb4_port_set_configured()
886 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
896 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
900 * usb4_port_configure() - Set USB4 port configured
911 * usb4_port_unconfigure() - Set USB4 port unconfigured
926 if (!port->cap_usb4) in usb4_set_xdomain_configured()
927 return -EINVAL; in usb4_set_xdomain_configured()
930 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
940 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
944 * usb4_port_configure_xdomain() - Configure port for XDomain
956 * usb4_port_unconfigure_xdomain() - Unconfigure port for XDomain
985 return -ETIMEDOUT; in usb4_port_wait_for_bit()
991 return -EINVAL; in usb4_port_read_data()
993 return tb_port_read(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_read_data()
1001 return -EINVAL; in usb4_port_write_data()
1003 return tb_port_write(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_write_data()
1014 if (!port->cap_usb4) in usb4_port_sb_read()
1015 return -EINVAL; in usb4_port_sb_read()
1025 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1029 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_read()
1035 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1040 return -ENODEV; in usb4_port_sb_read()
1042 return -EIO; in usb4_port_sb_read()
1054 if (!port->cap_usb4) in usb4_port_sb_write()
1055 return -EINVAL; in usb4_port_sb_write()
1072 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1076 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_write()
1082 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1087 return -ENODEV; in usb4_port_sb_write()
1089 return -EIO; in usb4_port_sb_write()
1116 switch (val) { in usb4_port_sb_op()
1121 return -EAGAIN; in usb4_port_sb_op()
1124 return -EOPNOTSUPP; in usb4_port_sb_op()
1128 return -EIO; in usb4_port_sb_op()
1133 return -ETIMEDOUT; in usb4_port_sb_op()
1137 * usb4_port_enumerate_retimers() - Send RT broadcast transaction
1162 * usb4_port_retimer_read() - Read from retimer sideband registers
1164 * @index: Retimer index
1169 * Function reads retimer sideband registers starting from @reg. The
1170 * retimer is connected to @port at @index. Returns %0 in case of
1171 * success, and read data is copied to @buf. If there is no retimer
1172 * present at given @index returns %-ENODEV. In any other failure
1183 * usb4_port_retimer_write() - Write to retimer sideband registers
1185 * @index: Retimer index
1190 * Writes retimer sideband registers starting from @reg. The retimer is
1192 * is no retimer present at given @index returns %-ENODEV. In any other
1203 * usb4_port_retimer_is_last() - Is the retimer last on-board retimer
1205 * @index: Retimer index
1207 * If the retimer at @index is last one (connected directly to the
1208 * Type-C port) this function returns %1. If it is not returns %0. If
1209 * the retimer is not present returns %-ENODEV. Otherwise returns
1228 * usb4_port_retimer_nvm_sector_size() - Read retimer NVM sector size
1230 * @index: Retimer index
1232 * Reads NVM sector size (in bytes) of a retimer at @index. This
1233 * operation can be used to determine whether the retimer supports NVM
1235 * in case of error. Specifically returns %-ENODEV if there is no
1236 * retimer at @index.
1282 struct tb_port *port = info->port; in usb4_port_retimer_nvm_write_next_block()
1283 u8 index = info->index; in usb4_port_retimer_nvm_write_next_block()
1296 * usb4_port_retimer_nvm_write() - Write to retimer NVM
1298 * @index: Retimer index
1303 * Writes @size bytes from @buf to the retimer NVM. Used for NVM
1305 * errno in case of failure. Specifically returns %-ENODEV if there is
1306 * no retimer at @index.
1323 * usb4_port_retimer_nvm_authenticate() - Start retimer NVM upgrade
1325 * @index: Retimer index
1329 * successful the retimer restarts with the new NVM and may not have the
1339 * authentication completes the retimer index is not set anymore in usb4_port_retimer_nvm_authenticate()
1348 * usb4_port_retimer_nvm_authenticate_status() - Read status of NVM upgrade
1350 * @index: Retimer index
1371 switch (val) { in usb4_port_retimer_nvm_authenticate_status()
1386 return -EOPNOTSUPP; in usb4_port_retimer_nvm_authenticate_status()
1389 return -EIO; in usb4_port_retimer_nvm_authenticate_status()
1397 struct tb_port *port = info->port; in usb4_port_retimer_nvm_read_block()
1398 u8 index = info->index; in usb4_port_retimer_nvm_read_block()
1420 * usb4_port_retimer_nvm_read() - Read contents of retimer NVM
1422 * @index: Retimer index
1427 * Reads retimer NVM and copies the contents to @buf. Returns %0 if the
1429 * Specifically returns %-ENODEV if there is no retimer at @index.
1441 * usb4_usb3_port_max_link_rate() - Maximum support USB3 link rate
1453 return -EINVAL; in usb4_usb3_port_max_link_rate()
1456 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_max_link_rate()
1465 * usb4_usb3_port_actual_link_rate() - Established USB3 link rate
1477 return -EINVAL; in usb4_usb3_port_actual_link_rate()
1480 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_actual_link_rate()
1497 return -EINVAL; in usb4_usb3_port_cm_request()
1498 if (tb_route(port->sw)) in usb4_usb3_port_cm_request()
1499 return -EINVAL; in usb4_usb3_port_cm_request()
1502 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
1512 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
1521 return usb4_port_wait_for_bit(port, port->cap_adap + ADP_USB3_CS_1, in usb4_usb3_port_cm_request()
1547 /* 1 uframe is 1/8 ms (125 us) -> 1 / 8000 s */ in mbps_to_usb3_bw()
1560 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_read_allocated_bandwidth()
1565 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_allocated_bandwidth()
1581 * usb4_usb3_port_allocated_bandwidth() - Bandwidth allocated for USB3
1614 port->cap_adap + ADP_USB3_CS_1, 1); in usb4_usb3_port_read_consumed_bandwidth()
1619 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_consumed_bandwidth()
1651 return -EINVAL; in usb4_usb3_port_write_allocated_bandwidth()
1654 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_write_allocated_bandwidth()
1664 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
1673 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
1677 * usb4_usb3_port_allocate_bandwidth() - Allocate bandwidth for USB3
1725 * usb4_usb3_port_release_bandwidth() - Release allocated USB3 bandwidth