2004-12-13 08:12:06 +00:00
|
|
|
/* $NetBSD: usbdi.h,v 1.64 2004/10/23 13:26:34 augustss Exp $ */
|
1999-01-22 00:51:12 +00:00
|
|
|
/* $FreeBSD$ */
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
1998-11-26 23:13:13 +00:00
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
1999-01-07 23:07:57 +00:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2000-05-14 16:43:10 +00:00
|
|
|
* by Lennart Augustsson (lennart@augustsson.net) at
|
1999-01-07 23:07:57 +00:00
|
|
|
* Carlstedt Research & Technology.
|
1998-11-26 23:13:13 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2005-03-25 12:49:26 +00:00
|
|
|
#ifndef _USBDI_H_
|
|
|
|
#define _USBDI_H_
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
typedef struct usbd_bus *usbd_bus_handle;
|
|
|
|
typedef struct usbd_device *usbd_device_handle;
|
|
|
|
typedef struct usbd_interface *usbd_interface_handle;
|
|
|
|
typedef struct usbd_pipe *usbd_pipe_handle;
|
1999-11-17 22:33:51 +00:00
|
|
|
typedef struct usbd_xfer *usbd_xfer_handle;
|
1998-11-26 23:13:13 +00:00
|
|
|
typedef void *usbd_private_handle;
|
|
|
|
|
2003-07-04 01:50:39 +00:00
|
|
|
typedef enum { /* keep in sync with usbd_status_msgs */
|
1999-11-17 22:33:51 +00:00
|
|
|
USBD_NORMAL_COMPLETION = 0, /* must be 0 */
|
2002-04-01 17:43:28 +00:00
|
|
|
USBD_IN_PROGRESS, /* 1 */
|
1998-11-26 23:13:13 +00:00
|
|
|
/* errors */
|
2002-04-01 17:43:28 +00:00
|
|
|
USBD_PENDING_REQUESTS, /* 2 */
|
|
|
|
USBD_NOT_STARTED, /* 3 */
|
|
|
|
USBD_INVAL, /* 4 */
|
|
|
|
USBD_NOMEM, /* 5 */
|
|
|
|
USBD_CANCELLED, /* 6 */
|
|
|
|
USBD_BAD_ADDRESS, /* 7 */
|
|
|
|
USBD_IN_USE, /* 8 */
|
|
|
|
USBD_NO_ADDR, /* 9 */
|
|
|
|
USBD_SET_ADDR_FAILED, /* 10 */
|
|
|
|
USBD_NO_POWER, /* 11 */
|
|
|
|
USBD_TOO_DEEP, /* 12 */
|
|
|
|
USBD_IOERROR, /* 13 */
|
|
|
|
USBD_NOT_CONFIGURED, /* 14 */
|
|
|
|
USBD_TIMEOUT, /* 15 */
|
|
|
|
USBD_SHORT_XFER, /* 16 */
|
|
|
|
USBD_STALLED, /* 17 */
|
|
|
|
USBD_INTERRUPTED, /* 18 */
|
|
|
|
|
|
|
|
USBD_ERROR_MAX /* must be last */
|
1998-11-26 23:13:13 +00:00
|
|
|
} usbd_status;
|
|
|
|
|
2000-07-17 18:41:20 +00:00
|
|
|
typedef void (*usbd_callback)(usbd_xfer_handle, usbd_private_handle,
|
2002-04-01 17:43:28 +00:00
|
|
|
usbd_status);
|
1998-11-26 23:13:13 +00:00
|
|
|
|
|
|
|
/* Open flags */
|
|
|
|
#define USBD_EXCLUSIVE_USE 0x01
|
|
|
|
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
/* Use default (specified by ep. desc.) interval on interrupt pipe */
|
|
|
|
#define USBD_DEFAULT_INTERVAL (-1)
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
/* Request flags */
|
1999-11-17 22:33:51 +00:00
|
|
|
#define USBD_NO_COPY 0x01 /* do not copy data to DMA buffer */
|
|
|
|
#define USBD_SYNCHRONOUS 0x02 /* wait for completion */
|
1999-10-07 19:26:38 +00:00
|
|
|
/* in usb.h #define USBD_SHORT_XFER_OK 0x04*/ /* allow short reads */
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
#define USBD_FORCE_SHORT_XFER 0x08 /* force last short packet on write */
|
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
#define USBD_NO_TIMEOUT 0
|
|
|
|
#define USBD_DEFAULT_TIMEOUT 5000 /* ms = 5 s */
|
|
|
|
|
2004-12-13 08:08:57 +00:00
|
|
|
usbd_status usbd_open_pipe(usbd_interface_handle, u_int8_t,
|
|
|
|
u_int8_t, usbd_pipe_handle *);
|
|
|
|
usbd_status usbd_close_pipe(usbd_pipe_handle);
|
|
|
|
usbd_status usbd_transfer(usbd_xfer_handle);
|
2002-04-01 17:43:28 +00:00
|
|
|
usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle);
|
2004-12-13 08:08:57 +00:00
|
|
|
usbd_status usbd_free_xfer(usbd_xfer_handle);
|
|
|
|
void usbd_setup_xfer(usbd_xfer_handle, usbd_pipe_handle,
|
|
|
|
usbd_private_handle, void *,
|
|
|
|
u_int32_t, u_int16_t, u_int32_t,
|
2002-04-01 17:43:28 +00:00
|
|
|
usbd_callback);
|
2004-12-13 08:08:57 +00:00
|
|
|
void usbd_setup_default_xfer(usbd_xfer_handle, usbd_device_handle,
|
|
|
|
usbd_private_handle, u_int32_t,
|
|
|
|
usb_device_request_t *, void *,
|
|
|
|
u_int32_t, u_int16_t, usbd_callback);
|
|
|
|
void usbd_setup_isoc_xfer(usbd_xfer_handle, usbd_pipe_handle,
|
|
|
|
usbd_private_handle, u_int16_t *,
|
|
|
|
u_int32_t, u_int16_t, usbd_callback);
|
|
|
|
void usbd_get_xfer_status(usbd_xfer_handle, usbd_private_handle *,
|
|
|
|
void **, u_int32_t *, usbd_status *);
|
1998-11-26 23:13:13 +00:00
|
|
|
usb_endpoint_descriptor_t *usbd_interface2endpoint_descriptor
|
2004-12-13 08:08:57 +00:00
|
|
|
(usbd_interface_handle, u_int8_t);
|
|
|
|
usbd_status usbd_abort_pipe(usbd_pipe_handle);
|
2005-02-14 01:51:51 +00:00
|
|
|
usbd_status usbd_abort_default_pipe(usbd_device_handle);
|
2004-12-13 08:08:57 +00:00
|
|
|
usbd_status usbd_clear_endpoint_stall(usbd_pipe_handle);
|
|
|
|
usbd_status usbd_clear_endpoint_stall_async(usbd_pipe_handle);
|
|
|
|
void usbd_clear_endpoint_toggle(usbd_pipe_handle);
|
|
|
|
usbd_status usbd_endpoint_count(usbd_interface_handle, u_int8_t *);
|
|
|
|
usbd_status usbd_interface_count(usbd_device_handle, u_int8_t *);
|
|
|
|
void usbd_interface2device_handle(usbd_interface_handle,
|
|
|
|
usbd_device_handle *);
|
|
|
|
usbd_status usbd_device2interface_handle(usbd_device_handle,
|
|
|
|
u_int8_t, usbd_interface_handle *);
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2000-07-17 18:41:20 +00:00
|
|
|
usbd_device_handle usbd_pipe2device_handle(usbd_pipe_handle);
|
2004-12-13 08:08:57 +00:00
|
|
|
void *usbd_alloc_buffer(usbd_xfer_handle, u_int32_t);
|
|
|
|
void usbd_free_buffer(usbd_xfer_handle);
|
|
|
|
void *usbd_get_buffer(usbd_xfer_handle);
|
|
|
|
usbd_status usbd_sync_transfer(usbd_xfer_handle);
|
|
|
|
usbd_status usbd_open_pipe_intr(usbd_interface_handle, u_int8_t,
|
|
|
|
u_int8_t, usbd_pipe_handle *,
|
|
|
|
usbd_private_handle, void *,
|
|
|
|
u_int32_t, usbd_callback, int);
|
|
|
|
usbd_status usbd_do_request(usbd_device_handle, usb_device_request_t *, void *);
|
|
|
|
usbd_status usbd_do_request_async(usbd_device_handle,
|
|
|
|
usb_device_request_t *, void *);
|
|
|
|
usbd_status usbd_do_request_flags(usbd_device_handle, usb_device_request_t *,
|
|
|
|
void *, u_int16_t, int*, u_int32_t);
|
|
|
|
usbd_status usbd_do_request_flags_pipe(usbd_device_handle, usbd_pipe_handle,
|
|
|
|
usb_device_request_t *, void *, u_int16_t, int *, u_int32_t);
|
1998-11-26 23:13:13 +00:00
|
|
|
usb_interface_descriptor_t *usbd_get_interface_descriptor
|
2004-12-13 08:08:57 +00:00
|
|
|
(usbd_interface_handle);
|
|
|
|
usb_config_descriptor_t *usbd_get_config_descriptor(usbd_device_handle);
|
|
|
|
usb_device_descriptor_t *usbd_get_device_descriptor(usbd_device_handle);
|
2005-02-13 21:38:34 +00:00
|
|
|
int usbd_get_speed(usbd_device_handle);
|
2000-07-17 18:41:20 +00:00
|
|
|
usbd_status usbd_set_interface(usbd_interface_handle, int);
|
|
|
|
int usbd_get_no_alts(usb_config_descriptor_t *, int);
|
2004-12-13 08:08:57 +00:00
|
|
|
usbd_status usbd_get_interface(usbd_interface_handle, u_int8_t *);
|
2002-04-01 17:43:28 +00:00
|
|
|
void usbd_fill_deviceinfo(usbd_device_handle, struct usb_device_info *, int);
|
2004-12-13 08:08:57 +00:00
|
|
|
int usbd_get_interface_altindex(usbd_interface_handle);
|
1999-01-07 23:07:57 +00:00
|
|
|
|
2004-12-13 08:08:57 +00:00
|
|
|
usb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *,
|
|
|
|
int, int);
|
|
|
|
usb_endpoint_descriptor_t *usbd_find_edesc(usb_config_descriptor_t *,
|
|
|
|
int, int, int);
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2000-07-17 18:41:20 +00:00
|
|
|
void usbd_dopoll(usbd_interface_handle);
|
2004-12-13 08:08:57 +00:00
|
|
|
void usbd_set_polling(usbd_device_handle, int);
|
1998-11-26 23:13:13 +00:00
|
|
|
|
2004-12-13 08:08:57 +00:00
|
|
|
const char *usbd_errstr(usbd_status);
|
1999-11-17 22:33:51 +00:00
|
|
|
|
2002-04-01 17:43:28 +00:00
|
|
|
void usbd_add_dev_event(int, usbd_device_handle);
|
2006-09-06 23:44:25 +00:00
|
|
|
void usbd_add_drv_event(int, usbd_device_handle, device_t);
|
1999-11-17 22:33:51 +00:00
|
|
|
|
2000-07-17 18:41:20 +00:00
|
|
|
void usbd_devinfo(usbd_device_handle, int, char *);
|
2001-07-05 10:12:59 +00:00
|
|
|
const struct usbd_quirks *usbd_get_quirks(usbd_device_handle);
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
usb_endpoint_descriptor_t *usbd_get_endpoint_descriptor
|
2004-12-13 08:08:57 +00:00
|
|
|
(usbd_interface_handle, u_int8_t);
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
|
2000-07-17 18:41:20 +00:00
|
|
|
usbd_status usbd_reload_device_desc(usbd_device_handle);
|
More USB ethernet tweaks:
- Sync ohci, uhci and usbdi modules with NetBSD in order to obtain the
following improvements:
o New USBD_NO_TSLEEP flag can be used in place of UQ_NO_TSLEEP
quirk. This allows drivers to specify busy waiting only for
certain transfers (namely control transfers for reading/writing
registers and stuff).
o New USBD_FORCE_SHORT_XFER flag can be used to deal with
devices like the ADMtek Pegasus that sense the end of bulk OUT
transfers in a special way (if a transfer is exactly a multiple
of 64 bytes in size, you need to send an extra empty packet
to terminate the transfer).
o usbd_open_pipe_intr() now accepts an interval argument which
can be used to change the rate at which the interrupt callback
routine is invoked. Specifying USBD_DEFAULT_INTERVAL uses the
value specified in the device's config data, but drivers can
override it if needed.
- Change if_aue to use USBD_FORCE_SHORT_XFER for packet transmissions.
- Change if_aue, if_kue and if_cue to use USBD_NO_TSLEEP for all
control transfers. We no longer force the non-tsleep hack for
bulk transfers since these are done asynchronously anyway.
- Removed quirk entry fiddling from if_aue and if_kue since we don't
need it anymore now that we have the USBD_NO_TSLEEP flag.
- Tweak ulpt, uhid, ums and ukbd drivers to use the new arg to
usbd_open_pipe_intr().
- Add a flag to the softc struct in the ethernet drivers to indicate
when a device has been detached, and use this flag to perform
tests to prevent the drivers from trying to do control transfers
if this is the case. This is necessary because calling if_detach()
with INET6 enabled will eventually result in a call to the driver's
ioctl() routine to delete the multicast groups on the interface,
which will result in attempts to perform control transfers. (It's
possible this also happens even without INET6 support enabled.) This
is pointless since we know that if the detach method has been called,
the hardware has been unplugged.
- Changed watchdog timeout routines to just call the driver init routines
to initialize the device states without trying to close and re-open the
pipes. This is partly because we don't want to frob things at interrupt
context, but also because this doesn't seem to work right and I don't
want to panic the system just because a USB device may have stopped
responding.
- Fix aue_rxeof() to be a little smarter about detecting when a double
transfer is needed. Unfortunately, the design of the chip makes it hard
to get this exactly right. Hopefully, this will go away once either
Nick or Lennart finds the bug in the uhci driver that makes this ugly
hack necessary.
- Also sync usbdevs with NetBSD.
2000-01-20 07:38:33 +00:00
|
|
|
|
2002-04-07 11:56:19 +00:00
|
|
|
int usbd_ratecheck(struct timeval *last);
|
|
|
|
|
2007-06-30 20:18:44 +00:00
|
|
|
usbd_status usbd_get_string(usbd_device_handle dev, int si, char *buf,
|
|
|
|
size_t len);
|
2005-03-01 08:01:22 +00:00
|
|
|
|
|
|
|
/* An iterator for descriptors. */
|
|
|
|
typedef struct {
|
|
|
|
const uByte *cur;
|
|
|
|
const uByte *end;
|
|
|
|
} usbd_desc_iter_t;
|
|
|
|
void usb_desc_iter_init(usbd_device_handle dev, usbd_desc_iter_t *iter);
|
|
|
|
const usb_descriptor_t *usb_desc_iter_next(usbd_desc_iter_t *iter);
|
|
|
|
|
2002-04-02 09:49:36 +00:00
|
|
|
/*
|
|
|
|
* The usb_task structs form a queue of things to run in the USB event
|
|
|
|
* thread. Normally this is just device discovery when a connect/disconnect
|
|
|
|
* has been detected. But it may also be used by drivers that need to
|
|
|
|
* perform (short) tasks that must have a process context.
|
|
|
|
*/
|
|
|
|
struct usb_task {
|
2002-04-02 09:58:16 +00:00
|
|
|
TAILQ_ENTRY(usb_task) next;
|
2002-04-02 09:49:36 +00:00
|
|
|
void (*fun)(void *);
|
|
|
|
void *arg;
|
2006-10-19 01:15:58 +00:00
|
|
|
int queue;
|
2002-04-02 09:49:36 +00:00
|
|
|
};
|
2006-10-19 01:15:58 +00:00
|
|
|
#define USB_TASKQ_HC 0
|
|
|
|
#define USB_TASKQ_DRIVER 1
|
|
|
|
#define USB_NUM_TASKQS 2
|
|
|
|
#define USB_TASKQ_NAMES {"usbtask-hc", "usbtask-dr"}
|
2002-04-02 09:49:36 +00:00
|
|
|
|
2006-10-19 01:15:58 +00:00
|
|
|
void usb_add_task(usbd_device_handle, struct usb_task *, int queue);
|
2004-12-13 08:08:57 +00:00
|
|
|
void usb_rem_task(usbd_device_handle, struct usb_task *);
|
2006-10-19 01:15:58 +00:00
|
|
|
#define usb_init_task(t, f, a) ((t)->fun = (f), (t)->arg = (a), (t)->queue = -1)
|
2002-04-02 09:49:36 +00:00
|
|
|
|
2002-02-11 03:15:08 +00:00
|
|
|
struct usb_devno {
|
|
|
|
u_int16_t ud_vendor;
|
|
|
|
u_int16_t ud_product;
|
|
|
|
};
|
2004-12-13 08:08:57 +00:00
|
|
|
const struct usb_devno *usb_match_device(const struct usb_devno *,
|
|
|
|
u_int, u_int, u_int16_t, u_int16_t);
|
2002-02-11 03:15:08 +00:00
|
|
|
#define usb_lookup(tbl, vendor, product) \
|
|
|
|
usb_match_device((const struct usb_devno *)(tbl), sizeof (tbl) / sizeof ((tbl)[0]), sizeof ((tbl)[0]), (vendor), (product))
|
2002-04-07 12:42:18 +00:00
|
|
|
#define USB_PRODUCT_ANY 0xffff
|
2002-02-11 03:15:08 +00:00
|
|
|
|
1998-11-26 23:13:13 +00:00
|
|
|
/* NetBSD attachment information */
|
|
|
|
|
|
|
|
/* Attach data */
|
|
|
|
struct usb_attach_arg {
|
1999-01-07 23:07:57 +00:00
|
|
|
int port;
|
|
|
|
int configno;
|
|
|
|
int ifaceno;
|
1999-10-07 19:26:38 +00:00
|
|
|
int vendor;
|
|
|
|
int product;
|
|
|
|
int release;
|
2002-04-02 14:08:43 +00:00
|
|
|
int matchlvl;
|
1999-01-07 23:07:57 +00:00
|
|
|
usbd_device_handle device; /* current device */
|
|
|
|
usbd_interface_handle iface; /* current interface */
|
1998-11-26 23:13:13 +00:00
|
|
|
int usegeneric;
|
1999-01-07 23:07:57 +00:00
|
|
|
usbd_interface_handle *ifaces; /* all interfaces */
|
|
|
|
int nifaces; /* number of interfaces */
|
1998-11-26 23:13:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* FreeBSD needs values less than zero */
|
1999-10-07 20:58:43 +00:00
|
|
|
#define UMATCH_VENDOR_PRODUCT_REV (-10)
|
|
|
|
#define UMATCH_VENDOR_PRODUCT (-20)
|
|
|
|
#define UMATCH_VENDOR_DEVCLASS_DEVPROTO (-30)
|
|
|
|
#define UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO (-40)
|
|
|
|
#define UMATCH_DEVCLASS_DEVSUBCLASS (-50)
|
|
|
|
#define UMATCH_VENDOR_PRODUCT_REV_CONF_IFACE (-60)
|
|
|
|
#define UMATCH_VENDOR_PRODUCT_CONF_IFACE (-70)
|
|
|
|
#define UMATCH_VENDOR_IFACESUBCLASS_IFACEPROTO (-80)
|
|
|
|
#define UMATCH_VENDOR_IFACESUBCLASS (-90)
|
|
|
|
#define UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO (-100)
|
|
|
|
#define UMATCH_IFACECLASS_IFACESUBCLASS (-110)
|
|
|
|
#define UMATCH_IFACECLASS (-120)
|
|
|
|
#define UMATCH_IFACECLASS_GENERIC (-130)
|
|
|
|
#define UMATCH_GENERIC (-140)
|
|
|
|
#define UMATCH_NONE (ENXIO)
|
1999-10-07 19:26:38 +00:00
|
|
|
|
2004-08-15 23:39:18 +00:00
|
|
|
#define USBD_SHOW_DEVICE_CLASS 0x1
|
|
|
|
#define USBD_SHOW_INTERFACE_CLASS 0x2
|
|
|
|
|
2000-07-17 18:41:20 +00:00
|
|
|
int usbd_driver_load(module_t mod, int what, void *arg);
|
2005-05-16 06:58:43 +00:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
usb_get_port(device_t dev)
|
|
|
|
{
|
|
|
|
struct usb_attach_arg *uap = device_get_ivars(dev);
|
|
|
|
return (uap->port);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct usbd_interface *
|
|
|
|
usb_get_iface(device_t dev)
|
|
|
|
{
|
|
|
|
struct usb_attach_arg *uap = device_get_ivars(dev);
|
|
|
|
return (uap->iface);
|
|
|
|
}
|
|
|
|
|
2002-04-01 21:34:01 +00:00
|
|
|
/* XXX Perhaps USB should have its own levels? */
|
|
|
|
#ifdef USB_USE_SOFTINTR
|
2002-04-02 10:53:42 +00:00
|
|
|
#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
|
2002-04-01 21:34:01 +00:00
|
|
|
#define splusb splsoftnet
|
|
|
|
#else
|
2002-04-02 10:53:42 +00:00
|
|
|
#define splusb splsoftclock
|
|
|
|
#endif /* __HAVE_GENERIC_SOFT_INTERRUPTS */
|
|
|
|
#else
|
1999-01-07 23:07:57 +00:00
|
|
|
#define splusb splbio
|
2002-04-02 10:53:42 +00:00
|
|
|
#endif /* USB_USE_SOFTINTR */
|
2002-01-26 12:04:22 +00:00
|
|
|
#define splhardusb splbio
|
1999-01-07 23:07:57 +00:00
|
|
|
#define IPL_USB IPL_BIO
|
2005-03-25 12:49:26 +00:00
|
|
|
|
2005-03-25 13:22:58 +00:00
|
|
|
#endif /* _USBDI_H_ */
|