| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: usbdivar.h,v 1.109.2.25 2016/03/17 09:04:53 skrll Exp $ */ | | 1 | /* $NetBSD: usbdivar.h,v 1.109.2.26 2016/03/29 08:42:41 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | | 8 | * by Lennart Augustsson (lennart@augustsson.net) at |
9 | * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au). | | 9 | * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au). |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -142,146 +142,153 @@ struct usbd_hub { | | | @@ -142,146 +142,153 @@ struct usbd_hub { |
142 | | | 142 | |
143 | struct usbd_bus { | | 143 | struct usbd_bus { |
144 | /* Filled by HC driver */ | | 144 | /* Filled by HC driver */ |
145 | void *ub_hcpriv; | | 145 | void *ub_hcpriv; |
146 | int ub_revision; /* USB revision */ | | 146 | int ub_revision; /* USB revision */ |
147 | #define USBREV_UNKNOWN 0 | | 147 | #define USBREV_UNKNOWN 0 |
148 | #define USBREV_PRE_1_0 1 | | 148 | #define USBREV_PRE_1_0 1 |
149 | #define USBREV_1_0 2 | | 149 | #define USBREV_1_0 2 |
150 | #define USBREV_1_1 3 | | 150 | #define USBREV_1_1 3 |
151 | #define USBREV_2_0 4 | | 151 | #define USBREV_2_0 4 |
152 | #define USBREV_3_0 5 | | 152 | #define USBREV_3_0 5 |
153 | #define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1", "2.0", "3.0" } | | 153 | #define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1", "2.0", "3.0" } |
154 | | | 154 | |
155 | const struct usbd_bus_methods *ub_methods; | | 155 | const struct usbd_bus_methods |
| | | 156 | *ub_methods; |
156 | uint32_t ub_pipesize; /* size of a pipe struct */ | | 157 | uint32_t ub_pipesize; /* size of a pipe struct */ |
157 | bool ub_usedma; /* Does this HC support DMA */ | | 158 | bool ub_usedma; /* Does this HC support DMA */ |
158 | int ub_dmaflags; | | 159 | int ub_dmaflags; |
159 | bus_dma_tag_t ub_dmatag; /* DMA tag */ | | 160 | bus_dma_tag_t ub_dmatag; /* DMA tag */ |
160 | | | 161 | |
161 | /* Filled by usb driver */ | | 162 | /* Filled by usb driver */ |
162 | kmutex_t *ub_lock; | | 163 | kmutex_t *ub_lock; |
163 | struct usbd_device *ub_roothub; | | 164 | struct usbd_device *ub_roothub; |
164 | uint8_t ub_rhaddr; /* roothub address */ | | 165 | uint8_t ub_rhaddr; /* roothub address */ |
165 | uint8_t ub_rhconf; /* roothub configuration */ | | 166 | uint8_t ub_rhconf; /* roothub configuration */ |
166 | struct usbd_device * ub_devices[USB_MAX_DEVICES]; | | 167 | struct usbd_device *ub_devices[USB_MAX_DEVICES]; |
167 | kcondvar_t ub_needsexplore_cv; | | 168 | kcondvar_t ub_needsexplore_cv; |
168 | char ub_needsexplore;/* a hub a signalled a change */ | | 169 | char ub_needsexplore;/* a hub a signalled a change */ |
169 | char ub_usepolling; | | 170 | char ub_usepolling; |
170 | device_t ub_usbctl; | | 171 | device_t ub_usbctl; |
171 | struct usb_device_stats ub_stats; | | 172 | struct usb_device_stats ub_stats; |
172 | | | 173 | |
173 | void *ub_soft; /* soft interrupt cookie */ | | 174 | void *ub_soft; /* soft interrupt cookie */ |
174 | }; | | 175 | }; |
175 | | | 176 | |
176 | struct usbd_device { | | 177 | struct usbd_device { |
177 | struct usbd_bus *ud_bus; /* our controller */ | | 178 | struct usbd_bus *ud_bus; /* our controller */ |
178 | struct usbd_pipe *ud_pipe0; /* pipe 0 */ | | 179 | struct usbd_pipe *ud_pipe0; /* pipe 0 */ |
179 | uint8_t ud_addr; /* device addess */ | | 180 | uint8_t ud_addr; /* device addess */ |
180 | uint8_t ud_config; /* current configuration # */ | | 181 | uint8_t ud_config; /* current configuration # */ |
181 | uint8_t ud_depth; /* distance from root hub */ | | 182 | uint8_t ud_depth; /* distance from root hub */ |
182 | uint8_t ud_speed; /* low/full/high speed */ | | 183 | uint8_t ud_speed; /* low/full/high speed */ |
183 | uint8_t ud_selfpowered; /* flag for self powered */ | | 184 | uint8_t ud_selfpowered; /* flag for self powered */ |
184 | uint16_t ud_power; /* mA the device uses */ | | 185 | uint16_t ud_power; /* mA the device uses */ |
185 | int16_t ud_langid; /* language for strings */ | | 186 | int16_t ud_langid; /* language for strings */ |
186 | #define USBD_NOLANG (-1) | | 187 | #define USBD_NOLANG (-1) |
187 | usb_event_cookie_t ud_cookie; /* unique connection id */ | | 188 | usb_event_cookie_t ud_cookie; /* unique connection id */ |
188 | struct usbd_port *ud_powersrc; /* upstream hub port, or 0 */ | | 189 | struct usbd_port *ud_powersrc; /* upstream hub port, or 0 */ |
189 | struct usbd_device *ud_myhub; /* upstream hub */ | | 190 | struct usbd_device *ud_myhub; /* upstream hub */ |
190 | struct usbd_port *ud_myhsport; /* closest high speed port */ | | 191 | struct usbd_port *ud_myhsport; /* closest high speed port */ |
191 | struct usbd_endpoint ud_ep0; /* for pipe 0 */ | | 192 | struct usbd_endpoint ud_ep0; /* for pipe 0 */ |
192 | usb_endpoint_descriptor_t ud_ep0desc; /* for pipe 0 */ | | 193 | usb_endpoint_descriptor_t |
| | | 194 | ud_ep0desc; /* for pipe 0 */ |
193 | struct usbd_interface *ud_ifaces; /* array of all interfaces */ | | 195 | struct usbd_interface *ud_ifaces; /* array of all interfaces */ |
194 | usb_device_descriptor_t ud_ddesc; /* device descriptor */ | | 196 | usb_device_descriptor_t ud_ddesc; /* device descriptor */ |
195 | usb_config_descriptor_t *ud_cdesc; /* full config descr */ | | 197 | usb_config_descriptor_t *ud_cdesc; /* full config descr */ |
196 | usb_bos_descriptor_t *ud_bdesc; /* full BOS descr */ | | 198 | usb_bos_descriptor_t *ud_bdesc; /* full BOS descr */ |
197 | const struct usbd_quirks *ud_quirks;/* device quirks, always set */ | | 199 | const struct usbd_quirks |
| | | 200 | *ud_quirks; /* device quirks, always set */ |
198 | struct usbd_hub *ud_hub; /* only if this is a hub */ | | 201 | struct usbd_hub *ud_hub; /* only if this is a hub */ |
199 | int ud_subdevlen; /* array length of following */ | | 202 | int ud_subdevlen; /* array length of following */ |
200 | device_t *ud_subdevs; /* sub-devices */ | | 203 | device_t *ud_subdevs; /* sub-devices */ |
201 | int ud_nifaces_claimed; /* number of ifaces in use */ | | 204 | int ud_nifaces_claimed; /* number of ifaces in use */ |
202 | void *ud_hcpriv; | | 205 | void *ud_hcpriv; |
203 | | | 206 | |
204 | char *ud_serial; /* serial number, can be NULL */ | | 207 | char *ud_serial; /* serial number, can be NULL */ |
205 | char *ud_vendor; /* vendor string, can be NULL */ | | 208 | char *ud_vendor; /* vendor string, can be NULL */ |
206 | char *ud_product; /* product string can be NULL */ | | 209 | char *ud_product; /* product string can be NULL */ |
207 | }; | | 210 | }; |
208 | | | 211 | |
209 | struct usbd_interface { | | 212 | struct usbd_interface { |
210 | struct usbd_device *ui_dev; | | 213 | struct usbd_device *ui_dev; |
211 | usb_interface_descriptor_t *ui_idesc; | | 214 | usb_interface_descriptor_t |
| | | 215 | *ui_idesc; |
212 | int ui_index; | | 216 | int ui_index; |
213 | int ui_altindex; | | 217 | int ui_altindex; |
214 | struct usbd_endpoint *ui_endpoints; | | 218 | struct usbd_endpoint *ui_endpoints; |
215 | void *ui_priv; | | 219 | void *ui_priv; |
216 | LIST_HEAD(, usbd_pipe) ui_pipes; | | 220 | LIST_HEAD(, usbd_pipe) ui_pipes; |
217 | }; | | 221 | }; |
218 | | | 222 | |
219 | struct usbd_pipe { | | 223 | struct usbd_pipe { |
220 | struct usbd_interface *up_iface; | | 224 | struct usbd_interface *up_iface; |
221 | struct usbd_device *up_dev; | | 225 | struct usbd_device *up_dev; |
222 | struct usbd_endpoint *up_endpoint; | | 226 | struct usbd_endpoint *up_endpoint; |
223 | char up_running; | | 227 | char up_running; |
224 | char up_aborting; | | 228 | char up_aborting; |
225 | bool up_serialise; | | 229 | bool up_serialise; |
226 | SIMPLEQ_HEAD(, usbd_xfer) up_queue; | | 230 | SIMPLEQ_HEAD(, usbd_xfer) |
| | | 231 | up_queue; |
227 | LIST_ENTRY(usbd_pipe) up_next; | | 232 | LIST_ENTRY(usbd_pipe) up_next; |
228 | struct usb_task up_async_task; | | 233 | struct usb_task up_async_task; |
229 | | | 234 | |
230 | struct usbd_xfer *up_intrxfer; /* used for repeating requests */ | | 235 | struct usbd_xfer *up_intrxfer; /* used for repeating requests */ |
231 | char up_repeat; | | 236 | char up_repeat; |
232 | int up_interval; | | 237 | int up_interval; |
233 | uint8_t up_flags; | | 238 | uint8_t up_flags; |
234 | | | 239 | |
235 | /* Filled by HC driver. */ | | 240 | /* Filled by HC driver. */ |
236 | const struct usbd_pipe_methods *up_methods; | | 241 | const struct usbd_pipe_methods |
| | | 242 | *up_methods; |
237 | }; | | 243 | }; |
238 | | | 244 | |
239 | struct usbd_xfer { | | 245 | struct usbd_xfer { |
240 | struct usbd_pipe *ux_pipe; | | 246 | struct usbd_pipe *ux_pipe; |
241 | void *ux_priv; | | 247 | void *ux_priv; |
242 | void *ux_buffer; | | 248 | void *ux_buffer; |
243 | kcondvar_t ux_cv; | | 249 | kcondvar_t ux_cv; |
244 | uint32_t ux_length; | | 250 | uint32_t ux_length; |
245 | uint32_t ux_actlen; | | 251 | uint32_t ux_actlen; |
246 | uint16_t ux_flags; | | 252 | uint16_t ux_flags; |
247 | uint32_t ux_timeout; | | 253 | uint32_t ux_timeout; |
248 | usbd_status ux_status; | | 254 | usbd_status ux_status; |
249 | usbd_callback ux_callback; | | 255 | usbd_callback ux_callback; |
250 | volatile uint8_t ux_done; | | 256 | volatile uint8_t ux_done; |
251 | uint8_t ux_state; /* used for DIAGNOSTIC */ | | 257 | uint8_t ux_state; /* used for DIAGNOSTIC */ |
252 | #define XFER_FREE 0x46 | | 258 | #define XFER_FREE 0x46 |
253 | #define XFER_BUSY 0x55 | | 259 | #define XFER_BUSY 0x55 |
254 | #define XFER_ONQU 0x9e | | 260 | #define XFER_ONQU 0x9e |
255 | | | 261 | |
256 | /* For control pipe */ | | 262 | /* For control pipe */ |
257 | usb_device_request_t ux_request; | | 263 | usb_device_request_t ux_request; |
258 | | | 264 | |
259 | /* For isoc */ | | 265 | /* For isoc */ |
260 | uint16_t *ux_frlengths; | | 266 | uint16_t *ux_frlengths; |
261 | int ux_nframes; | | 267 | int ux_nframes; |
262 | | | 268 | |
263 | const struct usbd_pipe_methods *ux_methods; | | 269 | const struct usbd_pipe_methods *ux_methods; |
264 | | | 270 | |
265 | /* For memory allocation and softc */ | | 271 | /* For memory allocation and softc */ |
266 | struct usbd_bus *ux_bus; | | 272 | struct usbd_bus *ux_bus; |
267 | usb_dma_t ux_dmabuf; | | 273 | usb_dma_t ux_dmabuf; |
268 | void *ux_buf; | | 274 | void *ux_buf; |
269 | uint32_t ux_bufsize; | | 275 | uint32_t ux_bufsize; |
270 | | | 276 | |
271 | uint8_t ux_rqflags; | | 277 | uint8_t ux_rqflags; |
272 | #define URQ_REQUEST 0x01 | | 278 | #define URQ_REQUEST 0x01 |
273 | | | 279 | |
274 | SIMPLEQ_ENTRY(usbd_xfer) ux_next; | | 280 | SIMPLEQ_ENTRY(usbd_xfer) |
| | | 281 | ux_next; |
275 | | | 282 | |
276 | void *ux_hcpriv; /* private use by the HC driver */ | | 283 | void *ux_hcpriv; /* private use by the HC driver */ |
277 | uint8_t ux_hcflags; /* private use by the HC driver */ | | 284 | uint8_t ux_hcflags; /* private use by the HC driver */ |
278 | #define UXFER_ABORTING 0x01 /* xfer is aborting. */ | | 285 | #define UXFER_ABORTING 0x01 /* xfer is aborting. */ |
279 | #define UXFER_ABORTWAIT 0x02 /* abort completion is being awaited. */ | | 286 | #define UXFER_ABORTWAIT 0x02 /* abort completion is being awaited. */ |
280 | kcondvar_t ux_hccv; /* private use by the HC driver */ | | 287 | kcondvar_t ux_hccv; /* private use by the HC driver */ |
281 | | | 288 | |
282 | struct callout ux_callout; | | 289 | struct callout ux_callout; |
283 | }; | | 290 | }; |
284 | | | 291 | |
285 | void usbd_init(void); | | 292 | void usbd_init(void); |
286 | void usbd_finish(void); | | 293 | void usbd_finish(void); |
287 | | | 294 | |