Lines Matching full:sw
37 static struct nvm_auth_status *__nvm_get_auth_status(const struct tb_switch *sw) in __nvm_get_auth_status() argument
42 if (uuid_equal(&st->uuid, sw->uuid)) in __nvm_get_auth_status()
49 static void nvm_get_auth_status(const struct tb_switch *sw, u32 *status) in nvm_get_auth_status() argument
54 st = __nvm_get_auth_status(sw); in nvm_get_auth_status()
60 static void nvm_set_auth_status(const struct tb_switch *sw, u32 status) in nvm_set_auth_status() argument
64 if (WARN_ON(!sw->uuid)) in nvm_set_auth_status()
68 st = __nvm_get_auth_status(sw); in nvm_set_auth_status()
75 memcpy(&st->uuid, sw->uuid, sizeof(st->uuid)); in nvm_set_auth_status()
85 static void nvm_clear_auth_status(const struct tb_switch *sw) in nvm_clear_auth_status() argument
90 st = __nvm_get_auth_status(sw); in nvm_clear_auth_status()
98 static int nvm_validate_and_write(struct tb_switch *sw) in nvm_validate_and_write() argument
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()
115 if (tb_switch_is_usb4(sw)) in nvm_validate_and_write()
116 ret = usb4_switch_nvm_write(sw, 0, buf, image_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()
126 static int nvm_authenticate_host_dma_port(struct tb_switch *sw) in nvm_authenticate_host_dma_port() argument
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()
153 tb_sw_warn(sw, "failed to authenticate NVM, power cycling\n"); 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()
155 nvm_set_auth_status(sw, status); in nvm_authenticate_host_dma_port()
162 dma_port_power_cycle(sw->dma_port); in nvm_authenticate_host_dma_port()
166 static int nvm_authenticate_device_dma_port(struct tb_switch *sw) in nvm_authenticate_device_dma_port() argument
170 ret = dma_port_flash_update_auth(sw->dma_port); in nvm_authenticate_device_dma_port()
191 ret = dma_port_flash_update_auth_status(sw->dma_port, &status); in nvm_authenticate_device_dma_port()
196 tb_sw_warn(sw, "failed to authenticate NVM\n"); in nvm_authenticate_device_dma_port()
197 nvm_set_auth_status(sw, status); in nvm_authenticate_device_dma_port()
200 tb_sw_info(sw, "power cycling the switch now\n"); in nvm_authenticate_device_dma_port()
201 dma_port_power_cycle(sw->dma_port); in nvm_authenticate_device_dma_port()
211 static void nvm_authenticate_start_dma_port(struct tb_switch *sw) in nvm_authenticate_start_dma_port() argument
221 root_port = pcie_find_root_port(sw->tb->nhi->pdev); in nvm_authenticate_start_dma_port()
226 static void nvm_authenticate_complete_dma_port(struct tb_switch *sw) in nvm_authenticate_complete_dma_port() argument
230 root_port = pcie_find_root_port(sw->tb->nhi->pdev); in nvm_authenticate_complete_dma_port()
235 static inline bool nvm_readable(struct tb_switch *sw) in nvm_readable() argument
237 if (tb_switch_is_usb4(sw)) { in nvm_readable()
244 return usb4_switch_nvm_sector_size(sw) > 0; in nvm_readable()
248 return !!sw->dma_port; in nvm_readable()
251 static inline bool nvm_upgradeable(struct tb_switch *sw) in nvm_upgradeable() argument
253 if (sw->no_nvm_upgrade) in nvm_upgradeable()
255 return nvm_readable(sw); in nvm_upgradeable()
258 static int nvm_authenticate(struct tb_switch *sw, bool auth_only) in nvm_authenticate() argument
262 if (tb_switch_is_usb4(sw)) { in nvm_authenticate()
264 ret = usb4_switch_nvm_set_offset(sw, 0); in nvm_authenticate()
268 sw->nvm->authenticating = true; in nvm_authenticate()
269 return usb4_switch_nvm_authenticate(sw); in nvm_authenticate()
274 sw->nvm->authenticating = true; in nvm_authenticate()
275 if (!tb_route(sw)) { in nvm_authenticate()
276 nvm_authenticate_start_dma_port(sw); in nvm_authenticate()
277 ret = nvm_authenticate_host_dma_port(sw); in nvm_authenticate()
279 ret = nvm_authenticate_device_dma_port(sw); in nvm_authenticate()
287 * @sw: Router whose NVM to read
296 int tb_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf, in tb_switch_nvm_read() argument
299 if (tb_switch_is_usb4(sw)) in tb_switch_nvm_read()
300 return usb4_switch_nvm_read(sw, address, buf, size); in tb_switch_nvm_read()
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() local
310 pm_runtime_get_sync(&sw->dev); in nvm_read()
312 if (!mutex_trylock(&sw->tb->lock)) { in nvm_read()
317 ret = tb_switch_nvm_read(sw, offset, val, bytes); 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() local
333 if (!mutex_trylock(&sw->tb->lock)) in nvm_write()
343 mutex_unlock(&sw->tb->lock); in nvm_write()
348 static int tb_switch_nvm_add(struct tb_switch *sw) in tb_switch_nvm_add() argument
353 if (!nvm_readable(sw)) in tb_switch_nvm_add()
356 nvm = tb_nvm_alloc(&sw->dev); in tb_switch_nvm_add()
371 if (!sw->safe_mode) { in tb_switch_nvm_add()
377 if (!sw->no_nvm_upgrade) { in tb_switch_nvm_add()
383 sw->nvm = nvm; in tb_switch_nvm_add()
387 tb_sw_dbg(sw, "NVM upgrade disabled\n"); in tb_switch_nvm_add()
388 sw->no_nvm_upgrade = true; in tb_switch_nvm_add()
395 static void tb_switch_nvm_remove(struct tb_switch *sw) in tb_switch_nvm_remove() argument
399 nvm = sw->nvm; in tb_switch_nvm_remove()
400 sw->nvm = NULL; in tb_switch_nvm_remove()
407 nvm_clear_auth_status(sw); in tb_switch_nvm_remove()
570 if (credits == 0 || port->sw->is_unplugged) in tb_port_add_nfc_credits()
577 if (tb_switch_is_usb4(port->sw) && !tb_port_is_null(port)) in tb_port_add_nfc_credits()
619 if (tb_switch_is_icm(port->sw)) in tb_port_unlock()
623 if (tb_switch_is_usb4(port->sw)) in tb_port_unlock()
700 tb_dbg(port->sw->tb, " Port %d: not implemented\n", in tb_init_port()
745 tb_dump_port(port->sw->tb, port); in tb_init_port()
825 const struct tb_switch *sw) in tb_switch_is_reachable() argument
828 return (tb_route(parent) & mask) == (tb_route(sw) & mask); in tb_switch_is_reachable()
854 if (prev->sw == end->sw) { in tb_next_port_on_path()
860 if (tb_switch_is_reachable(prev->sw, end->sw)) { in tb_next_port_on_path()
861 next = tb_port_at(tb_route(end->sw), prev->sw); in tb_next_port_on_path()
870 next = tb_upstream_port(prev->sw); in tb_next_port_on_path()
1213 if (tb_switch_is_usb4(port->sw)) in tb_port_start_lane_initialization()
1388 if (tb_switch_is_usb4(port->sw)) in tb_dp_port_set_hops()
1454 static const char *tb_switch_generation_name(const struct tb_switch *sw) in tb_switch_generation_name() argument
1456 switch (sw->generation) { in tb_switch_generation_name()
1470 static void tb_dump_switch(const struct tb *tb, const struct tb_switch *sw) in tb_dump_switch() argument
1472 const struct tb_regs_switch_header *regs = &sw->config; in tb_dump_switch()
1475 tb_switch_generation_name(sw), regs->vendor_id, regs->device_id, in tb_dump_switch()
1490 * @sw: Switch to reset
1494 int tb_switch_reset(struct tb_switch *sw) in tb_switch_reset() argument
1498 if (sw->generation > 1) in tb_switch_reset()
1501 tb_sw_dbg(sw, "resetting switch\n"); in tb_switch_reset()
1503 res.err = tb_sw_write(sw, ((u32 *) &sw->config) + 2, in tb_switch_reset()
1507 res = tb_cfg_reset(sw->tb->ctl, tb_route(sw)); in tb_switch_reset()
1515 * @sw: Router to read the offset value from
1525 int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit, in tb_switch_wait_for_bit() argument
1534 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, offset, 1); in tb_switch_wait_for_bit()
1554 static int tb_plug_events_active(struct tb_switch *sw, bool active) in tb_plug_events_active() argument
1559 if (tb_switch_is_icm(sw) || tb_switch_is_usb4(sw)) in tb_plug_events_active()
1562 sw->config.plug_events_delay = 0xff; in tb_plug_events_active()
1563 res = tb_sw_write(sw, ((u32 *) &sw->config) + 4, TB_CFG_SWITCH, 4, 1); in tb_plug_events_active()
1567 res = tb_sw_read(sw, &data, TB_CFG_SWITCH, sw->cap_plug_events + 1, 1); in tb_plug_events_active()
1573 switch (sw->config.device_id) { in tb_plug_events_active()
1584 if (!tb_switch_is_alpine_ridge(sw)) in tb_plug_events_active()
1590 return tb_sw_write(sw, &data, TB_CFG_SWITCH, in tb_plug_events_active()
1591 sw->cap_plug_events + 1, 1); in tb_plug_events_active()
1598 struct tb_switch *sw = tb_to_switch(dev); in authorized_show() local
1600 return sysfs_emit(buf, "%u\n", sw->authorized); in authorized_show()
1606 struct tb_switch *sw; in disapprove_switch() local
1608 sw = tb_to_switch(dev); in disapprove_switch()
1609 if (sw && sw->authorized) { in disapprove_switch()
1613 ret = device_for_each_child_reverse(&sw->dev, NULL, disapprove_switch); in disapprove_switch()
1617 ret = tb_domain_disapprove_switch(sw->tb, sw); in disapprove_switch()
1621 sw->authorized = 0; in disapprove_switch()
1622 kobject_uevent_env(&sw->dev.kobj, KOBJ_CHANGE, envp); in disapprove_switch()
1628 static int tb_switch_set_authorized(struct tb_switch *sw, unsigned int val) in tb_switch_set_authorized() argument
1634 if (!mutex_trylock(&sw->tb->lock)) in tb_switch_set_authorized()
1637 if (!!sw->authorized == !!val) in tb_switch_set_authorized()
1643 if (tb_route(sw)) { in tb_switch_set_authorized()
1644 ret = disapprove_switch(&sw->dev, NULL); in tb_switch_set_authorized()
1651 if (sw->key) in tb_switch_set_authorized()
1652 ret = tb_domain_approve_switch_key(sw->tb, sw); in tb_switch_set_authorized()
1654 ret = tb_domain_approve_switch(sw->tb, sw); in tb_switch_set_authorized()
1659 if (sw->key) in tb_switch_set_authorized()
1660 ret = tb_domain_challenge_switch_key(sw->tb, sw); in tb_switch_set_authorized()
1668 sw->authorized = val; in tb_switch_set_authorized()
1673 sprintf(envp_string, "AUTHORIZED=%u", sw->authorized); in tb_switch_set_authorized()
1674 kobject_uevent_env(&sw->dev.kobj, KOBJ_CHANGE, envp); in tb_switch_set_authorized()
1678 mutex_unlock(&sw->tb->lock); in tb_switch_set_authorized()
1686 struct tb_switch *sw = tb_to_switch(dev); in authorized_store() local
1696 pm_runtime_get_sync(&sw->dev); in authorized_store()
1697 ret = tb_switch_set_authorized(sw, val); in authorized_store()
1698 pm_runtime_mark_last_busy(&sw->dev); in authorized_store()
1699 pm_runtime_put_autosuspend(&sw->dev); in authorized_store()
1708 struct tb_switch *sw = tb_to_switch(dev); in boot_show() local
1710 return sysfs_emit(buf, "%u\n", sw->boot); in boot_show()
1717 struct tb_switch *sw = tb_to_switch(dev); in device_show() local
1719 return sysfs_emit(buf, "%#x\n", sw->device); in device_show()
1726 struct tb_switch *sw = tb_to_switch(dev); in device_name_show() local
1728 return sysfs_emit(buf, "%s\n", sw->device_name ?: ""); in device_name_show()
1735 struct tb_switch *sw = tb_to_switch(dev); in generation_show() local
1737 return sysfs_emit(buf, "%u\n", sw->generation); in generation_show()
1744 struct tb_switch *sw = tb_to_switch(dev); in key_show() local
1747 if (!mutex_trylock(&sw->tb->lock)) in key_show()
1750 if (sw->key) in key_show()
1751 ret = sysfs_emit(buf, "%*phN\n", TB_SWITCH_KEY_SIZE, sw->key); in key_show()
1755 mutex_unlock(&sw->tb->lock); in key_show()
1762 struct tb_switch *sw = tb_to_switch(dev); in key_store() local
1772 if (!mutex_trylock(&sw->tb->lock)) in key_store()
1775 if (sw->authorized) { in key_store()
1778 kfree(sw->key); in key_store()
1780 sw->key = NULL; in key_store()
1782 sw->key = kmemdup(key, sizeof(key), GFP_KERNEL); in key_store()
1783 if (!sw->key) in key_store()
1788 mutex_unlock(&sw->tb->lock); in key_store()
1796 struct tb_switch *sw = tb_to_switch(dev); in speed_show() local
1798 return sysfs_emit(buf, "%u.0 Gb/s\n", sw->link_speed); in speed_show()
1811 struct tb_switch *sw = tb_to_switch(dev); in rx_lanes_show() local
1814 switch (sw->link_width) { in rx_lanes_show()
1837 struct tb_switch *sw = tb_to_switch(dev); in tx_lanes_show() local
1840 switch (sw->link_width) { in tx_lanes_show()
1863 struct tb_switch *sw = tb_to_switch(dev); in nvm_authenticate_show() local
1866 nvm_get_auth_status(sw, &status); in nvm_authenticate_show()
1873 struct tb_switch *sw = tb_to_switch(dev); in nvm_authenticate_sysfs() local
1876 pm_runtime_get_sync(&sw->dev); in nvm_authenticate_sysfs()
1878 if (!mutex_trylock(&sw->tb->lock)) { in nvm_authenticate_sysfs()
1883 if (sw->no_nvm_upgrade) { in nvm_authenticate_sysfs()
1889 if (!sw->nvm) { in nvm_authenticate_sysfs()
1899 nvm_clear_auth_status(sw); in nvm_authenticate_sysfs()
1906 ret = nvm_authenticate(sw, true); in nvm_authenticate_sysfs()
1908 if (!sw->nvm->flushed) { in nvm_authenticate_sysfs()
1909 if (!sw->nvm->buf) { in nvm_authenticate_sysfs()
1914 ret = nvm_validate_and_write(sw); in nvm_authenticate_sysfs()
1920 ret = tb_lc_force_power(sw); in nvm_authenticate_sysfs()
1922 ret = nvm_authenticate(sw, false); in nvm_authenticate_sysfs()
1928 mutex_unlock(&sw->tb->lock); in nvm_authenticate_sysfs()
1930 pm_runtime_mark_last_busy(&sw->dev); in nvm_authenticate_sysfs()
1931 pm_runtime_put_autosuspend(&sw->dev); in nvm_authenticate_sysfs()
1965 struct tb_switch *sw = tb_to_switch(dev); in nvm_version_show() local
1968 if (!mutex_trylock(&sw->tb->lock)) in nvm_version_show()
1971 if (sw->safe_mode) in nvm_version_show()
1973 else if (!sw->nvm) in nvm_version_show()
1976 ret = sysfs_emit(buf, "%x.%x\n", sw->nvm->major, sw->nvm->minor); in nvm_version_show()
1978 mutex_unlock(&sw->tb->lock); in nvm_version_show()
1987 struct tb_switch *sw = tb_to_switch(dev); in vendor_show() local
1989 return sysfs_emit(buf, "%#x\n", sw->vendor); in vendor_show()
1996 struct tb_switch *sw = tb_to_switch(dev); in vendor_name_show() local
1998 return sysfs_emit(buf, "%s\n", sw->vendor_name ?: ""); in vendor_name_show()
2005 struct tb_switch *sw = tb_to_switch(dev); in unique_id_show() local
2007 return sysfs_emit(buf, "%pUb\n", sw->uuid); in unique_id_show()
2035 struct tb_switch *sw = tb_to_switch(dev); in switch_attr_is_visible() local
2038 if (sw->tb->security_level == TB_SECURITY_NOPCIE || in switch_attr_is_visible()
2039 sw->tb->security_level == TB_SECURITY_DPONLY) in switch_attr_is_visible()
2042 if (!sw->device) in switch_attr_is_visible()
2045 if (!sw->device_name) in switch_attr_is_visible()
2048 if (!sw->vendor) in switch_attr_is_visible()
2051 if (!sw->vendor_name) in switch_attr_is_visible()
2054 if (tb_route(sw) && in switch_attr_is_visible()
2055 sw->tb->security_level == TB_SECURITY_SECURE && in switch_attr_is_visible()
2056 sw->security_level == TB_SECURITY_SECURE) in switch_attr_is_visible()
2063 if (tb_route(sw)) in switch_attr_is_visible()
2067 if (nvm_upgradeable(sw)) in switch_attr_is_visible()
2071 if (nvm_readable(sw)) in switch_attr_is_visible()
2075 if (tb_route(sw)) in switch_attr_is_visible()
2079 if (sw->quirks & QUIRK_FORCE_POWER_LINK_CONTROLLER) in switch_attr_is_visible()
2084 return sw->safe_mode ? 0 : attr->mode; in switch_attr_is_visible()
2099 struct tb_switch *sw = tb_to_switch(dev); in tb_switch_release() local
2102 dma_port_free(sw->dma_port); in tb_switch_release()
2104 tb_switch_for_each_port(sw, port) { in tb_switch_release()
2109 kfree(sw->uuid); in tb_switch_release()
2110 kfree(sw->device_name); in tb_switch_release()
2111 kfree(sw->vendor_name); in tb_switch_release()
2112 kfree(sw->ports); in tb_switch_release()
2113 kfree(sw->drom); in tb_switch_release()
2114 kfree(sw->key); in tb_switch_release()
2115 kfree(sw); in tb_switch_release()
2120 const struct tb_switch *sw = tb_to_switch(dev); in tb_switch_uevent() local
2123 if (tb_switch_is_usb4(sw)) { in tb_switch_uevent()
2125 usb4_switch_version(sw))) in tb_switch_uevent()
2129 if (!tb_route(sw)) { in tb_switch_uevent()
2136 tb_switch_for_each_port(sw, port) { in tb_switch_uevent()
2158 struct tb_switch *sw = tb_to_switch(dev); in tb_switch_runtime_suspend() local
2159 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in tb_switch_runtime_suspend()
2162 return cm_ops->runtime_suspend_switch(sw); in tb_switch_runtime_suspend()
2169 struct tb_switch *sw = tb_to_switch(dev); in tb_switch_runtime_resume() local
2170 const struct tb_cm_ops *cm_ops = sw->tb->cm_ops; in tb_switch_runtime_resume()
2173 return cm_ops->runtime_resume_switch(sw); in tb_switch_runtime_resume()
2189 static int tb_switch_get_generation(struct tb_switch *sw) in tb_switch_get_generation() argument
2191 if (tb_switch_is_usb4(sw)) in tb_switch_get_generation()
2194 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_get_generation()
2195 switch (sw->config.device_id) { in tb_switch_get_generation()
2229 tb_sw_warn(sw, "unsupported switch device id %#x\n", in tb_switch_get_generation()
2230 sw->config.device_id); in tb_switch_get_generation()
2234 static bool tb_switch_exceeds_max_depth(const struct tb_switch *sw, int depth) in tb_switch_exceeds_max_depth() argument
2238 if (tb_switch_is_usb4(sw) || in tb_switch_exceeds_max_depth()
2239 (sw->tb->root_switch && tb_switch_is_usb4(sw->tb->root_switch))) in tb_switch_exceeds_max_depth()
2264 struct tb_switch *sw; in tb_switch_alloc() local
2283 sw = kzalloc(sizeof(*sw), GFP_KERNEL); in tb_switch_alloc()
2284 if (!sw) in tb_switch_alloc()
2287 sw->tb = tb; in tb_switch_alloc()
2288 ret = tb_cfg_read(tb->ctl, &sw->config, route, 0, TB_CFG_SWITCH, 0, 5); in tb_switch_alloc()
2292 sw->generation = tb_switch_get_generation(sw); in tb_switch_alloc()
2295 tb_dump_switch(tb, sw); in tb_switch_alloc()
2298 sw->config.upstream_port_number = upstream_port; in tb_switch_alloc()
2299 sw->config.depth = depth; in tb_switch_alloc()
2300 sw->config.route_hi = upper_32_bits(route); in tb_switch_alloc()
2301 sw->config.route_lo = lower_32_bits(route); in tb_switch_alloc()
2302 sw->config.enabled = 0; in tb_switch_alloc()
2305 if (tb_switch_exceeds_max_depth(sw, depth)) { in tb_switch_alloc()
2311 sw->ports = kcalloc(sw->config.max_port_number + 1, sizeof(*sw->ports), in tb_switch_alloc()
2313 if (!sw->ports) { in tb_switch_alloc()
2318 for (i = 0; i <= sw->config.max_port_number; i++) { in tb_switch_alloc()
2320 sw->ports[i].sw = sw; in tb_switch_alloc()
2321 sw->ports[i].port = i; in tb_switch_alloc()
2325 ida_init(&sw->ports[i].in_hopids); in tb_switch_alloc()
2326 ida_init(&sw->ports[i].out_hopids); in tb_switch_alloc()
2330 ret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS); in tb_switch_alloc()
2332 sw->cap_plug_events = ret; in tb_switch_alloc()
2334 ret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_TIME2); in tb_switch_alloc()
2336 sw->cap_vsec_tmu = ret; in tb_switch_alloc()
2338 ret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_LINK_CONTROLLER); in tb_switch_alloc()
2340 sw->cap_lc = ret; in tb_switch_alloc()
2342 ret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_CP_LP); in tb_switch_alloc()
2344 sw->cap_lp = ret; in tb_switch_alloc()
2348 sw->authorized = true; in tb_switch_alloc()
2350 device_initialize(&sw->dev); in tb_switch_alloc()
2351 sw->dev.parent = parent; in tb_switch_alloc()
2352 sw->dev.bus = &tb_bus_type; in tb_switch_alloc()
2353 sw->dev.type = &tb_switch_type; in tb_switch_alloc()
2354 sw->dev.groups = switch_groups; in tb_switch_alloc()
2355 dev_set_name(&sw->dev, "%u-%llx", tb->index, tb_route(sw)); in tb_switch_alloc()
2357 return sw; in tb_switch_alloc()
2360 kfree(sw->ports); in tb_switch_alloc()
2361 kfree(sw); in tb_switch_alloc()
2383 struct tb_switch *sw; in tb_switch_alloc_safe_mode() local
2385 sw = kzalloc(sizeof(*sw), GFP_KERNEL); in tb_switch_alloc_safe_mode()
2386 if (!sw) in tb_switch_alloc_safe_mode()
2389 sw->tb = tb; in tb_switch_alloc_safe_mode()
2390 sw->config.depth = tb_route_length(route); in tb_switch_alloc_safe_mode()
2391 sw->config.route_hi = upper_32_bits(route); in tb_switch_alloc_safe_mode()
2392 sw->config.route_lo = lower_32_bits(route); in tb_switch_alloc_safe_mode()
2393 sw->safe_mode = true; in tb_switch_alloc_safe_mode()
2395 device_initialize(&sw->dev); in tb_switch_alloc_safe_mode()
2396 sw->dev.parent = parent; in tb_switch_alloc_safe_mode()
2397 sw->dev.bus = &tb_bus_type; in tb_switch_alloc_safe_mode()
2398 sw->dev.type = &tb_switch_type; in tb_switch_alloc_safe_mode()
2399 sw->dev.groups = switch_groups; in tb_switch_alloc_safe_mode()
2400 dev_set_name(&sw->dev, "%u-%llx", tb->index, tb_route(sw)); in tb_switch_alloc_safe_mode()
2402 return sw; in tb_switch_alloc_safe_mode()
2407 * @sw: Switch to configure
2416 int tb_switch_configure(struct tb_switch *sw) in tb_switch_configure() argument
2418 struct tb *tb = sw->tb; in tb_switch_configure()
2422 route = tb_route(sw); in tb_switch_configure()
2425 sw->config.enabled ? "restoring" : "initializing", route, in tb_switch_configure()
2426 tb_route_length(route), sw->config.upstream_port_number); in tb_switch_configure()
2428 sw->config.enabled = 1; in tb_switch_configure()
2430 if (tb_switch_is_usb4(sw)) { in tb_switch_configure()
2437 if (usb4_switch_version(sw) < 2) in tb_switch_configure()
2438 sw->config.cmuv = ROUTER_CS_4_CMUV_V1; in tb_switch_configure()
2440 sw->config.cmuv = ROUTER_CS_4_CMUV_V2; in tb_switch_configure()
2441 sw->config.plug_events_delay = 0xa; in tb_switch_configure()
2444 ret = tb_sw_write(sw, (u32 *)&sw->config + 1, TB_CFG_SWITCH, in tb_switch_configure()
2449 ret = usb4_switch_setup(sw); in tb_switch_configure()
2451 if (sw->config.vendor_id != PCI_VENDOR_ID_INTEL) in tb_switch_configure()
2452 tb_sw_warn(sw, "unknown switch vendor id %#x\n", in tb_switch_configure()
2453 sw->config.vendor_id); in tb_switch_configure()
2455 if (!sw->cap_plug_events) { in tb_switch_configure()
2456 tb_sw_warn(sw, "cannot find TB_VSE_CAP_PLUG_EVENTS aborting\n"); in tb_switch_configure()
2461 ret = tb_sw_write(sw, (u32 *)&sw->config + 1, TB_CFG_SWITCH, in tb_switch_configure()
2467 return tb_plug_events_active(sw, true); in tb_switch_configure()
2472 * @sw: Router to configure
2479 int tb_switch_configuration_valid(struct tb_switch *sw) in tb_switch_configuration_valid() argument
2481 if (tb_switch_is_usb4(sw)) in tb_switch_configuration_valid()
2482 return usb4_switch_configuration_valid(sw); in tb_switch_configuration_valid()
2486 static int tb_switch_set_uuid(struct tb_switch *sw) in tb_switch_set_uuid() argument
2492 if (sw->uuid) in tb_switch_set_uuid()
2495 if (tb_switch_is_usb4(sw)) { in tb_switch_set_uuid()
2496 ret = usb4_switch_read_uid(sw, &sw->uid); in tb_switch_set_uuid()
2505 ret = tb_lc_read_uuid(sw, uuid); in tb_switch_set_uuid()
2520 uuid[0] = sw->uid & 0xffffffff; in tb_switch_set_uuid()
2521 uuid[1] = (sw->uid >> 32) & 0xffffffff; in tb_switch_set_uuid()
2526 sw->uuid = kmemdup(uuid, sizeof(uuid), GFP_KERNEL); in tb_switch_set_uuid()
2527 if (!sw->uuid) in tb_switch_set_uuid()
2532 static int tb_switch_add_dma_port(struct tb_switch *sw) in tb_switch_add_dma_port() argument
2537 switch (sw->generation) { in tb_switch_add_dma_port()
2540 if (tb_route(sw)) in tb_switch_add_dma_port()
2546 ret = tb_switch_set_uuid(sw); in tb_switch_add_dma_port()
2556 if (!sw->safe_mode) in tb_switch_add_dma_port()
2561 if (sw->no_nvm_upgrade) in tb_switch_add_dma_port()
2564 if (tb_switch_is_usb4(sw)) { in tb_switch_add_dma_port()
2565 ret = usb4_switch_nvm_authenticate_status(sw, &status); in tb_switch_add_dma_port()
2570 tb_sw_info(sw, "switch flash authentication failed\n"); in tb_switch_add_dma_port()
2571 nvm_set_auth_status(sw, status); in tb_switch_add_dma_port()
2578 if (!tb_route(sw) && !tb_switch_is_icm(sw)) in tb_switch_add_dma_port()
2581 sw->dma_port = dma_port_alloc(sw); in tb_switch_add_dma_port()
2582 if (!sw->dma_port) in tb_switch_add_dma_port()
2591 nvm_get_auth_status(sw, &status); in tb_switch_add_dma_port()
2593 if (!tb_route(sw)) in tb_switch_add_dma_port()
2594 nvm_authenticate_complete_dma_port(sw); in tb_switch_add_dma_port()
2603 ret = dma_port_flash_update_auth_status(sw->dma_port, &status); in tb_switch_add_dma_port()
2608 if (!tb_route(sw)) in tb_switch_add_dma_port()
2609 nvm_authenticate_complete_dma_port(sw); in tb_switch_add_dma_port()
2612 tb_sw_info(sw, "switch flash authentication failed\n"); in tb_switch_add_dma_port()
2613 nvm_set_auth_status(sw, status); in tb_switch_add_dma_port()
2616 tb_sw_info(sw, "power cycling the switch now\n"); in tb_switch_add_dma_port()
2617 dma_port_power_cycle(sw->dma_port); in tb_switch_add_dma_port()
2626 static void tb_switch_default_link_ports(struct tb_switch *sw) in tb_switch_default_link_ports() argument
2630 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_switch_default_link_ports()
2631 struct tb_port *port = &sw->ports[i]; in tb_switch_default_link_ports()
2638 if (i == sw->config.max_port_number || in tb_switch_default_link_ports()
2639 !tb_port_is_null(&sw->ports[i + 1])) in tb_switch_default_link_ports()
2643 subordinate = &sw->ports[i + 1]; in tb_switch_default_link_ports()
2650 tb_sw_dbg(sw, "linked ports %d <-> %d\n", in tb_switch_default_link_ports()
2656 static bool tb_switch_lane_bonding_possible(struct tb_switch *sw) in tb_switch_lane_bonding_possible() argument
2658 const struct tb_port *up = tb_upstream_port(sw); in tb_switch_lane_bonding_possible()
2663 if (tb_switch_is_usb4(sw)) in tb_switch_lane_bonding_possible()
2664 return usb4_switch_lane_bonding_possible(sw); in tb_switch_lane_bonding_possible()
2665 return tb_lc_lane_bonding_possible(sw); in tb_switch_lane_bonding_possible()
2668 static int tb_switch_update_link_attributes(struct tb_switch *sw) in tb_switch_update_link_attributes() argument
2674 if (!tb_route(sw) || tb_switch_is_icm(sw)) in tb_switch_update_link_attributes()
2677 up = tb_upstream_port(sw); in tb_switch_update_link_attributes()
2682 if (sw->link_speed != ret) in tb_switch_update_link_attributes()
2684 sw->link_speed = ret; in tb_switch_update_link_attributes()
2689 if (sw->link_width != ret) in tb_switch_update_link_attributes()
2691 sw->link_width = ret; in tb_switch_update_link_attributes()
2694 if (device_is_registered(&sw->dev) && change) in tb_switch_update_link_attributes()
2695 kobject_uevent(&sw->dev.kobj, KOBJ_CHANGE); in tb_switch_update_link_attributes()
2702 * @sw: Switch to enable lane bonding
2708 int tb_switch_lane_bonding_enable(struct tb_switch *sw) in tb_switch_lane_bonding_enable() argument
2711 u64 route = tb_route(sw); in tb_switch_lane_bonding_enable()
2718 if (!tb_switch_lane_bonding_possible(sw)) in tb_switch_lane_bonding_enable()
2721 up = tb_upstream_port(sw); in tb_switch_lane_bonding_enable()
2722 down = tb_switch_downstream_port(sw); in tb_switch_lane_bonding_enable()
2760 tb_switch_update_link_attributes(sw); in tb_switch_lane_bonding_enable()
2762 tb_sw_dbg(sw, "lane bonding enabled\n"); in tb_switch_lane_bonding_enable()
2768 * @sw: Switch whose lane bonding to disable
2770 * Disables lane bonding between @sw and parent. This can be called even
2773 void tb_switch_lane_bonding_disable(struct tb_switch *sw) in tb_switch_lane_bonding_disable() argument
2778 if (!tb_route(sw)) in tb_switch_lane_bonding_disable()
2781 up = tb_upstream_port(sw); in tb_switch_lane_bonding_disable()
2785 down = tb_switch_downstream_port(sw); in tb_switch_lane_bonding_disable()
2796 tb_sw_warn(sw, "timeout disabling lane bonding\n"); in tb_switch_lane_bonding_disable()
2800 tb_switch_update_link_attributes(sw); in tb_switch_lane_bonding_disable()
2802 tb_sw_dbg(sw, "lane bonding disabled\n"); in tb_switch_lane_bonding_disable()
2807 * @sw: Switch whose link is configured
2809 * Sets the link upstream from @sw configured (from both ends) so that
2817 int tb_switch_configure_link(struct tb_switch *sw) in tb_switch_configure_link() argument
2822 if (!tb_route(sw) || tb_switch_is_icm(sw)) in tb_switch_configure_link()
2825 up = tb_upstream_port(sw); in tb_switch_configure_link()
2826 if (tb_switch_is_usb4(up->sw)) in tb_switch_configure_link()
2834 if (tb_switch_is_usb4(down->sw)) in tb_switch_configure_link()
2841 * @sw: Switch whose link is unconfigured
2843 * Sets the link unconfigured so the @sw will be disconnected if the
2846 void tb_switch_unconfigure_link(struct tb_switch *sw) in tb_switch_unconfigure_link() argument
2850 if (sw->is_unplugged) in tb_switch_unconfigure_link()
2852 if (!tb_route(sw) || tb_switch_is_icm(sw)) in tb_switch_unconfigure_link()
2855 up = tb_upstream_port(sw); in tb_switch_unconfigure_link()
2856 if (tb_switch_is_usb4(up->sw)) in tb_switch_unconfigure_link()
2862 if (tb_switch_is_usb4(down->sw)) in tb_switch_unconfigure_link()
2868 static void tb_switch_credits_init(struct tb_switch *sw) in tb_switch_credits_init() argument
2870 if (tb_switch_is_icm(sw)) in tb_switch_credits_init()
2872 if (!tb_switch_is_usb4(sw)) in tb_switch_credits_init()
2874 if (usb4_switch_credits_init(sw)) in tb_switch_credits_init()
2875 tb_sw_info(sw, "failed to determine preferred buffer allocation, using defaults\n"); in tb_switch_credits_init()
2878 static int tb_switch_port_hotplug_enable(struct tb_switch *sw) in tb_switch_port_hotplug_enable() argument
2882 if (tb_switch_is_icm(sw)) in tb_switch_port_hotplug_enable()
2885 tb_switch_for_each_port(sw, port) { in tb_switch_port_hotplug_enable()
2900 * @sw: Switch to add
2910 int tb_switch_add(struct tb_switch *sw) in tb_switch_add() argument
2921 ret = tb_switch_add_dma_port(sw); in tb_switch_add()
2923 dev_err(&sw->dev, "failed to add DMA port\n"); in tb_switch_add()
2927 if (!sw->safe_mode) { in tb_switch_add()
2928 tb_switch_credits_init(sw); in tb_switch_add()
2931 ret = tb_drom_read(sw); in tb_switch_add()
2933 dev_warn(&sw->dev, "reading DROM failed: %d\n", ret); in tb_switch_add()
2934 tb_sw_dbg(sw, "uid: %#llx\n", sw->uid); in tb_switch_add()
2936 ret = tb_switch_set_uuid(sw); in tb_switch_add()
2938 dev_err(&sw->dev, "failed to set UUID\n"); in tb_switch_add()
2942 for (i = 0; i <= sw->config.max_port_number; i++) { in tb_switch_add()
2943 if (sw->ports[i].disabled) { in tb_switch_add()
2944 tb_port_dbg(&sw->ports[i], "disabled by eeprom\n"); in tb_switch_add()
2947 ret = tb_init_port(&sw->ports[i]); in tb_switch_add()
2949 dev_err(&sw->dev, "failed to initialize port %d\n", i); in tb_switch_add()
2954 tb_check_quirks(sw); in tb_switch_add()
2956 tb_switch_default_link_ports(sw); in tb_switch_add()
2958 ret = tb_switch_update_link_attributes(sw); in tb_switch_add()
2962 ret = tb_switch_clx_init(sw); in tb_switch_add()
2966 ret = tb_switch_tmu_init(sw); in tb_switch_add()
2971 ret = tb_switch_port_hotplug_enable(sw); in tb_switch_add()
2975 ret = device_add(&sw->dev); in tb_switch_add()
2977 dev_err(&sw->dev, "failed to add device: %d\n", ret); in tb_switch_add()
2981 if (tb_route(sw)) { in tb_switch_add()
2982 dev_info(&sw->dev, "new device found, vendor=%#x device=%#x\n", in tb_switch_add()
2983 sw->vendor, sw->device); in tb_switch_add()
2984 if (sw->vendor_name && sw->device_name) in tb_switch_add()
2985 dev_info(&sw->dev, "%s %s\n", sw->vendor_name, in tb_switch_add()
2986 sw->device_name); in tb_switch_add()
2989 ret = usb4_switch_add_ports(sw); in tb_switch_add()
2991 dev_err(&sw->dev, "failed to add USB4 ports\n"); in tb_switch_add()
2995 ret = tb_switch_nvm_add(sw); in tb_switch_add()
2997 dev_err(&sw->dev, "failed to add NVM devices\n"); in tb_switch_add()
3006 device_init_wakeup(&sw->dev, true); in tb_switch_add()
3008 pm_runtime_set_active(&sw->dev); in tb_switch_add()
3009 if (sw->rpm) { in tb_switch_add()
3010 pm_runtime_set_autosuspend_delay(&sw->dev, TB_AUTOSUSPEND_DELAY); in tb_switch_add()
3011 pm_runtime_use_autosuspend(&sw->dev); in tb_switch_add()
3012 pm_runtime_mark_last_busy(&sw->dev); in tb_switch_add()
3013 pm_runtime_enable(&sw->dev); in tb_switch_add()
3014 pm_request_autosuspend(&sw->dev); in tb_switch_add()
3017 tb_switch_debugfs_init(sw); in tb_switch_add()
3021 usb4_switch_remove_ports(sw); in tb_switch_add()
3023 device_del(&sw->dev); in tb_switch_add()
3030 * @sw: Switch to remove
3036 void tb_switch_remove(struct tb_switch *sw) in tb_switch_remove() argument
3040 tb_switch_debugfs_remove(sw); in tb_switch_remove()
3042 if (sw->rpm) { in tb_switch_remove()
3043 pm_runtime_get_sync(&sw->dev); in tb_switch_remove()
3044 pm_runtime_disable(&sw->dev); in tb_switch_remove()
3048 tb_switch_for_each_port(sw, port) { in tb_switch_remove()
3050 tb_switch_remove(port->remote->sw); in tb_switch_remove()
3061 if (!sw->is_unplugged) in tb_switch_remove()
3062 tb_plug_events_active(sw, false); in tb_switch_remove()
3064 tb_switch_nvm_remove(sw); in tb_switch_remove()
3065 usb4_switch_remove_ports(sw); in tb_switch_remove()
3067 if (tb_route(sw)) in tb_switch_remove()
3068 dev_info(&sw->dev, "device disconnected\n"); in tb_switch_remove()
3069 device_unregister(&sw->dev); in tb_switch_remove()
3074 * @sw: Router to mark unplugged
3076 void tb_sw_set_unplugged(struct tb_switch *sw) in tb_sw_set_unplugged() argument
3080 if (sw == sw->tb->root_switch) { in tb_sw_set_unplugged()
3081 tb_sw_WARN(sw, "cannot unplug root switch\n"); in tb_sw_set_unplugged()
3084 if (sw->is_unplugged) { in tb_sw_set_unplugged()
3085 tb_sw_WARN(sw, "is_unplugged already set\n"); in tb_sw_set_unplugged()
3088 sw->is_unplugged = true; in tb_sw_set_unplugged()
3089 tb_switch_for_each_port(sw, port) { in tb_sw_set_unplugged()
3091 tb_sw_set_unplugged(port->remote->sw); in tb_sw_set_unplugged()
3097 static int tb_switch_set_wake(struct tb_switch *sw, unsigned int flags) in tb_switch_set_wake() argument
3100 tb_sw_dbg(sw, "enabling wakeup: %#x\n", flags); in tb_switch_set_wake()
3102 tb_sw_dbg(sw, "disabling wakeup\n"); in tb_switch_set_wake()
3104 if (tb_switch_is_usb4(sw)) in tb_switch_set_wake()
3105 return usb4_switch_set_wake(sw, flags); in tb_switch_set_wake()
3106 return tb_lc_set_wake(sw, flags); in tb_switch_set_wake()
3109 int tb_switch_resume(struct tb_switch *sw) in tb_switch_resume() argument
3114 tb_sw_dbg(sw, "resuming switch\n"); in tb_switch_resume()
3120 if (tb_route(sw)) { in tb_switch_resume()
3128 err = tb_cfg_get_upstream_port(sw->tb->ctl, tb_route(sw)); in tb_switch_resume()
3130 tb_sw_info(sw, "switch not present anymore\n"); in tb_switch_resume()
3135 if (!sw->uid) in tb_switch_resume()
3138 if (tb_switch_is_usb4(sw)) in tb_switch_resume()
3139 err = usb4_switch_read_uid(sw, &uid); in tb_switch_resume()
3141 err = tb_drom_read_uid_only(sw, &uid); in tb_switch_resume()
3143 tb_sw_warn(sw, "uid read failed\n"); in tb_switch_resume()
3146 if (sw->uid != uid) { in tb_switch_resume()
3147 tb_sw_info(sw, in tb_switch_resume()
3149 sw->uid, uid); in tb_switch_resume()
3154 err = tb_switch_configure(sw); in tb_switch_resume()
3159 tb_switch_set_wake(sw, 0); in tb_switch_resume()
3161 err = tb_switch_tmu_init(sw); in tb_switch_resume()
3166 tb_switch_for_each_port(sw, port) { in tb_switch_resume()
3177 tb_sw_set_unplugged(port->remote->sw); in tb_switch_resume()
3187 if (port->remote && tb_switch_resume(port->remote->sw)) { in tb_switch_resume()
3190 tb_sw_set_unplugged(port->remote->sw); in tb_switch_resume()
3199 * @sw: Switch to suspend
3203 * value of @runtime and then sets sleep bit for the router. If @sw is
3207 void tb_switch_suspend(struct tb_switch *sw, bool runtime) in tb_switch_suspend() argument
3213 tb_sw_dbg(sw, "suspending switch\n"); in tb_switch_suspend()
3219 tb_switch_clx_disable(sw); in tb_switch_suspend()
3221 err = tb_plug_events_active(sw, false); in tb_switch_suspend()
3225 tb_switch_for_each_port(sw, port) { in tb_switch_suspend()
3227 tb_switch_suspend(port->remote->sw, runtime); in tb_switch_suspend()
3235 } else if (device_may_wakeup(&sw->dev)) { in tb_switch_suspend()
3239 tb_switch_set_wake(sw, flags); in tb_switch_suspend()
3241 if (tb_switch_is_usb4(sw)) in tb_switch_suspend()
3242 usb4_switch_set_sleep(sw); in tb_switch_suspend()
3244 tb_lc_set_sleep(sw); in tb_switch_suspend()
3249 * @sw: Switch whose DP resource is queried
3255 bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in) in tb_switch_query_dp_resource() argument
3257 if (tb_switch_is_usb4(sw)) in tb_switch_query_dp_resource()
3258 return usb4_switch_query_dp_resource(sw, in); in tb_switch_query_dp_resource()
3259 return tb_lc_dp_sink_query(sw, in); in tb_switch_query_dp_resource()
3264 * @sw: Switch whose DP resource is allocated
3271 int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in) in tb_switch_alloc_dp_resource() argument
3275 if (tb_switch_is_usb4(sw)) in tb_switch_alloc_dp_resource()
3276 ret = usb4_switch_alloc_dp_resource(sw, in); in tb_switch_alloc_dp_resource()
3278 ret = tb_lc_dp_sink_alloc(sw, in); in tb_switch_alloc_dp_resource()
3281 tb_sw_warn(sw, "failed to allocate DP resource for port %d\n", in tb_switch_alloc_dp_resource()
3284 tb_sw_dbg(sw, "allocated DP resource for port %d\n", in->port); in tb_switch_alloc_dp_resource()
3291 * @sw: Switch whose DP resource is de-allocated
3297 void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in) in tb_switch_dealloc_dp_resource() argument
3301 if (tb_switch_is_usb4(sw)) in tb_switch_dealloc_dp_resource()
3302 ret = usb4_switch_dealloc_dp_resource(sw, in); in tb_switch_dealloc_dp_resource()
3304 ret = tb_lc_dp_sink_dealloc(sw, in); in tb_switch_dealloc_dp_resource()
3307 tb_sw_warn(sw, "failed to de-allocate DP resource for port %d\n", in tb_switch_dealloc_dp_resource()
3310 tb_sw_dbg(sw, "released DP resource for port %d\n", in->port); in tb_switch_dealloc_dp_resource()
3323 struct tb_switch *sw = tb_to_switch(dev); in tb_switch_match() local
3326 if (!sw) in tb_switch_match()
3328 if (sw->tb != lookup->tb) in tb_switch_match()
3332 return !memcmp(sw->uuid, lookup->uuid, sizeof(*lookup->uuid)); in tb_switch_match()
3335 return sw->config.route_lo == lower_32_bits(lookup->route) && in tb_switch_match()
3336 sw->config.route_hi == upper_32_bits(lookup->route); in tb_switch_match()
3341 return !sw->depth; in tb_switch_match()
3343 return sw->link == lookup->link && sw->depth == lookup->depth; in tb_switch_match()
3424 * tb_switch_find_port() - return the first port of @type on @sw or NULL
3425 * @sw: Switch to find the port from
3428 struct tb_port *tb_switch_find_port(struct tb_switch *sw, in tb_switch_find_port() argument
3433 tb_switch_for_each_port(sw, port) { in tb_switch_find_port()
3445 static int tb_switch_pcie_bridge_write(struct tb_switch *sw, unsigned int bridge, in tb_switch_pcie_bridge_write() argument
3451 if (sw->generation != 3) in tb_switch_pcie_bridge_write()
3454 offset = sw->cap_plug_events + TB_PLUG_EVENTS_PCIE_WR_DATA; in tb_switch_pcie_bridge_write()
3455 ret = tb_sw_write(sw, &value, TB_CFG_SWITCH, offset, 1); in tb_switch_pcie_bridge_write()
3466 offset = sw->cap_plug_events + TB_PLUG_EVENTS_PCIE_CMD; in tb_switch_pcie_bridge_write()
3468 ret = tb_sw_write(sw, &command, TB_CFG_SWITCH, offset, 1); in tb_switch_pcie_bridge_write()
3472 ret = tb_switch_wait_for_bit(sw, offset, in tb_switch_pcie_bridge_write()
3477 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, offset, 1); in tb_switch_pcie_bridge_write()
3489 * @sw: Router to enable PCIe L1
3496 int tb_switch_pcie_l1_enable(struct tb_switch *sw) in tb_switch_pcie_l1_enable() argument
3498 struct tb_switch *parent = tb_switch_parent(sw); in tb_switch_pcie_l1_enable()
3501 if (!tb_route(sw)) in tb_switch_pcie_l1_enable()
3504 if (!tb_switch_is_titan_ridge(sw)) in tb_switch_pcie_l1_enable()
3512 ret = tb_switch_pcie_bridge_write(sw, 5, 0x143, 0x0c7806b1); in tb_switch_pcie_l1_enable()
3517 return tb_switch_pcie_bridge_write(sw, 0, 0x143, 0x0c5806b1); in tb_switch_pcie_l1_enable()
3522 * @sw: Router whose xHCI to connect
3530 int tb_switch_xhci_connect(struct tb_switch *sw) in tb_switch_xhci_connect() argument
3535 if (sw->generation != 3) in tb_switch_xhci_connect()
3538 port1 = &sw->ports[1]; in tb_switch_xhci_connect()
3539 port3 = &sw->ports[3]; in tb_switch_xhci_connect()
3541 if (tb_switch_is_alpine_ridge(sw)) { in tb_switch_xhci_connect()
3557 } else if (tb_switch_is_titan_ridge(sw)) { in tb_switch_xhci_connect()
3569 * @sw: Router whose xHCI to disconnect
3574 void tb_switch_xhci_disconnect(struct tb_switch *sw) in tb_switch_xhci_disconnect() argument
3576 if (sw->generation == 3) { in tb_switch_xhci_disconnect()
3577 struct tb_port *port1 = &sw->ports[1]; in tb_switch_xhci_disconnect()
3578 struct tb_port *port3 = &sw->ports[3]; in tb_switch_xhci_disconnect()