2 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Lennart Augustsson (lennart@augustsson.net) at
7 * Carlstedt Research & Technology.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
31 /* Modified by Synopsys, Inc, 12/12/2007 */
42 * The USB records contain some unaligned little-endian word
43 * components. The U[SG]ETW macros take care of both the alignment
44 * and endian problem and should always be used to access non-byte
47 typedef u_int8_t uByte;
48 typedef u_int8_t uWord[2];
49 typedef u_int8_t uDWord[4];
51 #define UGETW(w) ((w)[0] | ((w)[1] << 8))
52 #define USETW(w,v) ((w)[0] = (u_int8_t)(v), (w)[1] = (u_int8_t)((v) >> 8))
53 #define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24))
54 #define USETDW(w,v) ((w)[0] = (u_int8_t)(v), \
55 (w)[1] = (u_int8_t)((v) >> 8), \
56 (w)[2] = (u_int8_t)((v) >> 16), \
57 (w)[3] = (u_int8_t)((v) >> 24))
59 #define UPACKED __attribute__((__packed__))
67 } UPACKED usb_device_request_t;
69 #define UT_GET_DIR(a) ((a) & 0x80)
73 #define UT_GET_TYPE(a) ((a) & 0x60)
74 #define UT_STANDARD 0x00
76 #define UT_VENDOR 0x40
78 #define UT_GET_RECIPIENT(a) ((a) & 0x1f)
79 #define UT_DEVICE 0x00
80 #define UT_INTERFACE 0x01
81 #define UT_ENDPOINT 0x02
85 #define UR_GET_STATUS 0x00
86 #define USTAT_STANDARD_STATUS 0x00
87 #define WUSTAT_WUSB_FEATURE 0x01
88 #define WUSTAT_CHANNEL_INFO 0x02
89 #define WUSTAT_RECEIVED_DATA 0x03
90 #define WUSTAT_MAS_AVAILABILITY 0x04
91 #define WUSTAT_CURRENT_TRANSMIT_POWER 0x05
92 #define UR_CLEAR_FEATURE 0x01
93 #define UR_SET_FEATURE 0x03
94 #define UR_SET_AND_TEST_FEATURE 0x0c
95 #define UR_SET_ADDRESS 0x05
96 #define UR_GET_DESCRIPTOR 0x06
97 #define UDESC_DEVICE 0x01
98 #define UDESC_CONFIG 0x02
99 #define UDESC_STRING 0x03
100 #define UDESC_INTERFACE 0x04
101 #define UDESC_ENDPOINT 0x05
102 #define UDESC_SS_USB_COMPANION 0x30
103 #define UDESC_DEVICE_QUALIFIER 0x06
104 #define UDESC_OTHER_SPEED_CONFIGURATION 0x07
105 #define UDESC_INTERFACE_POWER 0x08
106 #define UDESC_OTG 0x09
107 #define WUDESC_SECURITY 0x0c
108 #define WUDESC_KEY 0x0d
109 #define WUD_GET_KEY_INDEX(_wValue_) ((_wValue_) & 0xf)
110 #define WUD_GET_KEY_TYPE(_wValue_) (((_wValue_) & 0x30) >> 4)
111 #define WUD_KEY_TYPE_ASSOC 0x01
112 #define WUD_KEY_TYPE_GTK 0x02
113 #define WUD_GET_KEY_ORIGIN(_wValue_) (((_wValue_) & 0x40) >> 6)
114 #define WUD_KEY_ORIGIN_HOST 0x00
115 #define WUD_KEY_ORIGIN_DEVICE 0x01
116 #define WUDESC_ENCRYPTION_TYPE 0x0e
117 #define WUDESC_BOS 0x0f
118 #define WUDESC_DEVICE_CAPABILITY 0x10
119 #define WUDESC_WIRELESS_ENDPOINT_COMPANION 0x11
120 #define UDESC_BOS 0x0f
121 #define UDESC_DEVICE_CAPABILITY 0x10
122 #define UDESC_CS_DEVICE 0x21 /* class specific */
123 #define UDESC_CS_CONFIG 0x22
124 #define UDESC_CS_STRING 0x23
125 #define UDESC_CS_INTERFACE 0x24
126 #define UDESC_CS_ENDPOINT 0x25
127 #define UDESC_HUB 0x29
128 #define UR_SET_DESCRIPTOR 0x07
129 #define UR_GET_CONFIG 0x08
130 #define UR_SET_CONFIG 0x09
131 #define UR_GET_INTERFACE 0x0a
132 #define UR_SET_INTERFACE 0x0b
133 #define UR_SYNCH_FRAME 0x0c
134 #define WUR_SET_ENCRYPTION 0x0d
135 #define WUR_GET_ENCRYPTION 0x0e
136 #define WUR_SET_HANDSHAKE 0x0f
137 #define WUR_GET_HANDSHAKE 0x10
138 #define WUR_SET_CONNECTION 0x11
139 #define WUR_SET_SECURITY_DATA 0x12
140 #define WUR_GET_SECURITY_DATA 0x13
141 #define WUR_SET_WUSB_DATA 0x14
142 #define WUDATA_DRPIE_INFO 0x01
143 #define WUDATA_TRANSMIT_DATA 0x02
144 #define WUDATA_TRANSMIT_PARAMS 0x03
145 #define WUDATA_RECEIVE_PARAMS 0x04
146 #define WUDATA_TRANSMIT_POWER 0x05
147 #define WUR_LOOPBACK_DATA_WRITE 0x15
148 #define WUR_LOOPBACK_DATA_READ 0x16
149 #define WUR_SET_INTERFACE_DS 0x17
151 /* Feature numbers */
152 #define UF_ENDPOINT_HALT 0
153 #define UF_DEVICE_REMOTE_WAKEUP 1
154 #define UF_TEST_MODE 2
155 #define UF_DEVICE_B_HNP_ENABLE 3
156 #define UF_DEVICE_A_HNP_SUPPORT 4
157 #define UF_DEVICE_A_ALT_HNP_SUPPORT 5
159 #define WUF_TX_DRPIE 0x0
160 #define WUF_DEV_XMIT_PACKET 0x1
161 #define WUF_COUNT_PACKETS 0x2
162 #define WUF_CAPTURE_PACKETS 0x3
163 #define UF_FUNCTION_SUSPEND 0
164 #define UF_U1_ENABLE 48
165 #define UF_U2_ENABLE 49
166 #define UF_LTM_ENABLE 50
168 /* Class requests from the USB 2.0 hub spec, table 11-15 */
169 #define UCR_CLEAR_HUB_FEATURE (0x2000 | UR_CLEAR_FEATURE)
170 #define UCR_CLEAR_PORT_FEATURE (0x2300 | UR_CLEAR_FEATURE)
171 #define UCR_GET_HUB_DESCRIPTOR (0xa000 | UR_GET_DESCRIPTOR)
172 #define UCR_GET_HUB_STATUS (0xa000 | UR_GET_STATUS)
173 #define UCR_GET_PORT_STATUS (0xa300 | UR_GET_STATUS)
174 #define UCR_SET_HUB_FEATURE (0x2000 | UR_SET_FEATURE)
175 #define UCR_SET_PORT_FEATURE (0x2300 | UR_SET_FEATURE)
176 #define UCR_SET_AND_TEST_PORT_FEATURE (0xa300 | UR_SET_AND_TEST_FEATURE)
179 #include <pshpack1.h>
184 uByte bDescriptorType;
185 uByte bEndpointAddress;
186 #define UE_GET_DIR(a) ((a) & 0x80)
187 #define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7))
188 #define UE_DIR_IN 0x80
189 #define UE_DIR_OUT 0x00
191 #define UE_GET_ADDR(a) ((a) & UE_ADDR)
193 #define UE_XFERTYPE 0x03
194 #define UE_CONTROL 0x00
195 #define UE_ISOCHRONOUS 0x01
197 #define UE_INTERRUPT 0x03
198 #define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE)
199 #define UE_ISO_TYPE 0x0c
200 #define UE_ISO_ASYNC 0x04
201 #define UE_ISO_ADAPT 0x08
202 #define UE_ISO_SYNC 0x0c
203 #define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE)
204 uWord wMaxPacketSize;
206 } UPACKED usb_endpoint_descriptor_t;
207 #define USB_ENDPOINT_DESCRIPTOR_SIZE 7
209 /* Hub specific request */
210 #define UR_GET_BUS_STATE 0x02
211 #define UR_CLEAR_TT_BUFFER 0x08
212 #define UR_RESET_TT 0x09
213 #define UR_GET_TT_STATE 0x0a
214 #define UR_STOP_TT 0x0b
217 #define UHF_C_HUB_LOCAL_POWER 0
218 #define UHF_C_HUB_OVER_CURRENT 1
219 #define UHF_PORT_CONNECTION 0
220 #define UHF_PORT_ENABLE 1
221 #define UHF_PORT_SUSPEND 2
222 #define UHF_PORT_OVER_CURRENT 3
223 #define UHF_PORT_RESET 4
224 #define UHF_PORT_L1 5
225 #define UHF_PORT_POWER 8
226 #define UHF_PORT_LOW_SPEED 9
227 #define UHF_PORT_HIGH_SPEED 10
228 #define UHF_C_PORT_CONNECTION 16
229 #define UHF_C_PORT_ENABLE 17
230 #define UHF_C_PORT_SUSPEND 18
231 #define UHF_C_PORT_OVER_CURRENT 19
232 #define UHF_C_PORT_RESET 20
233 #define UHF_C_PORT_L1 23
234 #define UHF_PORT_TEST 21
235 #define UHF_PORT_INDICATOR 22
239 uByte bDescriptorType;
241 uWord wHubCharacteristics;
242 #define UHD_PWR 0x0003
243 #define UHD_PWR_GANGED 0x0000
244 #define UHD_PWR_INDIVIDUAL 0x0001
245 #define UHD_PWR_NO_SWITCH 0x0002
246 #define UHD_COMPOUND 0x0004
247 #define UHD_OC 0x0018
248 #define UHD_OC_GLOBAL 0x0000
249 #define UHD_OC_INDIVIDUAL 0x0008
250 #define UHD_OC_NONE 0x0010
251 #define UHD_TT_THINK 0x0060
252 #define UHD_TT_THINK_8 0x0000
253 #define UHD_TT_THINK_16 0x0020
254 #define UHD_TT_THINK_24 0x0040
255 #define UHD_TT_THINK_32 0x0060
256 #define UHD_PORT_IND 0x0080
257 uByte bPwrOn2PwrGood; /* delay in 2 ms units */
258 #define UHD_PWRON_FACTOR 2
259 uByte bHubContrCurrent;
260 uByte DeviceRemovable[32]; /* max 255 ports */
261 #define UHD_NOT_REMOV(desc, i) \
262 (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
263 /* deprecated */ uByte PortPowerCtrlMask[1];
264 } UPACKED usb_hub_descriptor_t;
265 #define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */