sched: add macros to define bitops for task atomic flags
[pandora-kernel.git] / include / linux / usb / ch11.h
1 /*
2  * This file holds Hub protocol constants and data structures that are
3  * defined in chapter 11 (Hub Specification) of the USB 2.0 specification.
4  *
5  * It is used/shared between the USB core, the HCDs and couple of other USB
6  * drivers.
7  */
8
9 #ifndef __LINUX_CH11_H
10 #define __LINUX_CH11_H
11
12 #include <linux/types.h>        /* __u8 etc */
13
14 /* See USB 3.1 spec Table 10-5 */
15 #define USB_SS_MAXPORTS         15
16
17 /*
18  * Hub request types
19  */
20
21 #define USB_RT_HUB      (USB_TYPE_CLASS | USB_RECIP_DEVICE)
22 #define USB_RT_PORT     (USB_TYPE_CLASS | USB_RECIP_OTHER)
23
24 /*
25  * Hub class requests
26  * See USB 2.0 spec Table 11-16
27  */
28 #define HUB_CLEAR_TT_BUFFER     8
29 #define HUB_RESET_TT            9
30 #define HUB_GET_TT_STATE        10
31 #define HUB_STOP_TT             11
32 #define HUB_SET_DEPTH           12
33
34 /*
35  * Hub class additional requests defined by USB 3.0 spec
36  * See USB 3.0 spec Table 10-6
37  */
38 #define HUB_SET_DEPTH           12
39 #define HUB_GET_PORT_ERR_COUNT  13
40
41 /*
42  * Hub Class feature numbers
43  * See USB 2.0 spec Table 11-17
44  */
45 #define C_HUB_LOCAL_POWER       0
46 #define C_HUB_OVER_CURRENT      1
47
48 /*
49  * Port feature numbers
50  * See USB 2.0 spec Table 11-17
51  */
52 #define USB_PORT_FEAT_CONNECTION        0
53 #define USB_PORT_FEAT_ENABLE            1
54 #define USB_PORT_FEAT_SUSPEND           2       /* L2 suspend */
55 #define USB_PORT_FEAT_OVER_CURRENT      3
56 #define USB_PORT_FEAT_RESET             4
57 #define USB_PORT_FEAT_L1                5       /* L1 suspend */
58 #define USB_PORT_FEAT_POWER             8
59 #define USB_PORT_FEAT_LOWSPEED          9       /* Should never be used */
60 #define USB_PORT_FEAT_C_CONNECTION      16
61 #define USB_PORT_FEAT_C_ENABLE          17
62 #define USB_PORT_FEAT_C_SUSPEND         18
63 #define USB_PORT_FEAT_C_OVER_CURRENT    19
64 #define USB_PORT_FEAT_C_RESET           20
65 #define USB_PORT_FEAT_TEST              21
66 #define USB_PORT_FEAT_INDICATOR         22
67 #define USB_PORT_FEAT_C_PORT_L1         23
68
69 /*
70  * Port feature selectors added by USB 3.0 spec.
71  * See USB 3.0 spec Table 10-7
72  */
73 #define USB_PORT_FEAT_LINK_STATE                5
74 #define USB_PORT_FEAT_U1_TIMEOUT                23
75 #define USB_PORT_FEAT_U2_TIMEOUT                24
76 #define USB_PORT_FEAT_C_PORT_LINK_STATE         25
77 #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR       26
78 #define USB_PORT_FEAT_REMOTE_WAKE_MASK          27
79 #define USB_PORT_FEAT_BH_PORT_RESET             28
80 #define USB_PORT_FEAT_C_BH_PORT_RESET           29
81 #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT       30
82
83 /*
84  * Hub Status and Hub Change results
85  * See USB 2.0 spec Table 11-19 and Table 11-20
86  */
87 struct usb_port_status {
88         __le16 wPortStatus;
89         __le16 wPortChange;
90 } __attribute__ ((packed));
91
92 /*
93  * wPortStatus bit field
94  * See USB 2.0 spec Table 11-21
95  */
96 #define USB_PORT_STAT_CONNECTION        0x0001
97 #define USB_PORT_STAT_ENABLE            0x0002
98 #define USB_PORT_STAT_SUSPEND           0x0004
99 #define USB_PORT_STAT_OVERCURRENT       0x0008
100 #define USB_PORT_STAT_RESET             0x0010
101 #define USB_PORT_STAT_L1                0x0020
102 /* bits 6 to 7 are reserved */
103 #define USB_PORT_STAT_POWER             0x0100
104 #define USB_PORT_STAT_LOW_SPEED         0x0200
105 #define USB_PORT_STAT_HIGH_SPEED        0x0400
106 #define USB_PORT_STAT_TEST              0x0800
107 #define USB_PORT_STAT_INDICATOR         0x1000
108 /* bits 13 to 15 are reserved */
109
110 /*
111  * Additions to wPortStatus bit field from USB 3.0
112  * See USB 3.0 spec Table 10-10
113  */
114 #define USB_PORT_STAT_LINK_STATE        0x01e0
115 #define USB_SS_PORT_STAT_POWER          0x0200
116 #define USB_SS_PORT_STAT_SPEED          0x1c00
117 #define USB_PORT_STAT_SPEED_5GBPS       0x0000
118 /* Valid only if port is enabled */
119 /* Bits that are the same from USB 2.0 */
120 #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION |           \
121                                 USB_PORT_STAT_ENABLE |      \
122                                 USB_PORT_STAT_OVERCURRENT | \
123                                 USB_PORT_STAT_RESET)
124
125 /*
126  * Definitions for PORT_LINK_STATE values
127  * (bits 5-8) in wPortStatus
128  */
129 #define USB_SS_PORT_LS_U0               0x0000
130 #define USB_SS_PORT_LS_U1               0x0020
131 #define USB_SS_PORT_LS_U2               0x0040
132 #define USB_SS_PORT_LS_U3               0x0060
133 #define USB_SS_PORT_LS_SS_DISABLED      0x0080
134 #define USB_SS_PORT_LS_RX_DETECT        0x00a0
135 #define USB_SS_PORT_LS_SS_INACTIVE      0x00c0
136 #define USB_SS_PORT_LS_POLLING          0x00e0
137 #define USB_SS_PORT_LS_RECOVERY         0x0100
138 #define USB_SS_PORT_LS_HOT_RESET        0x0120
139 #define USB_SS_PORT_LS_COMP_MOD         0x0140
140 #define USB_SS_PORT_LS_LOOPBACK         0x0160
141
142 /*
143  * wPortChange bit field
144  * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
145  * Bits 0 to 5 shown, bits 6 to 15 are reserved
146  */
147 #define USB_PORT_STAT_C_CONNECTION      0x0001
148 #define USB_PORT_STAT_C_ENABLE          0x0002
149 #define USB_PORT_STAT_C_SUSPEND         0x0004
150 #define USB_PORT_STAT_C_OVERCURRENT     0x0008
151 #define USB_PORT_STAT_C_RESET           0x0010
152 #define USB_PORT_STAT_C_L1              0x0020
153 /*
154  * USB 3.0 wPortChange bit fields
155  * See USB 3.0 spec Table 10-11
156  */
157 #define USB_PORT_STAT_C_BH_RESET        0x0020
158 #define USB_PORT_STAT_C_LINK_STATE      0x0040
159 #define USB_PORT_STAT_C_CONFIG_ERROR    0x0080
160
161 /*
162  * wHubCharacteristics (masks)
163  * See USB 2.0 spec Table 11-13, offset 3
164  */
165 #define HUB_CHAR_LPSM           0x0003 /* D1 .. D0 */
166 #define HUB_CHAR_COMPOUND       0x0004 /* D2       */
167 #define HUB_CHAR_OCPM           0x0018 /* D4 .. D3 */
168 #define HUB_CHAR_TTTT           0x0060 /* D6 .. D5 */
169 #define HUB_CHAR_PORTIND        0x0080 /* D7       */
170
171 struct usb_hub_status {
172         __le16 wHubStatus;
173         __le16 wHubChange;
174 } __attribute__ ((packed));
175
176 /*
177  * Hub Status & Hub Change bit masks
178  * See USB 2.0 spec Table 11-19 and Table 11-20
179  * Bits 0 and 1 for wHubStatus and wHubChange
180  * Bits 2 to 15 are reserved for both
181  */
182 #define HUB_STATUS_LOCAL_POWER  0x0001
183 #define HUB_STATUS_OVERCURRENT  0x0002
184 #define HUB_CHANGE_LOCAL_POWER  0x0001
185 #define HUB_CHANGE_OVERCURRENT  0x0002
186
187
188 /*
189  * Hub descriptor
190  * See USB 2.0 spec Table 11-13
191  */
192
193 #define USB_DT_HUB                      (USB_TYPE_CLASS | 0x09)
194 #define USB_DT_SS_HUB                   (USB_TYPE_CLASS | 0x0a)
195 #define USB_DT_HUB_NONVAR_SIZE          7
196 #define USB_DT_SS_HUB_SIZE              12
197
198 struct usb_hub_descriptor {
199         __u8  bDescLength;
200         __u8  bDescriptorType;
201         __u8  bNbrPorts;
202         __le16 wHubCharacteristics;
203         __u8  bPwrOn2PwrGood;
204         __u8  bHubContrCurrent;
205
206         /* 2.0 and 3.0 hubs differ here */
207         union {
208                 struct {
209                         /* add 1 bit for hub status change; round to bytes */
210                         __u8  DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
211                         __u8  PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
212                 }  __attribute__ ((packed)) hs;
213
214                 struct {
215                         __u8 bHubHdrDecLat;
216                         __u16 wHubDelay;
217                         __u16 DeviceRemovable;
218                 }  __attribute__ ((packed)) ss;
219         } u;
220 } __attribute__ ((packed));
221
222 /* port indicator status selectors, tables 11-7 and 11-25 */
223 #define HUB_LED_AUTO    0
224 #define HUB_LED_AMBER   1
225 #define HUB_LED_GREEN   2
226 #define HUB_LED_OFF     3
227
228 enum hub_led_mode {
229         INDICATOR_AUTO = 0,
230         INDICATOR_CYCLE,
231         /* software blinks for attention:  software, hardware, reserved */
232         INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
233         INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
234         INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
235 } __attribute__ ((packed));
236
237 /* Transaction Translator Think Times, in bits */
238 #define HUB_TTTT_8_BITS         0x00
239 #define HUB_TTTT_16_BITS        0x20
240 #define HUB_TTTT_24_BITS        0x40
241 #define HUB_TTTT_32_BITS        0x60
242
243 #endif /* __LINUX_CH11_H */