Lines Matching refs:sw

18 int tb_lc_read_uuid(struct tb_switch *sw, u32 *uuid)  in tb_lc_read_uuid()  argument
20 if (!sw->cap_lc) in tb_lc_read_uuid()
22 return tb_sw_read(sw, uuid, TB_CFG_SWITCH, sw->cap_lc + TB_LC_FUSE, 4); in tb_lc_read_uuid()
25 static int read_lc_desc(struct tb_switch *sw, u32 *desc) in read_lc_desc() argument
27 if (!sw->cap_lc) in read_lc_desc()
29 return tb_sw_read(sw, desc, TB_CFG_SWITCH, sw->cap_lc + TB_LC_DESC, 1); in read_lc_desc()
34 struct tb_switch *sw = port->sw; in find_port_lc_cap() local
38 ret = read_lc_desc(sw, &desc); in find_port_lc_cap()
47 return sw->cap_lc + start + phys * size; in find_port_lc_cap()
61 struct tb_switch *sw = port->sw; in tb_lc_reset_port() local
65 if (sw->generation < 2) in tb_lc_reset_port()
72 ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
78 ret = tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
84 ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
90 return tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); in tb_lc_reset_port()
96 struct tb_switch *sw = port->sw; in tb_lc_set_port_configured() local
100 if (sw->generation < 2) in tb_lc_set_port_configured()
107 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_port_configured()
127 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_port_configured()
154 struct tb_switch *sw = port->sw; in tb_lc_set_xdomain_configured() local
158 if (sw->generation < 2) in tb_lc_set_xdomain_configured()
165 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_xdomain_configured()
180 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_set_xdomain_configured()
218 struct tb_switch *sw = port->sw; in tb_lc_start_lane_initialization() local
222 if (!tb_route(sw)) in tb_lc_start_lane_initialization()
225 if (sw->generation < 2) in tb_lc_start_lane_initialization()
232 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_start_lane_initialization()
238 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, cap + TB_LC_SX_CTRL, 1); in tb_lc_start_lane_initialization()
250 struct tb_switch *sw = port->sw; in tb_lc_is_clx_supported() local
258 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_ATTR, 1); in tb_lc_is_clx_supported()
273 struct tb_switch *sw = port->sw; in tb_lc_is_usb_plugged() local
277 if (sw->generation != 3) in tb_lc_is_usb_plugged()
284 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_CS_42, 1); in tb_lc_is_usb_plugged()
299 struct tb_switch *sw = port->sw; in tb_lc_is_xhci_connected() local
303 if (sw->generation != 3) in tb_lc_is_xhci_connected()
310 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in tb_lc_is_xhci_connected()
319 struct tb_switch *sw = port->sw; in __tb_lc_xhci_connect() local
323 if (sw->generation != 3) in __tb_lc_xhci_connect()
330 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in __tb_lc_xhci_connect()
339 return tb_sw_write(sw, &val, TB_CFG_SWITCH, cap + TB_LC_LINK_REQ, 1); in __tb_lc_xhci_connect()
375 static int tb_lc_set_wake_one(struct tb_switch *sw, unsigned int offset, in tb_lc_set_wake_one() argument
385 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_wake_one()
402 return tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, offset + TB_LC_SX_CTRL, 1); in tb_lc_set_wake_one()
412 int tb_lc_set_wake(struct tb_switch *sw, unsigned int flags) in tb_lc_set_wake() argument
417 if (sw->generation < 2) in tb_lc_set_wake()
420 if (!tb_route(sw)) in tb_lc_set_wake()
423 ret = read_lc_desc(sw, &desc); in tb_lc_set_wake()
434 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_wake()
436 ret = tb_lc_set_wake_one(sw, offset, flags); in tb_lc_set_wake()
451 int tb_lc_set_sleep(struct tb_switch *sw) in tb_lc_set_sleep() argument
456 if (sw->generation < 2) in tb_lc_set_sleep()
459 ret = read_lc_desc(sw, &desc); in tb_lc_set_sleep()
470 unsigned int offset = sw->cap_lc + start + i * size; in tb_lc_set_sleep()
473 ret = tb_sw_read(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
479 ret = tb_sw_write(sw, &ctrl, TB_CFG_SWITCH, in tb_lc_set_sleep()
495 bool tb_lc_lane_bonding_possible(struct tb_switch *sw) in tb_lc_lane_bonding_possible() argument
501 if (sw->generation < 2) in tb_lc_lane_bonding_possible()
504 up = tb_upstream_port(sw); in tb_lc_lane_bonding_possible()
509 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, cap + TB_LC_PORT_ATTR, 1); in tb_lc_lane_bonding_possible()
516 static int tb_lc_dp_sink_from_port(const struct tb_switch *sw, in tb_lc_dp_sink_from_port() argument
522 tb_switch_for_each_port(sw, port) { in tb_lc_dp_sink_from_port()
530 static int tb_lc_dp_sink_available(struct tb_switch *sw, int sink) in tb_lc_dp_sink_available() argument
535 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_available()
536 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_available()
566 bool tb_lc_dp_sink_query(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_query() argument
574 if (sw->generation < 3) in tb_lc_dp_sink_query()
577 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_query()
581 return !tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_query()
594 int tb_lc_dp_sink_alloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_alloc() argument
599 if (sw->generation < 3) in tb_lc_dp_sink_alloc()
602 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_alloc()
606 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_alloc()
610 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
611 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
624 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_alloc()
625 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_alloc()
641 int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in) in tb_lc_dp_sink_dealloc() argument
646 if (sw->generation < 3) in tb_lc_dp_sink_dealloc()
649 sink = tb_lc_dp_sink_from_port(sw, in); in tb_lc_dp_sink_dealloc()
654 ret = tb_lc_dp_sink_available(sw, sink); in tb_lc_dp_sink_dealloc()
658 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
659 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
668 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_lc_dp_sink_dealloc()
669 sw->cap_lc + TB_LC_SNK_ALLOCATION, 1); in tb_lc_dp_sink_dealloc()
684 int tb_lc_force_power(struct tb_switch *sw) in tb_lc_force_power() argument
688 return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1); in tb_lc_force_power()