Lines Matching +full:port +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
64 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, offset, 1); in usb4_switch_wait_for_bit()
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()
97 return tb_sw_read(sw, metadata, TB_CFG_SWITCH, ROUTER_CS_25, 1); in usb4_switch_op_read_metadata()
102 return tb_sw_write(sw, &metadata, TB_CFG_SWITCH, ROUTER_CS_25, 1); in usb4_switch_op_write_metadata()
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()
181 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); in usb4_switch_op()
189 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); in usb4_switch_op()
194 return -EOPNOTSUPP; in usb4_switch_op()
202 struct tb_port *port; in usb4_switch_check_wakes() local
206 if (!device_may_wakeup(&sw->dev)) in usb4_switch_check_wakes()
210 if (tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1)) in usb4_switch_check_wakes()
221 tb_switch_for_each_port(sw, port) { in usb4_switch_check_wakes()
222 if (!tb_port_has_remote(port)) in usb4_switch_check_wakes()
225 if (tb_port_read(port, &val, TB_CFG_PORT, in usb4_switch_check_wakes()
226 port->cap_usb4 + PORT_CS_18, 1)) in usb4_switch_check_wakes()
229 tb_port_dbg(port, "USB4 wake: %s\n", in usb4_switch_check_wakes()
237 pm_wakeup_event(&sw->dev, 0); in usb4_switch_check_wakes()
240 static bool link_is_usb4(struct tb_port *port) in link_is_usb4() argument
244 if (!port->cap_usb4) in link_is_usb4()
247 if (tb_port_read(port, &val, TB_CFG_PORT, 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
278 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1); in usb4_switch_setup()
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()
293 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_setup()
297 if (sw->link_usb4 && tb_switch_find_port(parent, TB_TYPE_USB3_DOWN)) { in usb4_switch_setup()
319 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); 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
414 struct tb_port *port; in usb4_switch_set_wake() local
422 * upstream USB4 port. in usb4_switch_set_wake()
424 tb_switch_for_each_port(sw, port) { in usb4_switch_set_wake()
425 if (!tb_port_is_null(port)) in usb4_switch_set_wake()
427 if (!route && tb_is_upstream_port(port)) in usb4_switch_set_wake()
429 if (!port->cap_usb4) in usb4_switch_set_wake()
432 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_switch_set_wake()
433 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
446 ret = tb_port_write(port, &val, TB_CFG_PORT, in usb4_switch_set_wake()
447 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
457 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_wake()
467 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_wake()
476 * usb4_switch_set_sleep() - Prepare the router to enter sleep
488 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_sleep()
494 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_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
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()
754 static int usb4_port_idx(const struct tb_switch *sw, const struct tb_port *port) in usb4_port_idx() argument
759 /* Assume port is primary */ in usb4_port_idx()
765 if (!p->link_nr) { in usb4_port_idx()
766 if (p == port) in usb4_port_idx()
776 * usb4_switch_map_pcie_down() - Map USB4 port to a PCIe downstream adapter
778 * @port: USB4 port
786 const struct tb_port *port) in usb4_switch_map_pcie_down() argument
788 int usb4_idx = usb4_port_idx(sw, port); in usb4_switch_map_pcie_down()
792 /* Find PCIe down port matching usb4_port */ in usb4_switch_map_pcie_down()
807 * usb4_switch_map_usb3_down() - Map USB4 port to a USB3 downstream adapter
809 * @port: USB4 port
817 const struct tb_port *port) in usb4_switch_map_usb3_down() argument
819 int usb4_idx = usb4_port_idx(sw, port); in usb4_switch_map_usb3_down()
823 /* Find USB3 down port matching usb4_port */ in usb4_switch_map_usb3_down()
838 * usb4_port_unlock() - Unlock USB4 downstream port
839 * @port: USB4 port to unlock
841 * Unlocks USB4 downstream port so that the connection manager can
842 * access the router below this port.
844 int usb4_port_unlock(struct tb_port *port) in usb4_port_unlock() argument
849 ret = tb_port_read(port, &val, TB_CFG_PORT, ADP_CS_4, 1); in usb4_port_unlock()
854 return tb_port_write(port, &val, TB_CFG_PORT, ADP_CS_4, 1); in usb4_port_unlock()
858 * usb4_port_hotplug_enable() - Enables hotplug for a port
859 * @port: USB4 port to operate on
861 * Enables hot plug events on a given port. This is only intended
862 * to be used on lane, DP-IN, and DP-OUT adapters.
864 int usb4_port_hotplug_enable(struct tb_port *port) in usb4_port_hotplug_enable() argument
869 ret = tb_port_read(port, &val, TB_CFG_PORT, ADP_CS_5, 1); in usb4_port_hotplug_enable()
874 return tb_port_write(port, &val, TB_CFG_PORT, ADP_CS_5, 1); in usb4_port_hotplug_enable()
877 static int usb4_port_set_configured(struct tb_port *port, bool configured) in usb4_port_set_configured() argument
882 if (!port->cap_usb4) in usb4_port_set_configured()
883 return -EINVAL; in usb4_port_set_configured()
885 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_port_set_configured()
886 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
895 return tb_port_write(port, &val, TB_CFG_PORT, 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
901 * @port: USB4 router
905 int usb4_port_configure(struct tb_port *port) in usb4_port_configure() argument
907 return usb4_port_set_configured(port, true); in usb4_port_configure()
911 * usb4_port_unconfigure() - Set USB4 port unconfigured
912 * @port: USB4 router
916 void usb4_port_unconfigure(struct tb_port *port) in usb4_port_unconfigure() argument
918 usb4_port_set_configured(port, false); in usb4_port_unconfigure()
921 static int usb4_set_xdomain_configured(struct tb_port *port, bool configured) in usb4_set_xdomain_configured() argument
926 if (!port->cap_usb4) in usb4_set_xdomain_configured()
927 return -EINVAL; in usb4_set_xdomain_configured()
929 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_set_xdomain_configured()
930 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
939 return tb_port_write(port, &val, TB_CFG_PORT, 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
945 * @port: USB4 port connected to another host
947 * Marks the USB4 port as being connected to another host. Returns %0 in
950 int usb4_port_configure_xdomain(struct tb_port *port) in usb4_port_configure_xdomain() argument
952 return usb4_set_xdomain_configured(port, true); in usb4_port_configure_xdomain()
956 * usb4_port_unconfigure_xdomain() - Unconfigure port for XDomain
957 * @port: USB4 port that was connected to another host
959 * Clears USB4 port from being marked as XDomain.
961 void usb4_port_unconfigure_xdomain(struct tb_port *port) in usb4_port_unconfigure_xdomain() argument
963 usb4_set_xdomain_configured(port, false); in usb4_port_unconfigure_xdomain()
966 static int usb4_port_wait_for_bit(struct tb_port *port, u32 offset, u32 bit, in usb4_port_wait_for_bit() argument
975 ret = tb_port_read(port, &val, TB_CFG_PORT, offset, 1); in usb4_port_wait_for_bit()
985 return -ETIMEDOUT; in usb4_port_wait_for_bit()
988 static int usb4_port_read_data(struct tb_port *port, void *data, size_t dwords) in usb4_port_read_data() argument
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()
997 static int usb4_port_write_data(struct tb_port *port, const void *data, in usb4_port_write_data() argument
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()
1007 static int usb4_port_sb_read(struct tb_port *port, enum usb4_sb_target target, in usb4_port_sb_read() argument
1014 if (!port->cap_usb4) in usb4_port_sb_read()
1015 return -EINVAL; in usb4_port_sb_read()
1024 ret = tb_port_write(port, &val, TB_CFG_PORT, 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()
1034 ret = tb_port_read(port, &val, TB_CFG_PORT, 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()
1044 return buf ? usb4_port_read_data(port, buf, dwords) : 0; in usb4_port_sb_read()
1047 static int usb4_port_sb_write(struct tb_port *port, enum usb4_sb_target target, in usb4_port_sb_write() argument
1054 if (!port->cap_usb4) in usb4_port_sb_write()
1055 return -EINVAL; in usb4_port_sb_write()
1058 ret = usb4_port_write_data(port, buf, dwords); in usb4_port_sb_write()
1071 ret = tb_port_write(port, &val, TB_CFG_PORT, 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()
1081 ret = tb_port_read(port, &val, TB_CFG_PORT, 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()
1094 static int usb4_port_sb_op(struct tb_port *port, enum usb4_sb_target target, in usb4_port_sb_op() argument
1102 ret = usb4_port_sb_write(port, target, index, USB4_SB_OPCODE, &val, in usb4_port_sb_op()
1111 ret = usb4_port_sb_read(port, target, index, USB4_SB_OPCODE, 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
1138 * @port: USB4 port
1140 * This forces the USB4 port to send broadcast RT transaction which
1144 int usb4_port_enumerate_retimers(struct tb_port *port) in usb4_port_enumerate_retimers() argument
1149 return usb4_port_sb_write(port, USB4_SB_TARGET_ROUTER, 0, in usb4_port_enumerate_retimers()
1153 static inline int usb4_port_retimer_op(struct tb_port *port, u8 index, in usb4_port_retimer_op() argument
1157 return usb4_port_sb_op(port, USB4_SB_TARGET_RETIMER, index, opcode, in usb4_port_retimer_op()
1162 * usb4_port_retimer_read() - Read from retimer sideband registers
1163 * @port: USB4 port
1170 * retimer is connected to @port at @index. Returns %0 in case of
1172 * present at given @index returns %-ENODEV. In any other failure
1175 int usb4_port_retimer_read(struct tb_port *port, u8 index, u8 reg, void *buf, in usb4_port_retimer_read() argument
1178 return usb4_port_sb_read(port, USB4_SB_TARGET_RETIMER, index, reg, buf, in usb4_port_retimer_read()
1183 * usb4_port_retimer_write() - Write to retimer sideband registers
1184 * @port: USB4 port
1191 * connected to @port at @index. Returns %0 in case of success. If there
1192 * is no retimer present at given @index returns %-ENODEV. In any other
1195 int usb4_port_retimer_write(struct tb_port *port, u8 index, u8 reg, in usb4_port_retimer_write() argument
1198 return usb4_port_sb_write(port, USB4_SB_TARGET_RETIMER, index, reg, buf, in usb4_port_retimer_write()
1203 * usb4_port_retimer_is_last() - Is the retimer last on-board retimer
1204 * @port: USB4 port
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
1212 int usb4_port_retimer_is_last(struct tb_port *port, u8 index) in usb4_port_retimer_is_last() argument
1217 ret = usb4_port_retimer_op(port, index, USB4_SB_OPCODE_QUERY_LAST_RETIMER, in usb4_port_retimer_is_last()
1222 ret = usb4_port_retimer_read(port, index, USB4_SB_METADATA, &metadata, in usb4_port_retimer_is_last()
1224 return ret ? ret : metadata & 1; in usb4_port_retimer_is_last()
1228 * usb4_port_retimer_nvm_sector_size() - Read retimer NVM sector size
1229 * @port: USB4 port
1235 * in case of error. Specifically returns %-ENODEV if there is no
1238 int usb4_port_retimer_nvm_sector_size(struct tb_port *port, u8 index) in usb4_port_retimer_nvm_sector_size() argument
1243 ret = usb4_port_retimer_op(port, index, USB4_SB_OPCODE_GET_NVM_SECTOR_SIZE, in usb4_port_retimer_nvm_sector_size()
1248 ret = usb4_port_retimer_read(port, index, USB4_SB_METADATA, &metadata, in usb4_port_retimer_nvm_sector_size()
1253 static int usb4_port_retimer_nvm_set_offset(struct tb_port *port, u8 index, in usb4_port_retimer_nvm_set_offset() argument
1263 ret = usb4_port_retimer_write(port, index, USB4_SB_METADATA, &metadata, in usb4_port_retimer_nvm_set_offset()
1268 return usb4_port_retimer_op(port, index, USB4_SB_OPCODE_NVM_SET_OFFSET, in usb4_port_retimer_nvm_set_offset()
1273 struct tb_port *port; member
1282 struct tb_port *port = info->port; in usb4_port_retimer_nvm_write_next_block() local
1283 u8 index = info->index; in usb4_port_retimer_nvm_write_next_block()
1286 ret = usb4_port_retimer_write(port, index, USB4_SB_DATA, in usb4_port_retimer_nvm_write_next_block()
1291 return usb4_port_retimer_op(port, index, in usb4_port_retimer_nvm_write_next_block()
1296 * usb4_port_retimer_nvm_write() - Write to retimer NVM
1297 * @port: USB4 port
1305 * errno in case of failure. Specifically returns %-ENODEV if there is
1308 int usb4_port_retimer_nvm_write(struct tb_port *port, u8 index, unsigned int address, in usb4_port_retimer_nvm_write() argument
1311 struct retimer_info info = { .port = port, .index = index }; in usb4_port_retimer_nvm_write()
1314 ret = usb4_port_retimer_nvm_set_offset(port, index, address); in usb4_port_retimer_nvm_write()
1323 * usb4_port_retimer_nvm_authenticate() - Start retimer NVM upgrade
1324 * @port: USB4 port
1333 int usb4_port_retimer_nvm_authenticate(struct tb_port *port, u8 index) in usb4_port_retimer_nvm_authenticate() argument
1343 return usb4_port_sb_write(port, USB4_SB_TARGET_RETIMER, index, in usb4_port_retimer_nvm_authenticate()
1348 * usb4_port_retimer_nvm_authenticate_status() - Read status of NVM upgrade
1349 * @port: USB4 port
1360 int usb4_port_retimer_nvm_authenticate_status(struct tb_port *port, u8 index, in usb4_port_retimer_nvm_authenticate_status() argument
1366 ret = usb4_port_retimer_read(port, index, USB4_SB_OPCODE, &val, in usb4_port_retimer_nvm_authenticate_status()
1377 ret = usb4_port_retimer_read(port, index, USB4_SB_METADATA, 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() local
1398 u8 index = info->index; in usb4_port_retimer_nvm_read_block()
1406 ret = usb4_port_retimer_write(port, index, USB4_SB_METADATA, &metadata, in usb4_port_retimer_nvm_read_block()
1411 ret = usb4_port_retimer_op(port, index, USB4_SB_OPCODE_NVM_READ, 500); in usb4_port_retimer_nvm_read_block()
1415 return usb4_port_retimer_read(port, index, USB4_SB_DATA, buf, in usb4_port_retimer_nvm_read_block()
1420 * usb4_port_retimer_nvm_read() - Read contents of retimer NVM
1421 * @port: USB4 port
1429 * Specifically returns %-ENODEV if there is no retimer at @index.
1431 int usb4_port_retimer_nvm_read(struct tb_port *port, u8 index, in usb4_port_retimer_nvm_read() argument
1434 struct retimer_info info = { .port = port, .index = index }; in usb4_port_retimer_nvm_read()
1441 * usb4_usb3_port_max_link_rate() - Maximum support USB3 link rate
1442 * @port: USB3 adapter port
1447 int usb4_usb3_port_max_link_rate(struct tb_port *port) in usb4_usb3_port_max_link_rate() argument
1452 if (!tb_port_is_usb3_down(port) && !tb_port_is_usb3_up(port)) in usb4_usb3_port_max_link_rate()
1453 return -EINVAL; in usb4_usb3_port_max_link_rate()
1455 ret = tb_port_read(port, &val, TB_CFG_PORT, 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
1466 * @port: USB3 adapter port
1471 int usb4_usb3_port_actual_link_rate(struct tb_port *port) in usb4_usb3_port_actual_link_rate() argument
1476 if (!tb_port_is_usb3_down(port) && !tb_port_is_usb3_up(port)) in usb4_usb3_port_actual_link_rate()
1477 return -EINVAL; in usb4_usb3_port_actual_link_rate()
1479 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_actual_link_rate()
1480 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_actual_link_rate()
1491 static int usb4_usb3_port_cm_request(struct tb_port *port, bool request) in usb4_usb3_port_cm_request() argument
1496 if (!tb_port_is_usb3_down(port)) in usb4_usb3_port_cm_request()
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()
1501 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_cm_request()
1502 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
1511 ret = tb_port_write(port, &val, TB_CFG_PORT, 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()
1525 static inline int usb4_usb3_port_set_cm_request(struct tb_port *port) in usb4_usb3_port_set_cm_request() argument
1527 return usb4_usb3_port_cm_request(port, true); in usb4_usb3_port_set_cm_request()
1530 static inline int usb4_usb3_port_clear_cm_request(struct tb_port *port) in usb4_usb3_port_clear_cm_request() argument
1532 return usb4_usb3_port_cm_request(port, false); in usb4_usb3_port_clear_cm_request()
1547 /* 1 uframe is 1/8 ms (125 us) -> 1 / 8000 s */ in mbps_to_usb3_bw()
1552 static int usb4_usb3_port_read_allocated_bandwidth(struct tb_port *port, in usb4_usb3_port_read_allocated_bandwidth() argument
1559 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_read_allocated_bandwidth()
1560 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_read_allocated_bandwidth()
1564 ret = tb_port_read(port, &scale, TB_CFG_PORT, 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
1582 * @port: USB3 adapter port
1590 int usb4_usb3_port_allocated_bandwidth(struct tb_port *port, int *upstream_bw, in usb4_usb3_port_allocated_bandwidth() argument
1595 ret = usb4_usb3_port_set_cm_request(port); in usb4_usb3_port_allocated_bandwidth()
1599 ret = usb4_usb3_port_read_allocated_bandwidth(port, upstream_bw, in usb4_usb3_port_allocated_bandwidth()
1601 usb4_usb3_port_clear_cm_request(port); in usb4_usb3_port_allocated_bandwidth()
1606 static int usb4_usb3_port_read_consumed_bandwidth(struct tb_port *port, in usb4_usb3_port_read_consumed_bandwidth() argument
1613 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_read_consumed_bandwidth()
1614 port->cap_adap + ADP_USB3_CS_1, 1); in usb4_usb3_port_read_consumed_bandwidth()
1618 ret = tb_port_read(port, &scale, TB_CFG_PORT, in usb4_usb3_port_read_consumed_bandwidth()
1619 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_consumed_bandwidth()
1634 static int usb4_usb3_port_write_allocated_bandwidth(struct tb_port *port, in usb4_usb3_port_write_allocated_bandwidth() argument
1642 ret = tb_port_read(port, &scale, TB_CFG_PORT, in usb4_usb3_port_write_allocated_bandwidth()
1643 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_write_allocated_bandwidth()
1651 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_write_allocated_bandwidth()
1652 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
1660 return tb_port_write(port, &val, TB_CFG_PORT, in usb4_usb3_port_write_allocated_bandwidth()
1661 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
1665 * usb4_usb3_port_allocate_bandwidth() - Allocate bandwidth for USB3
1666 * @port: USB3 adapter port
1681 int usb4_usb3_port_allocate_bandwidth(struct tb_port *port, int *upstream_bw, in usb4_usb3_port_allocate_bandwidth() argument
1686 ret = usb4_usb3_port_set_cm_request(port); in usb4_usb3_port_allocate_bandwidth()
1690 ret = usb4_usb3_port_read_consumed_bandwidth(port, &consumed_up, in usb4_usb3_port_allocate_bandwidth()
1699 ret = usb4_usb3_port_write_allocated_bandwidth(port, allocate_up, in usb4_usb3_port_allocate_bandwidth()
1708 usb4_usb3_port_clear_cm_request(port); in usb4_usb3_port_allocate_bandwidth()
1713 * usb4_usb3_port_release_bandwidth() - Release allocated USB3 bandwidth
1714 * @port: USB3 adapter port
1723 int usb4_usb3_port_release_bandwidth(struct tb_port *port, int *upstream_bw, in usb4_usb3_port_release_bandwidth() argument
1728 ret = usb4_usb3_port_set_cm_request(port); in usb4_usb3_port_release_bandwidth()
1732 ret = usb4_usb3_port_read_consumed_bandwidth(port, &consumed_up, in usb4_usb3_port_release_bandwidth()
1746 ret = usb4_usb3_port_write_allocated_bandwidth(port, consumed_up, in usb4_usb3_port_release_bandwidth()
1755 usb4_usb3_port_clear_cm_request(port); in usb4_usb3_port_release_bandwidth()