Lines Matching full:sw

14 static const char *tb_switch_tmu_mode_name(const struct tb_switch *sw)  in tb_switch_tmu_mode_name()  argument
16 bool root_switch = !tb_route(sw); in tb_switch_tmu_mode_name()
18 switch (sw->tmu.rate) { in tb_switch_tmu_mode_name()
26 if (sw->tmu.unidirectional) in tb_switch_tmu_mode_name()
40 static bool tb_switch_tmu_ucap_supported(struct tb_switch *sw) in tb_switch_tmu_ucap_supported() argument
45 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_switch_tmu_ucap_supported()
46 sw->tmu.cap + TMU_RTR_CS_0, 1); in tb_switch_tmu_ucap_supported()
53 static int tb_switch_tmu_rate_read(struct tb_switch *sw) in tb_switch_tmu_rate_read() argument
58 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_switch_tmu_rate_read()
59 sw->tmu.cap + TMU_RTR_CS_3, 1); in tb_switch_tmu_rate_read()
67 static int tb_switch_tmu_rate_write(struct tb_switch *sw, int rate) in tb_switch_tmu_rate_write() argument
72 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_switch_tmu_rate_write()
73 sw->tmu.cap + TMU_RTR_CS_3, 1); in tb_switch_tmu_rate_write()
80 return tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_switch_tmu_rate_write()
81 sw->tmu.cap + TMU_RTR_CS_3, 1); in tb_switch_tmu_rate_write()
106 if (!port->sw->tmu.has_ucap) in tb_port_tmu_set_unidirectional()
131 static int tb_switch_tmu_set_time_disruption(struct tb_switch *sw, bool set) in tb_switch_tmu_set_time_disruption() argument
136 ret = tb_sw_read(sw, &val, TB_CFG_SWITCH, in tb_switch_tmu_set_time_disruption()
137 sw->tmu.cap + TMU_RTR_CS_0, 1); in tb_switch_tmu_set_time_disruption()
146 return tb_sw_write(sw, &val, TB_CFG_SWITCH, in tb_switch_tmu_set_time_disruption()
147 sw->tmu.cap + TMU_RTR_CS_0, 1); in tb_switch_tmu_set_time_disruption()
152 * @sw: Switch to initialized
158 int tb_switch_tmu_init(struct tb_switch *sw) in tb_switch_tmu_init() argument
163 if (tb_switch_is_icm(sw)) in tb_switch_tmu_init()
166 ret = tb_switch_find_cap(sw, TB_SWITCH_CAP_TMU); in tb_switch_tmu_init()
168 sw->tmu.cap = ret; in tb_switch_tmu_init()
170 tb_switch_for_each_port(sw, port) { in tb_switch_tmu_init()
178 ret = tb_switch_tmu_rate_read(sw); in tb_switch_tmu_init()
182 sw->tmu.rate = ret; in tb_switch_tmu_init()
184 sw->tmu.has_ucap = tb_switch_tmu_ucap_supported(sw); in tb_switch_tmu_init()
185 if (sw->tmu.has_ucap) { in tb_switch_tmu_init()
186 tb_sw_dbg(sw, "TMU: supports uni-directional mode\n"); in tb_switch_tmu_init()
188 if (tb_route(sw)) { in tb_switch_tmu_init()
189 struct tb_port *up = tb_upstream_port(sw); in tb_switch_tmu_init()
191 sw->tmu.unidirectional = in tb_switch_tmu_init()
195 sw->tmu.unidirectional = false; in tb_switch_tmu_init()
198 tb_sw_dbg(sw, "TMU: current mode: %s\n", tb_switch_tmu_mode_name(sw)); in tb_switch_tmu_init()
204 * @sw: Switch whose time to update
208 int tb_switch_tmu_post_time(struct tb_switch *sw) in tb_switch_tmu_post_time() argument
211 struct tb_switch *root_switch = sw->tb->root_switch; in tb_switch_tmu_post_time()
216 if (!tb_route(sw)) in tb_switch_tmu_post_time()
219 if (!tb_switch_is_usb4(sw)) in tb_switch_tmu_post_time()
244 ret = tb_switch_tmu_set_time_disruption(sw, true); in tb_switch_tmu_post_time()
248 post_local_time_offset = sw->tmu.cap + TMU_RTR_CS_22; in tb_switch_tmu_post_time()
249 post_time_offset = sw->tmu.cap + TMU_RTR_CS_24; in tb_switch_tmu_post_time()
255 ret = tb_sw_write(sw, &local_time, TB_CFG_SWITCH, in tb_switch_tmu_post_time()
268 ret = tb_sw_write(sw, &post_time, TB_CFG_SWITCH, post_time_offset, 2); in tb_switch_tmu_post_time()
274 ret = tb_sw_read(sw, &post_time, TB_CFG_SWITCH, in tb_switch_tmu_post_time()
285 tb_sw_dbg(sw, "TMU: updated local time to %#llx\n", local_time); in tb_switch_tmu_post_time()
288 tb_switch_tmu_set_time_disruption(sw, false); in tb_switch_tmu_post_time()
294 * @sw: Switch whose TMU to disable
296 * Turns off TMU of @sw if it is enabled. If not enabled does nothing.
298 int tb_switch_tmu_disable(struct tb_switch *sw) in tb_switch_tmu_disable() argument
302 if (!tb_switch_is_usb4(sw)) in tb_switch_tmu_disable()
306 if (sw->tmu.rate == TB_SWITCH_TMU_RATE_OFF) in tb_switch_tmu_disable()
309 if (sw->tmu.unidirectional) { in tb_switch_tmu_disable()
310 struct tb_switch *parent = tb_switch_parent(sw); in tb_switch_tmu_disable()
313 up = tb_upstream_port(sw); in tb_switch_tmu_disable()
314 down = tb_port_at(tb_route(sw), parent); in tb_switch_tmu_disable()
323 tb_switch_tmu_rate_write(sw, TB_SWITCH_TMU_RATE_OFF); in tb_switch_tmu_disable()
325 sw->tmu.unidirectional = false; in tb_switch_tmu_disable()
326 sw->tmu.rate = TB_SWITCH_TMU_RATE_OFF; in tb_switch_tmu_disable()
328 tb_sw_dbg(sw, "TMU: disabled\n"); in tb_switch_tmu_disable()
334 * @sw: Switch whose TMU to enable
339 int tb_switch_tmu_enable(struct tb_switch *sw) in tb_switch_tmu_enable() argument
343 if (!tb_switch_is_usb4(sw)) in tb_switch_tmu_enable()
346 if (tb_switch_tmu_is_enabled(sw)) in tb_switch_tmu_enable()
349 ret = tb_switch_tmu_set_time_disruption(sw, true); in tb_switch_tmu_enable()
354 if (tb_route(sw) && sw->tmu.unidirectional) { in tb_switch_tmu_enable()
355 struct tb_switch *parent = tb_switch_parent(sw); in tb_switch_tmu_enable()
358 up = tb_upstream_port(sw); in tb_switch_tmu_enable()
359 down = tb_port_at(tb_route(sw), parent); in tb_switch_tmu_enable()
365 ret = tb_switch_tmu_rate_write(sw, TB_SWITCH_TMU_RATE_HIFI); in tb_switch_tmu_enable()
373 ret = tb_switch_tmu_rate_write(sw, TB_SWITCH_TMU_RATE_HIFI); in tb_switch_tmu_enable()
378 sw->tmu.unidirectional = false; in tb_switch_tmu_enable()
379 sw->tmu.rate = TB_SWITCH_TMU_RATE_HIFI; in tb_switch_tmu_enable()
380 tb_sw_dbg(sw, "TMU: mode set to: %s\n", tb_switch_tmu_mode_name(sw)); in tb_switch_tmu_enable()
382 return tb_switch_tmu_set_time_disruption(sw, false); in tb_switch_tmu_enable()