svn commit: r216018 - in stable/8: share/man/man4 sys/dev/usb/quirk sys/dev/usb/serial usr.sbin/usbconfig

Nick Hibma n_hibma at FreeBSD.org
Sun Nov 28 22:07:09 UTC 2010


Author: n_hibma
Date: Sun Nov 28 22:07:08 2010
New Revision: 216018
URL: http://svn.freebsd.org/changeset/base/216018

Log:
  MFC r215095,215104:
  
  Add quirks for 3G MSC resets.
  Add a man page for the usb_quirks module.

Added:
  stable/8/share/man/man4/usb_quirk.4
     - copied unchanged from r215104, head/share/man/man4/usb_quirk.4
Modified:
  stable/8/share/man/man4/Makefile
  stable/8/share/man/man4/u3g.4
  stable/8/sys/dev/usb/quirk/usb_quirk.c
  stable/8/sys/dev/usb/quirk/usb_quirk.h
  stable/8/sys/dev/usb/serial/u3g.c
  stable/8/usr.sbin/usbconfig/usbconfig.8
Directory Properties:
  stable/8/share/man/man4/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/usr.sbin/usbconfig/   (props changed)

Modified: stable/8/share/man/man4/Makefile
==============================================================================
--- stable/8/share/man/man4/Makefile	Sun Nov 28 20:56:51 2010	(r216017)
+++ stable/8/share/man/man4/Makefile	Sun Nov 28 22:07:08 2010	(r216018)
@@ -459,6 +459,7 @@ MAN=	aac.4 \
 	urio.4 \
 	${_urtw.4} \
 	usb.4 \
+	usb_quirk.4 \
 	uslcom.4 \
 	utopia.4 \
 	uvisor.4 \

Modified: stable/8/share/man/man4/u3g.4
==============================================================================
--- stable/8/share/man/man4/u3g.4	Sun Nov 28 20:56:51 2010	(r216017)
+++ stable/8/share/man/man4/u3g.4	Sun Nov 28 22:07:08 2010	(r216018)
@@ -85,26 +85,19 @@ In some of these devices a mass storage 
 .Xr umass 4
 driver is present which contains Windows and Mac OS X drivers.
 The device starts up in disk mode (TruInstall, ZeroCD, etc.) and requires
-additional commands to switch it to modem mode.
+additional commands to switch it to modem mode. If your device is not
+switching automatically, please try to add quirks. See
+.Xr usbconfig 5
+and
+.Xr usb_quirk 4 .
 .Pp
-The
-.Xr u3gstub 4
-device will attach temporarily to a 3G device with a mass storage device and
-force it to switch to modem mode,
-The attach and detach of
-.Xr u3gstub
-and any driver disk device present on the 3G device is hidden, unless the
-machine was booted in verbose mode (see
-.Xr boot 8 ) .
-To temporarily unhide the device, set
-.Va debug.bootverbose
-to 1 using
-.Xr sysctl 8
-and replug the device.
 .Sh SEE ALSO
 .Xr tty 4 ,
 .Xr ucom 4 ,
-.Xr usb 4
+.XR u3g 4 ,
+.Xr usb 4 ,
+.Xr usb_quirk 4 ,
+.Xr usbconfig 5
 .Sh HISTORY
 The
 .Nm

Copied: stable/8/share/man/man4/usb_quirk.4 (from r215104, head/share/man/man4/usb_quirk.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/8/share/man/man4/usb_quirk.4	Sun Nov 28 22:07:08 2010	(r216018, copy of r215104, head/share/man/man4/usb_quirk.4)
@@ -0,0 +1,196 @@
+.\"
+.\" Copyright (c) 2010 AnyWi Technologies
+.\" All rights reserved.
+.\"
+.\" 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$
+.\"
+.Dd November 9, 2010
+.Dt USB_QUIRK 4
+.Os
+.Sh NAME
+.Nm usb_quirk
+.Nd USB quirks module
+.Sh SYNOPSIS
+To compile this module into the kernel,
+place the following line in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device ucom"
+.Ed
+.Pp
+Alternatively, to load the module at boot
+time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+usb_quirk_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+module provides support for dynamically adding and removing quirks for
+USB devices with
+.Xr usbconfig 5 .
+.Sh General quirks:
+.Bl -tag -width Ds
+.It UQ_AUDIO_SWAP_LR
+swap left and right channels
+.It UQ_AU_INP_ASYNC
+input is async despite claim of adaptive
+.It UQ_AU_NO_FRAC
+don't adjust for fractional samples
+.It UQ_AU_NO_XU
+audio device has broken extension unit
+.It UQ_BAD_ADC
+bad audio spec version number
+.It UQ_BAD_AUDIO
+device claims audio class, but isn't
+.It UQ_BROKEN_BIDIR
+printer has broken bidir mode
+.It UQ_BUS_POWERED
+device is bus powered, despite claim
+.It UQ_HID_IGNORE
+device should be ignored by hid class
+.It UQ_KBD_IGNORE
+device should be ignored by kbd class
+.It UQ_KBD_BOOTPROTO
+device should set the boot protocol
+.It UQ_MS_BAD_CLASS
+doesn't identify properly
+.It UQ_MS_LEADING_BYTE
+mouse sends an unknown leading byte
+.It UQ_MS_REVZ
+mouse has Z-axis reversed
+.It UQ_NO_STRINGS
+string descriptors are broken
+.It UQ_OPEN_CLEARSTALL
+device needs clear endpoint stall
+.It UQ_POWER_CLAIM
+hub lies about power status
+.It UQ_SPUR_BUT_UP
+spurious mouse button up events
+.It UQ_SWAP_UNICODE
+has some Unicode strings swapped
+.It UQ_CFG_INDEX_1
+select configuration index 1 by default
+.It UQ_CFG_INDEX_2
+select configuration index 2 by default
+.It UQ_CFG_INDEX_3
+select configuration index 3 by default
+.It UQ_CFG_INDEX_4
+select configuration index 4 by default
+.It UQ_CFG_INDEX_0
+select configuration index 0 by default
+.It UQ_ASSUME_CM_OVER_DATA
+assume cm over data feature
+.El
+.Sh USB Mass Storage Quirks
+.Bl -tag -width Ds
+.It UQ_MSC_NO_TEST_UNIT_READY
+send start/stop instead of TUR
+.It UQ_MSC_NO_RS_CLEAR_UA
+does not reset Unit Att.
+.It UQ_MSC_NO_START_STOP
+does not support start/stop
+.It UQ_MSC_NO_GETMAXLUN
+does not support get max LUN
+.It UQ_MSC_NO_INQUIRY
+fake generic inq response
+.It UQ_MSC_NO_INQUIRY_EVPD
+does not support inq EVPD
+.It UQ_MSC_NO_SYNC_CACHE
+does not support sync cache
+.It UQ_MSC_SHUTTLE_INIT
+requires Shuttle init sequence
+.It UQ_MSC_ALT_IFACE_1
+switch to alternate interface 1
+.It UQ_MSC_FLOPPY_SPEED
+does floppy speeds (20kb/s)
+.It UQ_MSC_IGNORE_RESIDUE
+gets residue wrong
+.It UQ_MSC_WRONG_CSWSIG
+uses wrong CSW signature
+.It UQ_MSC_RBC_PAD_TO_12
+pad RBC requests to 12 bytes
+.It UQ_MSC_READ_CAP_OFFBY1
+reports sector count, not max sec.
+.It UQ_MSC_FORCE_SHORT_INQ
+does not support full inq.
+.It UQ_MSC_FORCE_WIRE_BBB
+force BBB wire protocol
+.It UQ_MSC_FORCE_WIRE_CBI
+force CBI wire protocol
+.It UQ_MSC_FORCE_WIRE_CBI_I
+force CBI with int. wire protocol
+.It UQ_MSC_FORCE_PROTO_SCSI
+force SCSI command protocol
+.It UQ_MSC_FORCE_PROTO_ATAPI
+force ATAPI command protocol
+.It UQ_MSC_FORCE_PROTO_UFI
+force UFI command protocol
+.It UQ_MSC_FORCE_PROTO_RBC
+force RBC command protocol
+.El
+.Sh Mass Storage Change (u3g) quirks:
+.Bl -tag -width Ds
+.It UQ_MSC_EJECT_HUAWEI
+ejects after Huawei USB command
+.It UQ_MSC_EJECT_SIERRA
+ejects after Sierra USB command
+.It UQ_MSC_EJECT_SCSIEJECT
+ejects after SCSI eject command
+0x1b0000000200
+.It UQ_MSC_EJECT_REZERO
+ejects after SCSI rezero command
+0x010000000000
+.It UQ_MSC_EJECT_ZTESTOR
+ejects after ZTE SCSI command
+0x850101011801010101010000
+.It UQ_MSC_EJECT_CMOTECH
+ejects after C-motech SCSI command
+0xff52444556434847
+.It UQ_MSC_EJECT_WAIT
+wait for the device to eject
+.It UQ_MSC_EJECT_SAEL_M460
+ejects after Sael USB commands
+.It UQ_MSC_EJECT_HUAWEISCSI
+ejects after Huawei SCSI command
+0x11060000000000000000000000000000
+.It UQ_MSC_EJECT_TCT
+ejects after TCT SCSI command
+0x06f504025270
+.El
+See
+.Pa /sys/dev/usb/quirk/usb_quirk.h
+for the complete list of supported quirks.
+.Sh EXAMPLES
+After attaching a
+.Nm u3g
+device which appears as a USB device on
+.Pa ugen0.3 :
+.Bd -literal -offset indent
+usbconfig -d ugen0.3 add_quirk UQ_MSC_EJECT_WAIT
+.Ed
+.Sh SEE ALSO
+.Xr usb_quirk 4 ,
+.Xr usbconfig 5
+.Sh HISTORY
+The
+.Nm
+module appeared in
+.Fx 8.0 ,
+and was written by
+.An Hans Petter Selasky Aq hselasky at FreeBSD.org .
+This manual page was written by
+.An Nick Hibma Aq n_hibma at FreeBSD.org .

Modified: stable/8/sys/dev/usb/quirk/usb_quirk.c
==============================================================================
--- stable/8/sys/dev/usb/quirk/usb_quirk.c	Sun Nov 28 20:56:51 2010	(r216017)
+++ stable/8/sys/dev/usb/quirk/usb_quirk.c	Sun Nov 28 22:07:08 2010	(r216018)
@@ -512,6 +512,16 @@ static const char *usb_quirk_str[USB_QUI
 	[UQ_MSC_FORCE_PROTO_ATAPI]	= "UQ_MSC_FORCE_PROTO_ATAPI",
 	[UQ_MSC_FORCE_PROTO_UFI]	= "UQ_MSC_FORCE_PROTO_UFI",
 	[UQ_MSC_FORCE_PROTO_RBC]	= "UQ_MSC_FORCE_PROTO_RBC",
+	[UQ_MSC_EJECT_HUAWEI]		= "UQ_MSC_EJECT_HUAWEI",
+	[UQ_MSC_EJECT_SIERRA]		= "UQ_MSC_EJECT_SIERRA",
+	[UQ_MSC_EJECT_SCSIEJECT]	= "UQ_MSC_EJECT_SCSIEJECT",
+	[UQ_MSC_EJECT_REZERO]		= "UQ_MSC_EJECT_REZERO",
+	[UQ_MSC_EJECT_ZTESTOR]		= "UQ_MSC_EJECT_ZTESTOR",
+	[UQ_MSC_EJECT_CMOTECH]		= "UQ_MSC_EJECT_CMOTECH",
+	[UQ_MSC_EJECT_WAIT]		= "UQ_MSC_EJECT_WAIT",
+	[UQ_MSC_EJECT_SAEL_M460]	= "UQ_MSC_EJECT_SAEL_M460",
+	[UQ_MSC_EJECT_HUAWEISCSI]	= "UQ_MSC_EJECT_HUAWEISCSI",
+	[UQ_MSC_EJECT_TCT]		= "UQ_MSC_EJECT_TCT",
 };
 
 /*------------------------------------------------------------------------*

Modified: stable/8/sys/dev/usb/quirk/usb_quirk.h
==============================================================================
--- stable/8/sys/dev/usb/quirk/usb_quirk.h	Sun Nov 28 20:56:51 2010	(r216017)
+++ stable/8/sys/dev/usb/quirk/usb_quirk.h	Sun Nov 28 22:07:08 2010	(r216018)
@@ -27,11 +27,14 @@
 #ifndef _USB_QUIRK_H_
 #define	_USB_QUIRK_H_
 
-/* NOTE: UQ_NONE is not a valid quirk */
-enum {	/* keep in sync with usb_quirk_str table */
-	UQ_NONE,
+enum {
+	/*
+	 * Keep in sync with theusb_quirk_str usb_quirk.c, and with the
+	 * share/man/man4/usb_quirk.4
+	 */
+	UQ_NONE,		/* not a valid quirk */
 
-	UQ_MATCH_VENDOR_ONLY,
+	UQ_MATCH_VENDOR_ONLY,	/* match quirk on vendor only */
 
 	/* Various quirks */
 
@@ -59,31 +62,43 @@ enum {	/* keep in sync with usb_quirk_st
 	UQ_CFG_INDEX_3,		/* select configuration index 3 by default */
 	UQ_CFG_INDEX_4,		/* select configuration index 4 by default */
 	UQ_CFG_INDEX_0,		/* select configuration index 0 by default */
-	UQ_ASSUME_CM_OVER_DATA,	/* modem device breaks on cm over data */
+	UQ_ASSUME_CM_OVER_DATA,	/* assume cm over data feature */
 
 	/* USB Mass Storage Quirks. See "storage/umass.c" for a detailed description. */
-	UQ_MSC_NO_TEST_UNIT_READY,
-	UQ_MSC_NO_RS_CLEAR_UA,
-	UQ_MSC_NO_START_STOP,
-	UQ_MSC_NO_GETMAXLUN,
-	UQ_MSC_NO_INQUIRY,
-	UQ_MSC_NO_INQUIRY_EVPD,
-	UQ_MSC_NO_SYNC_CACHE,
-	UQ_MSC_SHUTTLE_INIT,
-	UQ_MSC_ALT_IFACE_1,
-	UQ_MSC_FLOPPY_SPEED,
-	UQ_MSC_IGNORE_RESIDUE,
-	UQ_MSC_WRONG_CSWSIG,
-	UQ_MSC_RBC_PAD_TO_12,
-	UQ_MSC_READ_CAP_OFFBY1,
-	UQ_MSC_FORCE_SHORT_INQ,
-	UQ_MSC_FORCE_WIRE_BBB,
-	UQ_MSC_FORCE_WIRE_CBI,
-	UQ_MSC_FORCE_WIRE_CBI_I,
-	UQ_MSC_FORCE_PROTO_SCSI,
-	UQ_MSC_FORCE_PROTO_ATAPI,
-	UQ_MSC_FORCE_PROTO_UFI,
-	UQ_MSC_FORCE_PROTO_RBC,
+	UQ_MSC_NO_TEST_UNIT_READY,	/* send start/stop instead of TUR */
+	UQ_MSC_NO_RS_CLEAR_UA,		/* does not reset Unit Att. */
+	UQ_MSC_NO_START_STOP,		/* does not support start/stop */
+	UQ_MSC_NO_GETMAXLUN,		/* does not support get max LUN */
+	UQ_MSC_NO_INQUIRY,		/* fake generic inq response */
+	UQ_MSC_NO_INQUIRY_EVPD,		/* does not support inq EVPD */
+	UQ_MSC_NO_SYNC_CACHE,		/* does not support sync cache */ 
+	UQ_MSC_SHUTTLE_INIT,		/* requires Shuttle init sequence */
+	UQ_MSC_ALT_IFACE_1,		/* switch to alternate interface 1 */
+	UQ_MSC_FLOPPY_SPEED,		/* does floppy speeds (20kb/s) */
+	UQ_MSC_IGNORE_RESIDUE,		/* gets residue wrong */
+	UQ_MSC_WRONG_CSWSIG,		/* uses wrong CSW signature */
+	UQ_MSC_RBC_PAD_TO_12,		/* pad RBC requests to 12 bytes */
+	UQ_MSC_READ_CAP_OFFBY1,		/* reports sector count, not max sec. */
+	UQ_MSC_FORCE_SHORT_INQ,		/* does not support full inq. */
+	UQ_MSC_FORCE_WIRE_BBB,		/* force BBB wire protocol */
+	UQ_MSC_FORCE_WIRE_CBI,		/* force CBI wire protocol */
+	UQ_MSC_FORCE_WIRE_CBI_I,	/* force CBI with int. wire protocol */
+	UQ_MSC_FORCE_PROTO_SCSI,	/* force SCSI command protocol */
+	UQ_MSC_FORCE_PROTO_ATAPI,	/* force ATAPI command protocol */
+	UQ_MSC_FORCE_PROTO_UFI,		/* force UFI command protocol */
+	UQ_MSC_FORCE_PROTO_RBC,		/* force RBC command protocol */
+
+	/* Ejection of mass storage (driver disk) */
+	UQ_MSC_EJECT_HUAWEI,		/* ejects after Huawei USB command */
+	UQ_MSC_EJECT_SIERRA,		/* ejects after Sierra USB command */
+	UQ_MSC_EJECT_SCSIEJECT,		/* ejects after SCSI eject command */
+	UQ_MSC_EJECT_REZERO,		/* ejects after SCSI rezero command */
+	UQ_MSC_EJECT_ZTESTOR,		/* ejects after ZTE SCSI command */
+	UQ_MSC_EJECT_CMOTECH,		/* ejects after C-motech SCSI cmd */
+	UQ_MSC_EJECT_WAIT,		/* wait for the device to eject */
+	UQ_MSC_EJECT_SAEL_M460,		/* ejects after Sael USB commands */ 
+	UQ_MSC_EJECT_HUAWEISCSI,	/* ejects after Huawei SCSI command */
+	UQ_MSC_EJECT_TCT,		/* ejects after TCT SCSI command */
 
 	USB_QUIRK_MAX
 };

Modified: stable/8/sys/dev/usb/serial/u3g.c
==============================================================================
--- stable/8/sys/dev/usb/serial/u3g.c	Sun Nov 28 20:56:51 2010	(r216017)
+++ stable/8/sys/dev/usb/serial/u3g.c	Sun Nov 28 22:07:08 2010	(r216018)
@@ -62,6 +62,7 @@
 #include <dev/usb/usb_msctest.h>
 
 #include <dev/usb/serial/usb_serial.h>
+#include <dev/usb/quirk/usb_quirk.h>
 
 #ifdef USB_DEBUG
 static int u3g_debug = 0;
@@ -84,6 +85,7 @@ SYSCTL_INT(_hw_usb_u3g, OID_AUTO, debug,
 #define	U3GSP_HSPA		6
 #define	U3GSP_MAX		7
 
+/* Eject methods; See also usb_quirks.h:UQ_MSC_EJECT_* */
 #define	U3GINIT_HUAWEI		1	/* Requires Huawei init command */
 #define	U3GINIT_SIERRA		2	/* Requires Sierra init command */
 #define	U3GINIT_SCSIEJECT	3	/* Requires SCSI eject command */
@@ -643,6 +645,7 @@ u3g_test_autoinst(void *arg, struct usb_
 	struct usb_interface *iface;
 	struct usb_interface_descriptor *id;
 	int error;
+	unsigned long method;
 
 	if (uaa->dev_state != UAA_DEV_READY)
 		return;
@@ -653,10 +656,37 @@ u3g_test_autoinst(void *arg, struct usb_
 	id = iface->idesc;
 	if (id == NULL || id->bInterfaceClass != UICLASS_MASS)
 		return;
-	if (usbd_lookup_id_by_uaa(u3g_devs, sizeof(u3g_devs), uaa))
+
+	if (usb_test_quirk(uaa, UQ_MSC_EJECT_HUAWEI))
+		method = U3GINIT_HUAWEI;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_SIERRA))
+		method = U3GINIT_SIERRA;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_SCSIEJECT))
+		method = U3GINIT_SCSIEJECT;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_REZERO))
+		method = U3GINIT_REZERO;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_ZTESTOR))
+		method = U3GINIT_ZTESTOR;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_CMOTECH))
+		method = U3GINIT_CMOTECH;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_WAIT))
+		method = U3GINIT_WAIT;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_HUAWEISCSI))
+		method = U3GINIT_HUAWEISCSI;
+	else if (usb_test_quirk(uaa, UQ_MSC_EJECT_TCT))
+		method = U3GINIT_TCT;
+	else if (usbd_lookup_id_by_uaa(u3g_devs, sizeof(u3g_devs), uaa) == 0)
+		method = USB_GET_DRIVER_INFO(uaa);
+	else
 		return;		/* no device match */
 
-	switch (USB_GET_DRIVER_INFO(uaa)) {
+	if (bootverbose) {
+		printf("Ejecting 0x%04x:0x%04x using method %ld\n",
+		       uaa->info.idVendor, uaa->info.idProduct,
+		       USB_GET_DRIVER_INFO(uaa));
+	}
+
+	switch (method) {
 		case U3GINIT_HUAWEI:
 			error = u3g_huawei_init(udev);
 			break;
@@ -747,8 +777,10 @@ u3g_attach(device_t dev)
 	DPRINTF("sc=%p\n", sc);
 
 	type = USB_GET_DRIVER_INFO(uaa);
-	if (type == U3GINIT_SAEL_M460)
+	if (type == U3GINIT_SAEL_M460
+	    || usb_test_quirk(uaa, UQ_MSC_EJECT_SAEL_M460)) {
 		u3g_sael_m460_init(uaa->device);
+	}
 
 	/* copy in USB config */
 	for (n = 0; n != U3G_N_TRANSFER; n++) 

Modified: stable/8/usr.sbin/usbconfig/usbconfig.8
==============================================================================
--- stable/8/usr.sbin/usbconfig/usbconfig.8	Sun Nov 28 20:56:51 2010	(r216017)
+++ stable/8/usr.sbin/usbconfig/usbconfig.8	Sun Nov 28 22:07:08 2010	(r216018)
@@ -92,5 +92,9 @@ Display a list of available quirk names:
 .Pp
 .Dl usbconfig dump_quirk_names
 .Pp
+See
+.Xr usb_quirk 4
+for more information on quirks.
 .Sh SEE ALSO
-.Xr usb 4
+.Xr usb 4 ,
+.Xr usb_quirk 4


More information about the svn-src-all mailing list