blob: be6094cfd4500039353dd088cad683d97b3816d8 [file] [log] [blame]
Gerd Hoffmanne144bb72013-06-03 16:30:18 +02001#ifndef __USB_XHCI_H
2#define __USB_XHCI_H
3
4struct usbdevice_s;
5struct usb_endpoint_descriptor;
6struct usb_pipe;
7
8// --------------------------------------------------------------
9
10// usb-xhci.c
Kevin O'Connorec443ff2013-12-05 18:43:20 -050011void xhci_setup(void);
Gerd Hoffmanne144bb72013-06-03 16:30:18 +020012struct usb_pipe *xhci_alloc_pipe(struct usbdevice_s *usbdev
13 , struct usb_endpoint_descriptor *epdesc);
14struct usb_pipe *xhci_update_pipe(struct usbdevice_s *usbdev
15 , struct usb_pipe *pipe
16 , struct usb_endpoint_descriptor *epdesc);
17int xhci_control(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
18 , void *data, int datasize);
19int xhci_send_bulk(struct usb_pipe *p, int dir, void *data, int datasize);
20int xhci_poll_intr(struct usb_pipe *p, void *data);
21
22// --------------------------------------------------------------
23// register interface
24
25// capabilities
26struct xhci_caps {
27 u8 caplength;
28 u8 reserved_01;
29 u16 hciversion;
30 u32 hcsparams1;
31 u32 hcsparams2;
32 u32 hcsparams3;
33 u32 hccparams;
34 u32 dboff;
35 u32 rtsoff;
36} PACKED;
37
38// extended capabilities
39struct xhci_xcap {
40 u32 cap;
41 u32 data[];
42} PACKED;
43
44// operational registers
45struct xhci_op {
46 u32 usbcmd;
47 u32 usbsts;
48 u32 pagesize;
49 u32 reserved_01[2];
50 u32 dnctl;
51 u32 crcr_low;
52 u32 crcr_high;
53 u32 reserved_02[4];
54 u32 dcbaap_low;
55 u32 dcbaap_high;
56 u32 config;
57} PACKED;
58
59// port registers
60struct xhci_pr {
61 u32 portsc;
62 u32 portpmsc;
63 u32 portli;
64 u32 reserved_01;
65} PACKED;
66
67// doorbell registers
68struct xhci_db {
69 u32 doorbell;
70} PACKED;
71
72// runtime registers
73struct xhci_rts {
74 u32 mfindex;
75} PACKED;
76
77// interrupter registers
78struct xhci_ir {
79 u32 iman;
80 u32 imod;
81 u32 erstsz;
82 u32 reserved_01;
83 u32 erstba_low;
84 u32 erstba_high;
85 u32 erdp_low;
86 u32 erdp_high;
87} PACKED;
88
89// --------------------------------------------------------------
90// memory data structs
91
92// slot context
93struct xhci_slotctx {
94 u32 ctx[4];
95 u32 reserved_01[4];
96} PACKED;
97
98// endpoint context
99struct xhci_epctx {
100 u32 ctx[2];
101 u32 deq_low;
102 u32 deq_high;
103 u32 length;
104 u32 reserved_01[3];
105} PACKED;
106
107// device context
108struct xhci_devctx {
109 struct xhci_slotctx slot;
110 struct xhci_epctx ep[31];
111} PACKED;
112
113// device context array element
114struct xhci_devlist {
115 u32 ptr_low;
116 u32 ptr_high;
117} PACKED;
118
119// input context
120struct xhci_inctx {
121 u32 del;
122 u32 add;
123 u32 reserved_01[6];
124 struct xhci_slotctx slot;
125 struct xhci_epctx ep[31];
126} PACKED;
127
128// transfer block (ring element)
129struct xhci_trb {
130 u32 ptr_low;
131 u32 ptr_high;
132 u32 status;
133 u32 control;
134} PACKED;
135
136// event ring segment
137struct xhci_er_seg {
138 u32 ptr_low;
139 u32 ptr_high;
140 u32 size;
141 u32 reserved_01;
142} PACKED;
143
144#endif // usb-xhci.h