1 /* override default macros from ../port/usb.h */
6 #define dprint if(ehcidebug)print
7 #define ddprint if(ehcidebug>1)print
8 #define deprint if(ehcidebug || ep->debug)print
9 #define ddeprint if(ehcidebug>1 || ep->debug>1)print
11 typedef struct Ctlr Ctlr;
12 typedef struct Eopio Eopio;
13 typedef struct Ecapio Ecapio;
14 typedef struct Isoio Isoio;
15 typedef struct Poll Poll;
17 typedef struct Qtree Qtree;
19 #pragma incomplete Ctlr;
20 #pragma incomplete Eopio;
21 #pragma incomplete Isoio;
22 #pragma incomplete Poll;
23 #pragma incomplete Qh;
24 #pragma incomplete Qtree;
28 /* Ecapio->parms reg. */
29 Cnports = 0xF, /* nport bits */
30 Cdbgportshift = 20, /* debug port */
33 /* Ecapio->capparms bits */
34 C64 = 1<<0, /* 64-bits */
35 Cpfl = 1<<1, /* program'ble frame list: can be <1024 */
36 Casp = 1<<2, /* asynch. sched. park */
37 Ceecpshift = 8, /* extended capabilities ptr. */
38 Ceecpmask = (1<<8) - 1,
40 Clegacy = 1, /* legacy support cap. id */
41 CLbiossem = 2, /* legacy cap. bios sem. */
42 CLossem = 3, /* legacy cap. os sem */
43 CLcontrol = 4, /* legacy support control & status */
50 Lfstn = 3<<1, /* we don't use these */
53 Cstop = 0x00000, /* stop running */
54 Crun = 0x00001, /* start operation */
55 Chcreset = 0x00002, /* host controller reset */
56 Cflsmask = 0x0000C, /* frame list size bits */
57 Cfls1024 = 0x00000, /* frame list size 1024 */
58 Cfls512 = 0x00004, /* frame list size 512 frames */
59 Cfls256 = 0x00008, /* frame list size 256 frames */
60 Cpse = 0x00010, /* periodic sched. enable */
61 Case = 0x00020, /* async sched. enable */
62 Ciasync = 0x00040, /* interrupt on async advance doorbell */
63 /* interrupt threshold ctl. in µframes (1-32 in powers of 2) */
65 Citcmask = 0xff << Citcshift,
68 Sasyncss = 0x08000, /* aync schedule status */
69 Speriodss = 0x04000, /* periodic schedule status */
70 Srecl = 0x02000, /* reclamnation (empty async sched.) */
71 Shalted = 0x01000, /* h.c. is halted */
72 Sasync = 0x00020, /* interrupt on async advance */
73 Sherr = 0x00010, /* host system error */
74 Sfrroll = 0x00008, /* frame list roll over */
75 Sportchg = 0x00004, /* port change detect */
76 Serrintr = 0x00002, /* error interrupt */
77 Sintr = 0x00001, /* interrupt */
78 Sintrs = 0x0003F, /* interrupts status */
81 Iusb = 0x01, /* intr. on usb */
82 Ierr = 0x02, /* intr. on usb error */
83 Iportchg = 0x04, /* intr. on port change */
84 Ifrroll = 0x08, /* intr. on frlist roll over */
85 Ihcerr = 0x10, /* intr. on host error */
86 Iasync = 0x20, /* intr. on async advance enable */
87 Iall = 0x3F, /* all interrupts */
90 Callmine = 1, /* route all ports to us */
93 Pspresent = 0x00000001, /* device present */
94 Psstatuschg = 0x00000002, /* Pspresent changed */
95 Psenable = 0x00000004, /* device enabled */
96 Pschange = 0x00000008, /* Psenable changed */
97 Psresume = 0x00000040, /* resume detected */
98 Pssuspend = 0x00000080, /* port suspended */
99 Psreset = 0x00000100, /* port reset */
100 Pspower = 0x00001000, /* port power on */
101 Psowner = 0x00002000, /* port owned by companion */
102 Pslinemask = 0x00000C00, /* line status bits */
103 Pslow = 0x00000400, /* low speed device */
105 /* Debug port csw reg. */
106 Cowner = 0x40000000, /* port owned by ehci */
107 Cenable = 0x10000000, /* debug port enabled */
108 Cdone = 0x00010000, /* request is done */
109 Cbusy = 0x00000400, /* port in use by a driver */
110 Cerrmask= 0x00000380, /* error code bits */
111 Chwerr = 0x00000100, /* hardware error */
112 Cterr = 0x00000080, /* transaction error */
113 Cfailed = 0x00000040, /* transaction did fail */
114 Cgo = 0x00000020, /* execute the transaction */
115 Cwrite = 0x00000010, /* request is a write */
116 Clen = 0x0000000F, /* data len */
118 /* Debug port pid reg. */
119 Prpidshift = 16, /* received pid */
121 Pspidshift = 8, /* sent pid */
123 Ptokshift = 0, /* token pid */
126 Ptoggle = 0x00008800, /* to update toggles */
127 Ptogglemask = 0x0000FF00,
129 /* Debug port addr reg. */
130 Adevshift = 8, /* device address */
132 Aepshift = 0, /* endpoint number */
146 Rendez; /* for waiting to async advance doorbell */
147 Lock; /* for ilock. qh lists and basic ctlr I/O */
148 QLock portlck; /* for port resets/enable... (and doorbell) */
149 int active; /* in use or not */
150 Ecapio* capio; /* Capability i/o regs */
151 Eopio* opio; /* Operational i/o regs */
153 void* (*tdalloc)(usize,int,usize);
154 void* (*dmaalloc)(usize);
155 void (*dmafree)(void*);
157 int nframes; /* 1024, 512, or 256 frames in the list */
158 ulong* frames; /* periodic frame list (hw) */
159 Qh* qhs; /* async Qh circular list for bulk/ctl */
160 Qtree* tree; /* tree of Qhs for the periodic list */
161 int ntree; /* number of dummy qhs in tree */
162 Qh* intrqhs; /* list of (not dummy) qhs in tree */
163 Isoio* iso; /* list of active Iso I/O */
166 int nintr; /* number of interrupts attended */
167 int ntdintr; /* number of intrs. with something to do */
168 int nqhintr; /* number of async td intrs. */
169 int nisointr; /* number of periodic td intrs. */
175 * Operational registers (hw)
179 ulong cmd; /* 00 command */
180 ulong sts; /* 04 status */
181 ulong intr; /* 08 interrupt enable */
182 ulong frno; /* 0c frame index */
183 ulong seg; /* 10 bits 63:32 of EHCI datastructs (unused) */
184 ulong frbase; /* 14 frame list base addr, 4096-byte boundary */
185 ulong link; /* 18 link for async list */
186 uchar d2c[0x40-0x1c]; /* 1c dummy */
187 ulong config; /* 40 1: all ports default-routed to this HC */
188 ulong portsc[3]; /* 44 Port status and control, one per port */
190 /* defined for omap35 ehci at least */
191 uchar _pad0[0x80 - 0x50];
192 ulong insn[6]; /* implementation-specific */
196 * Capability registers (hw)
200 ulong cap; /* 00 controller capability register */
201 ulong parms; /* 04 structural parameters register */
202 ulong capparms; /* 08 capability parameters */
203 ulong portroute; /* 0c not on the CS5536 */
206 typedef struct Uhh Uhh;
208 ulong revision; /* ro */
209 uchar _pad0[0x10-0x4];
211 ulong sysstatus; /* ro */
213 uchar _pad1[0x40-0x18];
219 /* hostconfig bits */
220 P1ulpi_bypass = 1<<0, /* utmi if set; else ulpi */
223 extern int ehcidebugport;
225 extern int ehcidebug;
227 void ehcilinkage(Hci *hp);
228 void ehcimeminit(Ctlr *ctlr);
229 void ehcirun(Ctlr *ctlr, int on);
231 #define dmaflush(clean, addr, len)