Lines Matching full:sw

13  * @sw: Switch whose UUID is read
16 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid) in tb_lc_read_uuid() argument
18 if (!sw->cap_lc) in tb_lc_read_uuid()
20 return tb_sw_read(sw, uuid, TB_CFG_SWITCH, sw->cap_lc + TB_LC_FUSE, 4); in tb_lc_read_uuid()
23 static int read_lc_desc(struct tb_switch *sw, u32 *desc) in read_lc_desc() argument
25 if (!sw->cap_lc) in read_lc_desc()
27 return tb_sw_read(sw, desc, TB_CFG_SWITCH, sw->cap_lc + TB_LC_DESC, 1); in read_lc_desc()
32 struct tb_switch *sw = port->sw; in find_port_lc_cap() local
36 ret = read_lc_desc(sw, &desc); in find_port_lc_cap()
45 return sw->cap_lc + start + phys * size; in find_port_lc_cap()
51 struct tb_switch *sw = port->sw; in tb_lc_set_port_configured() local
55 if (sw->generation < 2) in tb_lc_set_port_configured()
62 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_port_configured()
82 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_port_configured()
109 struct tb_switch *sw = port->sw; in tb_lc_set_xdomain_configured() local
113 if (sw->generation < 2) in tb_lc_set_xdomain_configured()
120 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_xdomain_configured()
135 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_xdomain_configured()
173 struct tb_switch *sw = port->sw; in tb_lc_start_lane_initialization() local
177 if (!tb_route(sw)) in tb_lc_start_lane_initialization()
180 if (sw->generation < 2) in tb_lc_start_lane_initialization()
187 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_start_lane_initialization()
193 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_start_lane_initialization()
205 struct tb_switch *sw = port->sw; in tb_lc_is_clx_supported() local
213 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_ATTR, 1); in tb_lc_is_clx_supported()
228 struct tb_switch *sw = port->sw; in tb_lc_is_usb_plugged() local
232 if (sw->generation != 3) in tb_lc_is_usb_plugged()
239 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_CS_42, 1); in tb_lc_is_usb_plugged()
254 struct tb_switch *sw = port->sw; in tb_lc_is_xhci_connected() local
258 if (sw->generation != 3) in tb_lc_is_xhci_connected()
265 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in tb_lc_is_xhci_connected()
274 struct tb_switch *sw = port->sw; in __tb_lc_xhci_connect() local
278 if (sw->generation != 3) in __tb_lc_xhci_connect()
285 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in __tb_lc_xhci_connect()
294 return tb_sw_write(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in __tb_lc_xhci_connect()
330 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset, in tb_lc_set_wake_one() argument
340 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_wake_one()
357 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1); in tb_lc_set_wake_one()
362 * @sw: Switch whose wakes to configure
367 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags) in tb_lc_set_wake() argument
372 if (sw->generation < 2) in tb_lc_set_wake()
375 if (!tb_route(sw)) in tb_lc_set_wake()
378 ret = read_lc_desc(sw, &desc); in tb_lc_set_wake()
389 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_wake()
391 ret = tb_lc_set_wake_one(sw, offset, flags); in tb_lc_set_wake()
401 * @sw: Switch to set sleep
406 int tb_lc_set_sleep(struct tb_switch *sw) in tb_lc_set_sleep() argument
411 if (sw->generation < 2) in tb_lc_set_sleep()
414 ret = read_lc_desc(sw, &desc); in tb_lc_set_sleep()
425 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_sleep()
428 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
434 ret = tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
445 * @sw: Switch to check
447 * Checks whether conditions for lane bonding from parent to @sw are
450 bool tb_lc_lane_bonding_possible(struct tb_switch *sw) in tb_lc_lane_bonding_possible() argument
456 if (sw->generation < 2) in tb_lc_lane_bonding_possible()
459 up = tb_upstream_port(sw); in tb_lc_lane_bonding_possible()
464 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1); in tb_lc_lane_bonding_possible()
471 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw, in tb_lc_dp_sink_from_port() argument
477 tb_switch_for_each_port(sw, port) { in tb_lc_dp_sink_from_port()
485 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink) in tb_lc_dp_sink_available() argument
490 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_available()
491 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_available()
496 * Sink is available for CM/SW to use if the allocation valie is in tb_lc_dp_sink_available()
515 * @sw: Switch whose DP sink is queried
521 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_query() argument
529 if (sw->generation < 3) in tb_lc_dp_sink_query()
532 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_query()
536 return !tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_query()
541 * @sw: Switch whose DP sink is allocated
549 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_alloc() argument
554 if (sw->generation < 3) in tb_lc_dp_sink_alloc()
557 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_alloc()
561 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_alloc()
565 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
566 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
579 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
580 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
591 * @sw: Switch whose DP sink is de-allocated
596 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_dealloc() argument
601 if (sw->generation < 3) in tb_lc_dp_sink_dealloc()
604 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_dealloc()
608 /* Needs to be owned by CM/SW */ in tb_lc_dp_sink_dealloc()
609 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_dealloc()
613 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
614 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
623 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
624 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
634 * @sw: Thunderbolt switch
639 int tb_lc_force_power(struct tb_switch *sw) in tb_lc_force_power() argument
643 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1); in tb_lc_force_power()