revert between 56095 -> 55830 in arch
[AROS.git] / rom / usb / pciusbhc / ohci / chip.h
bloba1b81632a055713a5d6ab4b260537115a9c8c6b8
1 /*
2 Copyright © 2002-2009, Chris Hodges. All rights reserved.
3 Copyright © 2009-2012, The AROS Development Team. All rights reserved.
4 $Id$
5 */
7 #ifndef CHIP_H
8 #define CHIP_H
10 #include <exec/types.h>
12 /* Framelist stuff
14 - Framelist contains all the same entries pointing to ISO-TD
15 - ISO-TD: is inactive by default. Links to Control-QH
16 - Control-QH: - Head links to Int-Queue
17 - Element: Links to dummy-TD if empty (inactive)
18 - Element: otherwise links to QH for control transfer
19 - Int-Queue : - Head links to Bulk-Queue
25 * --------------------- OHCI registers ------------------------
26 * Warning: These are BYTE offsets!
29 /* operational registers */
30 #define OHCI_REVISION 0x000 /* Host Controller Revision (r) */
31 #define OHCI_CONTROL 0x004 /* Control register (r/w) */
32 #define OHCI_CMDSTATUS 0x008 /* Command and Status */
33 #define OHCI_INTSTATUS 0x00c /* Interrupt Status (r/wc) */
34 #define OHCI_INTEN 0x010 /* Interrupt Enable (r/ws) */
35 #define OHCI_INTDIS 0x014 /* Interrupt Disable (r/wc) */
36 #define OHCI_HCCA 0x018 /* Pointer to HCCA */
37 #define OHCI_PERIODIC_ED 0x01c /* Current periodic ED */
38 #define OHCI_CTRL_HEAD_ED 0x020 /* Control Head ED */
39 #define OHCI_CTRL_ED 0x024 /* Current control ED */
40 #define OHCI_BULK_HEAD_ED 0x028 /* Bulk Head ED */
41 #define OHCI_BULK_ED 0x02c /* Current bulk ED */
42 #define OHCI_DONEHEAD 0x030 /* Done head pointer */
43 #define OHCI_FRAMEINTERVAL 0x034 /* Frame interval */
44 #define OHCI_FRAMEREMAINING 0x038 /* Frame remaining time */
45 #define OHCI_FRAMECOUNT 0x03c /* Frame number */
46 #define OHCI_PERIODICSTART 0x040 /* Periodic start (usually 10% of 12000 == 0x3e67) */
47 #define OHCI_LSTHRESHOLD 0x044 /* Lowspeed threshold (usually 0x0628) */
48 #define OHCI_HUBDESCA 0x048 /* Root Hub Descriptor A */
49 #define OHCI_HUBDESCB 0x04c /* Root Hub Descriptor B */
50 #define OHCI_HUBSTATUS 0x050 /* Root Hub Status */
51 #define OHCI_PORTSTATUS 0x054 /* Port Status */
53 /* OHCI_CONTROL defines */
54 #define OCLS_CBSR 0 /* Control Bulk Service Ratio */
55 #define OCLB_PERIODICENABLE 2 /* Periodic Enable */
56 #define OCLB_ISOENABLE 3 /* Isochronous Enable */
57 #define OCLB_CTRLENABLE 4 /* Control List enable */
58 #define OCLB_BULKENABLE 5 /* Bulk List enable */
59 #define OCLS_USBSTATE 6 /* Host controller functional state */
60 #define OCLB_SMIINT 8 /* SMI Interrupt routing */
61 #define OCLB_REMOTEWAKEUP 10 /* Remote wakeup enabled */
63 #define OCLF_PERIODICENABLE (1UL<<OCLB_PERIODICENABLE)
64 #define OCLF_ISOENABLE (1UL<<OCLB_ISOENABLE)
65 #define OCLF_CTRLENABLE (1UL<<OCLB_CTRLENABLE)
66 #define OCLF_BULKENABLE (1UL<<OCLB_BULKENABLE)
67 #define OCLF_SMIINT (1UL<<OCLB_SMIINT)
68 #define OCLF_REMOTEWAKEUP (1UL<<OCLB_REMOTEWAKEUP)
70 #define OCLM_CBSR (((1UL<<2)-1)<<OCLS_CBSR)
71 #define OCLM_USBSTATE (((1UL<<2)-1)<<OCLS_USBSTATE)
72 #define OCLF_USBRESET (0UL<<OCLS_USBSTATE)
73 #define OCLF_USBRESUME (1UL<<OCLS_USBSTATE)
74 #define OCLF_USBOPER (2UL<<OCLS_USBSTATE)
75 #define OCLF_USBSUSPEND (3UL<<OCLS_USBSTATE)
77 /* OHCI_CMDSTATUS defines */
78 #define OCSB_HCRESET 0 /* Host controller reset */
79 #define OCSB_CTRLENABLE 1 /* Enable Control List processing */
80 #define OCSB_BULKENABLE 2 /* Enable Bulk List processing */
81 #define OCSB_OWNERCHANGEREQ 3 /* Request change of ownership for BIOS handover */
83 #define OCSF_HCRESET (1UL<<OCSB_HCRESET)
84 #define OCSF_CTRLENABLE (1UL<<OCSB_CTRLENABLE)
85 #define OCSF_BULKENABLE (1UL<<OCSB_BULKENABLE)
86 #define OCSF_OWNERCHANGEREQ (1UL<<OCSB_OWNERCHANGEREQ)
88 /* OHCI_INTSTATUS, OHCI_INTEN and OHCI_INTDIS defines */
89 #define OISB_SCHEDOVERRUN 0 /* Schedule overrun */
90 #define OISB_DONEHEAD 1 /* Writeback done head */
91 #define OISB_SOF 2 /* Start of Frame */
92 #define OISB_RESUMEDTX 3 /* Resume detected */
93 #define OISB_HOSTERROR 4 /* Unrecoverable error */
94 #define OISB_FRAMECOUNTOVER 5 /* Frame counter overrun (15 bit) */
95 #define OISB_HUBCHANGE 6 /* Root Hub status change */
96 #define OISB_OWNERCHANGE 30 /* Ownership changed */
97 #define OISB_MASTERENABLE 31 /* Master Interrupt enable (INTEN only) */
99 #define OISF_SCHEDOVERRUN (1UL<<OISB_SCHEDOVERRUN)
100 #define OISF_DONEHEAD (1UL<<OISB_DONEHEAD)
101 #define OISF_SOF (1UL<<OISB_SOF)
102 #define OISF_RESUMEDTX (1UL<<OISB_RESUMEDTX)
103 #define OISF_HOSTERROR (1UL<<OISB_HOSTERROR)
104 #define OISF_FRAMECOUNTOVER (1UL<<OISB_FRAMECOUNTOVER)
105 #define OISF_HUBCHANGE (1UL<<OISB_HUBCHANGE)
106 #define OISF_OWNERCHANGE (1UL<<OISB_OWNERCHANGE)
107 #define OISF_MASTERENABLE (1UL<<OISB_MASTERENABLE)
109 #define OISF_ALL_INTS (OISF_SCHEDOVERRUN|OISF_DONEHEAD|OISF_SOF|OISF_RESUMEDTX|OISF_HOSTERROR|OISF_FRAMECOUNTOVER|OISF_HUBCHANGE|OISF_MASTERENABLE)
111 /* OHCI_INTERVAL defines */
112 #define OIVS_INTERVAL 0 /* Interval, usually 11999 == 0x2edf */
113 #define OIVS_BITSPERFRAME 16 /* Size of the frames in bits, usually ((12000 - 210) * 6) / 7 == 10105 */
114 #define OIVB_TOGGLE 31 /* Toggle on change of interval */
116 #define OIVM_INTERVAL (((1UL<<14)-1)<<OIVS_INTERVAL)
117 #define OIVM_BITSPERFRAME (((1UL<<15)-1)<<OIVS_BITSPERFRAME)
118 #define OIVF_TOGGLE (1UL<<OIVB_TOGGLE)
120 #define OHCI_DEF_BITSPERFRAME 10105
122 /* OHCI_HUBDESCA defines */
123 #define OHAS_NUMPORTS 0 /* Number of downstream ports */
124 #define OHAB_INDIVIDUALPS 8 /* Power switching per port */
125 #define OHAB_NOPOWERSWITCH 9 /* Ports always powered */
126 #define OHAB_INDIVIDUALOC 11 /* Overcurrent Detection per port */
127 #define OHAB_NOOVERCURRENT 12 /* No over-current detection */
128 #define OHAS_POWERGOOD 24 /* Power-good delay */
130 #define OHAM_NUMPORTS (((1UL<<8)-1)<<OHAS_NUMPORTS)
131 #define OHAF_INDIVIDUALPS (1UL<<OHAB_INDIVIDUALPS)
132 #define OHAF_NOPOWERSWITCH (1UL<<OHAB_NOPOWERSWITCH)
133 #define OHAF_INDIVIDUALOC (1UL<<OHAB_INDIVIDUALOC)
134 #define OHAF_NOOVERCURRENT (1UL<<OHAB_NOOVERCURRENT)
135 #define OHAM_POWERGOOD (((1UL<<8)-1)<<OHAS_POWERGOOD)
137 /* OHCI_HUBDESCB defines */
138 #define OHBS_DEVREMOVABLE 0 /* Bitmask of removable devices at roothub (port 1 == bit 1) */
139 #define OHBS_PORTPOWERCTRL 16 /* Bitmask of global power controlled ports */
141 #define OHBM_DEVREMOVABLE (((1UL<<16)-1)<<OHBS_DEVREMOVABLE)
142 #define OHBM_PORTPOWERCTRL (((1UL<<16)-1)<<OHBS_PORTPOWERCTRL)
144 /* OHCI_HUBSTATUS defines */
145 #define OHSB_UNPOWERHUB 0 /* Clear global Hub power */
146 #define OHSB_OVERCURRENT 1 /* Global over-current reported */
147 #define OHSB_POWERHUB 16 /* Set global Hub power */
148 #define OHSB_OVERCURRENTCHG 17 /* Reports change in over-current situation */
150 #define OHSF_UNPOWERHUB (1UL<<OHSB_UNPOWERHUB)
151 #define OHSF_OVERCURRENT (1UL<<OHSB_OVERCURRENT)
152 #define OHSF_POWERHUB (1UL<<OHSB_POWERHUB)
153 #define OHSF_OVERCURRENTCHG (1UL<<OHSB_OVERCURRENTCHG)
155 /* OHCI_PORTSTATUS defines */
156 #define OHPB_PORTCONNECTED 0 /* Port Connection status (r) */
157 #define OHPB_PORTDISABLE 0 /* Clear Port enable (w) */
158 #define OHPB_PORTENABLE 1 /* Port Enabled (r), Enable Port (w) */
159 #define OHPB_PORTSUSPEND 2 /* Port Suspended (r), Suspend Port (w) */
160 #define OHPB_OVERCURRENT 3 /* Port Overcurrent detected (r) */
161 #define OHPB_RESUME 3 /* Resume from suspend (w) */
162 #define OHPB_PORTRESET 4 /* Port in reset (r), Reset port (w) */
163 #define OHPB_PORTPOWER 8 /* Power powered (r), Power port (w) */
164 #define OHPB_LOWSPEED 9 /* Low speed device connected (r) */
165 #define OHPB_PORTUNPOWER 9 /* Clear Port power (w) */
166 #define OHPB_CONNECTCHANGE 16 /* Port Connection change */
167 #define OHPB_ENABLECHANGE 17 /* Port Enable/Disable change */
168 #define OHPB_RESUMEDTX 18 /* Resume detected */
169 #define OHPB_OVERCURRENTCHG 19 /* Over-current change */
170 #define OHPB_RESETCHANGE 20 /* Reset complete */
172 #define OHPF_PORTCONNECTED (1UL<<OHPB_PORTCONNECTED)
173 #define OHPF_PORTDISABLE (1UL<<OHPB_PORTDISABLE)
174 #define OHPF_PORTENABLE (1UL<<OHPB_PORTENABLE)
175 #define OHPF_PORTSUSPEND (1UL<<OHPB_PORTSUSPEND)
176 #define OHPF_OVERCURRENT (1UL<<OHPB_OVERCURRENT)
177 #define OHPF_RESUME (1UL<<OHPB_RESUME)
178 #define OHPF_PORTRESET (1UL<<OHPB_PORTRESET)
179 #define OHPF_PORTPOWER (1UL<<OHPB_PORTPOWER)
180 #define OHPF_LOWSPEED (1UL<<OHPB_LOWSPEED)
181 #define OHPF_PORTUNPOWER (1UL<<OHPB_PORTUNPOWER)
182 #define OHPF_CONNECTCHANGE (1UL<<OHPB_CONNECTCHANGE)
183 #define OHPF_ENABLECHANGE (1UL<<OHPB_ENABLECHANGE)
184 #define OHPF_RESUMEDTX (1UL<<OHPB_RESUMEDTX)
185 #define OHPF_OVERCURRENTCHG (1UL<<OHPB_OVERCURRENTCHG)
186 #define OHPF_RESETCHANGE (1UL<<OHPB_RESETCHANGE)
188 /* data structures */
190 /* HCCA */
192 #define OHCI_HCCA_SIZE 256 /* size of HCCA section */
193 #define OHCI_HCCA_ALIGNMENT 0x0ff /* alignment of HCCA section */
195 struct HCCA
197 ULONG ha_IntEDs[32]; /* LE PHYSICAL pointer to Interrupt EDs */
198 UWORD ha_FrameCount; /* LE Framecounter */
199 UWORD ha_FrmCntChg; /* Set 0 when framecounter was updated */
200 ULONG ha_DoneHead; /* LE PHYSICAL pointer to Head of ED finished + unmasked Int */
204 #define OHCI_PAGE_SIZE 4096
206 #define OHCI_TDQH_ALIGNMENT 0x001f
208 #define OHCI_ED_POOLSIZE 128
209 #define OHCI_TD_POOLSIZE 512
211 #define OHCI_TD_BULK_LIMIT (128<<10) // limit for one batch of BULK data TDs
214 struct EndpointDescriptor
216 /* HC data, aligned to 16 bytes */
217 ULONG EPCaps; /* LE MaxPacketSize and other stuff */
218 ULONG TailPtr; /* LE PHYSICAL TD Queue Tail Pointer */
219 ULONG HeadPtr; /* LE PHYSICAL TD Queue Head Pointer */
220 ULONG NextED; /* LE PHYSICAL Next Endpoint Descriptor */
223 struct EDNode
225 struct MinNode ed_Node;
226 ULONG ed_Self; /* LE PHYSICAL pointer to self */
227 /* On 64 bits a padding will be inserted here */
228 struct IOUsbHWReq *ed_IOReq; /* IO Request this belongs to */
229 struct MinList ed_TDList;
230 IPTR ed_Continue; /* Flag for fragmented bulk transfer */
231 APTR ed_Buffer; /* Mirror buffer for data outside DMA-accessible area */
232 struct UsbSetupData *ed_SetupData; /* Mirror buffer for setup packet */
233 IPTR ed_Pad[2];
234 struct EndpointDescriptor ed_ED;
237 struct TransferDescriptor
239 /* HC data, aligned to 16 bytes */
240 ULONG Ctrl; /* LE Ctrl stuff */
241 ULONG BufferPtr; /* LE PHYSICAL Current Buffer Pointer */
242 ULONG NextTD; /* LE PHYSICAL Next TD */
243 ULONG BufferEnd; /* LE PHYSICAL End of buffer */
246 /* N.B. The ULONGs are deliberately placed apart to ensure structure size
247 is a multiple of 16 bytes on 64-bit archs */
248 struct TDNode
250 struct MinNode td_Node;
251 ULONG td_Self; /* LE PHYSICAL pointer to TD */
252 struct EDNode *td_ED; /* Pointer to parent ED this TD belongs to */
253 ULONG td_Length; /* Length of transfer */
254 IPTR td_Pad[3];
255 struct TransferDescriptor td_TD;
258 /* pointer defines */
260 #define OHCI_PTRMASK 0xfffffff0 /* frame list pointer mask */
262 /* ED EPCaps defines */
264 #define OECB_LOWSPEED 13 /* Lowspeed */
265 #define OECB_SKIP 14 /* Skip ED */
266 #define OECB_ISO 15 /* Isochronous endpoint */
268 #define OECS_DEVADDR 0 /* Device Address */
269 #define OECS_ENDPOINT 7 /* Endpoint number */
270 #define OECS_DIRECTION 11 /* Direction */
271 #define OECS_MAXPKTLEN 16 /* MaxPacketLength */
273 #define OECF_LOWSPEED (1UL<<OECB_LOWSPEED)
274 #define OECF_SKIP (1UL<<OECB_SKIP)
275 #define OECF_ISO (1UL<<OECB_ISO)
277 #define OECM_DEVADDR (((1UL<<7)-1)<<OECS_DEVADDR)
278 #define OECM_ENDPOINT (((1UL<<4)-1)<<OECS_ENDPOINT)
279 #define OECM_MAXPKTLEN (((1UL<<11)-1)<<OECS_MAXPKTLEN)
281 #define OECM_DIRECTION (((1UL<<2)-1)<<OECS_DIRECTION)
282 #define OECF_DIRECTION_TD (0UL<<OECS_DIRECTION)
283 #define OECF_DIRECTION_OUT (1UL<<OECS_DIRECTION)
284 #define OECF_DIRECTION_IN (2UL<<OECS_DIRECTION)
286 /* ED HeadPtr defines */
288 #define OEHB_HALTED 0 /* TD Queue is halted */
289 #define OEHB_DATA1 1 /* Data 1 Toggle bit */
291 #define OEHF_HALTED (1UL<<OEHB_HALTED)
292 #define OEHF_DATA1 (1UL<<OEHB_DATA1)
294 /* TD Ctrl defines */
296 #define OTCB_ALLOWSHORTPKT 18 /* Allow short packets */
297 #define OTCB_DATA1 24 /* Data 1 toggle bit */
298 #define OTCB_TOGGLEFROMTD 25 /* Data toggle comes from TD */
300 #define OTCS_PIDCODE 19 /* PID code */
301 #define OTCS_DELAYINT 21 /* Delay interrupt by given amount of frames */
302 #define OTCS_ERRORCOUNT 26 /* Number of errors occurred so far */
303 #define OTCS_COMPLETIONCODE 28 /* Error codes */
305 #define OTCF_ALLOWSHORTPKT (1UL<<OTCB_ALLOWSHORTPKT)
306 #define OTCF_DATA0 (0UL<<OTCB_DATA1)
307 #define OTCF_DATA1 (1UL<<OTCB_DATA1)
308 #define OTCF_TOGGLEFROMTD (1UL<<OTCB_TOGGLEFROMTD)
310 #define OTCM_PIDCODE (((1UL<<2)-1)<<OTCS_PIDCODE)
311 #define OTCF_PIDCODE_SETUP (0UL<<OTCS_PIDCODE)
312 #define OTCF_PIDCODE_OUT (1UL<<OTCS_PIDCODE)
313 #define OTCF_PIDCODE_IN (2UL<<OTCS_PIDCODE)
315 #define OTCM_DELAYINT (((1UL<<3)-1)<<OTCS_DELAYINT)
316 #define OTCF_NOINT (7UL<<OTCS_DELAYINT)
318 #define OTCM_ERRORCOUNT (((1UL<<2)-1)<<OTCS_ERRORCOUNT)
319 #define OTCM_COMPLETIONCODE (((1UL<<4)-1)<<OTCS_COMPLETIONCODE)
320 #define OTCF_CC_NOERROR (0UL<<OTCS_COMPLETIONCODE)
321 #define OTCF_CC_CRCERROR (1UL<<OTCS_COMPLETIONCODE)
322 #define OTCF_CC_BABBLE (2UL<<OTCS_COMPLETIONCODE)
323 #define OTCF_CC_WRONGTOGGLE (3UL<<OTCS_COMPLETIONCODE)
324 #define OTCF_CC_STALL (4UL<<OTCS_COMPLETIONCODE)
325 #define OTCF_CC_TIMEOUT (5UL<<OTCS_COMPLETIONCODE)
326 #define OTCF_CC_PIDCORRUPT (6UL<<OTCS_COMPLETIONCODE)
327 #define OTCF_CC_WRONGPID (7UL<<OTCS_COMPLETIONCODE)
328 #define OTCF_CC_OVERFLOW (8UL<<OTCS_COMPLETIONCODE)
329 #define OTCF_CC_SHORTPKT (9UL<<OTCS_COMPLETIONCODE)
330 #define OTCF_CC_OVERRUN (12UL<<OTCS_COMPLETIONCODE)
331 #define OTCF_CC_UNDERRUN (13UL<<OTCS_COMPLETIONCODE)
332 #define OTCF_CC_INVALID (15UL<<OTCS_COMPLETIONCODE)
334 #endif /* CHIP_H */