Commit f07a3608 authored by Mika Westerberg's avatar Mika Westerberg

thunderbolt: Introduce tb_switch_is_icm()

We currently differentiate between SW CM (Software Connection Manager,
sometimes also called External Connection Manager) and ICM (Firmware
based Connection Manager, Internal Connection Manager) by looking
directly at the sw->config.enabled field which may be rather hard to
understand for the casual reader. For this reason introduce a wrapper
function with documentation that should make the intention more clear.
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 1c9c5bc5
...@@ -94,7 +94,7 @@ int tb_lc_configure_link(struct tb_switch *sw) ...@@ -94,7 +94,7 @@ int tb_lc_configure_link(struct tb_switch *sw)
struct tb_port *up, *down; struct tb_port *up, *down;
int ret; int ret;
if (!sw->config.enabled || !tb_route(sw)) if (!tb_route(sw) || tb_switch_is_icm(sw))
return 0; return 0;
up = tb_upstream_port(sw); up = tb_upstream_port(sw);
...@@ -124,7 +124,7 @@ void tb_lc_unconfigure_link(struct tb_switch *sw) ...@@ -124,7 +124,7 @@ void tb_lc_unconfigure_link(struct tb_switch *sw)
{ {
struct tb_port *up, *down; struct tb_port *up, *down;
if (sw->is_unplugged || !sw->config.enabled || !tb_route(sw)) if (sw->is_unplugged || !tb_route(sw) || tb_switch_is_icm(sw))
return; return;
up = tb_upstream_port(sw); up = tb_upstream_port(sw);
......
...@@ -986,7 +986,7 @@ static int tb_plug_events_active(struct tb_switch *sw, bool active) ...@@ -986,7 +986,7 @@ static int tb_plug_events_active(struct tb_switch *sw, bool active)
u32 data; u32 data;
int res; int res;
if (!sw->config.enabled) if (tb_switch_is_icm(sw))
return 0; return 0;
sw->config.plug_events_delay = 0xff; sw->config.plug_events_delay = 0xff;
...@@ -1720,7 +1720,7 @@ static int tb_switch_add_dma_port(struct tb_switch *sw) ...@@ -1720,7 +1720,7 @@ static int tb_switch_add_dma_port(struct tb_switch *sw)
} }
/* Root switch DMA port requires running firmware */ /* Root switch DMA port requires running firmware */
if (!tb_route(sw) && sw->config.enabled) if (!tb_route(sw) && !tb_switch_is_icm(sw))
return 0; return 0;
sw->dma_port = dma_port_alloc(sw); sw->dma_port = dma_port_alloc(sw);
......
...@@ -591,6 +591,20 @@ static inline bool tb_switch_is_fr(const struct tb_switch *sw) ...@@ -591,6 +591,20 @@ static inline bool tb_switch_is_fr(const struct tb_switch *sw)
} }
} }
/**
* tb_switch_is_icm() - Is the switch handled by ICM firmware
* @sw: Switch to check
*
* In case there is a need to differentiate whether ICM firmware or SW CM
* is handling @sw this function can be called. It is valid to call this
* after tb_switch_alloc() and tb_switch_configure() has been called
* (latter only for SW CM case).
*/
static inline bool tb_switch_is_icm(const struct tb_switch *sw)
{
return !sw->config.enabled;
}
int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged); int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged);
int tb_port_add_nfc_credits(struct tb_port *port, int credits); int tb_port_add_nfc_credits(struct tb_port *port, int credits);
int tb_port_set_initial_credits(struct tb_port *port, u32 credits); int tb_port_set_initial_credits(struct tb_port *port, u32 credits);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment