Commit 17fb1a3d authored by Mika Westerberg's avatar Mika Westerberg

thunderbolt: Introduce tb_xdomain_downstream_port()

In the same way we did for the routers add a function that returns the
parent routers downstream facing port for XDomain devices.
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 7ce54221
...@@ -1197,6 +1197,17 @@ static inline struct tb_switch *tb_xdomain_parent(struct tb_xdomain *xd) ...@@ -1197,6 +1197,17 @@ static inline struct tb_switch *tb_xdomain_parent(struct tb_xdomain *xd)
return tb_to_switch(xd->dev.parent); return tb_to_switch(xd->dev.parent);
} }
/**
* tb_xdomain_downstream_port() - Return downstream facing port of parent router
* @xd: Xdomain pointer
*
* Returns the downstream port the XDomain is connected to.
*/
static inline struct tb_port *tb_xdomain_downstream_port(struct tb_xdomain *xd)
{
return tb_port_at(xd->route, tb_xdomain_parent(xd));
}
int tb_retimer_nvm_read(struct tb_retimer *rt, unsigned int address, void *buf, int tb_retimer_nvm_read(struct tb_retimer *rt, unsigned int address, void *buf,
size_t size); size_t size);
int tb_retimer_scan(struct tb_port *port, bool add); int tb_retimer_scan(struct tb_port *port, bool add);
......
...@@ -537,9 +537,8 @@ static int tb_xdp_link_state_status_request(struct tb_ctl *ctl, u64 route, ...@@ -537,9 +537,8 @@ static int tb_xdp_link_state_status_request(struct tb_ctl *ctl, u64 route,
static int tb_xdp_link_state_status_response(struct tb *tb, struct tb_ctl *ctl, static int tb_xdp_link_state_status_response(struct tb *tb, struct tb_ctl *ctl,
struct tb_xdomain *xd, u8 sequence) struct tb_xdomain *xd, u8 sequence)
{ {
struct tb_switch *sw = tb_to_switch(xd->dev.parent);
struct tb_xdp_link_state_status_response res; struct tb_xdp_link_state_status_response res;
struct tb_port *port = tb_port_at(xd->route, sw); struct tb_port *port = tb_xdomain_downstream_port(xd);
u32 val[2]; u32 val[2];
int ret; int ret;
...@@ -1137,7 +1136,7 @@ static int tb_xdomain_update_link_attributes(struct tb_xdomain *xd) ...@@ -1137,7 +1136,7 @@ static int tb_xdomain_update_link_attributes(struct tb_xdomain *xd)
struct tb_port *port; struct tb_port *port;
int ret; int ret;
port = tb_port_at(xd->route, tb_xdomain_parent(xd)); port = tb_xdomain_downstream_port(xd);
ret = tb_port_get_link_speed(port); ret = tb_port_get_link_speed(port);
if (ret < 0) if (ret < 0)
...@@ -1251,8 +1250,7 @@ static int tb_xdomain_get_link_status(struct tb_xdomain *xd) ...@@ -1251,8 +1250,7 @@ static int tb_xdomain_get_link_status(struct tb_xdomain *xd)
static int tb_xdomain_link_state_change(struct tb_xdomain *xd, static int tb_xdomain_link_state_change(struct tb_xdomain *xd,
unsigned int width) unsigned int width)
{ {
struct tb_switch *sw = tb_to_switch(xd->dev.parent); struct tb_port *port = tb_xdomain_downstream_port(xd);
struct tb_port *port = tb_port_at(xd->route, sw);
struct tb *tb = xd->tb; struct tb *tb = xd->tb;
u8 tlw, tls; u8 tlw, tls;
u32 val; u32 val;
...@@ -1309,7 +1307,7 @@ static int tb_xdomain_bond_lanes_uuid_high(struct tb_xdomain *xd) ...@@ -1309,7 +1307,7 @@ static int tb_xdomain_bond_lanes_uuid_high(struct tb_xdomain *xd)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
port = tb_port_at(xd->route, tb_xdomain_parent(xd)); port = tb_xdomain_downstream_port(xd);
/* /*
* We can't use tb_xdomain_lane_bonding_enable() here because it * We can't use tb_xdomain_lane_bonding_enable() here because it
...@@ -1425,7 +1423,7 @@ static int tb_xdomain_get_properties(struct tb_xdomain *xd) ...@@ -1425,7 +1423,7 @@ static int tb_xdomain_get_properties(struct tb_xdomain *xd)
if (xd->bonding_possible) { if (xd->bonding_possible) {
struct tb_port *port; struct tb_port *port;
port = tb_port_at(xd->route, tb_xdomain_parent(xd)); port = tb_xdomain_downstream_port(xd);
if (!port->bonded) if (!port->bonded)
tb_port_disable(port->dual_link_port); tb_port_disable(port->dual_link_port);
} }
...@@ -1979,7 +1977,7 @@ int tb_xdomain_lane_bonding_enable(struct tb_xdomain *xd) ...@@ -1979,7 +1977,7 @@ int tb_xdomain_lane_bonding_enable(struct tb_xdomain *xd)
struct tb_port *port; struct tb_port *port;
int ret; int ret;
port = tb_port_at(xd->route, tb_xdomain_parent(xd)); port = tb_xdomain_downstream_port(xd);
if (!port->dual_link_port) if (!port->dual_link_port)
return -ENODEV; return -ENODEV;
...@@ -2024,7 +2022,7 @@ void tb_xdomain_lane_bonding_disable(struct tb_xdomain *xd) ...@@ -2024,7 +2022,7 @@ void tb_xdomain_lane_bonding_disable(struct tb_xdomain *xd)
{ {
struct tb_port *port; struct tb_port *port;
port = tb_port_at(xd->route, tb_xdomain_parent(xd)); port = tb_xdomain_downstream_port(xd);
if (port->dual_link_port) { if (port->dual_link_port) {
tb_port_lane_bonding_disable(port); tb_port_lane_bonding_disable(port);
if (tb_port_wait_for_link_width(port, 1, 100) == -ETIMEDOUT) if (tb_port_wait_for_link_width(port, 1, 100) == -ETIMEDOUT)
......
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