Lines Matching +full:dual +full:- +full:lane
1 // SPDX-License-Identifier: GPL-2.0
3 * Thunderbolt driver - switch/port utility functions
12 #include <linux/nvmem-provider.h>
42 if (uuid_equal(&st->uuid, sw->uuid)) in __nvm_get_auth_status()
57 *status = st ? st->status : 0; in nvm_get_auth_status()
64 if (WARN_ON(!sw->uuid)) in nvm_set_auth_status()
75 memcpy(&st->uuid, sw->uuid, sizeof(st->uuid)); in nvm_set_auth_status()
76 INIT_LIST_HEAD(&st->list); in nvm_set_auth_status()
77 list_add_tail(&st->list, &nvm_auth_status_cache); in nvm_set_auth_status()
80 st->status = status; in nvm_set_auth_status()
92 list_del(&st->list); in nvm_clear_auth_status()
104 ret = tb_nvm_validate(sw->nvm); in nvm_validate_and_write()
108 ret = tb_nvm_write_headers(sw->nvm); in nvm_validate_and_write()
112 buf = sw->nvm->buf_data_start; in nvm_validate_and_write()
113 image_size = sw->nvm->buf_data_size; in nvm_validate_and_write()
118 ret = dma_port_flash_write(sw->dma_port, 0, buf, image_size); in nvm_validate_and_write()
122 sw->nvm->flushed = true; in nvm_validate_and_write()
135 if (!sw->safe_mode) { in nvm_authenticate_host_dma_port()
138 ret = tb_domain_disconnect_all_paths(sw->tb); in nvm_authenticate_host_dma_port()
145 ret = dma_port_flash_update_auth(sw->dma_port); in nvm_authenticate_host_dma_port()
146 if (!ret || ret == -ETIMEDOUT) in nvm_authenticate_host_dma_port()
154 if (dma_port_flash_update_auth_status(sw->dma_port, &status) > 0) in nvm_authenticate_host_dma_port()
162 dma_port_power_cycle(sw->dma_port); in nvm_authenticate_host_dma_port()
170 ret = dma_port_flash_update_auth(sw->dma_port); in nvm_authenticate_device_dma_port()
173 case -ETIMEDOUT: in nvm_authenticate_device_dma_port()
174 case -EACCES: in nvm_authenticate_device_dma_port()
175 case -EINVAL: in nvm_authenticate_device_dma_port()
191 ret = dma_port_flash_update_auth_status(sw->dma_port, &status); in nvm_authenticate_device_dma_port()
192 if (ret < 0 && ret != -ETIMEDOUT) in nvm_authenticate_device_dma_port()
201 dma_port_power_cycle(sw->dma_port); in nvm_authenticate_device_dma_port()
206 } while (--retries); in nvm_authenticate_device_dma_port()
208 return -ETIMEDOUT; in nvm_authenticate_device_dma_port()
221 root_port = pcie_find_root_port(sw->tb->nhi->pdev); in nvm_authenticate_start_dma_port()
223 pm_runtime_get_noresume(&root_port->dev); in nvm_authenticate_start_dma_port()
230 root_port = pcie_find_root_port(sw->tb->nhi->pdev); in nvm_authenticate_complete_dma_port()
232 pm_runtime_put(&root_port->dev); in nvm_authenticate_complete_dma_port()
248 return !!sw->dma_port; in nvm_readable()
253 if (sw->no_nvm_upgrade) in nvm_upgradeable()
268 sw->nvm->authenticating = true; in nvm_authenticate()
272 return -EOPNOTSUPP; in nvm_authenticate()
274 sw->nvm->authenticating = true; in nvm_authenticate()
286 * tb_switch_nvm_read() - Read router NVM
301 return dma_port_flash_read(sw->dma_port, address, buf, size); in tb_switch_nvm_read()
307 struct tb_switch *sw = tb_to_switch(nvm->dev); in nvm_read()
310 pm_runtime_get_sync(&sw->dev); in nvm_read()
312 if (!mutex_trylock(&sw->tb->lock)) { in nvm_read()
318 mutex_unlock(&sw->tb->lock); in nvm_read()
321 pm_runtime_mark_last_busy(&sw->dev); in nvm_read()
322 pm_runtime_put_autosuspend(&sw->dev); in nvm_read()
330 struct tb_switch *sw = tb_to_switch(nvm->dev); in nvm_write()
333 if (!mutex_trylock(&sw->tb->lock)) in nvm_write()
343 mutex_unlock(&sw->tb->lock); in nvm_write()
356 nvm = tb_nvm_alloc(&sw->dev); in tb_switch_nvm_add()
358 ret = PTR_ERR(nvm) == -EOPNOTSUPP ? 0 : PTR_ERR(nvm); in tb_switch_nvm_add()
367 * If the switch is in safe-mode the only accessible portion of in tb_switch_nvm_add()
368 * the NVM is the non-active one where userspace is expected to in tb_switch_nvm_add()
371 if (!sw->safe_mode) { in tb_switch_nvm_add()
375 tb_sw_dbg(sw, "NVM version %x.%x\n", nvm->major, nvm->minor); in tb_switch_nvm_add()
378 if (!sw->no_nvm_upgrade) { in tb_switch_nvm_add()
384 sw->nvm = nvm; in tb_switch_nvm_add()
389 sw->no_nvm_upgrade = true; in tb_switch_nvm_add()
400 nvm = sw->nvm; in tb_switch_nvm_remove()
401 sw->nvm = NULL; in tb_switch_nvm_remove()
407 if (!nvm->authenticating) in tb_switch_nvm_remove()
417 switch (port->type >> 16) { in tb_port_type()
419 switch ((u8) port->type) { in tb_port_type()
446 const struct tb_regs_port_header *regs = &port->config; in tb_dump_port()
450 regs->port_number, regs->vendor_id, regs->device_id, in tb_dump_port()
451 regs->revision, regs->thunderbolt_version, tb_port_type(regs), in tb_dump_port()
452 regs->type); in tb_dump_port()
454 regs->max_in_hop_id, regs->max_out_hop_id); in tb_dump_port()
455 tb_dbg(tb, " Max counters: %d\n", regs->max_counters); in tb_dump_port()
456 tb_dbg(tb, " NFC Credits: %#x\n", regs->nfc_credits); in tb_dump_port()
457 tb_dbg(tb, " Credits (total/control): %u/%u\n", port->total_credits, in tb_dump_port()
458 port->ctl_credits); in tb_dump_port()
462 * tb_port_state() - get connectedness state of a port
473 if (port->cap_phy == 0) { in tb_port_state()
475 return -EINVAL; in tb_port_state()
477 res = tb_port_read(port, &phy, TB_CFG_PORT, port->cap_phy, 2); in tb_port_state()
484 * tb_wait_for_port() - wait for a port to become ready
502 if (!port->cap_phy) { in tb_wait_for_port()
504 return -EINVAL; in tb_wait_for_port()
508 return -EINVAL; in tb_wait_for_port()
511 while (retries--) { in tb_wait_for_port()
542 * After plug-in the state is TB_PORT_CONNECTING. Give it some in tb_wait_for_port()
558 * tb_port_add_nfc_credits() - add/remove non flow controlled credits to port
571 if (credits == 0 || port->sw->is_unplugged) in tb_port_add_nfc_credits()
575 * USB4 restricts programming NFC buffers to lane adapters only in tb_port_add_nfc_credits()
578 if (tb_switch_is_usb4(port->sw) && !tb_port_is_null(port)) in tb_port_add_nfc_credits()
581 nfc_credits = port->config.nfc_credits & ADP_CS_4_NFC_BUFFERS_MASK; in tb_port_add_nfc_credits()
583 credits = max_t(int, -nfc_credits, credits); in tb_port_add_nfc_credits()
588 port->config.nfc_credits & ADP_CS_4_NFC_BUFFERS_MASK); in tb_port_add_nfc_credits()
590 port->config.nfc_credits &= ~ADP_CS_4_NFC_BUFFERS_MASK; in tb_port_add_nfc_credits()
591 port->config.nfc_credits |= nfc_credits; in tb_port_add_nfc_credits()
593 return tb_port_write(port, &port->config.nfc_credits, in tb_port_add_nfc_credits()
598 * tb_port_clear_counter() - clear a counter in TB_CFG_COUNTER
612 * tb_port_unlock() - Unlock downstream port
620 if (tb_switch_is_icm(port->sw)) in tb_port_unlock()
623 return -EINVAL; in tb_port_unlock()
624 if (tb_switch_is_usb4(port->sw)) in tb_port_unlock()
635 return -EINVAL; in __tb_port_enable()
638 port->cap_phy + LANE_ADP_CS_1, 1); in __tb_port_enable()
649 port->cap_phy + LANE_ADP_CS_1, 1); in __tb_port_enable()
653 tb_port_dbg(port, "lane %s\n", str_enabled_disabled(enable)); in __tb_port_enable()
658 * tb_port_enable() - Enable lane adapter
661 * This is used for lane 0 and 1 adapters to enable it.
669 * tb_port_disable() - Disable lane adapter
672 * This is used for lane 0 and 1 adapters to disable it.
680 * tb_init_port() - initialize a port
692 INIT_LIST_HEAD(&port->list); in tb_init_port()
695 if (!port->port) in tb_init_port()
698 res = tb_port_read(port, &port->config, TB_CFG_PORT, 0, 8); in tb_init_port()
700 if (res == -ENODEV) { in tb_init_port()
701 tb_dbg(port->sw->tb, " Port %d: not implemented\n", in tb_init_port()
702 port->port); in tb_init_port()
703 port->disabled = true; in tb_init_port()
710 if (port->config.type == TB_TYPE_PORT) { in tb_init_port()
714 port->cap_phy = cap; in tb_init_port()
720 port->cap_usb4 = cap; in tb_init_port()
725 * devices we use hard-coded value. in tb_init_port()
727 if (port->cap_usb4) { in tb_init_port()
731 port->ctl_credits = hop.initial_credits; in tb_init_port()
733 if (!port->ctl_credits) in tb_init_port()
734 port->ctl_credits = 2; in tb_init_port()
739 port->cap_adap = cap; in tb_init_port()
742 port->total_credits = in tb_init_port()
743 (port->config.nfc_credits & ADP_CS_4_TOTAL_BUFFERS_MASK) >> in tb_init_port()
746 tb_dump_port(port->sw->tb, port); in tb_init_port()
757 port_max_hopid = port->config.max_in_hop_id; in tb_port_alloc_hopid()
758 ida = &port->in_hopids; in tb_port_alloc_hopid()
760 port_max_hopid = port->config.max_out_hop_id; in tb_port_alloc_hopid()
761 ida = &port->out_hopids; in tb_port_alloc_hopid()
765 * NHI can use HopIDs 1-max for other adapters HopIDs 0-7 are in tb_port_alloc_hopid()
778 * tb_port_alloc_in_hopid() - Allocate input HopID from port
792 * tb_port_alloc_out_hopid() - Allocate output HopID from port
806 * tb_port_release_in_hopid() - Release allocated input HopID from port
812 ida_simple_remove(&port->in_hopids, hopid); in tb_port_release_in_hopid()
816 * tb_port_release_out_hopid() - Release allocated output HopID from port
822 ida_simple_remove(&port->out_hopids, hopid); in tb_port_release_out_hopid()
828 u64 mask = (1ULL << parent->config.depth * 8) - 1; in tb_switch_is_reachable()
833 * tb_next_port_on_path() - Return next port for given port on a path
839 * are connected through zero or more switches. If the @prev is dual
845 * Domain tb->lock must be held when this function is called.
855 if (prev->sw == end->sw) { in tb_next_port_on_path()
861 if (tb_switch_is_reachable(prev->sw, end->sw)) { in tb_next_port_on_path()
862 next = tb_port_at(tb_route(end->sw), prev->sw); in tb_next_port_on_path()
864 if (prev->remote && in tb_next_port_on_path()
865 (next == prev || next->dual_link_port == prev)) in tb_next_port_on_path()
866 next = prev->remote; in tb_next_port_on_path()
869 next = prev->remote; in tb_next_port_on_path()
871 next = tb_upstream_port(prev->sw); in tb_next_port_on_path()
874 * dual link ports. in tb_next_port_on_path()
876 if (next->dual_link_port && in tb_next_port_on_path()
877 next->link_nr != prev->link_nr) { in tb_next_port_on_path()
878 next = next->dual_link_port; in tb_next_port_on_path()
887 * tb_port_get_link_speed() - Get current link speed
897 if (!port->cap_phy) in tb_port_get_link_speed()
898 return -EINVAL; in tb_port_get_link_speed()
901 port->cap_phy + LANE_ADP_CS_1, 1); in tb_port_get_link_speed()
919 * tb_port_get_link_generation() - Returns link generation
920 * @port: Lane adapter
945 * tb_port_get_link_width() - Get current link width
956 if (!port->cap_phy) in tb_port_get_link_width()
957 return -EINVAL; in tb_port_get_link_width()
960 port->cap_phy + LANE_ADP_CS_1, 1); in tb_port_get_link_width()
970 * tb_port_width_supported() - Is the given link width supported
974 * Can be called to any lane adapter. Checks if given @width is
982 if (!port->cap_phy) in tb_port_width_supported()
992 port->cap_phy + LANE_ADP_CS_0, 1); in tb_port_width_supported()
1005 * tb_port_set_link_width() - Set target link width of the lane adapter
1006 * @port: Lane adapter
1009 * Sets the target link width of the lane adapter to @width. Does not
1010 * enable/disable lane bonding. For that call tb_port_set_lane_bonding().
1019 if (!port->cap_phy) in tb_port_set_link_width()
1020 return -EINVAL; in tb_port_set_link_width()
1023 port->cap_phy + LANE_ADP_CS_1, 1); in tb_port_set_link_width()
1032 return -EOPNOTSUPP; in tb_port_set_link_width()
1049 return -EINVAL; in tb_port_set_link_width()
1053 port->cap_phy + LANE_ADP_CS_1, 1); in tb_port_set_link_width()
1057 * tb_port_set_lane_bonding() - Enable/disable lane bonding
1058 * @port: Lane adapter
1061 * Enables or disables lane bonding. This should be called after target
1064 * lane bonding.
1073 if (!port->cap_phy) in tb_port_set_lane_bonding()
1074 return -EINVAL; in tb_port_set_lane_bonding()
1077 port->cap_phy + LANE_ADP_CS_1, 1); in tb_port_set_lane_bonding()
1087 port->cap_phy + LANE_ADP_CS_1, 1); in tb_port_set_lane_bonding()
1091 * tb_port_lane_bonding_enable() - Enable bonding on port
1095 * port in case of dual link port. Does not wait for the link to
1108 * Enable lane bonding for both links if not already enabled by in tb_port_lane_bonding_enable()
1118 width = tb_port_get_link_width(port->dual_link_port); in tb_port_lane_bonding_enable()
1120 ret = tb_port_set_link_width(port->dual_link_port, in tb_port_lane_bonding_enable()
1128 * avoids the lane adapter to re-enter bonding state. in tb_port_lane_bonding_enable()
1137 * When lane 0 bonding is set it will affect lane 1 too so in tb_port_lane_bonding_enable()
1140 port->bonded = true; in tb_port_lane_bonding_enable()
1141 port->dual_link_port->bonded = true; in tb_port_lane_bonding_enable()
1146 tb_port_set_link_width(port->dual_link_port, TB_LINK_WIDTH_SINGLE); in tb_port_lane_bonding_enable()
1154 * tb_port_lane_bonding_disable() - Disable bonding on port
1158 * other port in case of dual link port.
1163 tb_port_set_link_width(port->dual_link_port, TB_LINK_WIDTH_SINGLE); in tb_port_lane_bonding_disable()
1165 port->dual_link_port->bonded = false; in tb_port_lane_bonding_disable()
1166 port->bonded = false; in tb_port_lane_bonding_disable()
1170 * tb_port_wait_for_link_width() - Wait until link reaches specific width
1177 * the expected state. Returns %-ETIMEDOUT if the width was not reached
1187 /* Gen 4 link does not support single lane */ in tb_port_wait_for_link_width()
1190 return -EOPNOTSUPP; in tb_port_wait_for_link_width()
1200 if (ret != -EACCES) in tb_port_wait_for_link_width()
1209 return -ETIMEDOUT; in tb_port_wait_for_link_width()
1221 if (nfc_credits != port->config.nfc_credits) { in tb_port_do_update_credits()
1227 tb_port_dbg(port, "total credits changed %u -> %u\n", in tb_port_do_update_credits()
1228 port->total_credits, total); in tb_port_do_update_credits()
1230 port->config.nfc_credits = nfc_credits; in tb_port_do_update_credits()
1231 port->total_credits = total; in tb_port_do_update_credits()
1238 * tb_port_update_credits() - Re-read port total credits
1242 * credits may change, so this function needs to be called to re-read
1243 * the credits. Updates also the second lane adapter.
1253 if (!port->dual_link_port) in tb_port_update_credits()
1255 return tb_port_do_update_credits(port->dual_link_port); in tb_port_update_credits()
1262 if (tb_switch_is_usb4(port->sw)) in tb_port_start_lane_initialization()
1266 return ret == -EINVAL ? 0 : ret; in tb_port_start_lane_initialization()
1277 if (port->usb4) { in tb_port_resume()
1278 usb4_port_device_resume(port->usb4); in tb_port_resume()
1281 * For disconnected downstream lane adapters start lane in tb_port_resume()
1284 * For XDomain start the lane initialzation now so the in tb_port_resume()
1285 * link gets re-established. in tb_port_resume()
1287 * This is only needed for non-USB4 ports. in tb_port_resume()
1289 if (!tb_is_upstream_port(port) || port->xdomain) in tb_port_resume()
1293 return has_remote || port->xdomain; in tb_port_resume()
1297 * tb_port_is_enabled() - Is the adapter port enabled
1302 switch (port->config.type) { in tb_port_is_enabled()
1321 * tb_usb3_port_is_enabled() - Is the USB3 adapter port enabled
1329 port->cap_adap + ADP_USB3_CS_0, 1)) in tb_usb3_port_is_enabled()
1336 * tb_usb3_port_enable() - Enable USB3 adapter port
1345 if (!port->cap_adap) in tb_usb3_port_enable()
1346 return -ENXIO; in tb_usb3_port_enable()
1348 port->cap_adap + ADP_USB3_CS_0, 1); in tb_usb3_port_enable()
1352 * tb_pci_port_is_enabled() - Is the PCIe adapter port enabled
1360 port->cap_adap + ADP_PCIE_CS_0, 1)) in tb_pci_port_is_enabled()
1367 * tb_pci_port_enable() - Enable PCIe adapter port
1374 if (!port->cap_adap) in tb_pci_port_enable()
1375 return -ENXIO; in tb_pci_port_enable()
1377 port->cap_adap + ADP_PCIE_CS_0, 1); in tb_pci_port_enable()
1381 * tb_dp_port_hpd_is_active() - Is HPD already active
1392 port->cap_adap + ADP_DP_CS_2, 1); in tb_dp_port_hpd_is_active()
1400 * tb_dp_port_hpd_clear() - Clear HPD from DP IN port
1411 port->cap_adap + ADP_DP_CS_3, 1); in tb_dp_port_hpd_clear()
1417 port->cap_adap + ADP_DP_CS_3, 1); in tb_dp_port_hpd_clear()
1421 * tb_dp_port_set_hops() - Set video/aux Hop IDs for DP port
1429 * are read-only.
1437 if (tb_switch_is_usb4(port->sw)) in tb_dp_port_set_hops()
1441 port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data)); in tb_dp_port_set_hops()
1456 port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data)); in tb_dp_port_set_hops()
1460 * tb_dp_port_is_enabled() - Is DP adapter port enabled
1467 if (tb_port_read(port, data, TB_CFG_PORT, port->cap_adap + ADP_DP_CS_0, in tb_dp_port_is_enabled()
1475 * tb_dp_port_enable() - Enables/disables DP paths of a port
1488 port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data)); in tb_dp_port_enable()
1498 port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data)); in tb_dp_port_enable()
1505 switch (sw->generation) { in tb_switch_generation_name()
1521 const struct tb_regs_switch_header *regs = &sw->config; in tb_dump_switch()
1524 tb_switch_generation_name(sw), regs->vendor_id, regs->device_id, in tb_dump_switch()
1525 regs->revision, regs->thunderbolt_version); in tb_dump_switch()
1526 tb_dbg(tb, " Max Port Number: %d\n", regs->max_port_number); in tb_dump_switch()
1530 regs->upstream_port_number, regs->depth, in tb_dump_switch()
1531 (((u64) regs->route_hi) << 32) | regs->route_lo, in tb_dump_switch()
1532 regs->enabled, regs->plug_events_delay); in tb_dump_switch()
1534 regs->__unknown1, regs->__unknown4); in tb_dump_switch()
1538 * tb_switch_reset() - reconfigure route, enable and send TB_CFG_PKG_RESET
1547 if (sw->generation > 1) in tb_switch_reset()
1552 res.err = tb_sw_write(sw, ((u32 *) &sw->config) + 2, in tb_switch_reset()
1556 res = tb_cfg_reset(sw->tb->ctl, tb_route(sw)); in tb_switch_reset()
1558 return -EIO; in tb_switch_reset()
1563 * tb_switch_wait_for_bit() - Wait for specified value of bits in offset
1571 * Returns %0 in case of success, %-ETIMEDOUT if the @value was not reached
1593 return -ETIMEDOUT; in tb_switch_wait_for_bit()
1597 * tb_plug_events_active() - enable/disable plug events on a switch
1611 sw->config.plug_events_delay = 0xff; in tb_plug_events_active()
1612 res = tb_sw_write(sw, ((u32 *) &sw->config) + 4, TB_CFG_SWITCH, 4, 1); in tb_plug_events_active()
1616 res = tb_sw_read(sw, &data, TB_CFG_SWITCH, sw->cap_plug_events + 1, 1); in tb_plug_events_active()
1622 switch (sw->config.device_id) { in tb_plug_events_active()
1640 sw->cap_plug_events + 1, 1); in tb_plug_events_active()
1649 return sysfs_emit(buf, "%u\n", sw->authorized); in authorized_show()
1658 if (sw && sw->authorized) { in disapprove_switch()
1662 ret = device_for_each_child_reverse(&sw->dev, NULL, disapprove_switch); in disapprove_switch()
1666 ret = tb_domain_disapprove_switch(sw->tb, sw); in disapprove_switch()
1670 sw->authorized = 0; in disapprove_switch()
1671 kobject_uevent_env(&sw->dev.kobj, KOBJ_CHANGE, envp); in disapprove_switch()
1680 int ret = -EINVAL; in tb_switch_set_authorized()
1683 if (!mutex_trylock(&sw->tb->lock)) in tb_switch_set_authorized()
1686 if (!!sw->authorized == !!val) in tb_switch_set_authorized()
1693 ret = disapprove_switch(&sw->dev, NULL); in tb_switch_set_authorized()
1700 if (sw->key) in tb_switch_set_authorized()
1701 ret = tb_domain_approve_switch_key(sw->tb, sw); in tb_switch_set_authorized()
1703 ret = tb_domain_approve_switch(sw->tb, sw); in tb_switch_set_authorized()
1708 if (sw->key) in tb_switch_set_authorized()
1709 ret = tb_domain_challenge_switch_key(sw->tb, sw); in tb_switch_set_authorized()
1717 sw->authorized = val; in tb_switch_set_authorized()
1722 sprintf(envp_string, "AUTHORIZED=%u", sw->authorized); in tb_switch_set_authorized()
1723 kobject_uevent_env(&sw->dev.kobj, KOBJ_CHANGE, envp); in tb_switch_set_authorized()
1727 mutex_unlock(&sw->tb->lock); in tb_switch_set_authorized()
1743 return -EINVAL; in authorized_store()
1745 pm_runtime_get_sync(&sw->dev); in authorized_store()
1747 pm_runtime_mark_last_busy(&sw->dev); in authorized_store()
1748 pm_runtime_put_autosuspend(&sw->dev); in authorized_store()
1759 return sysfs_emit(buf, "%u\n", sw->boot); in boot_show()
1768 return sysfs_emit(buf, "%#x\n", sw->device); in device_show()
1777 return sysfs_emit(buf, "%s\n", sw->device_name ?: ""); in device_name_show()
1786 return sysfs_emit(buf, "%u\n", sw->generation); in generation_show()
1796 if (!mutex_trylock(&sw->tb->lock)) in key_show()
1799 if (sw->key) in key_show()
1800 ret = sysfs_emit(buf, "%*phN\n", TB_SWITCH_KEY_SIZE, sw->key); in key_show()
1804 mutex_unlock(&sw->tb->lock); in key_show()
1819 return -EINVAL; in key_store()
1821 if (!mutex_trylock(&sw->tb->lock)) in key_store()
1824 if (sw->authorized) { in key_store()
1825 ret = -EBUSY; in key_store()
1827 kfree(sw->key); in key_store()
1829 sw->key = NULL; in key_store()
1831 sw->key = kmemdup(key, sizeof(key), GFP_KERNEL); in key_store()
1832 if (!sw->key) in key_store()
1833 ret = -ENOMEM; in key_store()
1837 mutex_unlock(&sw->tb->lock); in key_store()
1847 return sysfs_emit(buf, "%u.0 Gb/s\n", sw->link_speed); in speed_show()
1863 switch (sw->link_width) { in rx_lanes_show()
1876 return -EINVAL; in rx_lanes_show()
1889 switch (sw->link_width) { in tx_lanes_show()
1902 return -EINVAL; in tx_lanes_show()
1925 pm_runtime_get_sync(&sw->dev); in nvm_authenticate_sysfs()
1927 if (!mutex_trylock(&sw->tb->lock)) { in nvm_authenticate_sysfs()
1932 if (sw->no_nvm_upgrade) { in nvm_authenticate_sysfs()
1933 ret = -EOPNOTSUPP; in nvm_authenticate_sysfs()
1938 if (!sw->nvm) { in nvm_authenticate_sysfs()
1939 ret = -EAGAIN; in nvm_authenticate_sysfs()
1953 ret = -EINVAL; in nvm_authenticate_sysfs()
1957 if (!sw->nvm->flushed) { in nvm_authenticate_sysfs()
1958 if (!sw->nvm->buf) { in nvm_authenticate_sysfs()
1959 ret = -EINVAL; in nvm_authenticate_sysfs()
1977 mutex_unlock(&sw->tb->lock); in nvm_authenticate_sysfs()
1979 pm_runtime_mark_last_busy(&sw->dev); in nvm_authenticate_sysfs()
1980 pm_runtime_put_autosuspend(&sw->dev); in nvm_authenticate_sysfs()
2017 if (!mutex_trylock(&sw->tb->lock)) in nvm_version_show()
2020 if (sw->safe_mode) in nvm_version_show()
2021 ret = -ENODATA; in nvm_version_show()
2022 else if (!sw->nvm) in nvm_version_show()
2023 ret = -EAGAIN; in nvm_version_show()
2025 ret = sysfs_emit(buf, "%x.%x\n", sw->nvm->major, sw->nvm->minor); in nvm_version_show()
2027 mutex_unlock(&sw->tb->lock); in nvm_version_show()
2038 return sysfs_emit(buf, "%#x\n", sw->vendor); in vendor_show()
2047 return sysfs_emit(buf, "%s\n", sw->vendor_name ?: ""); in vendor_name_show()
2056 return sysfs_emit(buf, "%pUb\n", sw->uuid); in unique_id_show()
2087 if (sw->tb->security_level == TB_SECURITY_NOPCIE || in switch_attr_is_visible()
2088 sw->tb->security_level == TB_SECURITY_DPONLY) in switch_attr_is_visible()
2091 if (!sw->device) in switch_attr_is_visible()
2094 if (!sw->device_name) in switch_attr_is_visible()
2097 if (!sw->vendor) in switch_attr_is_visible()
2100 if (!sw->vendor_name) in switch_attr_is_visible()
2104 sw->tb->security_level == TB_SECURITY_SECURE && in switch_attr_is_visible()
2105 sw->security_level == TB_SECURITY_SECURE) in switch_attr_is_visible()
2106 return attr->mode; in switch_attr_is_visible()
2113 return attr->mode; in switch_attr_is_visible()
2117 return attr->mode; in switch_attr_is_visible()
2121 return attr->mode; in switch_attr_is_visible()
2125 return attr->mode; in switch_attr_is_visible()
2128 if (sw->quirks & QUIRK_FORCE_POWER_LINK_CONTROLLER) in switch_attr_is_visible()
2129 return attr->mode; in switch_attr_is_visible()
2133 return sw->safe_mode ? 0 : attr->mode; in switch_attr_is_visible()
2151 dma_port_free(sw->dma_port); in tb_switch_release()
2154 ida_destroy(&port->in_hopids); in tb_switch_release()
2155 ida_destroy(&port->out_hopids); in tb_switch_release()
2158 kfree(sw->uuid); in tb_switch_release()
2159 kfree(sw->device_name); in tb_switch_release()
2160 kfree(sw->vendor_name); in tb_switch_release()
2161 kfree(sw->ports); in tb_switch_release()
2162 kfree(sw->drom); in tb_switch_release()
2163 kfree(sw->key); in tb_switch_release()
2175 return -ENOMEM; in tb_switch_uevent()
2186 if (!port->disabled && !tb_is_upstream_port(port) && in tb_switch_uevent()
2197 return -ENOMEM; in tb_switch_uevent()
2208 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in tb_switch_runtime_suspend()
2210 if (cm_ops->runtime_suspend_switch) in tb_switch_runtime_suspend()
2211 return cm_ops->runtime_suspend_switch(sw); in tb_switch_runtime_suspend()
2219 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in tb_switch_runtime_resume()
2221 if (cm_ops->runtime_resume_switch) in tb_switch_runtime_resume()
2222 return cm_ops->runtime_resume_switch(sw); in tb_switch_runtime_resume()
2243 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_get_generation()
2244 switch (sw->config.device_id) { in tb_switch_get_generation()
2279 sw->config.device_id); in tb_switch_get_generation()
2288 (sw->tb->root_switch && tb_switch_is_usb4(sw->tb->root_switch))) in tb_switch_exceeds_max_depth()
2297 * tb_switch_alloc() - allocate a switch
2328 upstream_port = tb_cfg_get_upstream_port(tb->ctl, route); in tb_switch_alloc()
2334 return ERR_PTR(-ENOMEM); in tb_switch_alloc()
2336 sw->tb = tb; in tb_switch_alloc()
2337 ret = tb_cfg_read(tb->ctl, &sw->config, route, 0, TB_CFG_SWITCH, 0, 5); in tb_switch_alloc()
2341 sw->generation = tb_switch_get_generation(sw); in tb_switch_alloc()
2347 sw->config.upstream_port_number = upstream_port; in tb_switch_alloc()
2348 sw->config.depth = depth; in tb_switch_alloc()
2349 sw->config.route_hi = upper_32_bits(route); in tb_switch_alloc()
2350 sw->config.route_lo = lower_32_bits(route); in tb_switch_alloc()
2351 sw->config.enabled = 0; in tb_switch_alloc()
2355 ret = -EADDRNOTAVAIL; in tb_switch_alloc()
2360 sw->ports = kcalloc(sw->config.max_port_number + 1, sizeof(*sw->ports), in tb_switch_alloc()
2362 if (!sw->ports) { in tb_switch_alloc()
2363 ret = -ENOMEM; in tb_switch_alloc()
2367 for (i = 0; i <= sw->config.max_port_number; i++) { in tb_switch_alloc()
2369 sw->ports[i].sw = sw; in tb_switch_alloc()
2370 sw->ports[i].port = i; in tb_switch_alloc()
2374 ida_init(&sw->ports[i].in_hopids); in tb_switch_alloc()
2375 ida_init(&sw->ports[i].out_hopids); in tb_switch_alloc()
2381 sw->cap_plug_events = ret; in tb_switch_alloc()
2385 sw->cap_vsec_tmu = ret; in tb_switch_alloc()
2389 sw->cap_lc = ret; in tb_switch_alloc()
2393 sw->cap_lp = ret; in tb_switch_alloc()
2397 sw->authorized = true; in tb_switch_alloc()
2399 device_initialize(&sw->dev); in tb_switch_alloc()
2400 sw->dev.parent = parent; in tb_switch_alloc()
2401 sw->dev.bus = &tb_bus_type; in tb_switch_alloc()
2402 sw->dev.type = &tb_switch_type; in tb_switch_alloc()
2403 sw->dev.groups = switch_groups; in tb_switch_alloc()
2404 dev_set_name(&sw->dev, "%u-%llx", tb->index, tb_route(sw)); in tb_switch_alloc()
2409 kfree(sw->ports); in tb_switch_alloc()
2416 * tb_switch_alloc_safe_mode() - allocate a switch that is in safe mode
2436 return ERR_PTR(-ENOMEM); in tb_switch_alloc_safe_mode()
2438 sw->tb = tb; in tb_switch_alloc_safe_mode()
2439 sw->config.depth = tb_route_length(route); in tb_switch_alloc_safe_mode()
2440 sw->config.route_hi = upper_32_bits(route); in tb_switch_alloc_safe_mode()
2441 sw->config.route_lo = lower_32_bits(route); in tb_switch_alloc_safe_mode()
2442 sw->safe_mode = true; in tb_switch_alloc_safe_mode()
2444 device_initialize(&sw->dev); in tb_switch_alloc_safe_mode()
2445 sw->dev.parent = parent; in tb_switch_alloc_safe_mode()
2446 sw->dev.bus = &tb_bus_type; in tb_switch_alloc_safe_mode()
2447 sw->dev.type = &tb_switch_type; in tb_switch_alloc_safe_mode()
2448 sw->dev.groups = switch_groups; in tb_switch_alloc_safe_mode()
2449 dev_set_name(&sw->dev, "%u-%llx", tb->index, tb_route(sw)); in tb_switch_alloc_safe_mode()
2455 * tb_switch_configure() - Uploads configuration to the switch
2461 * resume from low power states to re-initialize it.
2467 struct tb *tb = sw->tb; in tb_switch_configure()
2474 sw->config.enabled ? "restoring" : "initializing", route, in tb_switch_configure()
2475 tb_route_length(route), sw->config.upstream_port_number); in tb_switch_configure()
2477 sw->config.enabled = 1; in tb_switch_configure()
2487 sw->config.cmuv = ROUTER_CS_4_CMUV_V1; in tb_switch_configure()
2489 sw->config.cmuv = ROUTER_CS_4_CMUV_V2; in tb_switch_configure()
2490 sw->config.plug_events_delay = 0xa; in tb_switch_configure()
2493 ret = tb_sw_write(sw, (u32 *)&sw->config + 1, TB_CFG_SWITCH, in tb_switch_configure()
2500 if (sw->config.vendor_id != PCI_VENDOR_ID_INTEL) in tb_switch_configure()
2502 sw->config.vendor_id); in tb_switch_configure()
2504 if (!sw->cap_plug_events) { in tb_switch_configure()
2506 return -ENODEV; in tb_switch_configure()
2510 ret = tb_sw_write(sw, (u32 *)&sw->config + 1, TB_CFG_SWITCH, in tb_switch_configure()
2520 * tb_switch_configuration_valid() - Set the tunneling configuration to be valid
2541 if (sw->uuid) in tb_switch_set_uuid()
2545 ret = usb4_switch_read_uid(sw, &sw->uid); in tb_switch_set_uuid()
2556 if (ret != -EINVAL) in tb_switch_set_uuid()
2569 uuid[0] = sw->uid & 0xffffffff; in tb_switch_set_uuid()
2570 uuid[1] = (sw->uid >> 32) & 0xffffffff; in tb_switch_set_uuid()
2575 sw->uuid = kmemdup(uuid, sizeof(uuid), GFP_KERNEL); in tb_switch_set_uuid()
2576 if (!sw->uuid) in tb_switch_set_uuid()
2577 return -ENOMEM; in tb_switch_set_uuid()
2586 switch (sw->generation) { in tb_switch_add_dma_port()
2605 if (!sw->safe_mode) in tb_switch_add_dma_port()
2610 if (sw->no_nvm_upgrade) in tb_switch_add_dma_port()
2630 sw->dma_port = dma_port_alloc(sw); in tb_switch_add_dma_port()
2631 if (!sw->dma_port) in tb_switch_add_dma_port()
2652 ret = dma_port_flash_update_auth_status(sw->dma_port, &status); in tb_switch_add_dma_port()
2666 dma_port_power_cycle(sw->dma_port); in tb_switch_add_dma_port()
2672 return -ESHUTDOWN; in tb_switch_add_dma_port()
2679 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_switch_default_link_ports()
2680 struct tb_port *port = &sw->ports[i]; in tb_switch_default_link_ports()
2687 if (i == sw->config.max_port_number || in tb_switch_default_link_ports()
2688 !tb_port_is_null(&sw->ports[i + 1])) in tb_switch_default_link_ports()
2692 subordinate = &sw->ports[i + 1]; in tb_switch_default_link_ports()
2693 if (!port->dual_link_port && !subordinate->dual_link_port) { in tb_switch_default_link_ports()
2694 port->link_nr = 0; in tb_switch_default_link_ports()
2695 port->dual_link_port = subordinate; in tb_switch_default_link_ports()
2696 subordinate->link_nr = 1; in tb_switch_default_link_ports()
2697 subordinate->dual_link_port = port; in tb_switch_default_link_ports()
2699 tb_sw_dbg(sw, "linked ports %d <-> %d\n", in tb_switch_default_link_ports()
2700 port->port, subordinate->port); in tb_switch_default_link_ports()
2709 if (!up->dual_link_port || !up->dual_link_port->remote) in tb_switch_lane_bonding_possible()
2731 if (sw->link_speed != ret) in tb_switch_update_link_attributes()
2733 sw->link_speed = ret; in tb_switch_update_link_attributes()
2738 if (sw->link_width != ret) in tb_switch_update_link_attributes()
2740 sw->link_width = ret; in tb_switch_update_link_attributes()
2743 if (device_is_registered(&sw->dev) && change) in tb_switch_update_link_attributes()
2744 kobject_uevent(&sw->dev.kobj, KOBJ_CHANGE); in tb_switch_update_link_attributes()
2758 tb_sw_dbg(sw, "current link speed %u.0 Gb/s\n", sw->link_speed); in tb_switch_link_init()
2759 tb_sw_dbg(sw, "current link width %s\n", tb_width_name(sw->link_width)); in tb_switch_link_init()
2761 bonded = sw->link_width >= TB_LINK_WIDTH_DUAL; in tb_switch_link_init()
2770 up->bonded = bonded; in tb_switch_link_init()
2771 if (up->dual_link_port) in tb_switch_link_init()
2772 up->dual_link_port->bonded = bonded; in tb_switch_link_init()
2775 down->bonded = bonded; in tb_switch_link_init()
2776 if (down->dual_link_port) in tb_switch_link_init()
2777 down->dual_link_port->bonded = bonded; in tb_switch_link_init()
2789 sw->preferred_link_width = sw->link_width; in tb_switch_link_init()
2791 tb_width_name(sw->preferred_link_width)); in tb_switch_link_init()
2795 * tb_switch_lane_bonding_enable() - Enable lane bonding
2796 * @sw: Switch to enable lane bonding
2798 * Connection manager can call this function to enable lane bonding of a
2819 * Both lanes need to be in CL0. Here we assume lane 0 already be in in tb_switch_lane_bonding_enable()
2820 * CL0 and check just for lane 1. in tb_switch_lane_bonding_enable()
2822 if (tb_wait_for_port(down->dual_link_port, false) <= 0) in tb_switch_lane_bonding_enable()
2823 return -ENOTCONN; in tb_switch_lane_bonding_enable()
2827 tb_port_warn(up, "failed to enable lane bonding\n"); in tb_switch_lane_bonding_enable()
2833 tb_port_warn(down, "failed to enable lane bonding\n"); in tb_switch_lane_bonding_enable()
2846 * tb_switch_lane_bonding_disable() - Disable lane bonding
2847 * @sw: Switch whose lane bonding to disable
2849 * Disables lane bonding between @sw and parent. This can be called even
2858 if (!up->bonded) in tb_switch_lane_bonding_disable()
2863 * two single lane links so avoid that here. Also don't bother in tb_switch_lane_bonding_disable()
2870 return -EOPNOTSUPP; in tb_switch_lane_bonding_disable()
2883 /* Note updating sw->link_width done in tb_switch_update_link_attributes() */
2913 if (sw->link_width != width) { in tb_switch_asym_enable()
2926 /* Note updating sw->link_width done in tb_switch_update_link_attributes() */
2948 if (sw->link_width > TB_LINK_WIDTH_DUAL) { in tb_switch_asym_disable()
2949 if (sw->link_width == TB_LINK_WIDTH_ASYM_TX) in tb_switch_asym_disable()
2965 * tb_switch_set_link_width() - Configure router link width
2994 if (sw->link_width == TB_LINK_WIDTH_ASYM_TX || in tb_switch_set_link_width()
2995 sw->link_width == TB_LINK_WIDTH_ASYM_RX) { in tb_switch_set_link_width()
3013 case -ETIMEDOUT: in tb_switch_set_link_width()
3017 case -ENOTCONN: in tb_switch_set_link_width()
3018 case -EOPNOTSUPP: in tb_switch_set_link_width()
3019 case -ENODEV: in tb_switch_set_link_width()
3037 * tb_switch_configure_link() - Set link configured
3044 * It is recommended that this is called after lane bonding is enabled.
3057 if (tb_switch_is_usb4(up->sw)) in tb_switch_configure_link()
3064 down = up->remote; in tb_switch_configure_link()
3065 if (tb_switch_is_usb4(down->sw)) in tb_switch_configure_link()
3071 * tb_switch_unconfigure_link() - Unconfigure link
3081 if (sw->is_unplugged) in tb_switch_unconfigure_link()
3087 if (tb_switch_is_usb4(up->sw)) in tb_switch_unconfigure_link()
3092 down = up->remote; in tb_switch_unconfigure_link()
3093 if (tb_switch_is_usb4(down->sw)) in tb_switch_unconfigure_link()
3119 if (!port->cap_usb4) in tb_switch_port_hotplug_enable()
3130 * tb_switch_add() - Add a switch to the domain
3154 dev_err(&sw->dev, "failed to add DMA port\n"); in tb_switch_add()
3158 if (!sw->safe_mode) { in tb_switch_add()
3164 dev_warn(&sw->dev, "reading DROM failed: %d\n", ret); in tb_switch_add()
3165 tb_sw_dbg(sw, "uid: %#llx\n", sw->uid); in tb_switch_add()
3169 dev_err(&sw->dev, "failed to set UUID\n"); in tb_switch_add()
3173 for (i = 0; i <= sw->config.max_port_number; i++) { in tb_switch_add()
3174 if (sw->ports[i].disabled) { in tb_switch_add()
3175 tb_port_dbg(&sw->ports[i], "disabled by eeprom\n"); in tb_switch_add()
3178 ret = tb_init_port(&sw->ports[i]); in tb_switch_add()
3180 dev_err(&sw->dev, "failed to initialize port %d\n", i); in tb_switch_add()
3208 ret = device_add(&sw->dev); in tb_switch_add()
3210 dev_err(&sw->dev, "failed to add device: %d\n", ret); in tb_switch_add()
3215 dev_info(&sw->dev, "new device found, vendor=%#x device=%#x\n", in tb_switch_add()
3216 sw->vendor, sw->device); in tb_switch_add()
3217 if (sw->vendor_name && sw->device_name) in tb_switch_add()
3218 dev_info(&sw->dev, "%s %s\n", sw->vendor_name, in tb_switch_add()
3219 sw->device_name); in tb_switch_add()
3224 dev_err(&sw->dev, "failed to add USB4 ports\n"); in tb_switch_add()
3230 dev_err(&sw->dev, "failed to add NVM devices\n"); in tb_switch_add()
3239 device_init_wakeup(&sw->dev, true); in tb_switch_add()
3241 pm_runtime_set_active(&sw->dev); in tb_switch_add()
3242 if (sw->rpm) { in tb_switch_add()
3243 pm_runtime_set_autosuspend_delay(&sw->dev, TB_AUTOSUSPEND_DELAY); in tb_switch_add()
3244 pm_runtime_use_autosuspend(&sw->dev); in tb_switch_add()
3245 pm_runtime_mark_last_busy(&sw->dev); in tb_switch_add()
3246 pm_runtime_enable(&sw->dev); in tb_switch_add()
3247 pm_request_autosuspend(&sw->dev); in tb_switch_add()
3256 device_del(&sw->dev); in tb_switch_add()
3262 * tb_switch_remove() - Remove and release a switch
3275 if (sw->rpm) { in tb_switch_remove()
3276 pm_runtime_get_sync(&sw->dev); in tb_switch_remove()
3277 pm_runtime_disable(&sw->dev); in tb_switch_remove()
3283 tb_switch_remove(port->remote->sw); in tb_switch_remove()
3284 port->remote = NULL; in tb_switch_remove()
3285 } else if (port->xdomain) { in tb_switch_remove()
3286 tb_xdomain_remove(port->xdomain); in tb_switch_remove()
3287 port->xdomain = NULL; in tb_switch_remove()
3294 if (!sw->is_unplugged) in tb_switch_remove()
3301 dev_info(&sw->dev, "device disconnected\n"); in tb_switch_remove()
3302 device_unregister(&sw->dev); in tb_switch_remove()
3306 * tb_sw_set_unplugged() - set is_unplugged on switch and downstream switches
3313 if (sw == sw->tb->root_switch) { in tb_sw_set_unplugged()
3317 if (sw->is_unplugged) { in tb_sw_set_unplugged()
3321 sw->is_unplugged = true; in tb_sw_set_unplugged()
3324 tb_sw_set_unplugged(port->remote->sw); in tb_sw_set_unplugged()
3325 else if (port->xdomain) in tb_sw_set_unplugged()
3326 port->xdomain->is_unplugged = true; in tb_sw_set_unplugged()
3361 err = tb_cfg_get_upstream_port(sw->tb->ctl, tb_route(sw)); in tb_switch_resume()
3368 if (!sw->uid) in tb_switch_resume()
3369 return -ENODEV; in tb_switch_resume()
3379 if (sw->uid != uid) { in tb_switch_resume()
3381 "changed while suspended (uid %#llx -> %#llx)\n", in tb_switch_resume()
3382 sw->uid, uid); in tb_switch_resume()
3383 return -ENODEV; in tb_switch_resume()
3410 tb_sw_set_unplugged(port->remote->sw); in tb_switch_resume()
3411 else if (port->xdomain) in tb_switch_resume()
3412 port->xdomain->is_unplugged = true; in tb_switch_resume()
3420 if (port->remote && tb_switch_resume(port->remote->sw)) { in tb_switch_resume()
3423 tb_sw_set_unplugged(port->remote->sw); in tb_switch_resume()
3431 * tb_switch_suspend() - Put a switch to sleep
3450 * done for USB4 device too as CLx is re-enabled at resume. in tb_switch_suspend()
3460 tb_switch_suspend(port->remote->sw, runtime); in tb_switch_suspend()
3468 } else if (device_may_wakeup(&sw->dev)) { in tb_switch_suspend()
3481 * tb_switch_query_dp_resource() - Query availability of DP resource
3496 * tb_switch_alloc_dp_resource() - Allocate available DP resource
3515 in->port); in tb_switch_alloc_dp_resource()
3517 tb_sw_dbg(sw, "allocated DP resource for port %d\n", in->port); in tb_switch_alloc_dp_resource()
3523 * tb_switch_dealloc_dp_resource() - De-allocate DP resource
3524 * @sw: Switch whose DP resource is de-allocated
3527 * De-allocates DP resource that was previously allocated for DP
3540 tb_sw_warn(sw, "failed to de-allocate DP resource for port %d\n", in tb_switch_dealloc_dp_resource()
3541 in->port); in tb_switch_dealloc_dp_resource()
3543 tb_sw_dbg(sw, "released DP resource for port %d\n", in->port); in tb_switch_dealloc_dp_resource()
3561 if (sw->tb != lookup->tb) in tb_switch_match()
3564 if (lookup->uuid) in tb_switch_match()
3565 return !memcmp(sw->uuid, lookup->uuid, sizeof(*lookup->uuid)); in tb_switch_match()
3567 if (lookup->route) { in tb_switch_match()
3568 return sw->config.route_lo == lower_32_bits(lookup->route) && in tb_switch_match()
3569 sw->config.route_hi == upper_32_bits(lookup->route); in tb_switch_match()
3573 if (!lookup->depth) in tb_switch_match()
3574 return !sw->depth; in tb_switch_match()
3576 return sw->link == lookup->link && sw->depth == lookup->depth; in tb_switch_match()
3580 * tb_switch_find_by_link_depth() - Find switch by link and depth
3606 * tb_switch_find_by_uuid() - Find switch by UUID
3630 * tb_switch_find_by_route() - Find switch by route string
3643 return tb_switch_get(tb->root_switch); in tb_switch_find_by_route()
3657 * tb_switch_find_port() - return the first port of @type on @sw or NULL
3667 if (port->config.type == type) in tb_switch_find_port()
3684 if (sw->generation != 3) in tb_switch_pcie_bridge_write()
3685 return -EOPNOTSUPP; in tb_switch_pcie_bridge_write()
3687 offset = sw->cap_plug_events + TB_PLUG_EVENTS_PCIE_WR_DATA; in tb_switch_pcie_bridge_write()
3699 offset = sw->cap_plug_events + TB_PLUG_EVENTS_PCIE_CMD; in tb_switch_pcie_bridge_write()
3715 return -ETIMEDOUT; in tb_switch_pcie_bridge_write()
3721 * tb_switch_pcie_l1_enable() - Enable PCIe link to enter L1 state
3754 * tb_switch_xhci_connect() - Connect internal xHCI
3759 * connected to the type-C port. Call only after PCIe tunnel has been
3768 if (sw->generation != 3) in tb_switch_xhci_connect()
3771 port1 = &sw->ports[1]; in tb_switch_xhci_connect()
3772 port3 = &sw->ports[3]; in tb_switch_xhci_connect()
3801 * tb_switch_xhci_disconnect() - Disconnect internal xHCI
3809 if (sw->generation == 3) { in tb_switch_xhci_disconnect()
3810 struct tb_port *port1 = &sw->ports[1]; in tb_switch_xhci_disconnect()
3811 struct tb_port *port3 = &sw->ports[3]; in tb_switch_xhci_disconnect()