patch-2.3.10 linux/drivers/usb/usb.h

Next file: linux/drivers/video/Makefile
Previous file: linux/drivers/usb/usb.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.9/linux/drivers/usb/usb.h linux/drivers/usb/usb.h
@@ -31,9 +31,16 @@
 } devrequest;
 
 /*
- * Class codes
+ * Device and/or Interface Class codes
  */
+#define USB_CLASS_PER_INTERFACE		0	/* for DeviceClass */
+#define USB_CLASS_AUDIO			1
+#define USB_CLASS_COMM			2
+#define USB_CLASS_HID			3
+#define USB_CLASS_PRINTER		7
+#define USB_CLASS_MASS_STORAGE		8
 #define USB_CLASS_HUB			9
+#define USB_CLASS_VENDOR_SPEC		0xff
 
 /*
  * Descriptor types
@@ -48,6 +55,28 @@
 #define USB_DT_HID			0x21
 
 /*
+ * Descriptor sizes per descriptor type
+ */
+#define USB_DT_DEVICE_SIZE		18
+#define USB_DT_CONFIG_SIZE		9
+#define USB_DT_INTERFACE_SIZE		9
+#define USB_DT_ENDPOINT_SIZE		7
+#define USB_DT_HUB_NONVAR_SIZE		7
+
+/*
+ * USB Request Type and Endpoint Directions
+ */
+#define USB_DIR_OUT			0
+#define USB_DIR_IN			0x80
+
+/*
+ * USB Packet IDs (PIDs)
+ */
+#define USB_PID_OUT			0xe1
+#define USB_PID_IN			0x69
+#define USB_PID_SETUP			0x2d
+
+/*
  * Standard requests
  */
 #define USB_REQ_GET_STATUS		0x00
@@ -97,16 +126,16 @@
 #define USB_RT_HIDD			(USB_TYPE_CLASS | USB_RECIP_INTERFACE)
 
 /* 
- * Status codes 
+ * Status codes (these follow an OHCI controllers condition codes)
  */
 #define USB_ST_NOERROR		0x0
 #define USB_ST_CRC		0x1
 #define USB_ST_BITSTUFF		0x2
-#define USB_ST_DTMISMATCH	0x3
+#define USB_ST_DTMISMATCH	0x3	/* data toggle mismatch */
 #define USB_ST_STALL		0x4
-#define USB_ST_TIMEOUT		0x5
-#define USB_ST_PIDCHECK		0x6
-#define USB_ST_PIDUNDEF		0x7
+#define USB_ST_NORESPONSE	0x5	/* device not responding/handshaking */
+#define USB_ST_PIDCHECK		0x6	/* Check bits on PID failed */
+#define USB_ST_PIDUNDEF		0x7	/* PID unexpected/undefined */
 #define USB_ST_DATAOVERRUN	0x8
 #define USB_ST_DATAUNDERRUN	0x9
 #define USB_ST_RESERVED1	0xA
@@ -118,6 +147,7 @@
 
 /* internal errors */
 #define USB_ST_REMOVED		0x100
+#define USB_ST_TIMEOUT		0x110
 #define USB_ST_INTERNALERROR	-1
 
 /*
@@ -275,7 +305,7 @@
 struct usb_device {
 	int devnum;			/* Device number on USB bus */
 	int slow;			/* Slow device? */
-	int maxpacketsize;		/* Maximum packet size */
+	int maxpacketsize;		/* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */
 	int toggle[2];			/* one bit for each endpoint ([0] = IN, [1] = OUT) */
 	int halted;			/* endpoint halts */
 	struct usb_config_descriptor *actconfig;/* the active configuration */
@@ -342,16 +372,16 @@
  * Let's not fall in that trap. We'll just encode it as a simple
  * unsigned int. The encoding is:
  *
+ *  - max size:		bits 0-1	(00 = 8, 01 = 16, 10 = 32, 11 = 64)
+ *  - direction:	bit 7		(0 = Host-to-Device, 1 = Device-to-Host)
  *  - device:		bits 8-14
  *  - endpoint:		bits 15-18
  *  - Data0/1:		bit 19
- *  - direction:	bit 7		(0 = Host-to-Device, 1 = Device-to-Host)
- *  - speed:		bit 26		(0 = High, 1 = Low Speed)
- *  - max size:		bits 0-1	(00 = 8, 01 = 16, 10 = 32, 11 = 64)
+ *  - speed:		bit 26		(00 = Full, 01 = Low Speed)
  *  - pipe type:	bits 30-31	(00 = isochronous, 01 = interrupt, 10 = control, 11 = bulk)
  *
  * Why? Because it's arbitrary, and whatever encoding we select is really
- * up to us. This one happens to share a lot of bit positions with the UCHI
+ * up to us. This one happens to share a lot of bit positions with the UHCI
  * specification, so that much of the uhci driver can just mask the bits
  * appropriately.
  */
@@ -372,6 +402,7 @@
 #define usb_pipebulk(pipe)	(usb_pipetype((pipe)) == 3)
 
 #define usb_pipe_endpdev(pipe)	(((pipe) >> 8) & 0x7ff)
+#define PIPE_DEVEP_MASK		0x0007ff00
 
 /* The D0/D1 toggle bits */
 #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> ep) & 1)
@@ -393,7 +424,7 @@
 	return (dev->slow << 26);
 }
 
-/* Create control pipes.. */
+/* Create various pipes... */
 #define usb_sndctrlpipe(dev,endpoint)	((2 << 30) | __create_pipe(dev,endpoint))
 #define usb_rcvctrlpipe(dev,endpoint)	((2 << 30) | __create_pipe(dev,endpoint) | 0x80)
 #define usb_sndisocpipe(dev,endpoint)	((0 << 30) | __create_pipe(dev,endpoint))

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)