Lines Matching refs:sw
13 * @sw: Switch whose UUID is read
16 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid)
18 if (!sw->cap_lc)
20 return tb_sw_read(sw, uuid, TB_CFG_SWITCH, sw->cap_lc + TB_LC_FUSE, 4);
23 static int read_lc_desc(struct tb_switch *sw, u32 *desc)
25 if (!sw->cap_lc)
27 return tb_sw_read(sw, desc, TB_CFG_SWITCH, sw->cap_lc + TB_LC_DESC, 1);
32 struct tb_switch *sw = port->sw;
36 ret = read_lc_desc(sw, &desc);
45 return sw->cap_lc + start + phys * size;
51 struct tb_switch *sw = port->sw;
55 if (sw->generation < 2)
62 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
82 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
109 struct tb_switch *sw = port->sw;
113 if (sw->generation < 2)
120 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
135 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
173 struct tb_switch *sw = port->sw;
177 if (!tb_route(sw))
180 if (sw->generation < 2)
187 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
193 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1);
205 struct tb_switch *sw = port->sw;
213 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_ATTR, 1);
228 struct tb_switch *sw = port->sw;
232 if (sw->generation != 3)
239 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_CS_42, 1);
254 struct tb_switch *sw = port->sw;
258 if (sw->generation != 3)
265 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1);
274 struct tb_switch *sw = port->sw;
278 if (sw->generation != 3)
285 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1);
294 return tb_sw_write(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1);
330 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset,
340 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH,
357 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1);
362 * @sw: Switch whose wakes to configure
367 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags)
372 if (sw->generation < 2)
375 if (!tb_route(sw))
378 ret = read_lc_desc(sw, &desc);
389 unsigned int offset = sw->cap_lc + start + i * size;
391 ret = tb_lc_set_wake_one(sw, offset, flags);
401 * @sw: Switch to set sleep
406 int tb_lc_set_sleep(struct tb_switch *sw)
411 if (sw->generation < 2)
414 ret = read_lc_desc(sw, &desc);
425 unsigned int offset = sw->cap_lc + start + i * size;
428 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH,
434 ret = tb_sw_write(sw, &ctrl, TB_CFG_SWITCH,
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)
456 if (sw->generation < 2)
459 up = tb_upstream_port(sw);
464 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1);
471 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw,
477 tb_switch_for_each_port(sw, port) {
485 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink)
490 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
491 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
515 * @sw: Switch whose DP sink is queried
521 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in)
529 if (sw->generation < 3)
532 sink = tb_lc_dp_sink_from_port(sw, in);
536 return !tb_lc_dp_sink_available(sw, sink);
541 * @sw: Switch whose DP sink is allocated
549 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in)
554 if (sw->generation < 3)
557 sink = tb_lc_dp_sink_from_port(sw, in);
561 ret = tb_lc_dp_sink_available(sw, sink);
565 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
566 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
579 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH,
580 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
591 * @sw: Switch whose DP sink is de-allocated
596 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in)
601 if (sw->generation < 3)
604 sink = tb_lc_dp_sink_from_port(sw, in);
609 ret = tb_lc_dp_sink_available(sw, sink);
613 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
614 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
623 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH,
624 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
634 * @sw: Thunderbolt switch
639 int tb_lc_force_power(struct tb_switch *sw)
643 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1);