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()
196 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset, in tb_lc_set_wake_one() argument
206 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_wake_one()
223 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1); in tb_lc_set_wake_one()
228 * @sw: Switch whose wakes to configure
233 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags) in tb_lc_set_wake() argument
238 if (sw->generation < 2) in tb_lc_set_wake()
241 if (!tb_route(sw)) in tb_lc_set_wake()
244 ret = read_lc_desc(sw, &desc); in tb_lc_set_wake()
255 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_wake()
257 ret = tb_lc_set_wake_one(sw, offset, flags); in tb_lc_set_wake()
267 * @sw: Switch to set sleep
272 int tb_lc_set_sleep(struct tb_switch *sw) in tb_lc_set_sleep() argument
277 if (sw->generation < 2) in tb_lc_set_sleep()
280 ret = read_lc_desc(sw, &desc); in tb_lc_set_sleep()
291 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_sleep()
294 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
300 ret = tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
311 * @sw: Switch to check
313 * Checks whether conditions for lane bonding from parent to @sw are
316 bool tb_lc_lane_bonding_possible(struct tb_switch *sw) in tb_lc_lane_bonding_possible() argument
322 if (sw->generation < 2) in tb_lc_lane_bonding_possible()
325 up = tb_upstream_port(sw); in tb_lc_lane_bonding_possible()
330 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1); in tb_lc_lane_bonding_possible()
337 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw, in tb_lc_dp_sink_from_port() argument
343 tb_switch_for_each_port(sw, port) { in tb_lc_dp_sink_from_port()
351 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink) in tb_lc_dp_sink_available() argument
356 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_available()
357 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_available()
362 * Sink is available for CM/SW to use if the allocation valie is in tb_lc_dp_sink_available()
381 * @sw: Switch whose DP sink is queried
387 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_query() argument
395 if (sw->generation < 3) in tb_lc_dp_sink_query()
398 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_query()
402 return !tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_query()
407 * @sw: Switch whose DP sink is allocated
415 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_alloc() argument
420 if (sw->generation < 3) in tb_lc_dp_sink_alloc()
423 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_alloc()
427 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_alloc()
431 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
432 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
445 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
446 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
457 * @sw: Switch whose DP sink is de-allocated
462 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_dealloc() argument
467 if (sw->generation < 3) in tb_lc_dp_sink_dealloc()
470 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_dealloc()
474 /* Needs to be owned by CM/SW */ in tb_lc_dp_sink_dealloc()
475 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_dealloc()
479 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
480 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
489 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
490 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
500 * @sw: Thunderbolt switch
505 int tb_lc_force_power(struct tb_switch *sw) in tb_lc_force_power() argument
509 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1); in tb_lc_force_power()