Lines Matching +full:sw +full:- +full:reset +full:- +full:number
1 // SPDX-License-Identifier: GPL-2.0
14 * tb_lc_read_uuid() - Read switch UUID from link controller common register
15 * @sw: Switch whose UUID is read
18 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid) in tb_lc_read_uuid() argument
20 if (!sw->cap_lc) in tb_lc_read_uuid()
21 return -EINVAL; in tb_lc_read_uuid()
22 return tb_sw_read(sw, uuid, TB_CFG_SWITCH, sw->cap_lc + TB_LC_FUSE, 4); in tb_lc_read_uuid()
25 static int read_lc_desc(struct tb_switch *sw, u32 *desc) in read_lc_desc() argument
27 if (!sw->cap_lc) in read_lc_desc()
28 return -EINVAL; in read_lc_desc()
29 return tb_sw_read(sw, desc, TB_CFG_SWITCH, sw->cap_lc + TB_LC_DESC, 1); in read_lc_desc()
34 struct tb_switch *sw = port->sw; in find_port_lc_cap() local
38 ret = read_lc_desc(sw, &desc); in find_port_lc_cap()
45 phys = tb_phy_port_from_link(port->port); in find_port_lc_cap()
47 return sw->cap_lc + start + phys * size; in find_port_lc_cap()
51 * tb_lc_reset_port() - Trigger downstream port reset through LC
52 * @port: Port that is reset
54 * Triggers downstream port reset through link controller registers.
56 * non-USB4 routers with link controller (that's Thunderbolt 2 and
61 struct tb_switch *sw = port->sw; in tb_lc_reset_port() local
65 if (sw->generation < 2) in tb_lc_reset_port()
66 return -EINVAL; in tb_lc_reset_port()
72 ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
78 ret = tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
84 ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
90 return tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
96 struct tb_switch *sw = port->sw; in tb_lc_set_port_configured() local
100 if (sw->generation < 2) in tb_lc_set_port_configured()
107 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_port_configured()
112 if (port->port % 2) in tb_lc_set_port_configured()
127 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_port_configured()
131 * tb_lc_configure_port() - Let LC know about configured port
142 * tb_lc_unconfigure_port() - Let LC know about unconfigured port
154 struct tb_switch *sw = port->sw; in tb_lc_set_xdomain_configured() local
158 if (sw->generation < 2) in tb_lc_set_xdomain_configured()
165 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_xdomain_configured()
170 if (port->port % 2) in tb_lc_set_xdomain_configured()
180 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_xdomain_configured()
184 * tb_lc_configure_xdomain() - Inform LC that the link is XDomain
196 * tb_lc_unconfigure_xdomain() - Unconfigure XDomain from port
207 * tb_lc_start_lane_initialization() - Start lane initialization
218 struct tb_switch *sw = port->sw; in tb_lc_start_lane_initialization() local
222 if (!tb_route(sw)) in tb_lc_start_lane_initialization()
225 if (sw->generation < 2) in tb_lc_start_lane_initialization()
232 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_start_lane_initialization()
238 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_start_lane_initialization()
242 * tb_lc_is_clx_supported() - Check whether CLx is supported by the lane adapter
250 struct tb_switch *sw = port->sw; in tb_lc_is_clx_supported() local
258 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_ATTR, 1); in tb_lc_is_clx_supported()
266 * tb_lc_is_usb_plugged() - Is there USB device connected to port
269 * Returns true if the @port has USB type-C device connected.
273 struct tb_switch *sw = port->sw; in tb_lc_is_usb_plugged() local
277 if (sw->generation != 3) in tb_lc_is_usb_plugged()
284 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_CS_42, 1); in tb_lc_is_usb_plugged()
292 * tb_lc_is_xhci_connected() - Is the internal xHCI connected
299 struct tb_switch *sw = port->sw; in tb_lc_is_xhci_connected() local
303 if (sw->generation != 3) in tb_lc_is_xhci_connected()
310 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in tb_lc_is_xhci_connected()
319 struct tb_switch *sw = port->sw; in __tb_lc_xhci_connect() local
323 if (sw->generation != 3) in __tb_lc_xhci_connect()
324 return -EINVAL; in __tb_lc_xhci_connect()
330 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in __tb_lc_xhci_connect()
339 return tb_sw_write(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in __tb_lc_xhci_connect()
343 * tb_lc_xhci_connect() - Connect internal xHCI
363 * tb_lc_xhci_disconnect() - Disconnect internal xHCI
375 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset, in tb_lc_set_wake_one() argument
385 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_wake_one()
402 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1); in tb_lc_set_wake_one()
406 * tb_lc_set_wake() - Enable/disable wake
407 * @sw: Switch whose wakes to configure
412 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags) in tb_lc_set_wake() argument
417 if (sw->generation < 2) in tb_lc_set_wake()
420 if (!tb_route(sw)) in tb_lc_set_wake()
423 ret = read_lc_desc(sw, &desc); in tb_lc_set_wake()
427 /* Figure out number of link controllers */ in tb_lc_set_wake()
434 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_wake()
436 ret = tb_lc_set_wake_one(sw, offset, flags); in tb_lc_set_wake()
445 * tb_lc_set_sleep() - Inform LC that the switch is going to sleep
446 * @sw: Switch to set sleep
451 int tb_lc_set_sleep(struct tb_switch *sw) in tb_lc_set_sleep() argument
456 if (sw->generation < 2) in tb_lc_set_sleep()
459 ret = read_lc_desc(sw, &desc); in tb_lc_set_sleep()
463 /* Figure out number of link controllers */ in tb_lc_set_sleep()
470 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_sleep()
473 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
479 ret = tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
489 * tb_lc_lane_bonding_possible() - Is lane bonding possible towards switch
490 * @sw: Switch to check
492 * Checks whether conditions for lane bonding from parent to @sw are
495 bool tb_lc_lane_bonding_possible(struct tb_switch *sw) in tb_lc_lane_bonding_possible() argument
501 if (sw->generation < 2) in tb_lc_lane_bonding_possible()
504 up = tb_upstream_port(sw); in tb_lc_lane_bonding_possible()
509 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1); in tb_lc_lane_bonding_possible()
516 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw, in tb_lc_dp_sink_from_port() argument
522 tb_switch_for_each_port(sw, port) { in tb_lc_dp_sink_from_port()
527 return -EINVAL; in tb_lc_dp_sink_from_port()
530 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink) in tb_lc_dp_sink_available() argument
535 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_available()
536 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_available()
541 * Sink is available for CM/SW to use if the allocation valie is in tb_lc_dp_sink_available()
555 return -EBUSY; in tb_lc_dp_sink_available()
559 * tb_lc_dp_sink_query() - Is DP sink available for DP IN port
560 * @sw: Switch whose DP sink is queried
566 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_query() argument
574 if (sw->generation < 3) in tb_lc_dp_sink_query()
577 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_query()
581 return !tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_query()
585 * tb_lc_dp_sink_alloc() - Allocate DP sink
586 * @sw: Switch whose DP sink is allocated
591 * other cases returs negative errno. In particular %-EBUSY is returned if
594 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_alloc() argument
599 if (sw->generation < 3) in tb_lc_dp_sink_alloc()
602 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_alloc()
606 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_alloc()
610 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
611 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
624 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
625 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
635 * tb_lc_dp_sink_dealloc() - De-allocate DP sink
636 * @sw: Switch whose DP sink is de-allocated
637 * @in: DP IN port whose DP sink is de-allocated
639 * De-allocate DP sink from @in using LC SNK_ALLOCATION registers.
641 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_dealloc() argument
646 if (sw->generation < 3) in tb_lc_dp_sink_dealloc()
649 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_dealloc()
653 /* Needs to be owned by CM/SW */ in tb_lc_dp_sink_dealloc()
654 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_dealloc()
658 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
659 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
668 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
669 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
673 tb_port_dbg(in, "sink %d de-allocated\n", sink); in tb_lc_dp_sink_dealloc()
678 * tb_lc_force_power() - Forces LC to be powered on
679 * @sw: Thunderbolt switch
684 int tb_lc_force_power(struct tb_switch *sw) in tb_lc_force_power() argument
688 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1); in tb_lc_force_power()