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()
132 size -= nbytes; in usb4_do_read_data()
158 if (ret == -ETIMEDOUT) { in usb4_do_write_data()
159 if (retries--) in usb4_do_write_data()
161 ret = -EIO; in usb4_do_write_data()
166 size -= nbytes; in usb4_do_write_data()
180 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); in usb4_switch_op()
188 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_26, 1); in usb4_switch_op()
193 return -EOPNOTSUPP; in usb4_switch_op()
201 struct tb_port *port; in usb4_switch_check_wakes() local
205 if (!device_may_wakeup(&sw->dev)) in usb4_switch_check_wakes()
209 if (tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1)) in usb4_switch_check_wakes()
220 tb_switch_for_each_port(sw, port) { in usb4_switch_check_wakes()
221 if (!tb_port_has_remote(port)) in usb4_switch_check_wakes()
224 if (tb_port_read(port, &val, TB_CFG_PORT, in usb4_switch_check_wakes()
225 port->cap_usb4 + PORT_CS_18, 1)) in usb4_switch_check_wakes()
228 tb_port_dbg(port, "USB4 wake: %s\n", in usb4_switch_check_wakes()
236 pm_wakeup_event(&sw->dev, 0); in usb4_switch_check_wakes()
239 static bool link_is_usb4(struct tb_port *port) in link_is_usb4() argument
243 if (!port->cap_usb4) in link_is_usb4()
246 if (tb_port_read(port, &val, TB_CFG_PORT, in link_is_usb4()
247 port->cap_usb4 + PORT_CS_18, 1)) in link_is_usb4()
254 * usb4_switch_setup() - Additional setup for USB4 device
277 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1); in usb4_switch_setup()
283 sw->link_usb4 = link_is_usb4(downstream_port); in usb4_switch_setup()
284 tb_sw_dbg(sw, "link: %s\n", sw->link_usb4 ? "USB4" : "TBT3"); in usb4_switch_setup()
292 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_setup()
296 if (sw->link_usb4 && tb_switch_find_port(parent, TB_TYPE_USB3_DOWN)) { in usb4_switch_setup()
318 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_setup()
327 * usb4_switch_read_uid() - Read UID from USB4 router
331 * Reads 64-bit UID from USB4 router config space.
360 return -EIO; in usb4_switch_drom_read_block()
366 * usb4_switch_drom_read() - Read arbitrary bytes from USB4 router DROM
373 * should always work but for hosts it may return %-EOPNOTSUPP in which
384 * usb4_switch_lane_bonding_possible() - Are conditions met for lane bonding
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
413 struct tb_port *port; in usb4_switch_set_wake() local
421 * upstream USB4 port. in usb4_switch_set_wake()
423 tb_switch_for_each_port(sw, port) { in usb4_switch_set_wake()
424 if (!tb_port_is_null(port)) in usb4_switch_set_wake()
426 if (!route && tb_is_upstream_port(port)) in usb4_switch_set_wake()
428 if (!port->cap_usb4) in usb4_switch_set_wake()
431 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_switch_set_wake()
432 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
445 ret = tb_port_write(port, &val, TB_CFG_PORT, in usb4_switch_set_wake()
446 port->cap_usb4 + PORT_CS_19, 1); in usb4_switch_set_wake()
456 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_wake()
466 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_wake()
475 * usb4_switch_set_sleep() - Prepare the router to enter sleep
487 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_sleep()
493 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1); in usb4_switch_set_sleep()
502 * usb4_switch_nvm_sector_size() - Return router NVM sector size
507 * %-EOPNOTSUPP.
520 return status == 0x2 ? -EOPNOTSUPP : -EIO; in usb4_switch_nvm_sector_size()
551 return -EIO; in usb4_switch_nvm_read_block()
557 * usb4_switch_nvm_read() - Read arbitrary bytes from router NVM
564 * %-EOPNOTSUPP.
592 return status ? -EIO : 0; in usb4_switch_nvm_set_offset()
610 return status ? -EIO : 0; in usb4_switch_nvm_write_next_block()
614 * usb4_switch_nvm_write() - Write to the router NVM
621 * write is not supported returns %-EOPNOTSUPP.
637 * usb4_switch_nvm_authenticate() - Authenticate new NVM
659 return -EINVAL; in usb4_switch_nvm_authenticate()
661 return -EAGAIN; in usb4_switch_nvm_authenticate()
663 return -EOPNOTSUPP; in usb4_switch_nvm_authenticate()
665 return -EIO; in usb4_switch_nvm_authenticate()
670 * usb4_switch_query_dp_resource() - Query availability of DP IN resource
683 ret = usb4_switch_op_write_metadata(sw, in->port); in usb4_switch_query_dp_resource()
692 if (ret == -EOPNOTSUPP) in usb4_switch_query_dp_resource()
701 * usb4_switch_alloc_dp_resource() - Allocate DP IN resource
707 * returns negative errno, in particular %-EBUSY if the resource is
715 ret = usb4_switch_op_write_metadata(sw, in->port); in usb4_switch_alloc_dp_resource()
720 if (ret == -EOPNOTSUPP) in usb4_switch_alloc_dp_resource()
725 return status ? -EBUSY : 0; in usb4_switch_alloc_dp_resource()
729 * usb4_switch_dealloc_dp_resource() - Releases allocated DP IN resource
740 ret = usb4_switch_op_write_metadata(sw, in->port); in usb4_switch_dealloc_dp_resource()
745 if (ret == -EOPNOTSUPP) in usb4_switch_dealloc_dp_resource()
750 return status ? -EIO : 0; in usb4_switch_dealloc_dp_resource()
753 static int usb4_port_idx(const struct tb_switch *sw, const struct tb_port *port) in usb4_port_idx() argument
758 /* Assume port is primary */ in usb4_port_idx()
764 if (!p->link_nr) { in usb4_port_idx()
765 if (p == port) in usb4_port_idx()
775 * usb4_switch_map_pcie_down() - Map USB4 port to a PCIe downstream adapter
777 * @port: USB4 port
785 const struct tb_port *port) in usb4_switch_map_pcie_down() argument
787 int usb4_idx = usb4_port_idx(sw, port); in usb4_switch_map_pcie_down()
791 /* Find PCIe down port matching usb4_port */ in usb4_switch_map_pcie_down()
806 * usb4_switch_map_usb3_down() - Map USB4 port to a USB3 downstream adapter
808 * @port: USB4 port
816 const struct tb_port *port) in usb4_switch_map_usb3_down() argument
818 int usb4_idx = usb4_port_idx(sw, port); in usb4_switch_map_usb3_down()
822 /* Find USB3 down port matching usb4_port */ in usb4_switch_map_usb3_down()
837 * usb4_port_unlock() - Unlock USB4 downstream port
838 * @port: USB4 port to unlock
840 * Unlocks USB4 downstream port so that the connection manager can
841 * access the router below this port.
843 int usb4_port_unlock(struct tb_port *port) in usb4_port_unlock() argument
848 ret = tb_port_read(port, &val, TB_CFG_PORT, ADP_CS_4, 1); in usb4_port_unlock()
853 return tb_port_write(port, &val, TB_CFG_PORT, ADP_CS_4, 1); in usb4_port_unlock()
856 static int usb4_port_set_configured(struct tb_port *port, bool configured) in usb4_port_set_configured() argument
861 if (!port->cap_usb4) in usb4_port_set_configured()
862 return -EINVAL; in usb4_port_set_configured()
864 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_port_set_configured()
865 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
874 return tb_port_write(port, &val, TB_CFG_PORT, in usb4_port_set_configured()
875 port->cap_usb4 + PORT_CS_19, 1); in usb4_port_set_configured()
879 * usb4_port_configure() - Set USB4 port configured
880 * @port: USB4 router
884 int usb4_port_configure(struct tb_port *port) in usb4_port_configure() argument
886 return usb4_port_set_configured(port, true); in usb4_port_configure()
890 * usb4_port_unconfigure() - Set USB4 port unconfigured
891 * @port: USB4 router
895 void usb4_port_unconfigure(struct tb_port *port) in usb4_port_unconfigure() argument
897 usb4_port_set_configured(port, false); in usb4_port_unconfigure()
900 static int usb4_set_xdomain_configured(struct tb_port *port, bool configured) in usb4_set_xdomain_configured() argument
905 if (!port->cap_usb4) in usb4_set_xdomain_configured()
906 return -EINVAL; in usb4_set_xdomain_configured()
908 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_set_xdomain_configured()
909 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
918 return tb_port_write(port, &val, TB_CFG_PORT, in usb4_set_xdomain_configured()
919 port->cap_usb4 + PORT_CS_19, 1); in usb4_set_xdomain_configured()
923 * usb4_port_configure_xdomain() - Configure port for XDomain
924 * @port: USB4 port connected to another host
926 * Marks the USB4 port as being connected to another host. Returns %0 in
929 int usb4_port_configure_xdomain(struct tb_port *port) in usb4_port_configure_xdomain() argument
931 return usb4_set_xdomain_configured(port, true); in usb4_port_configure_xdomain()
935 * usb4_port_unconfigure_xdomain() - Unconfigure port for XDomain
936 * @port: USB4 port that was connected to another host
938 * Clears USB4 port from being marked as XDomain.
940 void usb4_port_unconfigure_xdomain(struct tb_port *port) in usb4_port_unconfigure_xdomain() argument
942 usb4_set_xdomain_configured(port, false); in usb4_port_unconfigure_xdomain()
945 static int usb4_port_wait_for_bit(struct tb_port *port, u32 offset, u32 bit, in usb4_port_wait_for_bit() argument
954 ret = tb_port_read(port, &val, TB_CFG_PORT, offset, 1); in usb4_port_wait_for_bit()
964 return -ETIMEDOUT; in usb4_port_wait_for_bit()
967 static int usb4_port_read_data(struct tb_port *port, void *data, size_t dwords) in usb4_port_read_data() argument
970 return -EINVAL; in usb4_port_read_data()
972 return tb_port_read(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_read_data()
976 static int usb4_port_write_data(struct tb_port *port, const void *data, in usb4_port_write_data() argument
980 return -EINVAL; in usb4_port_write_data()
982 return tb_port_write(port, data, TB_CFG_PORT, port->cap_usb4 + PORT_CS_2, in usb4_port_write_data()
986 static int usb4_port_sb_read(struct tb_port *port, enum usb4_sb_target target, in usb4_port_sb_read() argument
993 if (!port->cap_usb4) in usb4_port_sb_read()
994 return -EINVAL; in usb4_port_sb_read()
1003 ret = tb_port_write(port, &val, TB_CFG_PORT, in usb4_port_sb_read()
1004 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1008 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_read()
1013 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_port_sb_read()
1014 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_read()
1019 return -ENODEV; in usb4_port_sb_read()
1021 return -EIO; in usb4_port_sb_read()
1023 return buf ? usb4_port_read_data(port, buf, dwords) : 0; in usb4_port_sb_read()
1026 static int usb4_port_sb_write(struct tb_port *port, enum usb4_sb_target target, in usb4_port_sb_write() argument
1033 if (!port->cap_usb4) in usb4_port_sb_write()
1034 return -EINVAL; in usb4_port_sb_write()
1037 ret = usb4_port_write_data(port, buf, dwords); in usb4_port_sb_write()
1050 ret = tb_port_write(port, &val, TB_CFG_PORT, in usb4_port_sb_write()
1051 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1055 ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1, in usb4_port_sb_write()
1060 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_port_sb_write()
1061 port->cap_usb4 + PORT_CS_1, 1); in usb4_port_sb_write()
1066 return -ENODEV; in usb4_port_sb_write()
1068 return -EIO; in usb4_port_sb_write()
1073 static int usb4_port_sb_op(struct tb_port *port, enum usb4_sb_target target, in usb4_port_sb_op() argument
1081 ret = usb4_port_sb_write(port, target, index, USB4_SB_OPCODE, &val, in usb4_port_sb_op()
1090 ret = usb4_port_sb_read(port, target, index, USB4_SB_OPCODE, in usb4_port_sb_op()
1100 return -EAGAIN; in usb4_port_sb_op()
1103 return -EOPNOTSUPP; in usb4_port_sb_op()
1107 return -EIO; in usb4_port_sb_op()
1112 return -ETIMEDOUT; in usb4_port_sb_op()
1116 * usb4_port_enumerate_retimers() - Send RT broadcast transaction
1117 * @port: USB4 port
1119 * This forces the USB4 port to send broadcast RT transaction which
1123 int usb4_port_enumerate_retimers(struct tb_port *port) in usb4_port_enumerate_retimers() argument
1128 return usb4_port_sb_write(port, USB4_SB_TARGET_ROUTER, 0, in usb4_port_enumerate_retimers()
1132 static inline int usb4_port_retimer_op(struct tb_port *port, u8 index, in usb4_port_retimer_op() argument
1136 return usb4_port_sb_op(port, USB4_SB_TARGET_RETIMER, index, opcode, in usb4_port_retimer_op()
1141 * usb4_port_retimer_read() - Read from retimer sideband registers
1142 * @port: USB4 port
1149 * retimer is connected to @port at @index. Returns %0 in case of
1151 * present at given @index returns %-ENODEV. In any other failure
1154 int usb4_port_retimer_read(struct tb_port *port, u8 index, u8 reg, void *buf, in usb4_port_retimer_read() argument
1157 return usb4_port_sb_read(port, USB4_SB_TARGET_RETIMER, index, reg, buf, in usb4_port_retimer_read()
1162 * usb4_port_retimer_write() - Write to retimer sideband registers
1163 * @port: USB4 port
1170 * connected to @port at @index. Returns %0 in case of success. If there
1171 * is no retimer present at given @index returns %-ENODEV. In any other
1174 int usb4_port_retimer_write(struct tb_port *port, u8 index, u8 reg, in usb4_port_retimer_write() argument
1177 return usb4_port_sb_write(port, USB4_SB_TARGET_RETIMER, index, reg, buf, in usb4_port_retimer_write()
1182 * usb4_port_retimer_is_last() - Is the retimer last on-board retimer
1183 * @port: USB4 port
1187 * Type-C port) this function returns %1. If it is not returns %0. If
1188 * the retimer is not present returns %-ENODEV. Otherwise returns
1191 int usb4_port_retimer_is_last(struct tb_port *port, u8 index) in usb4_port_retimer_is_last() argument
1196 ret = usb4_port_retimer_op(port, index, USB4_SB_OPCODE_QUERY_LAST_RETIMER, in usb4_port_retimer_is_last()
1201 ret = usb4_port_retimer_read(port, index, USB4_SB_METADATA, &metadata, in usb4_port_retimer_is_last()
1203 return ret ? ret : metadata & 1; in usb4_port_retimer_is_last()
1207 * usb4_port_retimer_nvm_sector_size() - Read retimer NVM sector size
1208 * @port: USB4 port
1214 * in case of error. Specifically returns %-ENODEV if there is no
1217 int usb4_port_retimer_nvm_sector_size(struct tb_port *port, u8 index) in usb4_port_retimer_nvm_sector_size() argument
1222 ret = usb4_port_retimer_op(port, index, USB4_SB_OPCODE_GET_NVM_SECTOR_SIZE, in usb4_port_retimer_nvm_sector_size()
1227 ret = usb4_port_retimer_read(port, index, USB4_SB_METADATA, &metadata, in usb4_port_retimer_nvm_sector_size()
1232 static int usb4_port_retimer_nvm_set_offset(struct tb_port *port, u8 index, in usb4_port_retimer_nvm_set_offset() argument
1242 ret = usb4_port_retimer_write(port, index, USB4_SB_METADATA, &metadata, in usb4_port_retimer_nvm_set_offset()
1247 return usb4_port_retimer_op(port, index, USB4_SB_OPCODE_NVM_SET_OFFSET, in usb4_port_retimer_nvm_set_offset()
1252 struct tb_port *port; member
1261 struct tb_port *port = info->port; in usb4_port_retimer_nvm_write_next_block() local
1262 u8 index = info->index; in usb4_port_retimer_nvm_write_next_block()
1265 ret = usb4_port_retimer_write(port, index, USB4_SB_DATA, in usb4_port_retimer_nvm_write_next_block()
1270 return usb4_port_retimer_op(port, index, in usb4_port_retimer_nvm_write_next_block()
1275 * usb4_port_retimer_nvm_write() - Write to retimer NVM
1276 * @port: USB4 port
1284 * errno in case of failure. Specifically returns %-ENODEV if there is
1287 int usb4_port_retimer_nvm_write(struct tb_port *port, u8 index, unsigned int address, in usb4_port_retimer_nvm_write() argument
1290 struct retimer_info info = { .port = port, .index = index }; in usb4_port_retimer_nvm_write()
1293 ret = usb4_port_retimer_nvm_set_offset(port, index, address); in usb4_port_retimer_nvm_write()
1302 * usb4_port_retimer_nvm_authenticate() - Start retimer NVM upgrade
1303 * @port: USB4 port
1312 int usb4_port_retimer_nvm_authenticate(struct tb_port *port, u8 index) in usb4_port_retimer_nvm_authenticate() argument
1322 return usb4_port_sb_write(port, USB4_SB_TARGET_RETIMER, index, in usb4_port_retimer_nvm_authenticate()
1327 * usb4_port_retimer_nvm_authenticate_status() - Read status of NVM upgrade
1328 * @port: USB4 port
1339 int usb4_port_retimer_nvm_authenticate_status(struct tb_port *port, u8 index, in usb4_port_retimer_nvm_authenticate_status() argument
1345 ret = usb4_port_retimer_read(port, index, USB4_SB_OPCODE, &val, in usb4_port_retimer_nvm_authenticate_status()
1356 ret = usb4_port_retimer_read(port, index, USB4_SB_METADATA, in usb4_port_retimer_nvm_authenticate_status()
1365 return -EOPNOTSUPP; in usb4_port_retimer_nvm_authenticate_status()
1368 return -EIO; in usb4_port_retimer_nvm_authenticate_status()
1376 struct tb_port *port = info->port; in usb4_port_retimer_nvm_read_block() local
1377 u8 index = info->index; in usb4_port_retimer_nvm_read_block()
1385 ret = usb4_port_retimer_write(port, index, USB4_SB_METADATA, &metadata, in usb4_port_retimer_nvm_read_block()
1390 ret = usb4_port_retimer_op(port, index, USB4_SB_OPCODE_NVM_READ, 500); in usb4_port_retimer_nvm_read_block()
1394 return usb4_port_retimer_read(port, index, USB4_SB_DATA, buf, in usb4_port_retimer_nvm_read_block()
1399 * usb4_port_retimer_nvm_read() - Read contents of retimer NVM
1400 * @port: USB4 port
1408 * Specifically returns %-ENODEV if there is no retimer at @index.
1410 int usb4_port_retimer_nvm_read(struct tb_port *port, u8 index, in usb4_port_retimer_nvm_read() argument
1413 struct retimer_info info = { .port = port, .index = index }; in usb4_port_retimer_nvm_read()
1420 * usb4_usb3_port_max_link_rate() - Maximum support USB3 link rate
1421 * @port: USB3 adapter port
1426 int usb4_usb3_port_max_link_rate(struct tb_port *port) in usb4_usb3_port_max_link_rate() argument
1431 if (!tb_port_is_usb3_down(port) && !tb_port_is_usb3_up(port)) in usb4_usb3_port_max_link_rate()
1432 return -EINVAL; in usb4_usb3_port_max_link_rate()
1434 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_max_link_rate()
1435 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_max_link_rate()
1444 * usb4_usb3_port_actual_link_rate() - Established USB3 link rate
1445 * @port: USB3 adapter port
1450 int usb4_usb3_port_actual_link_rate(struct tb_port *port) in usb4_usb3_port_actual_link_rate() argument
1455 if (!tb_port_is_usb3_down(port) && !tb_port_is_usb3_up(port)) in usb4_usb3_port_actual_link_rate()
1456 return -EINVAL; in usb4_usb3_port_actual_link_rate()
1458 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_actual_link_rate()
1459 port->cap_adap + ADP_USB3_CS_4, 1); in usb4_usb3_port_actual_link_rate()
1470 static int usb4_usb3_port_cm_request(struct tb_port *port, bool request) in usb4_usb3_port_cm_request() argument
1475 if (!tb_port_is_usb3_down(port)) in usb4_usb3_port_cm_request()
1476 return -EINVAL; in usb4_usb3_port_cm_request()
1477 if (tb_route(port->sw)) in usb4_usb3_port_cm_request()
1478 return -EINVAL; in usb4_usb3_port_cm_request()
1480 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_cm_request()
1481 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
1490 ret = tb_port_write(port, &val, TB_CFG_PORT, in usb4_usb3_port_cm_request()
1491 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_cm_request()
1500 return usb4_port_wait_for_bit(port, port->cap_adap + ADP_USB3_CS_1, in usb4_usb3_port_cm_request()
1504 static inline int usb4_usb3_port_set_cm_request(struct tb_port *port) in usb4_usb3_port_set_cm_request() argument
1506 return usb4_usb3_port_cm_request(port, true); in usb4_usb3_port_set_cm_request()
1509 static inline int usb4_usb3_port_clear_cm_request(struct tb_port *port) in usb4_usb3_port_clear_cm_request() argument
1511 return usb4_usb3_port_cm_request(port, false); in usb4_usb3_port_clear_cm_request()
1526 /* 1 uframe is 1/8 ms (125 us) -> 1 / 8000 s */ in mbps_to_usb3_bw()
1531 static int usb4_usb3_port_read_allocated_bandwidth(struct tb_port *port, in usb4_usb3_port_read_allocated_bandwidth() argument
1538 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_read_allocated_bandwidth()
1539 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_read_allocated_bandwidth()
1543 ret = tb_port_read(port, &scale, TB_CFG_PORT, in usb4_usb3_port_read_allocated_bandwidth()
1544 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_allocated_bandwidth()
1560 * usb4_usb3_port_allocated_bandwidth() - Bandwidth allocated for USB3
1561 * @port: USB3 adapter port
1569 int usb4_usb3_port_allocated_bandwidth(struct tb_port *port, int *upstream_bw, in usb4_usb3_port_allocated_bandwidth() argument
1574 ret = usb4_usb3_port_set_cm_request(port); in usb4_usb3_port_allocated_bandwidth()
1578 ret = usb4_usb3_port_read_allocated_bandwidth(port, upstream_bw, in usb4_usb3_port_allocated_bandwidth()
1580 usb4_usb3_port_clear_cm_request(port); in usb4_usb3_port_allocated_bandwidth()
1585 static int usb4_usb3_port_read_consumed_bandwidth(struct tb_port *port, in usb4_usb3_port_read_consumed_bandwidth() argument
1592 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_read_consumed_bandwidth()
1593 port->cap_adap + ADP_USB3_CS_1, 1); in usb4_usb3_port_read_consumed_bandwidth()
1597 ret = tb_port_read(port, &scale, TB_CFG_PORT, in usb4_usb3_port_read_consumed_bandwidth()
1598 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_read_consumed_bandwidth()
1613 static int usb4_usb3_port_write_allocated_bandwidth(struct tb_port *port, in usb4_usb3_port_write_allocated_bandwidth() argument
1621 ret = tb_port_read(port, &scale, TB_CFG_PORT, in usb4_usb3_port_write_allocated_bandwidth()
1622 port->cap_adap + ADP_USB3_CS_3, 1); in usb4_usb3_port_write_allocated_bandwidth()
1630 ret = tb_port_read(port, &val, TB_CFG_PORT, in usb4_usb3_port_write_allocated_bandwidth()
1631 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
1639 return tb_port_write(port, &val, TB_CFG_PORT, in usb4_usb3_port_write_allocated_bandwidth()
1640 port->cap_adap + ADP_USB3_CS_2, 1); in usb4_usb3_port_write_allocated_bandwidth()
1644 * usb4_usb3_port_allocate_bandwidth() - Allocate bandwidth for USB3
1645 * @port: USB3 adapter port
1660 int usb4_usb3_port_allocate_bandwidth(struct tb_port *port, int *upstream_bw, in usb4_usb3_port_allocate_bandwidth() argument
1665 ret = usb4_usb3_port_set_cm_request(port); in usb4_usb3_port_allocate_bandwidth()
1669 ret = usb4_usb3_port_read_consumed_bandwidth(port, &consumed_up, in usb4_usb3_port_allocate_bandwidth()
1678 ret = usb4_usb3_port_write_allocated_bandwidth(port, allocate_up, in usb4_usb3_port_allocate_bandwidth()
1687 usb4_usb3_port_clear_cm_request(port); in usb4_usb3_port_allocate_bandwidth()
1692 * usb4_usb3_port_release_bandwidth() - Release allocated USB3 bandwidth
1693 * @port: USB3 adapter port
1702 int usb4_usb3_port_release_bandwidth(struct tb_port *port, int *upstream_bw, in usb4_usb3_port_release_bandwidth() argument
1707 ret = usb4_usb3_port_set_cm_request(port); in usb4_usb3_port_release_bandwidth()
1711 ret = usb4_usb3_port_read_consumed_bandwidth(port, &consumed_up, in usb4_usb3_port_release_bandwidth()
1725 ret = usb4_usb3_port_write_allocated_bandwidth(port, consumed_up, in usb4_usb3_port_release_bandwidth()
1734 usb4_usb3_port_clear_cm_request(port); in usb4_usb3_port_release_bandwidth()