special usb hub handling, IDE disks, and retries all over the place
[linux-2.4.git] / drivers / usb / hub.h
1 #ifndef __LINUX_HUB_H
2 #define __LINUX_HUB_H
3
4 #include <linux/list.h>
5 #include <linux/compiler.h>     /* likely()/unlikely() */
6
7 /*
8  * Hub request types
9  */
10
11 #define USB_RT_HUB      (USB_TYPE_CLASS | USB_RECIP_DEVICE)
12 #define USB_RT_PORT     (USB_TYPE_CLASS | USB_RECIP_OTHER)
13
14 /*
15  * Hub Class feature numbers
16  * See USB 2.0 spec Table 11-17
17  */
18 #define C_HUB_LOCAL_POWER       0
19 #define C_HUB_OVER_CURRENT      1
20
21 /*
22  * Port feature numbers
23  * See USB 2.0 spec Table 11-17
24  */
25 #define USB_PORT_FEAT_CONNECTION        0
26 #define USB_PORT_FEAT_ENABLE            1
27 #define USB_PORT_FEAT_SUSPEND           2
28 #define USB_PORT_FEAT_OVER_CURRENT      3
29 #define USB_PORT_FEAT_RESET             4
30 #define USB_PORT_FEAT_POWER             8
31 #define USB_PORT_FEAT_LOWSPEED          9
32 #define USB_PORT_FEAT_HIGHSPEED         10
33 #define USB_PORT_FEAT_C_CONNECTION      16
34 #define USB_PORT_FEAT_C_ENABLE          17
35 #define USB_PORT_FEAT_C_SUSPEND         18
36 #define USB_PORT_FEAT_C_OVER_CURRENT    19
37 #define USB_PORT_FEAT_C_RESET           20
38 #define USB_PORT_FEAT_TEST              21
39 #define USB_PORT_FEAT_INDICATOR         22
40
41 /* 
42  * Hub Status and Hub Change results
43  * See USB 2.0 spec Table 11-19 and Table 11-20
44  */
45 struct usb_port_status {
46         __u16 wPortStatus;
47         __u16 wPortChange;      
48 } __attribute__ ((packed));
49
50 /* 
51  * wPortStatus bit field
52  * See USB 2.0 spec Table 11-21
53  */
54 #define USB_PORT_STAT_CONNECTION        0x0001
55 #define USB_PORT_STAT_ENABLE            0x0002
56 #define USB_PORT_STAT_SUSPEND           0x0004
57 #define USB_PORT_STAT_OVERCURRENT       0x0008
58 #define USB_PORT_STAT_RESET             0x0010
59 /* bits 5 for 7 are reserved */
60 #define USB_PORT_STAT_POWER             0x0100
61 #define USB_PORT_STAT_LOW_SPEED         0x0200
62 #define USB_PORT_STAT_HIGH_SPEED        0x0400
63 #define USB_PORT_STAT_TEST              0x0800
64 #define USB_PORT_STAT_INDICATOR         0x1000
65 /* bits 13 to 15 are reserved */
66
67 /* 
68  * wPortChange bit field
69  * See USB 2.0 spec Table 11-22
70  * Bits 0 to 4 shown, bits 5 to 15 are reserved
71  */
72 #define USB_PORT_STAT_C_CONNECTION      0x0001
73 #define USB_PORT_STAT_C_ENABLE          0x0002
74 #define USB_PORT_STAT_C_SUSPEND         0x0004
75 #define USB_PORT_STAT_C_OVERCURRENT     0x0008
76 #define USB_PORT_STAT_C_RESET           0x0010
77
78 /*
79  * wHubCharacteristics (masks) 
80  * See USB 2.0 spec Table 11-13, offset 3
81  */
82 #define HUB_CHAR_LPSM           0x0003 /* D1 .. D0 */
83 #define HUB_CHAR_COMPOUND       0x0004 /* D2       */
84 #define HUB_CHAR_OCPM           0x0018 /* D4 .. D3 */
85 #define HUB_CHAR_TTTT           0x0060 /* D6 .. D5 */
86 #define HUB_CHAR_PORTIND        0x0080 /* D7       */
87
88 struct usb_hub_status {
89         __u16 wHubStatus;
90         __u16 wHubChange;
91 } __attribute__ ((packed));
92
93 /*
94  * Hub Status & Hub Change bit masks
95  * See USB 2.0 spec Table 11-19 and Table 11-20
96  * Bits 0 and 1 for wHubStatus and wHubChange
97  * Bits 2 to 15 are reserved for both
98  */
99 #define HUB_STATUS_LOCAL_POWER  0x0001
100 #define HUB_STATUS_OVERCURRENT  0x0002
101 #define HUB_CHANGE_LOCAL_POWER  0x0001
102 #define HUB_CHANGE_OVERCURRENT  0x0002
103
104
105 /* 
106  * Hub descriptor 
107  * See USB 2.0 spec Table 11-13
108  */
109 struct usb_hub_descriptor {
110         __u8  bDescLength;
111         __u8  bDescriptorType;
112         __u8  bNbrPorts;
113         __u16 wHubCharacteristics;
114         __u8  bPwrOn2PwrGood;
115         __u8  bHubContrCurrent;
116                 /* add 1 bit for hub status change; round to bytes */
117         __u8  DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
118         __u8  PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
119 } __attribute__ ((packed));
120
121 struct usb_device;
122
123 struct usb_hub {
124         struct usb_device *dev;
125
126         struct urb *urb;                /* Interrupt polling pipe */
127
128         char buffer[(USB_MAXCHILDREN + 1 + 7) / 8]; /* add 1 bit for hub status change */
129                                         /* and add 7 bits to round up to byte boundary */
130         int error;
131         int nerrors;
132
133         struct list_head hub_list;
134
135         struct list_head event_list;
136
137         struct usb_hub_descriptor *descriptor;
138
139         struct semaphore khubd_sem;
140         struct usb_tt           tt;             /* Transaction Translator */
141 };
142
143 #endif /* __LINUX_HUB_H */