Lines Matching refs:sw
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()
161 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset, in tb_lc_set_wake_one() argument
171 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_wake_one()
186 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1); in tb_lc_set_wake_one()
196 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags) in tb_lc_set_wake() argument
201 if (sw->generation < 2) in tb_lc_set_wake()
204 if (!tb_route(sw)) in tb_lc_set_wake()
207 ret = read_lc_desc(sw, &desc); in tb_lc_set_wake()
218 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_wake()
220 ret = tb_lc_set_wake_one(sw, offset, flags); in tb_lc_set_wake()
235 int tb_lc_set_sleep(struct tb_switch *sw) in tb_lc_set_sleep() argument
240 if (sw->generation < 2) in tb_lc_set_sleep()
243 ret = read_lc_desc(sw, &desc); in tb_lc_set_sleep()
254 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_sleep()
257 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
263 ret = tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
279 bool tb_lc_lane_bonding_possible(struct tb_switch *sw) in tb_lc_lane_bonding_possible() argument
285 if (sw->generation < 2) in tb_lc_lane_bonding_possible()
288 up = tb_upstream_port(sw); in tb_lc_lane_bonding_possible()
293 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1); in tb_lc_lane_bonding_possible()
300 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw, in tb_lc_dp_sink_from_port() argument
306 tb_switch_for_each_port(sw, port) { in tb_lc_dp_sink_from_port()
314 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink) in tb_lc_dp_sink_available() argument
319 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_available()
320 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_available()
350 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_query() argument
358 if (sw->generation < 3) in tb_lc_dp_sink_query()
361 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_query()
365 return !tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_query()
378 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_alloc() argument
383 if (sw->generation < 3) in tb_lc_dp_sink_alloc()
386 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_alloc()
390 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_alloc()
394 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
395 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
408 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
409 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
425 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_dealloc() argument
430 if (sw->generation < 3) in tb_lc_dp_sink_dealloc()
433 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_dealloc()
438 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_dealloc()
442 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
443 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
452 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
453 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
468 int tb_lc_force_power(struct tb_switch *sw) in tb_lc_force_power() argument
472 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1); in tb_lc_force_power()