]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/zynq/usbehci.h
bootrc: allow kbmap to be set via plan9.ini (thanks Aaron Bieber)
[plan9front.git] / sys / src / 9 / zynq / 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 enum {
12         /* typed links  */
13         Lterm           = 1,
14         Litd            = 0<<1,
15         Lqh             = 1<<1,
16         Lsitd           = 2<<1,
17         Lfstn           = 3<<1,         /* we don't use these */
18
19         /* Cmd reg. */
20         Cstop           = 0x00000,      /* stop running */
21         Crun            = 0x00001,      /* start operation */
22         Chcreset        = 0x00002,      /* host controller reset */
23         Cflsmask        = 0x0000C,      /* frame list size bits */
24         Cfls1024        = 0x00000,      /* frame list size 1024 */
25         Cfls512         = 0x00004,      /* frame list size 512 frames */
26         Cfls256         = 0x00008,      /* frame list size 256 frames */
27         Cpse            = 0x00010,      /* periodic sched. enable */
28         Case            = 0x00020,      /* async sched. enable */
29         Ciasync         = 0x00040,      /* interrupt on async advance doorbell */
30         Citc1           = 0x10000,      /* interrupt threshold ctl. 1 µframe */
31         Citc4           = 0x40000,      /* same. 2 µframes */
32         /* ... */
33         Citc8           = 0x80000,      /* same. 8 µframes (can go up to 64) */
34
35         /* Sts reg. */
36         Sasyncss        = 0x08000,      /* aync schedule status */
37         Speriodss       = 0x04000,      /* periodic schedule status */
38         Srecl           = 0x02000,      /* reclamnation (empty async sched.) */
39         Shalted         = 0x01000,      /* h.c. is halted */
40         Sasync          = 0x00020,      /* interrupt on async advance */
41         Sherr           = 0x00010,      /* host system error */
42         Sfrroll         = 0x00008,      /* frame list roll over */
43         Sportchg        = 0x00004,      /* port change detect */
44         Serrintr        = 0x00002,              /* error interrupt */
45         Sintr           = 0x00001,      /* interrupt */
46         Sintrs          = 0x0003F,      /* interrupts status */
47
48         /* Portsc reg. */
49         Pspresent       = 0x00000001,   /* device present */
50         Psstatuschg     = 0x00000002,   /* Pspresent changed */
51         Psenable        = 0x00000004,   /* device enabled */
52         Pschange        = 0x00000008,   /* Psenable changed */
53         Psresume        = 0x00000040,   /* resume detected */
54         Pssuspend       = 0x00000080,   /* port suspended */
55         Psreset         = 0x00000100,   /* port reset */
56         Pspower         = 0x00001000,   /* port power on */
57
58         /* Intr reg. */
59         Iusb            = 0x01,         /* intr. on usb */
60         Ierr            = 0x02,         /* intr. on usb error */
61         Iportchg        = 0x04,         /* intr. on port change */
62         Ifrroll         = 0x08,         /* intr. on frlist roll over */
63         Ihcerr          = 0x10,         /* intr. on host error */
64         Iasync          = 0x20,         /* intr. on async advance enable */
65         Iall            = 0x3F,         /* all interrupts */
66         
67         Callmine        = 1,
68         
69         /* hack to disable port handoff */
70         Psowner = 0,
71         Pslinemask = 0,
72         Pslow = -1
73 };
74
75 typedef struct Ctlr Ctlr;
76 typedef void Ecapio;
77 typedef struct Eopio Eopio;
78 typedef struct Isoio Isoio;
79 typedef struct Poll Poll;
80 typedef struct Qh Qh;
81 typedef struct Qtree Qtree;
82
83 #pragma incomplete Ctlr
84
85 struct Eopio
86 {
87 /*140*/ ulong cmd;
88 /*144*/ ulong sts;
89 /*148*/ ulong intr;
90 /*14c*/ ulong frno;
91
92 /*150*/ ulong reserved1;
93
94 /*154*/ ulong frbase;
95 /*158*/ ulong link;
96
97 /*15c*/ ulong _ttctrl;
98 /*160*/ ulong _burstsize;
99 /*164*/ ulong _txfilltuning;
100 /*168*/ ulong _txttfilltuning;
101 /*16c*/ ulong _ic_usb;
102 /*170*/ ulong _ulpi_viewport;
103
104 /*174*/ ulong reserved2;
105
106 /*178*/ ulong _endptnak;
107 /*17c*/ ulong _endptnaken;
108
109 /*180*/ ulong config;
110 /*184*/ ulong portsc[1];
111 };
112
113 struct Poll
114 {
115         Lock;
116         Rendez;
117         int must;
118         int does;
119 };
120
121 struct Ctlr
122 {
123         Rendez;                 /* for waiting to async advance doorbell */
124         Lock;                   /* for ilock. qh lists and basic ctlr I/O */
125         QLock   portlck;        /* for port resets/enable... (and doorbell) */
126         int     active;         /* in use or not */
127         void*   capio;          /* base address for debug info */
128         Eopio*  opio;           /* Operational i/o regs */
129
130         void*   (*tdalloc)(ulong,int,ulong);
131         void*   (*dmaalloc)(ulong);
132         void    (*dmafree)(void*);
133
134         int     nframes;        /* 1024, 512, or 256 frames in the list */
135         ulong*  frames;         /* periodic frame list (hw) */
136         Qh*     qhs;            /* async Qh circular list for bulk/ctl */
137         Qtree*  tree;           /* tree of Qhs for the periodic list */
138         int     ntree;          /* number of dummy qhs in tree */
139         Qh*     intrqhs;                /* list of (not dummy) qhs in tree  */
140         Isoio*  iso;            /* list of active Iso I/O */
141         ulong   load;
142         ulong   isoload;
143         int     nintr;          /* number of interrupts attended */
144         int     ntdintr;        /* number of intrs. with something to do */
145         int     nqhintr;        /* number of async td intrs. */
146         int     nisointr;       /* number of periodic td intrs. */
147         int     nreqs;
148         Poll    poll;
149         
150         ulong   base;
151         int     irq;
152         ulong*  r;
153 };
154
155 extern int ehcidebug;
156
157 void    ehcilinkage(Hci *hp);
158 void    ehcimeminit(Ctlr *ctlr);
159 void    ehcirun(Ctlr *ctlr, int on);