Lines Matching +full:dma +full:- +full:router

1 // SPDX-License-Identifier: GPL-2.0
72 return -ETIMEDOUT; in usb4_switch_wait_for_bit()
109 return -EOPNOTSUPP; in usb4_native_switch_op()
134 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in __usb4_switch_op()
137 return -EINVAL; in __usb4_switch_op()
140 * If the connection manager implementation provides USB4 router in __usb4_switch_op()
144 if (cm_ops->usb4_switch_op) { in __usb4_switch_op()
147 ret = cm_ops->usb4_switch_op(sw, opcode, metadata, status, in __usb4_switch_op()
150 if (ret != -EOPNOTSUPP) in __usb4_switch_op()
155 * router operation instead. in __usb4_switch_op()
184 if (!device_may_wakeup(&sw->dev)) in usb4_switch_check_wakes()
204 port->cap_usb4 + PORT_CS_18, 1)) in usb4_switch_check_wakes()
215 pm_wakeup_event(&sw->dev, 0); in usb4_switch_check_wakes()
222 if (!port->cap_usb4) in link_is_usb4()
226 port->cap_usb4 + PORT_CS_18, 1)) in link_is_usb4()
233 * usb4_switch_setup() - Additional setup for USB4 device
234 * @sw: USB4 router to setup
262 sw->link_usb4 = link_is_usb4(downstream_port); in usb4_switch_setup()
263 tb_sw_dbg(sw, "link: %s\n", sw->link_usb4 ? "USB4" : "TBT"); in usb4_switch_setup()
275 if (tb_acpi_may_tunnel_usb3() && sw->link_usb4 && in usb4_switch_setup()
282 * Only enable PCIe tunneling if the parent router supports it in usb4_switch_setup()
311 * usb4_switch_read_uid() - Read UID from USB4 router
312 * @sw: USB4 router
315 * Reads 64-bit UID from USB4 router config space.
340 return status ? -EIO : 0; in usb4_switch_drom_read_block()
344 * usb4_switch_drom_read() - Read arbitrary bytes from USB4 router DROM
345 * @sw: USB4 router
350 * Uses USB4 router operations to read router DROM. For devices this
351 * should always work but for hosts it may return %-EOPNOTSUPP in which
352 * case the host router does not have DROM.
362 * usb4_switch_lane_bonding_possible() - Are conditions met for lane bonding
363 * @sw: USB4 router
366 * established with the upstream router. Call only for device routers.
375 ret = tb_port_read(up, &val, TB_CFG_PORT, up->cap_usb4 + PORT_CS_18, 1); in usb4_switch_lane_bonding_possible()
383 * usb4_switch_set_wake() - Enabled/disable wake
384 * @sw: USB4 router
387 * Enables/disables router to wake up from sleep.
406 if (!port->cap_usb4) in usb4_switch_set_wake()
410 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
430 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
436 * Enable wakes from PCIe, USB 3.x and DP on this router. Only in usb4_switch_set_wake()
461 * usb4_switch_set_sleep() - Prepare the router to enter sleep
462 * @sw: USB4 router
464 * Sets sleep bit for the router. Returns when the router sleep ready
488 * usb4_switch_nvm_sector_size() - Return router NVM sector size
489 * @sw: USB4 router
491 * If the router supports NVM operations this function returns the NVM
493 * %-EOPNOTSUPP.
507 return status == 0x2 ? -EOPNOTSUPP : -EIO; in usb4_switch_nvm_sector_size()
530 return status ? -EIO : 0; in usb4_switch_nvm_read_block()
534 * usb4_switch_nvm_read() - Read arbitrary bytes from router NVM
535 * @sw: USB4 router
540 * Reads NVM contents of the router. If NVM is not supported returns
541 * %-EOPNOTSUPP.
551 * usb4_switch_nvm_set_offset() - Set NVM write offset
552 * @sw: USB4 router
575 return status ? -EIO : 0; in usb4_switch_nvm_set_offset()
590 return status ? -EIO : 0; in usb4_switch_nvm_write_next_block()
594 * usb4_switch_nvm_write() - Write to the router NVM
595 * @sw: USB4 router
600 * Writes @buf to the router NVM using USB4 router operations. If NVM
601 * write is not supported returns %-EOPNOTSUPP.
617 * usb4_switch_nvm_authenticate() - Authenticate new NVM
618 * @sw: USB4 router
621 * function triggers NVM authentication process. The router gets power
627 * first router operation to avoid the status being lost.
636 * The router is power cycled once NVM_AUTH is started so it is in usb4_switch_nvm_authenticate()
639 case -EACCES: in usb4_switch_nvm_authenticate()
640 case -ENOTCONN: in usb4_switch_nvm_authenticate()
641 case -ETIMEDOUT: in usb4_switch_nvm_authenticate()
650 * usb4_switch_nvm_authenticate_status() - Read status of last NVM authenticate
651 * @sw: USB4 router
655 * authenticate router operation. If there is status then %0 is returned
659 * Must be called before any other router operation.
663 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in usb4_switch_nvm_authenticate_status()
668 if (cm_ops->usb4_switch_nvm_authenticate_status) { in usb4_switch_nvm_authenticate_status()
669 ret = cm_ops->usb4_switch_nvm_authenticate_status(sw, status); in usb4_switch_nvm_authenticate_status()
670 if (ret != -EOPNOTSUPP) in usb4_switch_nvm_authenticate_status()
682 return -EBUSY; in usb4_switch_nvm_authenticate_status()
684 return -EOPNOTSUPP; in usb4_switch_nvm_authenticate_status()
696 * usb4_switch_credits_init() - Read buffer allocation parameters
697 * @sw: USB4 router
700 * allocation fields accordingly. Specifically @sw->credits_allocation
720 return -EIO; in usb4_switch_credits_init()
724 return -EMSGSIZE; in usb4_switch_credits_init()
726 max_usb3 = -1; in usb4_switch_credits_init()
727 min_dp_aux = -1; in usb4_switch_credits_init()
728 min_dp_main = -1; in usb4_switch_credits_init()
729 max_pcie = -1; in usb4_switch_credits_init()
730 max_dma = -1; in usb4_switch_credits_init()
758 tb_sw_dbg(sw, " DMA: %u\n", value); in usb4_switch_credits_init()
770 * issues, log a warning and fall back using the hard-coded in usb4_switch_credits_init()
774 /* Host router must report baMaxHI */ in usb4_switch_credits_init()
776 tb_sw_warn(sw, "host router is missing baMaxHI\n"); in usb4_switch_credits_init()
818 sw->credit_allocation = true; in usb4_switch_credits_init()
820 sw->max_usb3_credits = max_usb3; in usb4_switch_credits_init()
822 sw->min_dp_aux_credits = min_dp_aux; in usb4_switch_credits_init()
824 sw->min_dp_main_credits = min_dp_main; in usb4_switch_credits_init()
826 sw->max_pcie_credits = max_pcie; in usb4_switch_credits_init()
828 sw->max_dma_credits = max_dma; in usb4_switch_credits_init()
833 return -EINVAL; in usb4_switch_credits_init()
837 * usb4_switch_query_dp_resource() - Query availability of DP IN resource
838 * @sw: USB4 router
847 u32 metadata = in->port; in usb4_switch_query_dp_resource()
857 if (ret == -EOPNOTSUPP) in usb4_switch_query_dp_resource()
866 * usb4_switch_alloc_dp_resource() - Allocate DP IN resource
867 * @sw: USB4 router
870 * Allocates DP IN resource for DP tunneling using USB4 router
872 * returns negative errno, in particular %-EBUSY if the resource is
877 u32 metadata = in->port; in usb4_switch_alloc_dp_resource()
883 if (ret == -EOPNOTSUPP) in usb4_switch_alloc_dp_resource()
888 return status ? -EBUSY : 0; in usb4_switch_alloc_dp_resource()
892 * usb4_switch_dealloc_dp_resource() - Releases allocated DP IN resource
893 * @sw: USB4 router
900 u32 metadata = in->port; in usb4_switch_dealloc_dp_resource()
906 if (ret == -EOPNOTSUPP) in usb4_switch_dealloc_dp_resource()
911 return status ? -EIO : 0; in usb4_switch_dealloc_dp_resource()
925 if (!p->link_nr) { in usb4_port_idx()
936 * usb4_switch_map_pcie_down() - Map USB4 port to a PCIe downstream adapter
937 * @sw: USB4 router
967 * usb4_switch_map_usb3_down() - Map USB4 port to a USB3 downstream adapter
968 * @sw: USB4 router
998 * usb4_switch_add_ports() - Add USB4 ports for this router
999 * @sw: USB4 router
1001 * For USB4 router finds all USB4 ports and registers devices for each.
1002 * Can be called to any router.
1018 if (!port->cap_usb4) in usb4_switch_add_ports()
1027 port->usb4 = usb4; in usb4_switch_add_ports()
1034 * usb4_switch_remove_ports() - Removes USB4 ports from this router
1035 * @sw: USB4 router
1044 if (port->usb4) { in usb4_switch_remove_ports()
1045 usb4_port_device_remove(port->usb4); in usb4_switch_remove_ports()
1046 port->usb4 = NULL; in usb4_switch_remove_ports()
1052 * usb4_port_unlock() - Unlock USB4 downstream port
1056 * access the router below this port.
1076 if (!port->cap_usb4) in usb4_port_set_configured()
1077 return -EINVAL; in usb4_port_set_configured()
1080 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
1090 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
1094 * usb4_port_configure() - Set USB4 port configured
1095 * @port: USB4 router
1105 * usb4_port_unconfigure() - Set USB4 port unconfigured
1106 * @port: USB4 router
1120 if (!port->cap_usb4) in usb4_set_xdomain_configured()
1121 return -EINVAL; in usb4_set_xdomain_configured()
1124 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
1134 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
1138 * usb4_port_configure_xdomain() - Configure port for XDomain
1150 * usb4_port_unconfigure_xdomain() - Unconfigure port for XDomain
1179 return -ETIMEDOUT; in usb4_port_wait_for_bit()
1185 return -EINVAL; in usb4_port_read_data()
1187 return tb_port_read(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_read_data()
1195 return -EINVAL; in usb4_port_write_data()
1197 return tb_port_write(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_write_data()
1208 if (!port->cap_usb4) in usb4_port_sb_read()
1209 return -EINVAL; in usb4_port_sb_read()
1219 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1223 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_read()
1229 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1234 return -ENODEV; in usb4_port_sb_read()
1236 return -EIO; in usb4_port_sb_read()
1248 if (!port->cap_usb4) in usb4_port_sb_write()
1249 return -EINVAL; in usb4_port_sb_write()
1266 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1270 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_write()
1276 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1281 return -ENODEV; in usb4_port_sb_write()
1283 return -EIO; in usb4_port_sb_write()
1315 return -EAGAIN; in usb4_port_sb_op()
1318 return -EOPNOTSUPP; in usb4_port_sb_op()
1322 return -EIO; in usb4_port_sb_op()
1327 return -ETIMEDOUT; in usb4_port_sb_op()
1346 * usb4_port_router_offline() - Put the USB4 port to offline mode
1362 * usb4_port_router_online() - Put the USB4 port back to online
1373 * usb4_port_enumerate_retimers() - Send RT broadcast transaction
1398 * usb4_port_retimer_set_inbound_sbtx() - Enable sideband channel transactions
1412 if (ret != -ENODEV) in usb4_port_retimer_set_inbound_sbtx()
1425 * usb4_port_retimer_read() - Read from retimer sideband registers
1435 * present at given @index returns %-ENODEV. In any other failure
1446 * usb4_port_retimer_write() - Write to retimer sideband registers
1455 * is no retimer present at given @index returns %-ENODEV. In any other
1466 * usb4_port_retimer_is_last() - Is the retimer last on-board retimer
1471 * Type-C port) this function returns %1. If it is not returns %0. If
1472 * the retimer is not present returns %-ENODEV. Otherwise returns
1491 * usb4_port_retimer_nvm_sector_size() - Read retimer NVM sector size
1498 * in case of error. Specifically returns %-ENODEV if there is no
1517 * usb4_port_retimer_nvm_set_offset() - Set NVM write offset
1556 struct tb_port *port = info->port; in usb4_port_retimer_nvm_write_next_block()
1557 u8 index = info->index; in usb4_port_retimer_nvm_write_next_block()
1570 * usb4_port_retimer_nvm_write() - Write to retimer NVM
1579 * errno in case of failure. Specifically returns %-ENODEV if there is
1597 * usb4_port_retimer_nvm_authenticate() - Start retimer NVM upgrade
1622 * usb4_port_retimer_nvm_authenticate_status() - Read status of NVM upgrade
1660 return -EOPNOTSUPP; in usb4_port_retimer_nvm_authenticate_status()
1663 return -EIO; in usb4_port_retimer_nvm_authenticate_status()
1671 struct tb_port *port = info->port; in usb4_port_retimer_nvm_read_block()
1672 u8 index = info->index; in usb4_port_retimer_nvm_read_block()
1694 * usb4_port_retimer_nvm_read() - Read contents of retimer NVM
1703 * Specifically returns %-ENODEV if there is no retimer at @index.
1715 * usb4_usb3_port_max_link_rate() - Maximum support USB3 link rate
1727 return -EINVAL; in usb4_usb3_port_max_link_rate()
1730 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_max_link_rate()
1739 * usb4_usb3_port_actual_link_rate() - Established USB3 link rate
1751 return -EINVAL; in usb4_usb3_port_actual_link_rate()
1754 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_actual_link_rate()
1771 return -EINVAL; in usb4_usb3_port_cm_request()
1772 if (tb_route(port->sw)) in usb4_usb3_port_cm_request()
1773 return -EINVAL; in usb4_usb3_port_cm_request()
1776 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
1786 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
1795 return usb4_port_wait_for_bit(port, port->cap_adap + ADP_USB3_CS_1, in usb4_usb3_port_cm_request()
1821 /* 1 uframe is 1/8 ms (125 us) -> 1 / 8000 s */ in mbps_to_usb3_bw()
1834 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_read_allocated_bandwidth()
1839 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_allocated_bandwidth()
1855 * usb4_usb3_port_allocated_bandwidth() - Bandwidth allocated for USB3
1888 port->cap_adap + ADP_USB3_CS_1, 1); in usb4_usb3_port_read_consumed_bandwidth()
1893 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_consumed_bandwidth()
1917 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_write_allocated_bandwidth()
1926 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
1935 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
1939 * usb4_usb3_port_allocate_bandwidth() - Allocate bandwidth for USB3
1987 * usb4_usb3_port_release_bandwidth() - Release allocated USB3 bandwidth