3 * - By John Hodge (thePowersGang)
6 * - ECHI Hardware Header
12 typedef struct sEHCI_CapRegs tEHCI_CapRegs;
13 typedef struct sEHCI_OpRegs tEHCI_OpRegs;
14 typedef struct sEHCI_iTD tEHCI_iTD;
15 typedef struct sEHCI_siTD tEHCI_siTD;
16 typedef struct sEHCI_qTD tEHCI_qTD;
17 typedef struct sEHCI_QH tEHCI_QH;
21 Uint8 CapLength; // Byte offset of Operational registers
23 Uint16 HCIVersion; // BCD Version
25 * Structural Parameters
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)
40 * Capability Parameters
42 * 0 = 64-bit Addressing Capability
43 * 1 = Programmable Frame List Flag
44 * 2 = Asyncronous Schedule Park Capability
46 * 4: 7 = Isochronous Scheduling Threshold
47 * 8:15 = EHCI Extended Capabilitys Pointer (0 = None)
48 * 16:31 = Reserved (ZERO)
52 * Companion Port Route Description
60 * USB Command Register
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)
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)
89 * 14 = Periodic Schedule Status
90 * 15 = Asynchronous Schedule Status
91 * 16:31 = Reserved ?(Zero)
93 volatile Uint32 USBSts;
95 * USB Interrupt Enable Register
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)
107 * Current microframe number (14 bits)
109 * Bits 14:3 are used as n index into PeridocListBase
111 volatile Uint32 FrIndex;
113 * Control Data Structure Segment Register
115 * Most significant 32-bits of all addresses (only used if "64-bit addressing capability" is set)
117 Uint32 CtrlDSSegment;
119 * Periodic Frame List Base Address Register
121 Uint32 PeridocListBase;
123 * Current Asynchronous List Address Register
125 Uint32 AsyncListAddr;
127 Uint32 _resvd[(0x40-0x1C)/4];
129 * Configure Flag Register
131 * - When 0, all ports are routed to a USB1.1 controller
133 * 0 = Configure Flag - Driver sets when controller is configured
134 * 1:31 = Reserved (ZERO)
138 * Port Status and Control Register
140 * 0 = Current Connect Status
141 * 1 = Connect Status Change
143 * 3 = Port Enable Change
144 * 4 = Over-current Active
145 * 5 = Over-current change
146 * 6 = Force Port Resume
149 * 9 = Reserved (ZERO)
150 * 10:11 = Line Status (Use to detect non USB2) [USB2, USB2, USB1.1, USB2]
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)
160 volatile Uint32 PortSC[15];
163 #define USBCMD_Run 0x0001
164 #define USBCMD_HCReset 0x0002
165 #define USBCMD_PeriodicEnable 0x0010
166 #define USBCMD_AsyncEnable 0x0020
167 #define USBCMD_IAAD 0x0040
169 #define USBINTR_IOC 0x0001
170 #define USBINTR_Error 0x0002
171 #define USBINTR_PortChange 0x0004
172 #define USBINTR_FrameRollover 0x0008
173 #define USBINTR_HostSystemError 0x0010
174 #define USBINTR_IntrAsyncAdvance 0x0020
176 #define PORTSC_CurrentConnectStatus 0x0001
177 #define PORTSC_ConnectStatusChange 0x0002
178 #define PORTSC_PortEnabled 0x0004
179 #define PORTSC_PortEnableChange 0x0008
180 #define PORTSC_OvercurrentActive 0x0010
181 #define PORTSC_OvercurrentChange 0x0020
182 #define PORTSC_ForcePortResume 0x0040
183 #define PORTSC_Suspend 0x0080
184 #define PORTSC_PortReset 0x0100
185 #define PORTSC_Reserved1 0x0200
186 #define PORTSC_LineStatus_MASK 0x0C00
187 #define PORTSC_LineStatus_SE0 0x0000
188 #define PORTSC_LineStatus_Jstate 0x0400
189 #define PORTSC_LineStatus_Kstate 0x0800
190 #define PORTSC_LineStatus_Undef 0x0C00
191 #define PORTSC_PortPower 0x1000
192 #define PORTSC_PortOwner 0x2000
193 #define PORTSC_PortIndicator_MASK 0xC000
194 #define PORTSC_PortIndicator_Off 0x0000
195 #define PORTSC_PortIndicator_Amber 0x4000
196 #define PORTSC_PortIndicator_Green 0x800
198 // Isochronous (High-Speed) Transfer Descriptor
211 // 0:10 - Max packet size
213 Uint32 BufferPointers[8]; // Page aligned, low 12 bits are overloaded
216 // Split Transaction Isochronous Transfer Descriptor
228 // Queue Element Transfer Descriptor
232 Uint32 Link2; // Used when there's a short packet
234 Uint32 Pages[5]; //First has offset in low 12 bits
239 } __attribute__((aligned(32)));
242 #define QTD_TOKEN_DATATGL (1<<31)
243 #define QTD_TOKEN_IOC (1<<15)
244 #define QTD_TOKEN_STS_ACTIVE (1<< 7)
245 #define QTD_TOKEN_STS_HALT (1<< 6)
250 Uint32 HLink; // Horizontal link
264 tEHCI_Endpoint *Endpt;
269 } __attribute__((aligned(32)));
270 // sizeof = 48 (round up to 64)
272 #define QH_ENDPT_H (1<<15)