Lines Matching full:sw
15 * @sw: Switch whose UUID is read
20 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid) in tb_lc_read_uuid() argument
22 if (!sw->cap_lc) in tb_lc_read_uuid()
24 return tb_sw_read(sw, uuid, TB_CFG_SWITCH, sw->cap_lc + TB_LC_FUSE, 4); in tb_lc_read_uuid()
27 static int read_lc_desc(struct tb_switch *sw, u32 *desc) in read_lc_desc() argument
29 if (!sw->cap_lc) in read_lc_desc()
31 return tb_sw_read(sw, desc, TB_CFG_SWITCH, sw->cap_lc + TB_LC_DESC, 1); in read_lc_desc()
36 struct tb_switch *sw = port->sw; in find_port_lc_cap() local
40 ret = read_lc_desc(sw, &desc); in find_port_lc_cap()
49 return sw->cap_lc + start + phys * size; in find_port_lc_cap()
64 struct tb_switch *sw = port->sw; in tb_lc_reset_port() local
68 if (sw->generation < 2) in tb_lc_reset_port()
75 ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
81 ret = tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
87 ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
93 return tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
99 struct tb_switch *sw = port->sw; in tb_lc_set_port_configured() local
103 if (sw->generation < 2) in tb_lc_set_port_configured()
110 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_port_configured()
130 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_port_configured()
161 struct tb_switch *sw = port->sw; in tb_lc_set_xdomain_configured() local
165 if (sw->generation < 2) in tb_lc_set_xdomain_configured()
172 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_xdomain_configured()
187 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_xdomain_configured()
227 struct tb_switch *sw = port->sw; in tb_lc_start_lane_initialization() local
231 if (!tb_route(sw)) in tb_lc_start_lane_initialization()
234 if (sw->generation < 2) in tb_lc_start_lane_initialization()
241 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_start_lane_initialization()
247 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_start_lane_initialization()
261 struct tb_switch *sw = port->sw; in tb_lc_is_clx_supported() local
269 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_ATTR, 1); in tb_lc_is_clx_supported()
285 struct tb_switch *sw = port->sw; in tb_lc_is_usb_plugged() local
289 if (sw->generation != 3) in tb_lc_is_usb_plugged()
296 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_CS_42, 1); in tb_lc_is_usb_plugged()
312 struct tb_switch *sw = port->sw; in tb_lc_is_xhci_connected() local
316 if (sw->generation != 3) in tb_lc_is_xhci_connected()
323 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in tb_lc_is_xhci_connected()
332 struct tb_switch *sw = port->sw; in __tb_lc_xhci_connect() local
336 if (sw->generation != 3) in __tb_lc_xhci_connect()
343 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in __tb_lc_xhci_connect()
352 return tb_sw_write(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in __tb_lc_xhci_connect()
389 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset, in tb_lc_set_wake_one() argument
399 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_wake_one()
416 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1); in tb_lc_set_wake_one()
421 * @sw: Switch whose wakes to configure
428 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags) in tb_lc_set_wake() argument
433 if (sw->generation < 2) in tb_lc_set_wake()
436 if (!tb_route(sw)) in tb_lc_set_wake()
439 ret = read_lc_desc(sw, &desc); in tb_lc_set_wake()
450 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_wake()
452 ret = tb_lc_set_wake_one(sw, offset, flags); in tb_lc_set_wake()
462 * @sw: Switch to set sleep
469 int tb_lc_set_sleep(struct tb_switch *sw) in tb_lc_set_sleep() argument
474 if (sw->generation < 2) in tb_lc_set_sleep()
477 ret = read_lc_desc(sw, &desc); in tb_lc_set_sleep()
488 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_sleep()
491 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
497 ret = tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
508 * @sw: Switch to check
510 * Checks whether conditions for lane bonding from parent to @sw are
515 bool tb_lc_lane_bonding_possible(struct tb_switch *sw) in tb_lc_lane_bonding_possible() argument
521 if (sw->generation < 2) in tb_lc_lane_bonding_possible()
524 up = tb_upstream_port(sw); in tb_lc_lane_bonding_possible()
529 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1); in tb_lc_lane_bonding_possible()
536 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw, in tb_lc_dp_sink_from_port() argument
542 tb_switch_for_each_port(sw, port) { in tb_lc_dp_sink_from_port()
550 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink) in tb_lc_dp_sink_available() argument
555 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_available()
556 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_available()
561 * Sink is available for CM/SW to use if the allocation value is in tb_lc_dp_sink_available()
580 * @sw: Switch whose DP sink is queried
588 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_query() argument
596 if (sw->generation < 3) in tb_lc_dp_sink_query()
599 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_query()
603 return !tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_query()
608 * @sw: Switch whose DP sink is allocated
618 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_alloc() argument
623 if (sw->generation < 3) in tb_lc_dp_sink_alloc()
626 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_alloc()
630 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_alloc()
634 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
635 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
648 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
649 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
660 * @sw: Switch whose DP sink is de-allocated
667 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_dealloc() argument
672 if (sw->generation < 3) in tb_lc_dp_sink_dealloc()
675 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_dealloc()
679 /* Needs to be owned by CM/SW */ in tb_lc_dp_sink_dealloc()
680 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_dealloc()
684 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
685 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
694 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
695 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
705 * @sw: Thunderbolt switch
712 int tb_lc_force_power(struct tb_switch *sw) in tb_lc_force_power() argument
716 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1); in tb_lc_force_power()