]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/nusb/usbd/dat.h
audiohda: fix syntax error
[plan9front.git] / sys / src / cmd / nusb / usbd / dat.h
1 typedef struct Hub Hub;
2 typedef struct DHub DHub;
3 typedef struct DSSHub DSSHub;
4 typedef struct Port Port;
5
6 enum
7 {
8         Stack   = 32*1024,
9
10         Dhub            = 0x29,         /* hub descriptor type */
11         Dhublen         = 9,            /* hub descriptor length */
12
13         Dsshub          = 0x2A,         /* superspeed hub descriptor type */
14         Dsshublen       = 12,           /* superspeed hub descriptor length */
15
16         /* hub class feature selectors */
17         Fhublocalpower  = 0,
18         Fhubovercurrent = 1,
19
20         Fportconnection = 0,
21         Fportenable     = 1,
22         Fportsuspend    = 2,
23         Fportovercurrent = 3,
24         Fportreset      = 4,
25         Fportpower      = 8,
26         Fportlowspeed   = 9,
27         Fcportconnection        = 16,
28         Fcportenable    = 17,
29         Fcportsuspend   = 18,
30         Fcportovercurrent= 19,
31         Fcportreset     = 20,
32         Fportindicator  = 22,
33
34         /* Port status and status change bits
35          * Constants at /sys/src/9/pc/usb.h starting with HP-
36          * must have the same values or root hubs won't work.
37          */
38         PSpresent       = 0x0001,
39         PSenable        = 0x0002,
40         PSsuspend       = 0x0004,
41         PSovercurrent   = 0x0008,
42         PSreset         = 0x0010,
43         PSpower         = 0x0100,
44         PSslow          = 0x0200,
45         PShigh          = 0x0400,
46
47         PSstatuschg     = 0x10000,      /* PSpresent changed */
48         PSchange        = 0x20000,      /* PSenable changed */
49
50
51         /* port/device state */
52         Pdisabled = 0,          /* must be 0 */
53         Pattached,
54         Pconfiged,
55
56         /* Delays, timeouts (ms) */
57         Spawndelay      = 250,          /* how often may we re-spawn a driver */
58         Resetdelay      = 20,           /* how much to wait after a reset */
59         Enabledelay     = 20,           /* how much to wait after an enable */
60         Powerdelay      = 100,          /* after powering up ports */
61         Pollms          = 250,          /* port poll interval */
62         Chgdelay        = 100,          /* waiting for port become stable */
63         Chgtmout        = 1000,         /* ...but at most this much */
64
65         /*
66          * device tab for embedded usb drivers.
67          */
68         DCL = 0x01000000,               /* csp identifies just class */
69         DSC = 0x02000000,               /* csp identifies just subclass */
70         DPT = 0x04000000,               /* csp identifies just proto */
71
72 };
73
74 struct Hub
75 {
76         uchar   pwrmode;
77         uchar   compound;
78         uchar   pwrms;          /* time to wait in ms */
79         uchar   maxcurrent;     /*    after powering port*/
80         int     leds;           /* has port indicators? */
81         int     maxpkt;
82         uchar   nport;
83         Port    *port;
84         int     failed;         /* I/O error while enumerating */
85         int     isroot;         /* set if root hub */
86         Dev     *dev;           /* for this hub */
87         Hub     *next;          /* in list of hubs */
88 };
89
90 struct Port
91 {
92         int     state;          /* state of the device */
93         u32int  sts;            /* old port status */
94         uchar   removable;
95         uchar   pwrctl;
96         Dev     *dev;           /* attached device (if non-nil) */
97         Hub     *hub;           /* non-nil if hub attached */
98 };
99
100 /* USB HUB descriptor */
101 struct DHub
102 {
103         uchar   bLength;
104         uchar   bDescriptorType;
105         uchar   bNbrPorts;
106         uchar   wHubCharacteristics[2];
107         uchar   bPwrOn2PwrGood;
108         uchar   bHubContrCurrent;
109         uchar   DeviceRemovable[1];     /* variable length */
110 };
111
112 /* Superspeed HUB descriptor */
113 struct DSSHub
114 {
115         uchar   bLength;
116         uchar   bDescriptorType;
117         uchar   bNbrPorts;
118         uchar   wHubCharacteristics[2];
119         uchar   bPwrOn2PwrGood;
120         uchar   bHubContrCurrent;
121         uchar   bHubHdrDecLat;
122         uchar   wHubDelay[2];
123         uchar   DeviceRemovable[1];     /* variable length */
124 };
125
126 extern Hub *hubs;