Use the PRC status bit to detect when an XHCI port reset is complete (issue #31).

Some controllers do not set the PR status bit immediately after it's written,
so polling that to detect when the reset is complete is unsafe.
This commit is contained in:
Martin Whitaker 2022-04-02 09:28:34 +01:00
parent bbfaf10240
commit 95c49848c8
1 changed files with 3 additions and 3 deletions

View File

@ -60,7 +60,7 @@
#define XHCI_PORT_SC_PLS 0x000001e0 // Port Link State
#define XHCI_PORT_SC_PP 0x00000200 // Port Power
#define XHCI_PORT_SC_PS 0x00003c00 // Port Speed
#define XHCI_PORT_SC_PRSC 0x00200000 // Port Reset
#define XHCI_PORT_SC_PRC 0x00200000 // Port Reset Change
#define XHCI_PORT_SC_PS_OFFSET 10 // first bit of Port Speed
@ -472,8 +472,8 @@ static int get_xhci_device_speed(xhci_op_regs_t *op_regs, int port_idx)
static bool reset_xhci_port(xhci_op_regs_t *op_regs, int port_idx)
{
write32(&op_regs->port_regs[port_idx].sc, XHCI_PORT_SC_PP | XHCI_PORT_SC_PR);
return wait_until_clr(&op_regs->port_regs[port_idx].sc, XHCI_PORT_SC_PR, 1000*MILLISEC);
write32(&op_regs->port_regs[port_idx].sc, XHCI_PORT_SC_PP | XHCI_PORT_SC_PR | XHCI_PORT_SC_PRC);
return wait_until_set(&op_regs->port_regs[port_idx].sc, XHCI_PORT_SC_PRC, 1000*MILLISEC);
}
static void disable_xhci_port(xhci_op_regs_t *op_regs, int port_idx)