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);
161 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset,
171 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH,
186 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1);
191 * @sw: Switch whose wakes to configure
196 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags)
201 if (sw->generation < 2)
204 if (!tb_route(sw))
207 ret = read_lc_desc(sw, &desc);
218 unsigned int offset = sw->cap_lc + start + i * size;
220 ret = tb_lc_set_wake_one(sw, offset, flags);
230 * @sw: Switch to set sleep
235 int tb_lc_set_sleep(struct tb_switch *sw)
240 if (sw->generation < 2)
243 ret = read_lc_desc(sw, &desc);
254 unsigned int offset = sw->cap_lc + start + i * size;
257 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH,
263 ret = tb_sw_write(sw, &ctrl, TB_CFG_SWITCH,
274 * @sw: Switch to check
276 * Checks whether conditions for lane bonding from parent to @sw are
279 bool tb_lc_lane_bonding_possible(struct tb_switch *sw)
285 if (sw->generation < 2)
288 up = tb_upstream_port(sw);
293 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1);
300 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw,
306 tb_switch_for_each_port(sw, port) {
314 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink)
319 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
320 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
344 * @sw: Switch whose DP sink is queried
350 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in)
358 if (sw->generation < 3)
361 sink = tb_lc_dp_sink_from_port(sw, in);
365 return !tb_lc_dp_sink_available(sw, sink);
370 * @sw: Switch whose DP sink is allocated
378 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in)
383 if (sw->generation < 3)
386 sink = tb_lc_dp_sink_from_port(sw, in);
390 ret = tb_lc_dp_sink_available(sw, sink);
394 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
395 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
408 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH,
409 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
420 * @sw: Switch whose DP sink is de-allocated
425 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in)
430 if (sw->generation < 3)
433 sink = tb_lc_dp_sink_from_port(sw, in);
438 ret = tb_lc_dp_sink_available(sw, sink);
442 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH,
443 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
452 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH,
453 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1);
463 * @sw: Thunderbolt switch
468 int tb_lc_force_power(struct tb_switch *sw)
472 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1);