]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/omap/usbehci.h
Import sources from 2011-03-30 iso image
[plan9front.git] / sys / src / 9 / omap / usbehci.h
1 /* override default macros from ../port/usb.h */
2 #undef  dprint
3 #undef  ddprint
4 #undef  deprint
5 #undef  ddeprint
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
10
11 typedef struct Ctlr Ctlr;
12 typedef struct Ecapio Ecapio;
13 typedef struct Eopio Eopio;
14 typedef struct Edbgio Edbgio;
15 typedef struct Isoio Isoio;
16 typedef struct Poll Poll;
17 typedef struct Qh Qh;
18 typedef struct Qtree Qtree;
19
20 #pragma incomplete Ctlr;
21 #pragma incomplete Ecapio;
22 #pragma incomplete Eopio;
23 #pragma incomplete Edbgio;
24 #pragma incomplete Isoio;
25 #pragma incomplete Poll;
26 #pragma incomplete Qh;
27 #pragma incomplete Qtree;
28
29
30 /*
31  * EHCI interface registers and bits
32  */
33 enum
34 {
35         Cnports         = 0xF,          /* nport bits in Ecapio parms. */
36         Cdbgportshift   = 20,           /* debug port in Ecapio parms. */
37         Cdbgportmask    = 0xF,
38         C64             = 1,            /* 64-bits, in Ecapio capparms. */
39         Ceecpshift      = 8,            /* extended capabilities ptr. in */
40         Ceecpmask       = 8,            /* the Ecapio capparms reg. */
41         Clegacy         = 1,            /* legacy support cap. id */
42         CLbiossem       = 2,            /* legacy cap. bios sem. */
43         CLossem         = 3,            /* legacy cap. os sem */
44         CLcontrol       = 4,            /* legacy support control & status */
45
46         /* typed links  */
47         Lterm           = 1,
48         Litd            = 0<<1,
49         Lqh             = 1<<1,
50         Lsitd           = 2<<1,
51         Lfstn           = 3<<1,         /* we don't use these */
52
53         /* Cmd reg. */
54         Cstop           = 0x00000,      /* stop running */
55         Crun            = 0x00001,      /* start operation */
56         Chcreset        = 0x00002,      /* host controller reset */
57         Cflsmask        = 0x0000C,      /* frame list size bits */
58         Cfls1024        = 0x00000,      /* frame list size 1024 */
59         Cfls512         = 0x00004,      /* frame list size 512 frames */
60         Cfls256         = 0x00008,      /* frame list size 256 frames */
61         Cpse            = 0x00010,      /* periodic sched. enable */
62         Case            = 0x00020,      /* async sched. enable */
63         Ciasync         = 0x00040,      /* interrupt on async advance doorbell */
64         Citc1           = 0x10000,      /* interrupt threshold ctl. 1 µframe */
65         Citc4           = 0x40000,      /* same. 2 µframes */
66         /* ... */
67         Citc8           = 0x80000,      /* same. 8 µframes (can go up to 64) */
68
69         /* Sts reg. */
70         Sasyncss        = 0x08000,      /* aync schedule status */
71         Speriodss       = 0x04000,      /* periodic schedule status */
72         Srecl           = 0x02000,      /* reclamnation (empty async sched.) */
73         Shalted         = 0x01000,      /* h.c. is halted */
74         Sasync          = 0x00020,      /* interrupt on async advance */
75         Sherr           = 0x00010,      /* host system error */
76         Sfrroll         = 0x00008,      /* frame list roll over */
77         Sportchg        = 0x00004,      /* port change detect */
78         Serrintr        = 0x00002,              /* error interrupt */
79         Sintr           = 0x00001,      /* interrupt */
80         Sintrs          = 0x0003F,      /* interrupts status */
81
82         /* Intr reg. */
83         Iusb            = 0x01,         /* intr. on usb */
84         Ierr            = 0x02,         /* intr. on usb error */
85         Iportchg        = 0x04,         /* intr. on port change */
86         Ifrroll         = 0x08,         /* intr. on frlist roll over */
87         Ihcerr          = 0x10,         /* intr. on host error */
88         Iasync          = 0x20,         /* intr. on async advance enable */
89         Iall            = 0x3F,         /* all interrupts */
90
91         /* Config reg. */
92         Callmine        = 1,            /* route all ports to us */
93
94         /* Portsc reg. */
95         Pspresent       = 0x00000001,   /* device present */
96         Psstatuschg     = 0x00000002,   /* Pspresent changed */
97         Psenable        = 0x00000004,   /* device enabled */
98         Pschange        = 0x00000008,   /* Psenable changed */
99         Psresume        = 0x00000040,   /* resume detected */
100         Pssuspend       = 0x00000080,   /* port suspended */
101         Psreset         = 0x00000100,   /* port reset */
102         Pspower         = 0x00001000,   /* port power on */
103         Psowner         = 0x00002000,   /* port owned by companion */
104         Pslinemask      = 0x00000C00,   /* line status bits */
105         Pslow           = 0x00000400,   /* low speed device */
106
107         /* Debug port csw reg. */
108         Cowner  = 0x40000000,           /* port owned by ehci */
109         Cenable = 0x10000000,           /* debug port enabled */
110         Cdone   = 0x00010000,           /* request is done */
111         Cbusy   = 0x00000400,           /* port in use by a driver */
112         Cerrmask= 0x00000380,           /* error code bits */
113         Chwerr  = 0x00000100,           /* hardware error */
114         Cterr   = 0x00000080,           /* transaction error */
115         Cfailed = 0x00000040,           /* transaction did fail */
116         Cgo     = 0x00000020,           /* execute the transaction */
117         Cwrite  = 0x00000010,           /* request is a write */
118         Clen    = 0x0000000F,           /* data len */
119
120         /* Debug port pid reg. */
121         Prpidshift      = 16,           /* received pid */
122         Prpidmask       = 0xFF,
123         Pspidshift      = 8,            /* sent pid */
124         Pspidmask       = 0xFF,
125         Ptokshift       = 0,            /* token pid */
126         Ptokmask        = 0xFF,
127
128         Ptoggle         = 0x00008800,   /* to update toggles */
129         Ptogglemask     = 0x0000FF00,
130
131         /* Debug port addr reg. */
132         Adevshift       = 8,            /* device address */
133         Adevmask        = 0x7F,
134         Aepshift        = 0,            /* endpoint number */
135         Aepmask         = 0xF,
136 };
137
138 /*
139  * Capability registers (hw)
140  */
141 struct Ecapio
142 {
143         ulong   cap;            /* 00 controller capability register */
144         ulong   parms;          /* 04 structural parameters register */
145         ulong   capparms;       /* 08 capability parameters */
146         ulong   portroute;      /* 0c not on the CS5536 */
147 };
148
149 /*
150  * Debug port registers (hw)
151  */
152 struct Edbgio
153 {
154         ulong   csw;            /* control and status */
155         ulong   pid;            /* USB pid */
156         uchar   data[8];        /* data buffer */
157         ulong   addr;           /* device and endpoint addresses */
158 };
159
160 struct Poll
161 {
162         Lock;
163         Rendez;
164         int     must;
165         int     does;
166 };
167
168 struct Ctlr
169 {
170         Rendez;                 /* for waiting to async advance doorbell */
171         Lock;                   /* for ilock. qh lists and basic ctlr I/O */
172         QLock   portlck;        /* for port resets/enable... (and doorbell) */
173         int     active;         /* in use or not */
174         Ecapio* capio;          /* Capability i/o regs */
175         Eopio*  opio;           /* Operational i/o regs */
176
177         int     nframes;        /* 1024, 512, or 256 frames in the list */
178         ulong*  frames;         /* periodic frame list (hw) */
179         Qh*     qhs;            /* async Qh circular list for bulk/ctl */
180         Qtree*  tree;           /* tree of Qhs for the periodic list */
181         int     ntree;          /* number of dummy qhs in tree */
182         Qh*     intrqhs;        /* list of (not dummy) qhs in tree  */
183         Isoio*  iso;            /* list of active Iso I/O */
184         ulong   load;
185         ulong   isoload;
186         int     nintr;          /* number of interrupts attended */
187         int     ntdintr;        /* number of intrs. with something to do */
188         int     nqhintr;        /* number of async td intrs. */
189         int     nisointr;       /* number of periodic td intrs. */
190         int     nreqs;
191         Poll    poll;
192 };
193
194 /*
195  * OMAP3-specific stuff
196  */
197
198 enum {
199         /* hostconfig bits */
200         P1ulpi_bypass = 1<<0,   /* utmi if set; else ulpi */
201 };
202
203 /*
204  * Operational registers (hw)
205  */
206 struct Eopio
207 {
208         ulong   cmd;            /* 00 command */
209         ulong   sts;            /* 04 status */
210         ulong   intr;           /* 08 interrupt enable */
211         ulong   frno;           /* 0c frame index */
212         ulong   seg;            /* 10 bits 63:32 of EHCI datastructs (unused) */
213         ulong   frbase;         /* 14 frame list base addr, 4096-byte boundary */
214         ulong   link;           /* 18 link for async list */
215         uchar   d2c[0x40-0x1c]; /* 1c dummy */
216         ulong   config;         /* 40 1: all ports default-routed to this HC */
217         ulong   portsc[3];      /* 44 Port status and control, one per port */
218
219         /* defined for omap35 ehci at least */
220         uchar   _pad0[0x80 - 0x50];
221         ulong   insn[6];        /* implementation-specific */
222 };
223
224 typedef struct Uhh Uhh;
225 struct Uhh {
226         ulong   revision;       /* ro */
227         uchar   _pad0[0x10-0x4];
228         ulong   sysconfig;
229         ulong   sysstatus;      /* ro */
230
231         uchar   _pad1[0x40-0x18];
232         ulong   hostconfig;
233         ulong   debug_csr;
234 };
235
236 extern Ecapio *ehcidebugcapio;
237 extern int ehcidebugport;
238
239 extern int ehcidebug;
240
241 void    ehcilinkage(Hci *hp);
242 void    ehcimeminit(Ctlr *ctlr);
243 void    ehcirun(Ctlr *ctlr, int on);