Lines Matching refs:sw

15  * @sw: Switch whose UUID is read
18 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid)
20 if (!sw->cap_lc)
22 return tb_sw_read(sw, uuid, TB_CFG_SWITCH, sw->cap_lc + TB_LC_FUSE, 4);
25 static int read_lc_desc(struct tb_switch *sw, u32 *desc)
27 if (!sw->cap_lc)
29 return tb_sw_read(sw, desc, TB_CFG_SWITCH, sw->cap_lc + TB_LC_DESC, 1);
34 struct tb_switch *sw = port->sw;
38 ret = read_lc_desc(sw, &desc);
47 return sw->cap_lc + start + phys * size;
61 struct tb_switch *sw = port->sw;
65 if (sw->generation < 2)
72 ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1);
78 ret = tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1);
84 ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1);
90 return tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1);
96 struct tb_switch *sw = port->sw;
100 if (sw->generation < 2)
107 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
127 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
154 struct tb_switch *sw = port->sw;
158 if (sw->generation < 2)
165 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
180 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
218 struct tb_switch *sw = port->sw;
222 if (!tb_route(sw))
225 if (sw->generation < 2)
232 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
238 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
250 struct tb_switch *sw = port->sw;
258 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_ATTR, 1);
273 struct tb_switch *sw = port->sw;
277 if (sw->generation != 3)
284 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_CS_42, 1);
299 struct tb_switch *sw = port->sw;
303 if (sw->generation != 3)
310 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1);
319 struct tb_switch *sw = port->sw;
323 if (sw->generation != 3)
330 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1);
339 return tb_sw_write(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1);
375 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset,
385 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH,
402 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1);
407 * @sw: Switch whose wakes to configure
412 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags)
417 if (sw->generation < 2)
420 if (!tb_route(sw))
423 ret = read_lc_desc(sw, &desc);
434 unsigned int offset = sw->cap_lc + start + i * size;
436 ret = tb_lc_set_wake_one(sw, offset, flags);
446 * @sw: Switch to set sleep
451 int tb_lc_set_sleep(struct tb_switch *sw)
456 if (sw->generation < 2)
459 ret = read_lc_desc(sw, &desc);
470 unsigned int offset = sw->cap_lc + start + i * size;
473 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH,
479 ret = tb_sw_write(sw, &ctrl, TB_CFG_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)
501 if (sw->generation < 2)
504 up = tb_upstream_port(sw);
509 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1);
516 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw,
522 tb_switch_for_each_port(sw, port) {
530 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink)
535 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
536 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
560 * @sw: Switch whose DP sink is queried
566 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in)
574 if (sw->generation < 3)
577 sink = tb_lc_dp_sink_from_port(sw, in);
581 return !tb_lc_dp_sink_available(sw, sink);
586 * @sw: Switch whose DP sink is allocated
594 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in)
599 if (sw->generation < 3)
602 sink = tb_lc_dp_sink_from_port(sw, in);
606 ret = tb_lc_dp_sink_available(sw, sink);
610 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
611 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
624 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH,
625 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
636 * @sw: Switch whose DP sink is de-allocated
641 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in)
646 if (sw->generation < 3)
649 sink = tb_lc_dp_sink_from_port(sw, in);
654 ret = tb_lc_dp_sink_available(sw, sink);
658 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
659 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
668 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH,
669 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
679 * @sw: Thunderbolt switch
684 int tb_lc_force_power(struct tb_switch *sw)
688 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1);