diff options
author | Ian Moffett <industrial.reformer@gmail.com> | 2024-04-03 20:09:19 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-04-03 20:10:51 -0400 |
commit | cf7bfde63fca0d904447a82186018ca5cc6498c6 (patch) | |
tree | 4013e3bbdb5383b16bdd77def7885637b422fad3 /sys/dev | |
parent | f0275f1b2364648f26bbfcd58ab6a214d4ab1827 (diff) |
kernel: usb: Fix command ring TRB handling
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/xhci.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index a433fb9..a6996bf 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -110,16 +110,19 @@ xhci_submit_cmd(struct xhci_hc *hc, struct xhci_trb trb) struct xhci_caps *caps = XHCI_CAPS(hc->base); /* Push the TRB to the command ring */ - cmd_db = XHCI_CMD_DB(hc->base, caps->dboff); - hc->cmd_ring[hc->cmd_ptr++] = trb; - hc->cycle = ~hc->cycle; - - /* Wrap if needed */ - if (hc->cmd_ptr >= XHCI_CMDRING_LEN) { - hc->cmd_ptr = 0; + hc->cmd_ring[hc->cmd_ptr++] = trb.dword0; + hc->cmd_ring[hc->cmd_ptr++] = trb.dword1; + hc->cmd_ring[hc->cmd_ptr++] = trb.dword2; + hc->cmd_ring[hc->cmd_ptr++] = trb.dword3 | hc->cycle; + hc->cmd_count++; + + if (hc->cmd_count >= XHCI_CMDRING_LEN) { + /* TODO: Add link TRB */ + __assert(0 && "TODO"); } /* Ring the command doorbell */ + cmd_db = XHCI_CMD_DB(hc->base, caps->dboff); *cmd_db = 0; return 0; } @@ -371,6 +374,7 @@ xhci_init_hc(struct xhci_hc *hc) /* Set cmdring state */ hc->cycle = 1; hc->cmd_ptr = 0; + hc->cmd_count = 0; /* Allocate resources and tell the HC about them */ opregs->dcbaa_ptr = xhci_alloc_dcbaa(hc); |