-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
thunderbolt: Introduce tb_port_reset()
Introduce a function that issues Downstream Port Reset to a USB4 port. This supports Thunderbolt 2, 3 and USB4 routers. Signed-off-by: Sanath S <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
- Loading branch information
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
* Author: Mika Westerberg <[email protected]> | ||
*/ | ||
|
||
#include <linux/delay.h> | ||
|
||
#include "tb.h" | ||
|
||
/** | ||
|
@@ -45,6 +47,49 @@ static int find_port_lc_cap(struct tb_port *port) | |
return sw->cap_lc + start + phys * size; | ||
} | ||
|
||
/** | ||
* tb_lc_reset_port() - Trigger downstream port reset through LC | ||
* @port: Port that is reset | ||
* | ||
* Triggers downstream port reset through link controller registers. | ||
* Returns %0 in case of success negative errno otherwise. Only supports | ||
* non-USB4 routers with link controller (that's Thunderbolt 2 and | ||
* Thunderbolt 3). | ||
*/ | ||
int tb_lc_reset_port(struct tb_port *port) | ||
{ | ||
struct tb_switch *sw = port->sw; | ||
int cap, ret; | ||
u32 mode; | ||
|
||
if (sw->generation < 2) | ||
return -EINVAL; | ||
|
||
cap = find_port_lc_cap(port); | ||
if (cap < 0) | ||
return cap; | ||
|
||
ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); | ||
if (ret) | ||
return ret; | ||
|
||
mode |= TB_LC_PORT_MODE_DPR; | ||
|
||
ret = tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); | ||
if (ret) | ||
return ret; | ||
|
||
fsleep(10000); | ||
|
||
ret = tb_sw_read(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); | ||
if (ret) | ||
return ret; | ||
|
||
mode &= ~TB_LC_PORT_MODE_DPR; | ||
|
||
return tb_sw_write(sw, &mode, TB_CFG_SWITCH, cap + TB_LC_PORT_MODE, 1); | ||
} | ||
|
||
static int tb_lc_set_port_configured(struct tb_port *port, bool configured) | ||
{ | ||
bool upstream = tb_is_upstream_port(port); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters