Modules/EHCI - Planning out, might need USB HC API changes
[tpg/acess2.git] / KernelLand / Modules / USB / EHCI / ehci.h
1 /*
2  * Acess2 EHCI Driver
3  * - By John Hodge (thePowersGang)
4  *
5  * ehci.h
6  * - ECHI Header
7  */
8 #ifndef _EHCI_H_
9 #define _EHCI_H_
10
11 typedef struct sEHCI_CapRegs    tEHCI_CapRegs;
12 typedef struct sEHCI_OpRegs     tEHCI_OpRegs;
13 typedef struct sEHCI_iTD        tEHCI_iTD;
14 typedef struct sEHCI_siTD       tEHCI_siTD;
15 typedef struct sEHCI_qTD        tEHCI_qTD;
16 typedef struct sEHCI_QH         tEHCI_QH;
17 typedef struct sEHCI_Controller tEHCI_Controller;
18
19 struct sEHCI_CapRegs
20 {
21         Uint8   CapLength;      // Byte offset of Operational registers
22         Uint8   _pad;
23         Uint16  HCIVersion;     // BCD Version
24         /**
25          * Structural Parameters
26          *
27          *  0: 3 = Number of ports on this controller
28          *  4    = Port Power Control
29          *  5: 6 = Reserved (ZERO)
30          *  7    = Port Routing Rules
31          *  8:11 = Number of ports per companion controller
32          * 12:15 = Number of companion controllers
33          * 16    = Port Indicators
34          * 17:19 = Reserved (ZERO)
35          * 20:23 = Debug Port Number
36          * 24:31 = Reserved (ZERO)
37          */
38         Uint32  HCSParams;
39         /*
40          * Capability Parameters
41          *
42          *  0    = 64-bit Addressing Capability
43          *  1    = Programmable Frame List Flag
44          *  2    = Asyncronous Schedule Park Capability
45          *  3    = Reserved (ZERO)
46          *  4: 7 = Isochronous Scheduling Threshold
47          *  8:15 = EHCI Extended Capabilitys Pointer (0 = None)
48          * 16:31 = Reserved (ZERO)
49          */
50         Uint32  HCCParams;
51         /*
52          * Companion Port Route Description
53          */
54         Uint64  HCSPPortRoute;
55 };
56
57 struct sEHCI_OpRegs
58 {
59         /**
60          * USB Command Register
61          *
62          *  0    = Run/Stop (Stop, Run)
63          *  1    = Host Controller Reset
64          *  2: 3 = Frame List Size (1024 entries, 512, 256, Reserved)
65          *  4    = Periodic Schedule Enable
66          *  5    = Asynchronous Schedule Enable
67          *  6    = Interrupt on Async Advance Doorbell
68          *  7    = Light Host Controller Reset
69          *  8: 9 = Asynchronous Schedule Park Mode Count
70          * 10    = Reserved (ZERO)
71          * 11    = Asynchronous Schedule Park Mode Enable
72          * 12:15 = Reserved (ZERO)
73          * 16:23 = Interrupt Threshold Control
74          * 31:24 = Reserved (ZERO)
75          */
76         Uint32  USBCmd;
77         /**
78          * USB Status Register
79          *
80          *  0    = USB Interrupt
81          *  1    = USB Error Interrupt
82          *  2    = Port Change Detect
83          *  3    = Frame List Rollover
84          *  4    = Host System Error
85          *  5    = Interrupt on Async Advance
86          *  6:11 = Reserved (ZERO)
87          * 12    = HCHalted
88          * 13    = Reclamation
89          * 14    = Periodic Schedule Status
90          * 15    = Asynchronous Schedule Status
91          * 16:31 = Reserved ?(Zero)
92          */
93         Uint32  USBSts;
94         /**
95          * USB Interrupt Enable Register
96          *
97          *  0    = USB Interrupt Enable
98          *  1    = USB Error Interrupt Enable
99          *  2    = Port Change Interrupt Enable
100          *  3    = Frame List Rollover Enable
101          *  4    = Host System Error Enable
102          *  5    = Interrupt on Async Advance Enable
103          *  6:31 = Reserved (Zero)
104          */
105         Uint32  USBIntr;
106         /**
107          * Current microframe number (14 bits)
108          * 
109          * Bits 14:3 are used as n index into PeridocListBase
110          */
111         Uint32  FrIndex;
112         /**
113          * Control Data Structure Segment Register
114          *
115          * Most significant 32-bits of all addresses (only used if "64-bit addressing capability" is set)
116          */
117         Uint32  CtrlDSSegment;
118         /**
119          * Periodic Frame List Base Address Register
120          */
121         Uint32  PeridocListBase;
122         /**
123          * Current Asynchronous List Address Register
124          */
125         Uint32  AsyncListAddr;
126         // Padding
127         Uint32  _resvd[(0x40-0x1C)/4];
128         /**
129          * Configure Flag Register
130          *
131          * - When 0, all ports are routed to a USB1.1 controller
132          * 
133          *  0    = Configure Flag - Driver sets when controller is configured
134          *  1:31 = Reserved (ZERO)
135          */
136         Uint32  ConfigFlag;
137         /**
138          * Port Status and Control Register
139          * 
140          *  0    = Current Connect Status
141          *  1    = Connect Status Change
142          *  2    = Port Enable
143          *  3    = Port Enable Change
144          *  4    = Over-current Active
145          *  5    = Over-current change
146          *  6    = Force Port Resume
147          *  7    = Suspend
148          *  8    = Port Reset
149          *  9    = Reserved (ZERO)
150          * 10:11 = Line Status (Use to detect non USB2) [USB2, USB2, USB1.1, USB2]
151          * 12    = Port Power
152          * 13    = Port Owner (Set to 1 to give to companion controller)
153          * 14:15 = Port Indicator Control (Off, Amber, Green, Undef)
154          * 16:19 = Port Test Control
155          * 20    = Wake on Connect Enable
156          * 21    = Wake on Disconnect Enable
157          * 22    = Wake on Over-current Enable
158          * 23:31 = Reserved (ZERO)
159          */
160         Uint32  PortSC[15];
161 };
162
163 #define USBCMD_Run      0x0001
164 #define USBCMD_HCReset  0x0002
165 #define USBCMD_PeriodicEnable   0x0010
166 #define USBCMD_AsyncEnable      0x0020
167
168 #define USBINTR_IOC     0x0001
169 #define USBINTR_Error   0x0002
170 #define USBINTR_PortChange      0x0004
171 #define USBINTR_FrameRollover   0x0008
172 #define USBINTR_HostSystemError 0x0010
173 #define USBINTR_AsyncAdvance    0x0020
174
175 struct sEHCI_iTD
176 {
177         Uint32  Link;
178         struct {
179                 Uint16  Offset;
180                 Uint16  LengthSts;
181         } Transactions[8];
182         // -- 0 --
183         // 0:6  - Device
184         // 7    - Reserved
185         // 8:11 - Endpoint
186         // -- 1 --
187         // 0:10 - Max packet size
188         // 11   - IN/OUT
189         Uint32  BufferPointers[8];      // Page aligned, low 12 bits are overloaded
190 };
191
192 struct sEHCI_siTD
193 {
194         Uint32  Link;
195         Uint32  Dest;
196         Uint32  uFrame;
197         Uint32  StatusLength;
198         Uint32  Page0;
199         Uint32  Page1;
200         Uint32  BackLink;
201 };
202
203 struct sEHCI_qTD
204 {
205         Uint32  Link;
206         Uint32  Link2;  // Used when there's a short packet
207         Uint32  Token;
208         Uint32  Pages[5];       //First has offset in low 12 bits
209 };
210
211 struct sEHCI_QH
212 {
213         Uint32  HLink;  // Horizontal link
214         Uint32  Endpoint;
215         Uint32  EndpointExt;
216         Uint32  CurrentTD;
217         tEHCI_qTD       Overlay;
218 };
219
220 struct sEHCI_Controller
221 {
222         tPAddr  PhysBase;
223         tEHCI_CapRegs   *CapRegs;
224         tEHCI_OpRegs    *OpRegs;
225
226         Uint32  *PeriodicQueue;
227 };
228
229 #endif
230

UCC git Repository :: git.ucc.asn.au