diff options
Diffstat (limited to 'sys/include/dev/usb')
-rw-r--r-- | sys/include/dev/usb/xhciregs.h | 14 | ||||
-rw-r--r-- | sys/include/dev/usb/xhcivar.h | 49 |
2 files changed, 61 insertions, 2 deletions
diff --git a/sys/include/dev/usb/xhciregs.h b/sys/include/dev/usb/xhciregs.h index 8c47739..1cbfd14 100644 --- a/sys/include/dev/usb/xhciregs.h +++ b/sys/include/dev/usb/xhciregs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. + * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,6 +73,7 @@ struct xhci_opregs { /* USBCMD bits */ #define USBCMD_RUN BIT(0) /* Run/stop */ #define USBCMD_HCRST BIT(1) /* xHC reset */ +#define USBCMD_INTE BIT(2) /* Interrupt Enable */ /* USBSTS bits */ #define USBSTS_HCH BIT(0) /* HC halted */ @@ -97,6 +98,13 @@ struct xhci_opregs { #define XHCI_RTS(BASE, RTSOFF) PTR_OFFSET(BASE, RTSOFF) #define XHCI_CMD_DB(BASE, DBOFF) PTR_OFFSET(BASE, DBOFF) +/* Runtime register offsets */ +#define XHCI_RT_IMAN 0x20 +#define XHCI_RT_IMOD 0x24 +#define XHCI_RT_ERSTSZ 0x28 +#define XHCI_RT_ERSTBA 0x30 +#define XHCI_RT_ERDP 0x38 + /* Support protocol cap fields */ #define XHCI_PROTO_ID(PROTO) (PROTO & 0xFF) #define XHCI_PROTO_MINOR(PROTO) ((PROTO >> 16) & 0xFF) @@ -113,4 +121,8 @@ struct xhci_opregs { #define XHCI_BIOS_SEM BIT(16) #define XHCI_OS_SEM BIT(24) +/* IMAN bits */ +#define XHCI_IMAN_IP BIT(0) +#define XHCI_IMAN_IE BIT(1) + #endif /* !_USB_XHCIREGS_H_ */ diff --git a/sys/include/dev/usb/xhcivar.h b/sys/include/dev/usb/xhcivar.h index cd445c8..a9a8fc1 100644 --- a/sys/include/dev/usb/xhcivar.h +++ b/sys/include/dev/usb/xhcivar.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team. + * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,6 +32,7 @@ #include <sys/types.h> #include <sys/types.h> +#include <sys/param.h> #include <dev/usb/xhciregs.h> #define XHCI_TIMEOUT 500 /* In ms */ @@ -39,6 +40,10 @@ #define XHCI_EVRING_LEN 16 #define XHCI_TRB_SIZE 16 /* In bytes */ #define XHCI_MAX_PROTOS 4 +#define XHCI_IMOD_DEFAULT 0 + +/* Quirks */ +#define XHCI_QUIRK_HANDOFF BIT(0) /* * USB proto (USB 2.0 or 3.0) @@ -49,6 +54,43 @@ struct xhci_proto { uint8_t port_count; /* Number of ports */ }; +struct xhci_nop_trb { + uint32_t reserved; + uint32_t reserved1; + uint32_t reserved2; + uint8_t cycle : 1; + uint16_t reserved3 : 9; + uint8_t type : 6; + uint16_t reserved4; +}; + +struct xhci_enableslot_trb { + uint32_t reserved; + uint32_t reserved1; + uint32_t reserved2; + uint8_t cycle : 1; + uint16_t reserved3 : 9; + uint8_t type : 6; + uint8_t slot_type : 5; + uint16_t reserved4 : 10; +}; + +/* + * xHCI Transfer Request Block + */ +struct xhci_trb { + union { + struct xhci_nop_trb nop; + struct xhci_enableslot_trb enableslot; + struct { + uint32_t dword0; + uint32_t dword1; + uint32_t dword2; + uint32_t dword3; + }; + }; +}; + /* * xHCI event ring segment * @@ -70,6 +112,7 @@ struct xhci_hc { uint32_t *evring; uint8_t maxslots; uint8_t cr_cycle : 1; + uint16_t quirks; size_t maxports; size_t protocnt; struct xhci_caps *caps; @@ -77,4 +120,8 @@ struct xhci_hc { struct xhci_proto protos[XHCI_MAX_PROTOS]; }; +/* TRB types */ +#define XHCI_ENABLE_SLOT 9 +#define XHCI_LINK 6 + #endif /* !_USB_XHCIVAR_H_ */ |