src/lib/libusb20/libusb20_compat01.c

Fix some issues about re-scanning of the devices.

src/lib/libusb20/libusb20_ugen20.c

Fix issue about libusb20 having to release the
USB transfers before doing a SET_CONFIG, else
the kernel will kill the file handle.

src/sys/dev/usb2/core/usb2_device.
src/sys/dev/usb2/core/usb2_generic.c
src/sys/dev/usb2/core/usb2_generic.h

Add support for U3G devices.
Improve and cleanup FIFO free handling.
Improve device re-enumeration.

src/sys/dev/usb2/core/usb2_msctest.c
src/sys/dev/usb2/core/usb2_msctest.h

Fix some problems in the USB Mass Storage Test.
Add Huawei vendor specific quirks.

src/sys/dev/usb2/core/usb2_request.c

Improve device re-enumeration.

src/sys/dev/usb2/ethernet/if_aue2.c
src/sys/dev/usb2/include/usb2_devid.h
src/sys/dev/usb2/include/usb2_devtable.h
src/sys/dev/usb2/quirk/usb2_quirk.c

Integrate changes from the old USB driver.

src/sys/dev/usb2/include/usb2_standard.h

Add definition of USB3.0 structures from USB.org.

src/sys/dev/usb2/serial/u3g2.c
src/sys/dev/usb2/serial/ugensa2.c
src/sys/modules/usb2/Makefile
src/sys/modules/usb2/serial_3g/Makefile

Import U3G driver.

Submitted by:	Hans Petter Selasky (usb4bsd)
This commit is contained in:
Alfred Perlstein 2008-11-25 08:04:40 +00:00
parent 3f3137fee5
commit 6fda742dfe
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=185290
16 changed files with 778 additions and 166 deletions

View File

@ -177,19 +177,42 @@ usb_open(struct usb_device *dev)
if (err)
return (NULL);
/*
* Dequeue USB device from backend queue so that it does not get
* freed when the backend is re-scanned:
*/
libusb20_be_dequeue_device(usb_backend, dev->dev);
return (dev->dev);
}
int
usb_close(usb_dev_handle * dev)
usb_close(usb_dev_handle * udev)
{
struct usb_device *dev;
int err;
err = libusb20_dev_close((void *)dev);
err = libusb20_dev_close((void *)udev);
if (err)
return (-1);
if (usb_backend != NULL) {
/*
* Enqueue USB device to backend queue so that it gets freed
* when the backend is re-scanned:
*/
libusb20_be_enqueue_device(usb_backend, (void *)udev);
} else {
/*
* The backend is gone. Free device data so that we
* don't start leaking memory!
*/
dev = usb_device(udev);
libusb20_dev_free((void *)udev);
LIST_DEL(usb_global_bus.devices, dev);
free(dev);
}
return (0);
}
@ -697,7 +720,8 @@ usb_set_configuration(usb_dev_handle * udev, int bConfigurationValue)
/* "bConfigurationValue" not found */
return (-1);
}
if ((dev->config + i)->bConfigurationValue == bConfigurationValue) {
if ((dev->config + i)->bConfigurationValue ==
bConfigurationValue) {
break;
}
}
@ -821,36 +845,28 @@ usb_find_devices(void)
struct libusb20_device *pdev;
struct usb_device *udev;
struct LIBUSB20_DEVICE_DESC_DECODED *ddesc;
struct libusb20_backend *pold;
int err;
/* cleanup after last device search */
/* close all opened devices, if any */
pold = usb_backend;
pdev = NULL;
while ((pdev = libusb20_be_device_foreach(pold, pdev))) {
if (!pdev->is_opened) {
/*
* if the device has not been opened we free the
* device data
*/
udev = pdev->priv01Data;
libusb20_be_dequeue_device(pold, pdev);
libusb20_dev_free(pdev);
if (udev != NULL) {
LIST_DEL(usb_global_bus.devices, udev);
free(udev);
}
pdev = NULL; /* restart search */
while ((pdev = libusb20_be_device_foreach(usb_backend, NULL))) {
udev = pdev->priv01Data;
libusb20_be_dequeue_device(usb_backend, pdev);
libusb20_dev_free(pdev);
if (udev != NULL) {
LIST_DEL(usb_global_bus.devices, udev);
free(udev);
}
}
/* do a new backend device search */
/* free old USB backend, if any */
libusb20_be_free(usb_backend);
/* do a new backend device search */
usb_backend = libusb20_be_alloc_default();
if (usb_backend == NULL) {
usb_backend = pold; /* restore */
return (-1);
}
/* iterate all devices */
@ -904,17 +920,6 @@ usb_find_devices(void)
LIST_ADD(usb_global_bus.devices, udev);
}
/* move old devices over to the new USB backend */
while ((pdev = libusb20_be_device_foreach(pold, pdev))) {
libusb20_be_dequeue_device(pold, pdev);
libusb20_be_enqueue_device(usb_backend, pdev);
}
/* free old backend, if any */
libusb20_be_free(pold);
return (0); /* success */
}

View File

@ -307,10 +307,27 @@ ugen20_init_backend(struct libusb20_backend *pbe)
return (0); /* success */
}
static void
ugen20_tr_release(struct libusb20_device *pdev)
{
struct usb2_fs_uninit fs_uninit;
if (pdev->nTransfer == 0) {
return;
}
/* release all pending USB transfers */
if (pdev->privBeData != NULL) {
memset(&fs_uninit, 0, sizeof(fs_uninit));
if (ioctl(pdev->file, USB_FS_UNINIT, &fs_uninit)) {
/* ignore any errors of this kind */
}
}
return;
}
static int
ugen20_tr_renew(struct libusb20_device *pdev)
{
struct usb2_fs_uninit fs_uninit;
struct usb2_fs_init fs_init;
struct usb2_fs_endpoint *pfse;
int error;
@ -325,12 +342,7 @@ ugen20_tr_renew(struct libusb20_device *pdev)
}
size = nMaxTransfer * sizeof(*pfse);
if (pdev->privBeData != NULL) {
memset(&fs_uninit, 0, sizeof(fs_uninit));
if (ioctl(pdev->file, USB_FS_UNINIT, &fs_uninit)) {
/* ignore any errors of this kind */
}
} else {
if (pdev->privBeData == NULL) {
pfse = malloc(size);
if (pfse == NULL) {
error = LIBUSB20_ERROR_NO_MEM;
@ -338,7 +350,6 @@ ugen20_tr_renew(struct libusb20_device *pdev)
}
pdev->privBeData = pfse;
}
/* reset endpoint data */
memset(pdev->privBeData, 0, size);
@ -421,12 +432,11 @@ static int
ugen20_close_device(struct libusb20_device *pdev)
{
struct usb2_fs_uninit fs_uninit;
int error = 0;
if (pdev->privBeData) {
memset(&fs_uninit, 0, sizeof(fs_uninit));
if (ioctl(pdev->file, USB_FS_UNINIT, &fs_uninit)) {
error = LIBUSB20_ERROR_OTHER;
/* ignore this error */
}
free(pdev->privBeData);
}
@ -436,7 +446,7 @@ ugen20_close_device(struct libusb20_device *pdev)
close(pdev->file_ctrl);
pdev->file = -1;
pdev->file_ctrl = -1;
return (error);
return (0); /* success */
}
static void
@ -509,6 +519,9 @@ ugen20_set_config_index(struct libusb20_device *pdev, uint8_t cfg_index)
{
int temp = cfg_index;
/* release all active USB transfers */
ugen20_tr_release(pdev);
if (ioctl(pdev->file_ctrl, USB_SET_CONFIG, &temp)) {
return (LIBUSB20_ERROR_OTHER);
}
@ -548,6 +561,9 @@ ugen20_set_alt_index(struct libusb20_device *pdev,
alt_iface.uai_interface_index = iface_index;
alt_iface.uai_alt_index = alt_index;
/* release all active USB transfers */
ugen20_tr_release(pdev);
if (ioctl(pdev->file_ctrl, USB_SET_ALTINTERFACE, &alt_iface)) {
return (LIBUSB20_ERROR_OTHER);
}
@ -559,6 +575,9 @@ ugen20_reset_device(struct libusb20_device *pdev)
{
int temp = 0;
/* release all active USB transfers */
ugen20_tr_release(pdev);
if (ioctl(pdev->file_ctrl, USB_DEVICEENUMERATE, &temp)) {
return (LIBUSB20_ERROR_OTHER);
}

View File

@ -1605,18 +1605,16 @@ usb2_alloc_device(device_t parent_dev, struct usb2_bus *bus,
* Try to figure out if we have an
* auto-install disk there:
*/
if (usb2_test_autoinstall(udev, 0) == 0) {
if (usb2_test_autoinstall(udev, 0, 0) == 0) {
DPRINTFN(0, "Found possible auto-install "
"disk (trying next config)\n");
config_index++;
goto repeat_set_config;
}
}
} else if (UGETW(udev->ddesc.idVendor) == USB_VENDOR_HUAWEI) {
if (usb2_test_huawei(udev, 0) == 0) {
DPRINTFN(0, "Found Huawei auto-install disk!\n");
err = USB_ERR_STALLED; /* fake an error */
}
} else if (usb2_test_huawei(udev, &uaa) == 0) {
DPRINTFN(0, "Found Huawei auto-install disk!\n");
err = USB_ERR_STALLED; /* fake an error */
}
} else {
err = 0; /* set success */
@ -2114,38 +2112,23 @@ usb2_fifo_free_wrap(struct usb2_device *udev,
*/
continue;
}
if (f->dev_ep_index == 0) {
/*
* Don't free the generic control endpoint
* yet and make sure that any USB-FS
* activity is stopped!
*/
if (ugen_fs_uninit(f)) {
/* ignore any failures */
DPRINTFN(10, "udev=%p ugen_fs_uninit() "
"failed! (ignored)\n", udev);
}
if ((f->dev_ep_index == 0) &&
(f->fs_xfer == NULL)) {
/* no need to free this FIFO */
continue;
}
} else if (iface_index == USB_IFACE_INDEX_ANY) {
if ((f->methods == &usb2_ugen_methods) &&
(f->dev_ep_index == 0) && (flag == 0)) {
/*
* Don't free the generic control endpoint
* yet, but make sure that any USB-FS
* activity is stopped!
*/
if (ugen_fs_uninit(f)) {
/* ignore any failures */
DPRINTFN(10, "udev=%p ugen_fs_uninit() "
"failed! (ignored)\n", udev);
}
(f->dev_ep_index == 0) && (flag == 0) &&
(f->fs_xfer == NULL)) {
/* no need to free this FIFO */
continue;
}
} else {
/* no need to free this FIFO */
continue;
}
/* free the FIFO */
/* free this FIFO */
usb2_fifo_free(f);
}
return;

View File

@ -83,7 +83,7 @@ static int usb2_gen_fill_deviceinfo(struct usb2_fifo *f, struct usb2_device_info
static int ugen_re_enumerate(struct usb2_fifo *f);
static int ugen_iface_ioctl(struct usb2_fifo *f, u_long cmd, void *addr, int fflags);
static uint8_t ugen_fs_get_complete(struct usb2_fifo *f, uint8_t *pindex);
static int ugen_fs_uninit(struct usb2_fifo *f);
/* structures */
@ -192,6 +192,7 @@ ugen_close(struct usb2_fifo *f, int fflags, struct thread *td)
if (ugen_fs_uninit(f)) {
/* ignore any errors - we are closing */
DPRINTFN(6, "no FIFOs\n");
}
return;
}
@ -591,6 +592,12 @@ ugen_set_config(struct usb2_fifo *f, uint8_t index)
/* no change needed */
return (0);
}
/* make sure all FIFO's are gone */
/* else there can be a deadlock */
if (ugen_fs_uninit(f)) {
/* ignore any errors */
DPRINTFN(6, "no FIFOs\n");
}
/* change setting - will free generic FIFOs, if any */
if (usb2_set_config_index(f->udev, index)) {
return (EIO);
@ -612,6 +619,12 @@ ugen_set_interface(struct usb2_fifo *f,
/* not possible in device side mode */
return (ENOTTY);
}
/* make sure all FIFO's are gone */
/* else there can be a deadlock */
if (ugen_fs_uninit(f)) {
/* ignore any errors */
DPRINTFN(6, "no FIFOs\n");
}
/* change setting - will free generic FIFOs, if any */
if (usb2_set_alt_interface_index(f->udev, iface_index, alt_index)) {
return (EIO);

View File

@ -29,6 +29,5 @@
extern struct usb2_fifo_methods usb2_ugen_methods;
int ugen_do_request(struct usb2_fifo *f, struct usb2_ctl_request *ur);
int ugen_fs_uninit(struct usb2_fifo *f);
#endif /* _USB2_GENERIC_H_ */

View File

@ -36,6 +36,7 @@
#include <dev/usb2/include/usb2_mfunc.h>
#include <dev/usb2/include/usb2_error.h>
#include <dev/usb2/include/usb2_standard.h>
#include <dev/usb2/include/usb2_devid.h>
#define USB_DEBUG_VAR usb2_debug
@ -49,6 +50,7 @@
#include <dev/usb2/core/usb2_device.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_util.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/include/usb2_mfunc.h>
#include <dev/usb2/include/usb2_error.h>
@ -70,8 +72,7 @@ enum {
DIR_NONE,
};
#define BULK_SIZE 64 /* dummy */
#define BULK_SIZE 64 /* dummy */
/* Command Block Wrapper */
struct bbb_cbw {
@ -169,7 +170,7 @@ static const struct usb2_config bbb_config[ST_MAX] = {
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.mh.bufsize = BULK_SIZE,
.mh.flags = {.proxy_buffer = 1,.short_xfer_ok = 1,},
.mh.flags = {.proxy_buffer = 1,},
.mh.callback = &bbb_data_write_callback,
.mh.timeout = 4 * USB_MS_HZ, /* 4 seconds */
},
@ -272,6 +273,7 @@ bbb_command_callback(struct usb2_xfer *xfer)
USETDW(sc->cbw.dCBWDataTransferLength, sc->data_len);
sc->cbw.bCBWFlags = ((sc->dir == DIR_IN) ? CBWFLAGS_IN : CBWFLAGS_OUT);
sc->cbw.bCBWLUN = sc->lun;
sc->cbw.bCDBLength = sc->cmd_len;
if (sc->cbw.bCDBLength > sizeof(sc->cbw.CBWCDB)) {
sc->cbw.bCDBLength = sizeof(sc->cbw.CBWCDB);
DPRINTFN(0, "Truncating long command!\n");
@ -474,7 +476,8 @@ bbb_command_start(struct bbb_transfer *sc, uint8_t dir, uint8_t lun,
* Else: Not an auto install disk.
*------------------------------------------------------------------------*/
usb2_error_t
usb2_test_autoinstall(struct usb2_device *udev, uint8_t iface_index)
usb2_test_autoinstall(struct usb2_device *udev, uint8_t iface_index,
uint8_t do_eject)
{
struct usb2_interface *iface;
struct usb2_interface_descriptor *id;
@ -534,22 +537,40 @@ usb2_test_autoinstall(struct usb2_device *udev, uint8_t iface_index)
repeat_inquiry:
sc->cbw.CBWCDB[0] = 0x12; /* INQUIRY */
sc->cbw.CBWCDB[1] = 0;
sc->cbw.CBWCDB[2] = 0;
sc->cbw.CBWCDB[3] = 0;
sc->cbw.CBWCDB[4] = 0x24; /* length */
sc->cbw.CBWCDB[5] = 0;
err = bbb_command_start(sc, DIR_IN, 0,
sc->buffer, 0x24, 6, USB_MS_HZ);
err = bbb_command_start(sc, DIR_IN, 0, sc->buffer, 256, 6, USB_MS_HZ);
if (err) {
err = bbb_command_start(sc, DIR_IN, 0, sc->buffer, 256, 12, USB_MS_HZ);
if (err) {
err = bbb_command_start(sc, DIR_IN, 0, sc->buffer, 256, 16, USB_MS_HZ);
}
}
if ((sc->actlen != 0) && (err == 0)) {
sid_type = sc->buffer[0] & 0x1F;
if (sid_type == 0x05) {
/* CD-ROM */
/* XXX could investigate more */
return (0);
if (do_eject) {
/* 0: opcode: SCSI START/STOP */
sc->cbw.CBWCDB[0] = 0x1b;
/* 1: byte2: Not immediate */
sc->cbw.CBWCDB[1] = 0x00;
/* 2..3: reserved */
sc->cbw.CBWCDB[2] = 0x00;
sc->cbw.CBWCDB[3] = 0x00;
/* 4: Load/Eject command */
sc->cbw.CBWCDB[4] = 0x02;
/* 5: control */
sc->cbw.CBWCDB[5] = 0x00;
err = bbb_command_start(sc, DIR_OUT, 0,
NULL, 0, 6, USB_MS_HZ);
DPRINTFN(0, "Eject CD command "
"status: %s\n", usb2_errstr(err));
}
err = 0;
goto done;
}
} else if (--timeout) {
} else if ((err != 2) && --timeout) {
usb2_pause_mtx(&sc->mtx, USB_MS_HZ);
goto repeat_inquiry;
}
@ -566,28 +587,136 @@ usb2_test_autoinstall(struct usb2_device *udev, uint8_t iface_index)
}
/*
* Huawei Exxx radio devices have a built in flash disk which is their
* default power up configuration. This allows the device to carry its
* own installation software.
*
* Instead of following the USB spec, and create multiple
* configuration descriptors for this, the devices expects the driver
* to send UF_DEVICE_REMOTE_WAKEUP to endpoint 2 to reset the device,
* so it reprobes, now with the radio exposed.
* NOTE: The entries marked with XXX should be checked for the correct
* speed indication to set the buffer sizes.
*/
static const struct usb2_device_id u3g_devs[] = {
/* OEM: Option */
{USB_VPI(USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G, U3GINFO(U3GSP_UMTS, U3GFL_NONE))},
{USB_VPI(USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD, U3GINFO(U3GSP_UMTS, U3GFL_NONE))},
{USB_VPI(USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS, U3GINFO(U3GSP_UMTS, U3GFL_NONE))},
{USB_VPI(USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36, U3GINFO(U3GSP_HSDPA, U3GFL_NONE))},
{USB_VPI(USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAXHSUPA, U3GINFO(U3GSP_HSDPA, U3GFL_NONE))},
{USB_VPI(USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G, U3GINFO(U3GSP_UMTS, U3GFL_NONE))},
/* OEM: Qualcomm, Inc. */
{USB_VPI(USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_ZTE_STOR, U3GINFO(U3GSP_CDMA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM, U3GINFO(U3GSP_CDMA, U3GFL_SCSI_EJECT))},
/* OEM: Huawei */
{USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE, U3GINFO(U3GSP_HSDPA, U3GFL_HUAWEI_INIT))},
{USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220, U3GINFO(U3GSP_HSPA, U3GFL_HUAWEI_INIT))},
/* OEM: Novatel */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM, U3GINFO(U3GSP_CDMA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620, U3GINFO(U3GSP_UMTS, U3GFL_SCSI_EJECT))}, /* XXX */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_MC950D, U3GINFO(U3GSP_HSUPA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720, U3GINFO(U3GSP_UMTS, U3GFL_SCSI_EJECT))}, /* XXX */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727, U3GINFO(U3GSP_UMTS, U3GFL_SCSI_EJECT))}, /* XXX */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740, U3GINFO(U3GSP_HSDPA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2, U3GINFO(U3GSP_HSDPA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870, U3GINFO(U3GSP_UMTS, U3GFL_SCSI_EJECT))}, /* XXX */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620, U3GINFO(U3GSP_UMTS, U3GFL_SCSI_EJECT))}, /* XXX */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640, U3GINFO(U3GSP_UMTS, U3GFL_SCSI_EJECT))}, /* XXX */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720, U3GINFO(U3GSP_UMTS, U3GFL_SCSI_EJECT))}, /* XXX */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740, U3GINFO(U3GSP_HSDPA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D, U3GINFO(U3GSP_HSUPA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870, U3GINFO(U3GSP_HSDPA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ZEROCD, U3GINFO(U3GSP_HSUPA, U3GFL_SCSI_EJECT))},
{USB_VPI(USB_VENDOR_DELL, USB_PRODUCT_DELL_U740, U3GINFO(U3GSP_HSDPA, U3GFL_SCSI_EJECT))},
/* OEM: Merlin */
{USB_VPI(USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
/* OEM: Sierra Wireless: */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD580, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD595, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC595U, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC597E, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_C597, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880E, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880U, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881E, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881U, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_EM5625, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720_2, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5725, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MINI5725, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD875, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_2, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_3, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8765, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC875U, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8775_2, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8780, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8781, U3GINFO(U3GSP_UMTS, U3GFL_NONE))}, /* XXX */
/* Sierra TruInstaller device ID */
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_TRUINSTALL, U3GINFO(U3GSP_UMTS, U3GFL_SIERRA_INIT))},
};
usb2_error_t
usb2_test_huawei(struct usb2_device *udev, uint8_t iface_index)
static void
u3g_sierra_init(struct usb2_device *udev)
{
struct usb2_device_request req;
DPRINTFN(0, "\n");
req.bmRequestType = UT_VENDOR;
req.bRequest = UR_SET_INTERFACE;
USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP);
USETW(req.wIndex, UHF_PORT_CONNECTION);
USETW(req.wLength, 0);
if (usb2_do_request_flags(udev, NULL, &req,
NULL, 0, NULL, USB_MS_HZ)) {
/* ignore any errors */
}
return;
}
static void
u3g_huawei_init(struct usb2_device *udev)
{
struct usb2_device_request req;
DPRINTFN(0, "\n");
req.bmRequestType = UT_WRITE_DEVICE;
req.bRequest = UR_SET_FEATURE;
USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP);
USETW(req.wIndex, UHF_PORT_SUSPEND);
USETW(req.wLength, 0);
if (usb2_do_request_flags(udev, NULL, &req,
NULL, 0, NULL, USB_MS_HZ)) {
/* ignore any errors */
}
return;
}
int
usb2_lookup_huawei(struct usb2_attach_arg *uaa)
{
/* Calling the lookup function will also set the driver info! */
return (usb2_lookup_id_by_uaa(u3g_devs, sizeof(u3g_devs), uaa));
}
/*
* The following function handles 3G modem devices (E220, Mobile,
* etc.) with auto-install flash disks for Windows/MacOSX on the first
* interface. After some command or some delay they change appearance
* to a modem.
*/
usb2_error_t
usb2_test_huawei(struct usb2_device *udev, struct usb2_attach_arg *uaa)
{
struct usb2_interface *iface;
struct usb2_interface_descriptor *id;
usb2_error_t err;
uint32_t flags;
if (udev == NULL) {
return (USB_ERR_INVAL);
}
iface = usb2_get_iface(udev, iface_index);
iface = usb2_get_iface(udev, 0);
if (iface == NULL) {
return (USB_ERR_INVAL);
}
@ -598,15 +727,21 @@ usb2_test_huawei(struct usb2_device *udev, uint8_t iface_index)
if (id->bInterfaceClass != UICLASS_MASS) {
return (USB_ERR_INVAL);
}
/* Bend it like Beckham */
req.bmRequestType = UT_WRITE_DEVICE;
req.bRequest = UR_SET_FEATURE;
USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP);
USETW(req.wIndex, 2);
USETW(req.wLength, 0);
/* We get error at return, but it works */
err = usb2_do_request_flags(udev, NULL, &req, NULL, 0, NULL, 1 * USB_MS_HZ);
if (usb2_lookup_huawei(uaa)) {
/* no device match */
return (USB_ERR_INVAL);
}
flags = USB_GET_DRIVER_INFO(uaa);
if (flags & U3GFL_HUAWEI_INIT) {
u3g_huawei_init(udev);
} else if (flags & U3GFL_SCSI_EJECT) {
return (usb2_test_autoinstall(udev, 0, 1));
} else if (flags & U3GFL_SIERRA_INIT) {
u3g_sierra_init(udev);
} else {
/* no quirks */
return (USB_ERR_INVAL);
}
return (0); /* success */
}

View File

@ -27,7 +27,30 @@
#ifndef _USB2_MSCTEST_H_
#define _USB2_MSCTEST_H_
usb2_error_t usb2_test_autoinstall(struct usb2_device *udev, uint8_t iface_index);
usb2_error_t usb2_test_huawei(struct usb2_device *udev, uint8_t iface_index);
usb2_error_t usb2_test_autoinstall(struct usb2_device *udev, uint8_t iface_index, uint8_t do_eject);
usb2_error_t usb2_test_huawei(struct usb2_device *udev, struct usb2_attach_arg *uaa);
int usb2_lookup_huawei(struct usb2_attach_arg *uaa);
/* Huawei specific defines */
#define U3GINFO(flag,speed) ((flag)|((speed) * 256))
#define U3G_GET_SPEED(uaa) (USB_GET_DRIVER_INFO(uaa) / 256)
#define U3GFL_NONE 0x00
#define U3GFL_HUAWEI_INIT 0x01 /* Requires init command (Huawei
* cards) */
#define U3GFL_SCSI_EJECT 0x02 /* Requires SCSI eject command
* (Novatel) */
#define U3GFL_SIERRA_INIT 0x04 /* Requires init command (Sierra
* cards) */
#define U3GSP_GPRS 0
#define U3GSP_EDGE 1
#define U3GSP_CDMA 2
#define U3GSP_UMTS 3
#define U3GSP_HSDPA 4
#define U3GSP_HSUPA 5
#define U3GSP_HSPA 6
#define U3GSP_MAX 7
#endif /* _USB2_MSCTEST_H_ */

View File

@ -1325,16 +1325,17 @@ usb2_req_get_config(struct usb2_device *udev, struct mtx *mtx, uint8_t *pconf)
usb2_error_t
usb2_req_re_enumerate(struct usb2_device *udev, struct mtx *mtx)
{
struct usb2_device_descriptor ddesc;
struct usb2_device *parent_hub;
usb2_error_t err;
uint8_t old_addr;
if (udev->flags.usb2_mode != USB_MODE_HOST) {
return (USB_ERR_INVAL);
}
old_addr = udev->address;
parent_hub = udev->parent_hub;
if (parent_hub == NULL) {
err = USB_ERR_INVAL;
goto done;
return (USB_ERR_INVAL);
}
err = usb2_req_reset_port(parent_hub, mtx, udev->port_no);
if (err) {
@ -1347,6 +1348,9 @@ usb2_req_re_enumerate(struct usb2_device *udev, struct mtx *mtx)
*/
udev->address = USB_START_ADDR;
/* reset "bMaxPacketSize" */
udev->ddesc.bMaxPacketSize = USB_MAX_IPACKET;
/*
* Restore device address:
*/
@ -1364,7 +1368,15 @@ usb2_req_re_enumerate(struct usb2_device *udev, struct mtx *mtx)
usb2_pause_mtx(mtx, USB_SET_ADDRESS_SETTLE);
/* get the device descriptor */
err = usb2_req_get_device_desc(udev, mtx, &ddesc);
err = usb2_req_get_desc(udev, mtx, &udev->ddesc,
USB_MAX_IPACKET, USB_MAX_IPACKET, 0, UDESC_DEVICE, 0, 0);
if (err) {
DPRINTFN(0, "getting device descriptor "
"at addr %d failed!\n", udev->address);
goto done;
}
/* get the full device descriptor */
err = usb2_req_get_device_desc(udev, mtx, &udev->ddesc);
if (err) {
DPRINTFN(0, "addr=%d, getting device "
"descriptor failed!\n", old_addr);

View File

@ -736,6 +736,17 @@ aue_probe(device_t dev)
if (uaa->info.bIfaceIndex != AUE_IFACE_IDX) {
return (ENXIO);
}
/*
* Belkin USB Bluetooth dongles of the F8T012xx1 model series
* conflict with older Belkin USB2LAN adapters. Skip if_aue if
* we detect one of the devices that look like Bluetooth
* adapters.
*/
if ((uaa->info.idVendor == USB_VENDOR_BELKIN) &&
(uaa->info.idProduct == USB_PRODUCT_BELKIN_F8T012) &&
(uaa->info.bcdDevice == 0x0413)) {
return (ENXIO);
}
return (usb2_lookup_id_by_uaa(aue_devs, sizeof(aue_devs), uaa));
}

View File

@ -4,7 +4,7 @@
* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* FreeBSD: src/sys/dev/usb/usbdevs,v 1.381 2008/11/02 03:00:36 imp Exp
* FreeBSD: src/sys/dev/usb/usbdevs,v 1.383 2008/11/12 13:58:59 keramida Exp
*/
/* $NetBSD: usbdevs,v 1.392 2004/12/29 08:38:44 imp Exp $ */
@ -939,6 +939,7 @@
#define USB_PRODUCT_BELKIN_F5U103 0x0103 /* F5U103 Serial */
#define USB_PRODUCT_BELKIN_F5U109 0x0109 /* F5U109 Serial */
#define USB_PRODUCT_BELKIN_USB2SCSI 0x0115 /* USB to SCSI */
#define USB_PRODUCT_BELKIN_F8T012 0x0121 /* F8T012xx1 Bluetooth USB Adapter */
#define USB_PRODUCT_BELKIN_USB2LAN 0x0121 /* USB to LAN */
#define USB_PRODUCT_BELKIN_F5U208 0x0208 /* F5U208 VideoBus II */
#define USB_PRODUCT_BELKIN_F5U237 0x0237 /* F5U237 USB 2.0 7-Port Hub */
@ -1709,6 +1710,7 @@
#define USB_PRODUCT_MICROSOFT_MN110 0x007a /* 10/100 USB NIC */
#define USB_PRODUCT_MICROSOFT_WLINTELLIMOUSE 0x008c /* Wireless Optical IntelliMouse */
#define USB_PRODUCT_MICROSOFT_WLNOTEBOOK 0x00b9 /* Wireless Optical Mouse (Model 1023) */
#define USB_PRODUCT_MICROSOFT_COMFORT3000 0x00d1 /* Comfort Optical Mouse 3000 (Model 1043) */
#define USB_PRODUCT_MICROSOFT_WLNOTEBOOK2 0x00e1 /* Wireless Optical Mouse 3000 (Model 1056) */
#define USB_PRODUCT_MICROSOFT_WLNOTEBOOK3 0x00d2 /* Wireless Optical Mouse 3000 (Model 1049) */
#define USB_PRODUCT_MICROSOFT_WLUSBMOUSE 0x00b9 /* Wireless USB Mouse */

View File

@ -4,7 +4,7 @@
* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* FreeBSD: src/sys/dev/usb/usbdevs,v 1.381 2008/11/02 03:00:36 imp Exp
* FreeBSD: src/sys/dev/usb/usbdevs,v 1.383 2008/11/12 13:58:59 keramida Exp
*/
/* $NetBSD: usbdevs,v 1.392 2004/12/29 08:38:44 imp Exp $ */
@ -1096,6 +1096,12 @@ const struct usb_knowndev usb_knowndevs[] = {
"Belkin Components",
"USB to SCSI",
},
{
USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F8T012,
0,
"Belkin Components",
"F8T012xx1 Bluetooth USB Adapter",
},
{
USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_USB2LAN,
0,
@ -4222,6 +4228,12 @@ const struct usb_knowndev usb_knowndevs[] = {
"Microsoft",
"Wireless Optical Mouse (Model 1023)",
},
{
USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_COMFORT3000,
0,
"Microsoft",
"Comfort Optical Mouse 3000 (Model 1043)",
},
{
USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK2,
0,

View File

@ -26,6 +26,16 @@
* SUCH DAMAGE.
*/
/*
* This file contains standard definitions for the following USB
* protocol versions:
*
* USB v1.0
* USB v1.1
* USB v2.0
* USB v3.0
*/
#ifndef _USB2_STANDARD_H_
#define _USB2_STANDARD_H_
@ -133,26 +143,32 @@ struct usb2_device_request {
#define UDESC_DEVICE 0x01
#define UDESC_CONFIG 0x02
#define UDESC_STRING 0x03
#define USB_LANGUAGE_TABLE 0x00 /* Index of the language ID table
* string */
#define UDESC_INTERFACE 0x04
#define USB_LANGUAGE_TABLE 0x00 /* language ID string index */
#define UDESC_INTERFACE 0x04
#define UDESC_ENDPOINT 0x05
#define UDESC_DEVICE_QUALIFIER 0x06
#define UDESC_OTHER_SPEED_CONFIGURATION 0x07
#define UDESC_INTERFACE_POWER 0x08
#define UDESC_OTG 0x09
#define UDESC_CS_DEVICE 0x21 /* class specific */
#define UDESC_CS_CONFIG 0x22
#define UDESC_CS_STRING 0x23
#define UDESC_DEBUG 0x0A
#define UDESC_IFACE_ASSOC 0x0B /* interface association */
#define UDESC_BOS 0x0F /* binary object store */
#define UDESC_DEVICE_CAPABILITY 0x10
#define UDESC_CS_DEVICE 0x21 /* class specific */
#define UDESC_CS_CONFIG 0x22
#define UDESC_CS_STRING 0x23
#define UDESC_CS_INTERFACE 0x24
#define UDESC_CS_ENDPOINT 0x25
#define UDESC_HUB 0x29
#define UDESC_ENDPOINT_SS_COMP 0x30 /* super speed */
#define UR_SET_DESCRIPTOR 0x07
#define UR_GET_CONFIG 0x08
#define UR_SET_CONFIG 0x09
#define UR_GET_INTERFACE 0x0a
#define UR_SET_INTERFACE 0x0b
#define UR_SYNCH_FRAME 0x0c
#define UR_SET_SEL 0x30
#define UR_ISOCH_DELAY 0x31
/* HUB specific request */
#define UR_GET_BUS_STATE 0x02
@ -160,11 +176,16 @@ struct usb2_device_request {
#define UR_RESET_TT 0x09
#define UR_GET_TT_STATE 0x0a
#define UR_STOP_TT 0x0b
#define UR_SET_HUB_DEPTH 0x0c
#define UR_GET_PORT_ERR_COUNT 0x0d
/* Feature numbers */
#define UF_ENDPOINT_HALT 0
#define UF_DEVICE_REMOTE_WAKEUP 1
#define UF_TEST_MODE 2
#define UF_U1_ENABLE 0x30
#define UF_U2_ENABLE 0x31
#define UF_LTM_ENABLE 0x32
/* HUB specific features */
#define UHF_C_HUB_LOCAL_POWER 0
@ -174,6 +195,7 @@ struct usb2_device_request {
#define UHF_PORT_SUSPEND 2
#define UHF_PORT_OVER_CURRENT 3
#define UHF_PORT_RESET 4
#define UHF_PORT_LINK_STATE 5
#define UHF_PORT_POWER 8
#define UHF_PORT_LOW_SPEED 9
#define UHF_C_PORT_CONNECTION 16
@ -184,6 +206,16 @@ struct usb2_device_request {
#define UHF_PORT_TEST 21
#define UHF_PORT_INDICATOR 22
/* SuperSpeed HUB specific features */
#define UHF_PORT_U1_TIMEOUT 23
#define UHF_PORT_U2_TIMEOUT 24
#define UHF_C_PORT_LINK_STATE 25
#define UHF_C_PORT_CONFIG_ERROR 26
#define UHF_PORT_REMOTE_WAKE_MASK 27
#define UHF_BH_PORT_RESET 28
#define UHF_C_BH_PORT_RESET 29
#define UHF_FORCE_LINKPM_ACCEPT 30
struct usb2_descriptor {
uByte bLength;
uByte bDescriptorType;
@ -195,7 +227,9 @@ struct usb2_device_descriptor {
uByte bDescriptorType;
uWord bcdUSB;
#define UD_USB_2_0 0x0200
#define UD_IS_USB2(d) (UGETW((d)->bcdUSB) >= UD_USB_2_0)
#define UD_USB_3_0 0x0300
#define UD_IS_USB2(d) ((d)->bcdUSB[1] == 0x02)
#define UD_IS_USB3(d) ((d)->bcdUSB[1] == 0x03)
uByte bDeviceClass;
uByte bDeviceSubClass;
uByte bDeviceProtocol;
@ -210,6 +244,54 @@ struct usb2_device_descriptor {
uByte bNumConfigurations;
} __packed;
/* Binary Device Object Store (BOS) */
struct usb2_bos_descriptor {
uByte bLength;
uByte bDescriptorType;
uWord wTotalLength;
uByte bNumDeviceCaps;
} __packed;
/* Binary Device Object Store Capability */
struct usb2_bos_cap_descriptor {
uByte bLength;
uByte bDescriptorType;
uByte bDevCapabilityType;
#define USB_DEVCAP_RESERVED 0x00
#define USB_DEVCAP_WUSB 0x01
#define USB_DEVCAP_USB2EXT 0x02
#define USB_DEVCAP_SUPER_SPEED 0x03
#define USB_DEVCAP_CONTAINER_ID 0x04
/* data ... */
} __packed;
struct usb2_devcap_usb2ext_descriptor {
uByte bLength;
uByte bDescriptorType;
uByte bDevCapabilityType;
uByte bmAttributes;
#define USB_V2EXT_LPM 0x02
} __packed;
struct usb2_devcap_ss_descriptor {
uByte bLength;
uByte bDescriptorType;
uByte bDevCapabilityType;
uByte bmAttributes;
uWord wSpeedsSupported;
uByte bFunctionaltySupport;
uByte bU1DevExitLat;
uByte bU2DevExitLat;
} __packed;
struct usb2_devcap_container_id_descriptor {
uByte bLength;
uByte bDescriptorType;
uByte bDevCapabilityType;
uByte bReserved;
uByte ContainerID;
} __packed;
/* Device class codes */
#define UDCLASS_IN_INTERFACE 0x00
#define UDCLASS_COMM 0x02
@ -252,6 +334,17 @@ struct usb2_interface_descriptor {
uByte iInterface;
} __packed;
struct usb2_interface_assoc_descriptor {
uByte bLength;
uByte bDescriptorType;
uByte bFirstInterface;
uByte bInterfaceCount;
uByte bFunctionClass;
uByte bFunctionSubClass;
uByte bFunctionProtocol;
uByte iFunction;
} __packed;
/* Interface class codes */
#define UICLASS_UNSPEC 0x00
#define UICLASS_AUDIO 0x01 /* audio */
@ -372,6 +465,14 @@ struct usb2_endpoint_descriptor {
uByte bInterval;
} __packed;
struct usb2_endpoint_ss_comp_descriptor {
uByte bLength;
uByte bDescriptorType;
uWord bMaxBurst;
uByte bmAttributes;
uWord wBytesPerInterval;
} __packed;
struct usb2_string_descriptor {
uByte bLength;
uByte bDescriptorType;
@ -417,7 +518,19 @@ struct usb2_hub_descriptor {
uByte DeviceRemovable[32]; /* max 255 ports */
#define UHD_NOT_REMOV(desc, i) \
(((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
/* deprecated */ uByte PortPowerCtrlMask[1];
uByte PortPowerCtrlMask[1]; /* deprecated */
} __packed;
struct usb2_hub_ss_descriptor {
uByte bDescLength;
uByte bDescriptorType;
uByte bNbrPorts; /* max 15 */
uWord wHubCharacteristics;
uByte bPwrOn2PwrGood; /* delay in 2 ms units */
uByte bHubContrCurrent;
uByte bHubHdrDecLat;
uWord wHubDelay;
uByte DeviceRemovable[2]; /* max 15 ports */
} __packed;
/* minimum HUB descriptor (8-ports maximum) */

View File

@ -107,6 +107,7 @@ static struct usb2_quirk_entry usb2_quirks[USB_DEV_QUIRKS_MAX] = {
{USB_QUIRK_ENTRY(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK, 0x0000, 0xFFFF, UQ_MS_BAD_CLASS, UQ_MS_LEADING_BYTE, UQ_NONE)},
{USB_QUIRK_ENTRY(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK2, 0x0000, 0xFFFF, UQ_MS_BAD_CLASS, UQ_MS_LEADING_BYTE, UQ_NONE)},
{USB_QUIRK_ENTRY(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLINTELLIMOUSE, 0x0000, 0xFFFF, UQ_MS_LEADING_BYTE, UQ_NONE)},
{USB_QUIRK_ENTRY(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_COMFORT3000, 0x0000, 0xFFFF, UQ_MS_BAD_CLASS, UQ_MS_LEADING_BYTE, UQ_NONE)},
{USB_QUIRK_ENTRY(USB_VENDOR_METAGEEK, USB_PRODUCT_METAGEEK_WISPY24X, 0x0000, 0xFFFF, UQ_KBD_IGNORE, UQ_HID_IGNORE, UQ_NONE)},
};

322
sys/dev/usb2/serial/u3g2.c Normal file
View File

@ -0,0 +1,322 @@
/*
* Copyright (c) 2008 AnyWi Technologies
* Author: Andrea Guzzo <aguzzo@anywi.com>
* * based on uark.c 1.1 2006/08/14 08:30:22 jsg *
* * parts from ubsa.c 183348 2008-09-25 12:00:56Z phk *
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD$
*/
/*
* NOTE:
*
* - The detour through the tty layer is ridiculously expensive wrt
* buffering due to the high speeds.
*
* We should consider adding a simple r/w device which allows
* attaching of PPP in a more efficient way.
*
* NOTE:
*
* - The device ID's are stored in "core/usb2_msctest.c"
*/
#include <dev/usb2/include/usb2_devid.h>
#include <dev/usb2/include/usb2_standard.h>
#include <dev/usb2/include/usb2_mfunc.h>
#include <dev/usb2/include/usb2_error.h>
#include <dev/usb2/include/usb2_cdc.h>
#define USB_DEBUG_VAR u3g_debug
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
#include <dev/usb2/core/usb2_busdma.h>
#include <dev/usb2/core/usb2_msctest.h>
#include <dev/usb2/serial/usb2_serial.h>
#if USB_DEBUG
static int u3g_debug = 0;
SYSCTL_NODE(_hw_usb2, OID_AUTO, u3g, CTLFLAG_RW, 0, "USB u3g");
SYSCTL_INT(_hw_usb2_u3g, OID_AUTO, debug, CTLFLAG_RW,
&u3g_debug, 0, "u3g debug level");
#endif
#define U3G_N_TRANSFER 2
#define U3G_MAXPORTS 4
#define U3G_CONFIG_INDEX 0
#define U3G_BSIZE 2048
struct u3g_speeds_s {
uint32_t ispeed;
uint32_t ospeed;
};
struct u3g_softc {
struct usb2_com_super_softc sc_super_ucom;
struct usb2_com_softc sc_ucom;
struct usb2_xfer *sc_xfer[U3G_N_TRANSFER];
struct usb2_device *sc_udev;
uint8_t sc_iface_no; /* interface number */
uint8_t sc_iface_index; /* interface index */
uint8_t sc_lsr; /* local status register */
uint8_t sc_msr; /* U3G status register */
struct u3g_speeds_s sc_speed;
uint8_t sc_numports;
};
static device_probe_t u3g_probe;
static device_attach_t u3g_attach;
static device_detach_t u3g_detach;
static usb2_callback_t u3g_write_callback;
static usb2_callback_t u3g_read_callback;
static void u3g_start_read(struct usb2_com_softc *ucom);
static void u3g_stop_read(struct usb2_com_softc *ucom);
static void u3g_start_write(struct usb2_com_softc *ucom);
static void u3g_stop_write(struct usb2_com_softc *ucom);
static const struct usb2_config u3g_config[U3G_N_TRANSFER] = {
[0] = {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.mh.bufsize = U3G_BSIZE,/* bytes */
.mh.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.mh.callback = &u3g_write_callback,
},
[1] = {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.mh.bufsize = U3G_BSIZE,/* bytes */
.mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.mh.callback = &u3g_read_callback,
},
};
static const struct usb2_com_callback u3g_callback = {
.usb2_com_start_read = &u3g_start_read,
.usb2_com_stop_read = &u3g_stop_read,
.usb2_com_start_write = &u3g_start_write,
.usb2_com_stop_write = &u3g_stop_write,
};
static const struct u3g_speeds_s u3g_speeds[U3GSP_MAX] = {
[U3GSP_GPRS] = {64000, 64000},
[U3GSP_EDGE] = {384000, 64000},
[U3GSP_CDMA] = {384000, 64000},
[U3GSP_UMTS] = {384000, 64000},
[U3GSP_HSDPA] = {1200000, 384000},
[U3GSP_HSUPA] = {1200000, 384000},
[U3GSP_HSPA] = {7200000, 384000},
};
static device_method_t u3g_methods[] = {
DEVMETHOD(device_probe, u3g_probe),
DEVMETHOD(device_attach, u3g_attach),
DEVMETHOD(device_detach, u3g_detach),
{0, 0}
};
static devclass_t u3g_devclass;
static driver_t u3g_driver = {
.name = "u3g",
.methods = u3g_methods,
.size = sizeof(struct u3g_softc),
};
DRIVER_MODULE(u3g, ushub, u3g_driver, u3g_devclass, NULL, 0);
MODULE_DEPEND(u3g, usb2_serial, 1, 1, 1);
MODULE_DEPEND(u3g, usb2_core, 1, 1, 1);
static int
u3g_probe(device_t self)
{
struct usb2_attach_arg *uaa = device_get_ivars(self);
if (uaa->usb2_mode != USB_MODE_HOST) {
return (ENXIO);
}
if (uaa->info.bConfigIndex != U3G_CONFIG_INDEX) {
return (ENXIO);
}
if (uaa->info.bInterfaceClass != UICLASS_VENDOR) {
return (ENXIO);
}
return (usb2_lookup_huawei(uaa));
}
static int
u3g_attach(device_t dev)
{
struct usb2_attach_arg *uaa = device_get_ivars(dev);
struct u3g_softc *sc = device_get_softc(dev);
int error;
DPRINTF("sc=%p\n", sc);
if (sc == NULL) {
return (ENOMEM);
}
device_set_usb2_desc(dev);
sc->sc_udev = uaa->device;
sc->sc_iface_no = uaa->info.bIfaceNum;
sc->sc_iface_index = uaa->info.bIfaceIndex;
sc->sc_speed = u3g_speeds[U3G_GET_SPEED(uaa)];
error = usb2_transfer_setup(uaa->device, &sc->sc_iface_index,
sc->sc_xfer, u3g_config, U3G_N_TRANSFER, sc, &Giant);
if (error) {
DPRINTF("could not allocate all pipes\n");
goto detach;
}
/* set stall by default */
usb2_transfer_set_stall(sc->sc_xfer[0]);
usb2_transfer_set_stall(sc->sc_xfer[1]);
error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
&u3g_callback, &Giant);
if (error) {
DPRINTF("usb2_com_attach failed\n");
goto detach;
}
return (0);
detach:
u3g_detach(dev);
return (ENXIO);
}
static int
u3g_detach(device_t dev)
{
struct u3g_softc *sc = device_get_softc(dev);
DPRINTF("sc=%p\n", sc);
usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
usb2_transfer_unsetup(sc->sc_xfer, U3G_N_TRANSFER);
return (0);
}
static void
u3g_start_read(struct usb2_com_softc *ucom)
{
struct u3g_softc *sc = ucom->sc_parent;
/* start read endpoint */
usb2_transfer_start(sc->sc_xfer[1]);
return;
}
static void
u3g_stop_read(struct usb2_com_softc *ucom)
{
struct u3g_softc *sc = ucom->sc_parent;
/* stop read endpoint */
usb2_transfer_stop(sc->sc_xfer[1]);
return;
}
static void
u3g_start_write(struct usb2_com_softc *ucom)
{
struct u3g_softc *sc = ucom->sc_parent;
usb2_transfer_start(sc->sc_xfer[0]);
return;
}
static void
u3g_stop_write(struct usb2_com_softc *ucom)
{
struct u3g_softc *sc = ucom->sc_parent;
usb2_transfer_stop(sc->sc_xfer[0]);
return;
}
static void
u3g_write_callback(struct usb2_xfer *xfer)
{
struct u3g_softc *sc = xfer->priv_sc;
uint32_t actlen;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
case USB_ST_SETUP:
tr_setup:
if (usb2_com_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
U3G_BSIZE, &actlen)) {
xfer->frlengths[0] = actlen;
usb2_start_hardware(xfer);
}
break;
default: /* Error */
if (xfer->error != USB_ERR_CANCELLED) {
/* do a builtin clear-stall */
xfer->flags.stall_pipe = 1;
goto tr_setup;
}
break;
}
return;
}
static void
u3g_read_callback(struct usb2_xfer *xfer)
{
struct u3g_softc *sc = xfer->priv_sc;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
usb2_com_put_data(&sc->sc_ucom, xfer->frbuffers, 0, xfer->actlen);
case USB_ST_SETUP:
tr_setup:
xfer->frlengths[0] = xfer->max_data_length;
usb2_start_hardware(xfer);
break;
default: /* Error */
if (xfer->error != USB_ERR_CANCELLED) {
/* do a builtin clear-stall */
xfer->flags.stall_pipe = 1;
goto tr_setup;
}
break;
}
return;
}

View File

@ -181,46 +181,7 @@ static const struct usb2_device_id ugensa_devs[] = {
/* {USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E270, 0)}, */
{USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE, 0)},
{USB_VPI(USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2, 0)},
/* {USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U950D, 0)}, */
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870, 0)},
{USB_VPI(USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870, 0)},
{USB_VPI(USB_VENDOR_NOVATEL2, USB_PRODUCT_NOVATEL2_FLEXPACKGPS, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD580, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD595, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC595U, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC597E, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_C597, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880E, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880U, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881E, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881U, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_EM5625, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720_2, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5725, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MINI5725, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD875, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_2, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_3, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8765, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC875U, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8775_2, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8780, 0)},
{USB_VPI(USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8781, 0)},
};
static int

View File

@ -57,6 +57,7 @@ SUBDIR += ndis
SUBDIR += quirk
SUBDIR += scanner
SUBDIR += serial
SUBDIR += serial_3g
SUBDIR += serial_ark
SUBDIR += serial_bsa
SUBDIR += serial_bser