xref: /onnv-gate/usr/src/uts/common/sys/usb/usbai.h (revision 3341:52e5b1750941)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53255Slg150142  * Common Development and Distribution License (the "License").
63255Slg150142  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
203255Slg150142  */
213255Slg150142 /*
223255Slg150142  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_USB_USBAI_H
270Sstevel@tonic-gate #define	_SYS_USB_USBAI_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /* This header file is for USBA2.0 */
360Sstevel@tonic-gate #define	USBA_MAJOR_VER 2
370Sstevel@tonic-gate #define	USBA_MINOR_VER 0
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * USBAI: Interfaces Between USBA and Client Driver
410Sstevel@tonic-gate  *
420Sstevel@tonic-gate  *
430Sstevel@tonic-gate  * Universal USB device state management :
440Sstevel@tonic-gate  *
450Sstevel@tonic-gate  *	PWRED_DWN---<3----4>--ONLINE---<2-----1>-DISCONNECTED
460Sstevel@tonic-gate  *	    |			 ^		     |
470Sstevel@tonic-gate  *	    |			 6		     |
480Sstevel@tonic-gate  *	    |			 |		     |
490Sstevel@tonic-gate  *	    |			 5		     |
500Sstevel@tonic-gate  *	    |			 v		     |
510Sstevel@tonic-gate  *	    +----5>----------SUSPENDED----<5----7>---+
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  *	1 = Device Unplug
540Sstevel@tonic-gate  *	2 = Original Device reconnected
550Sstevel@tonic-gate  *	3 = Device idles for time T & transitions to low power state
560Sstevel@tonic-gate  *	4 = Remote wakeup by device OR Application kicking off IO to device
570Sstevel@tonic-gate  *	5 = Notification to save state prior to DDI_SUSPEND
580Sstevel@tonic-gate  *	6 = Notification to restore state after DDI_RESUME with correct device
590Sstevel@tonic-gate  *	7 = Notification to restore state after DDI_RESUME with device
600Sstevel@tonic-gate  *	    disconnected or a wrong device
610Sstevel@tonic-gate  *
620Sstevel@tonic-gate  *	NOTE: device states 0x80 to 0xff are device specific and can be
630Sstevel@tonic-gate  *		used by client drivers
640Sstevel@tonic-gate  */
650Sstevel@tonic-gate #define	USB_DEV_ONLINE		1	/* device is online */
660Sstevel@tonic-gate #define	USB_DEV_DISCONNECTED	2	/* indicates disconnect */
670Sstevel@tonic-gate #define	USB_DEV_SUSPENDED	3	/* DDI_SUSPEND operation */
680Sstevel@tonic-gate #define	USB_DEV_PWRED_DOWN	4	/* indicates power off state */
690Sstevel@tonic-gate 
700Sstevel@tonic-gate 
710Sstevel@tonic-gate /*
720Sstevel@tonic-gate  * ***************************************************************************
730Sstevel@tonic-gate  * USBA error and status definitions
740Sstevel@tonic-gate  * ***************************************************************************
750Sstevel@tonic-gate  */
760Sstevel@tonic-gate 
770Sstevel@tonic-gate 
780Sstevel@tonic-gate /*
790Sstevel@tonic-gate  * USBA function return values
800Sstevel@tonic-gate  */
810Sstevel@tonic-gate #define	USB_SUCCESS		0	/* call success			  */
820Sstevel@tonic-gate #define	USB_FAILURE		-1	/* unspecified USBA or HCD error  */
830Sstevel@tonic-gate #define	USB_NO_RESOURCES	-2	/* no resources available	  */
840Sstevel@tonic-gate #define	USB_NO_BANDWIDTH	-3	/* no bandwidth available	  */
850Sstevel@tonic-gate #define	USB_NOT_SUPPORTED	-4	/* function not supported by HCD  */
860Sstevel@tonic-gate #define	USB_PIPE_ERROR		-5	/* error occured on the pipe	  */
870Sstevel@tonic-gate #define	USB_INVALID_PIPE	-6	/* pipe handle passed is invalid  */
880Sstevel@tonic-gate #define	USB_NO_FRAME_NUMBER	-7	/* frame No or ASAP not specified */
890Sstevel@tonic-gate #define	USB_INVALID_START_FRAME	-8	/* starting USB frame not valid	  */
900Sstevel@tonic-gate #define	USB_HC_HARDWARE_ERROR	-9	/* usb host controller error	  */
910Sstevel@tonic-gate #define	USB_INVALID_REQUEST	-10	/* request had invalid values	  */
920Sstevel@tonic-gate #define	USB_INVALID_CONTEXT	-11	/* sleep flag in interrupt context */
930Sstevel@tonic-gate #define	USB_INVALID_VERSION	-12	/* invalid version specified	  */
940Sstevel@tonic-gate #define	USB_INVALID_ARGS	-13	/* invalid func args specified	  */
950Sstevel@tonic-gate #define	USB_INVALID_PERM	-14	/* privileged operation		  */
960Sstevel@tonic-gate #define	USB_BUSY		-15	/* busy condition		  */
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /*
1000Sstevel@tonic-gate  * USB request completion flags, more than one may be set.
1010Sstevel@tonic-gate  * The following flags are returned after a recovery action by
1020Sstevel@tonic-gate  * HCD or USBA (autoclearing) or callbacks from pipe_close,
1030Sstevel@tonic-gate  * abort, reset, or stop polling.  More than one may be set.
1040Sstevel@tonic-gate  *
1050Sstevel@tonic-gate  * For sync requests, the client should check the request structure
1060Sstevel@tonic-gate  * for this flag to determine what has happened.
1070Sstevel@tonic-gate  *
1080Sstevel@tonic-gate  * All callbacks are queued to preserve order.	Note that if a normal callback
1090Sstevel@tonic-gate  * uses a kernel thread, order is not guaranteed since each callback may use
1100Sstevel@tonic-gate  * its own thread.  The next request will be submitted to the
1110Sstevel@tonic-gate  * HCD after the threads exits.
1120Sstevel@tonic-gate  *
1130Sstevel@tonic-gate  * Exception callbacks using a kernel thread may do auto clearing and no
1140Sstevel@tonic-gate  * new request will be started until this thread has completed its work.
1150Sstevel@tonic-gate  */
1160Sstevel@tonic-gate typedef enum {
1170Sstevel@tonic-gate 	USB_CB_NO_INFO		= 0x00, /* no exception */
1180Sstevel@tonic-gate 	USB_CB_STALL_CLEARED	= 0x01,	/* func stall cleared */
1190Sstevel@tonic-gate 	USB_CB_FUNCTIONAL_STALL	= 0x02,	/* func stall occurred */
1200Sstevel@tonic-gate 	USB_CB_PROTOCOL_STALL	= 0x04,	/* protocal stall occurred */
1210Sstevel@tonic-gate 	USB_CB_RESET_PIPE	= 0x10, /* pipe was reset */
1220Sstevel@tonic-gate 	USB_CB_ASYNC_REQ_FAILED = 0x80, /* thread couldn't be started */
1230Sstevel@tonic-gate 	USB_CB_NO_RESOURCES	= 0x100, /* no resources */
1240Sstevel@tonic-gate 	USB_CB_SUBMIT_FAILED	= 0x200, /* req was queued then submitted */
1250Sstevel@tonic-gate 					/* to HCD which rejected it */
1260Sstevel@tonic-gate 	USB_CB_INTR_CONTEXT	= 0x400 /* Callback is in interrupt context. */
1270Sstevel@tonic-gate } usb_cb_flags_t;
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate /*
1310Sstevel@tonic-gate  * completion reason
1320Sstevel@tonic-gate  *
1330Sstevel@tonic-gate  * Set by HCD; only one can be set.
1340Sstevel@tonic-gate  */
1350Sstevel@tonic-gate typedef enum {
1360Sstevel@tonic-gate 	USB_CR_OK		= 0,	/* no errors detected		*/
1370Sstevel@tonic-gate 	USB_CR_CRC		= 1,	/* crc error detected		*/
1380Sstevel@tonic-gate 	USB_CR_BITSTUFFING	= 2,	/* bit stuffing violation	*/
1390Sstevel@tonic-gate 	USB_CR_DATA_TOGGLE_MM	= 3,	/* d/t PID did not match	*/
1400Sstevel@tonic-gate 	USB_CR_STALL		= 4,	/* e/p returned stall PID	*/
1410Sstevel@tonic-gate 	USB_CR_DEV_NOT_RESP	= 5,	/* device not responding	*/
1420Sstevel@tonic-gate 	USB_CR_PID_CHECKFAILURE = 6,	/* check bits on PID failed	*/
1430Sstevel@tonic-gate 	USB_CR_UNEXP_PID	= 7,	/* receive PID was not valid	*/
1440Sstevel@tonic-gate 	USB_CR_DATA_OVERRUN	= 8,	/* data size exceeded		*/
1450Sstevel@tonic-gate 	USB_CR_DATA_UNDERRUN	= 9,	/* less data received		*/
1460Sstevel@tonic-gate 	USB_CR_BUFFER_OVERRUN	= 10,	/* memory write can't keep up	*/
1470Sstevel@tonic-gate 	USB_CR_BUFFER_UNDERRUN	= 11,	/* buffer underrun		*/
1480Sstevel@tonic-gate 	USB_CR_TIMEOUT		= 12,	/* command timed out		*/
1490Sstevel@tonic-gate 	USB_CR_NOT_ACCESSED	= 13,	/* Not accessed by hardware	*/
1500Sstevel@tonic-gate 	USB_CR_NO_RESOURCES	= 14,	/* no resources			*/
1510Sstevel@tonic-gate 	USB_CR_UNSPECIFIED_ERR	= 15,	/* unspecified usba or hcd err	*/
1520Sstevel@tonic-gate 	USB_CR_STOPPED_POLLING	= 16,	/* intr/isoc IN polling stopped	*/
1530Sstevel@tonic-gate 	USB_CR_PIPE_CLOSING	= 17,	/* intr/isoc IN pipe closed	*/
1540Sstevel@tonic-gate 	USB_CR_PIPE_RESET	= 18,	/* intr/isoc IN pipe reset	*/
1550Sstevel@tonic-gate 	USB_CR_NOT_SUPPORTED	= 19,	/* command not supported	*/
1560Sstevel@tonic-gate 	USB_CR_FLUSHED		= 20,	/* this request was flushed	*/
1570Sstevel@tonic-gate 	USB_CR_HC_HARDWARE_ERR	= 21	/* usb host controller error	*/
1580Sstevel@tonic-gate } usb_cr_t;
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate /*
1620Sstevel@tonic-gate  * ***************************************************************************
1630Sstevel@tonic-gate  * General definitions, used all over
1640Sstevel@tonic-gate  * ***************************************************************************
1650Sstevel@tonic-gate  *
1660Sstevel@tonic-gate  *	A pipe handle is returned by usb_pipe_open() on success for
1670Sstevel@tonic-gate  *	all pipes except the default pipe which is accessed from
1680Sstevel@tonic-gate  *	the registration structure.  Placed here as forward referenced by
1690Sstevel@tonic-gate  *	usb_client_dev_data_t below.
1700Sstevel@tonic-gate  *
1710Sstevel@tonic-gate  *	The pipe_handle is opaque to the client driver.
1720Sstevel@tonic-gate  */
1730Sstevel@tonic-gate typedef	struct usb_pipe_handle	*usb_pipe_handle_t;
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate /*
1760Sstevel@tonic-gate  * General opaque pointer.
1770Sstevel@tonic-gate  */
1780Sstevel@tonic-gate typedef struct usb_opaque *usb_opaque_t;
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate /*
1820Sstevel@tonic-gate  * USB flags argument to USBA interfaces
1830Sstevel@tonic-gate  */
1840Sstevel@tonic-gate typedef enum {
1850Sstevel@tonic-gate 	/* do not block until resources are available */
1860Sstevel@tonic-gate 	USB_FLAGS_NOSLEEP		= 0x0000,
1870Sstevel@tonic-gate 	/* block until resources are available */
1880Sstevel@tonic-gate 	USB_FLAGS_SLEEP			= 0x0100,
1890Sstevel@tonic-gate 	/* reserved */
1900Sstevel@tonic-gate 	USB_FLAGS_RESERVED		= 0xFE00
1910Sstevel@tonic-gate } usb_flags_t;
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate /*
1950Sstevel@tonic-gate  * ***************************************************************************
1960Sstevel@tonic-gate  * Descriptor definitions (from USB 2.0 specification, chapter 9)
1970Sstevel@tonic-gate  * ***************************************************************************
1980Sstevel@tonic-gate  */
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate /*
2020Sstevel@tonic-gate  * USB Descriptor Management
2030Sstevel@tonic-gate  *
2040Sstevel@tonic-gate  * Standard USB descriptors:
2050Sstevel@tonic-gate  *
2060Sstevel@tonic-gate  * USB devices present their configuration information in response to
2070Sstevel@tonic-gate  * a GET_DESCRIPTOR request in a form which is little-endian and,
2080Sstevel@tonic-gate  * for multibyte integers, unaligned.  It is also position-dependent,
2090Sstevel@tonic-gate  * which makes non-sequential access to particular interface or
2100Sstevel@tonic-gate  * endpoint data inconvenient.
2110Sstevel@tonic-gate  * A GET_DESCRIPTOR request may yield a chunk of data that contains
2120Sstevel@tonic-gate  * multiple descriptor types.  For example, a GET_DESCRIPTOR request
2130Sstevel@tonic-gate  * for a CONFIGURATION descriptor could return the configuration
2140Sstevel@tonic-gate  * descriptor followed by an interface descriptor and the relevant
2150Sstevel@tonic-gate  * endpoint descriptors.
2160Sstevel@tonic-gate  *
2170Sstevel@tonic-gate  * usb_get_dev_data() interface provides an easy way to get all
2180Sstevel@tonic-gate  * the descriptors and avoids parsing standard descriptors by each
2190Sstevel@tonic-gate  * client driver
2200Sstevel@tonic-gate  *
2210Sstevel@tonic-gate  * usb_dev_descr:
2220Sstevel@tonic-gate  *	usb device descriptor, refer to	USB 2.0/9.6.1,
2230Sstevel@tonic-gate  */
2240Sstevel@tonic-gate typedef struct usb_dev_descr {
2250Sstevel@tonic-gate 	uint8_t		bLength;	/* descriptor size		*/
2260Sstevel@tonic-gate 	uint8_t		bDescriptorType; /* set to DEVICE		*/
2270Sstevel@tonic-gate 	uint16_t	bcdUSB;		/* USB spec rel. number	in bcd	*/
2280Sstevel@tonic-gate 	uint8_t		bDeviceClass;	/* class code			*/
2290Sstevel@tonic-gate 	uint8_t		bDeviceSubClass; /* sub	class code		*/
2300Sstevel@tonic-gate 	uint8_t		bDeviceProtocol; /* protocol code		*/
2310Sstevel@tonic-gate 	uint8_t		bMaxPacketSize0; /* max	pkt size of e/p	0	*/
2320Sstevel@tonic-gate 	uint16_t	idVendor;	/* vendor ID			*/
2330Sstevel@tonic-gate 	uint16_t	idProduct;	/* product ID			*/
2340Sstevel@tonic-gate 	uint16_t	bcdDevice;	/* device release number in bcd	*/
2350Sstevel@tonic-gate 	uint8_t		iManufacturer;	/* manufacturing string		*/
2360Sstevel@tonic-gate 	uint8_t		iProduct;	/* product string		*/
2370Sstevel@tonic-gate 	uint8_t		iSerialNumber;	/* serial number string index	*/
2380Sstevel@tonic-gate 	uint8_t		bNumConfigurations; /* #configs for device	*/
2390Sstevel@tonic-gate } usb_dev_descr_t;
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate /*
2430Sstevel@tonic-gate  * USB Device Qualifier Descriptor
2440Sstevel@tonic-gate  *
2450Sstevel@tonic-gate  * The device_qualifier descriptor describes information about a High
2460Sstevel@tonic-gate  * speed capable device that would change if the device were operating
2470Sstevel@tonic-gate  * at other (Full) speed. Example: if the device is currently operating
2480Sstevel@tonic-gate  * at Full-speed, the device_qualifier returns information about how if
2490Sstevel@tonic-gate  * would operate at high-speed and vice-versa.
2500Sstevel@tonic-gate  *
2510Sstevel@tonic-gate  * usb_dev_qlf_descr:
2520Sstevel@tonic-gate  *
2530Sstevel@tonic-gate  *	usb device qualifier descriptor, refer to USB 2.0/9.6.2
2540Sstevel@tonic-gate  */
2550Sstevel@tonic-gate typedef struct usb_dev_qlf_descr {
2560Sstevel@tonic-gate 	uint8_t		bLength;	/* descriptor size		*/
2570Sstevel@tonic-gate 	uint8_t		bDescriptorType; /* set to DEVICE		*/
2580Sstevel@tonic-gate 	uint16_t	bcdUSB;		/* USB spec rel. number	in bcd	*/
2590Sstevel@tonic-gate 	uint8_t		bDeviceClass;	/* class code			*/
2600Sstevel@tonic-gate 	uint8_t		bDeviceSubClass; /* sub	class code		*/
2610Sstevel@tonic-gate 	uint8_t		bDeviceProtocol; /* protocol code		*/
2620Sstevel@tonic-gate 	uint8_t		bMaxPacketSize0; /* max	pkt size of e/p	0	*/
2630Sstevel@tonic-gate 	uint8_t		bNumConfigurations; /* #configs for device	*/
2640Sstevel@tonic-gate 	uint8_t		bReserved;	/* reserved field		*/
2650Sstevel@tonic-gate } usb_dev_qlf_descr_t;
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate 
2680Sstevel@tonic-gate /*
2690Sstevel@tonic-gate  * usb_cfg_descr:
2700Sstevel@tonic-gate  *	usb configuration descriptor, refer to USB 2.0/9.6.3
2710Sstevel@tonic-gate  */
2720Sstevel@tonic-gate typedef struct usb_cfg_descr {
2730Sstevel@tonic-gate 	uint8_t		bLength;	/* descriptor size		*/
2740Sstevel@tonic-gate 	uint8_t		bDescriptorType; /* set to CONFIGURATION	*/
2750Sstevel@tonic-gate 	uint16_t	wTotalLength;	/* total length of data returned */
2760Sstevel@tonic-gate 	uint8_t		bNumInterfaces;	/* # interfaces	in config	*/
2770Sstevel@tonic-gate 	uint8_t		bConfigurationValue; /* arg for SetConfiguration */
2780Sstevel@tonic-gate 	uint8_t		iConfiguration;	/* configuration string		*/
2790Sstevel@tonic-gate 	uint8_t		bmAttributes;	/* config characteristics	*/
2800Sstevel@tonic-gate 	uint8_t		bMaxPower;	/* max pwr consumption		*/
2810Sstevel@tonic-gate } usb_cfg_descr_t;
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate /*
2840Sstevel@tonic-gate  * Default configuration index setting for devices with multiple
2850Sstevel@tonic-gate  * configurations. Note the distinction between config index and config
2860Sstevel@tonic-gate  * number
2870Sstevel@tonic-gate  */
2880Sstevel@tonic-gate #define	USB_DEV_DEFAULT_CONFIG_INDEX	0
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate /*
2910Sstevel@tonic-gate  * bmAttribute values for Configuration Descriptor
2920Sstevel@tonic-gate  */
2930Sstevel@tonic-gate #define	USB_CFG_ATTR_SELFPWR		0x40
2940Sstevel@tonic-gate #define	USB_CFG_ATTR_REMOTE_WAKEUP	0x20
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate 
2970Sstevel@tonic-gate /*
2980Sstevel@tonic-gate  * USB Other Speed Configuration Descriptor
2990Sstevel@tonic-gate  *
3000Sstevel@tonic-gate  * The other_speed_configuration descriptor describes a configuration of
3010Sstevel@tonic-gate  * a High speed capable device if it were operating at its other possible
3020Sstevel@tonic-gate  * (Full) speed and vice-versa.
3030Sstevel@tonic-gate  *
3040Sstevel@tonic-gate  * usb_other_speed_cfg_descr:
3050Sstevel@tonic-gate  *	usb other speed configuration descriptor, refer to USB 2.0/9.6.4
3060Sstevel@tonic-gate  */
3070Sstevel@tonic-gate typedef struct usb_other_speed_cfg_descr {
3080Sstevel@tonic-gate 	uint8_t		bLength;	/* descriptor size		*/
3090Sstevel@tonic-gate 	uint8_t		bDescriptorType; /* set to CONFIGURATION	*/
3100Sstevel@tonic-gate 	uint16_t	wTotalLength;	/* total length of data returned */
3110Sstevel@tonic-gate 	uint8_t		bNumInterfaces;	/* # interfaces	in config	*/
3120Sstevel@tonic-gate 	uint8_t		bConfigurationValue; /* arg for SetConfiguration */
3130Sstevel@tonic-gate 	uint8_t		iConfiguration;	/* configuration string		*/
3140Sstevel@tonic-gate 	uint8_t		bmAttributes;	/* config characteristics	*/
3150Sstevel@tonic-gate 	uint8_t		bMaxPower;	/* max pwr consumption		*/
3160Sstevel@tonic-gate } usb_other_speed_cfg_descr_t;
3170Sstevel@tonic-gate 
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate /*
320*3341Sgc161489  * usb_ia_descr:
321*3341Sgc161489  *	usb interface association descriptor, refer to USB 2.0 ECN(IAD)
322*3341Sgc161489  */
323*3341Sgc161489 typedef  struct usb_ia_descr {
324*3341Sgc161489 	uint8_t		bLength;		/* descriptor size	*/
325*3341Sgc161489 	uint8_t		bDescriptorType;	/* INTERFACE_ASSOCIATION */
326*3341Sgc161489 	uint8_t		bFirstInterface;	/* 1st interface number */
327*3341Sgc161489 	uint8_t		bInterfaceCount;	/* number of interfaces */
328*3341Sgc161489 	uint8_t		bFunctionClass;		/* class code		*/
329*3341Sgc161489 	uint8_t		bFunctionSubClass;	/* sub class code	*/
330*3341Sgc161489 	uint8_t		bFunctionProtocol;	/* protocol code	*/
331*3341Sgc161489 	uint8_t		iFunction;		/* description string	*/
332*3341Sgc161489 } usb_ia_descr_t;
333*3341Sgc161489 
334*3341Sgc161489 
335*3341Sgc161489 /*
3360Sstevel@tonic-gate  * usb_if_descr:
3370Sstevel@tonic-gate  *	usb interface descriptor, refer	to USB 2.0/9.6.5
3380Sstevel@tonic-gate  */
3390Sstevel@tonic-gate typedef  struct usb_if_descr {
3400Sstevel@tonic-gate 	uint8_t		bLength;		/* descriptor size	*/
3410Sstevel@tonic-gate 	uint8_t		bDescriptorType;	/* set to INTERFACE	*/
3420Sstevel@tonic-gate 	uint8_t		bInterfaceNumber;	/* interface number	*/
3430Sstevel@tonic-gate 	uint8_t		bAlternateSetting;	/* alt. interface number */
3440Sstevel@tonic-gate 	uint8_t		bNumEndpoints;		/* # of endpoints	*/
3450Sstevel@tonic-gate 	uint8_t		bInterfaceClass;	/* class code		*/
3460Sstevel@tonic-gate 	uint8_t		bInterfaceSubClass;	/* sub class code	*/
3470Sstevel@tonic-gate 	uint8_t		bInterfaceProtocol;	/* protocol code	*/
3480Sstevel@tonic-gate 	uint8_t		iInterface;		/* description string	*/
3490Sstevel@tonic-gate } usb_if_descr_t;
3500Sstevel@tonic-gate 
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate /*
3530Sstevel@tonic-gate  * usb_ep_descr:
3540Sstevel@tonic-gate  *	usb endpoint descriptor, refer to USB 2.0/9.6.6
3550Sstevel@tonic-gate  */
3560Sstevel@tonic-gate typedef struct usb_ep_descr {
3570Sstevel@tonic-gate 	uint8_t		bLength;		/* descriptor size	*/
3580Sstevel@tonic-gate 	uint8_t		bDescriptorType;	/* set to ENDPOINT	*/
3590Sstevel@tonic-gate 	uint8_t		bEndpointAddress;	/* address of this e/p */
3600Sstevel@tonic-gate 	uint8_t		bmAttributes;		/* transfer type	*/
3610Sstevel@tonic-gate 	uint16_t	wMaxPacketSize;		/* maximum packet size	*/
3620Sstevel@tonic-gate 	uint8_t		bInterval;		/* e/p polling interval */
3630Sstevel@tonic-gate } usb_ep_descr_t;
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate /*
3660Sstevel@tonic-gate  * bEndpointAddress masks
3670Sstevel@tonic-gate  */
3680Sstevel@tonic-gate #define	USB_EP_NUM_MASK		0x0F		/* endpoint number mask */
3690Sstevel@tonic-gate #define	USB_EP_DIR_MASK		0x80		/* direction mask */
3700Sstevel@tonic-gate #define	USB_EP_DIR_OUT		0x00		/* OUT endpoint */
3710Sstevel@tonic-gate #define	USB_EP_DIR_IN		0x80		/* IN endpoint */
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate /*
3740Sstevel@tonic-gate  * bmAttribute transfer types for endpoints
3750Sstevel@tonic-gate  */
3760Sstevel@tonic-gate #define	USB_EP_ATTR_MASK	0x03		/* transfer type mask */
3770Sstevel@tonic-gate #define	USB_EP_ATTR_CONTROL	0x00		/* control transfer */
3780Sstevel@tonic-gate #define	USB_EP_ATTR_ISOCH	0x01		/* isochronous transfer */
3790Sstevel@tonic-gate #define	USB_EP_ATTR_BULK	0x02		/* bulk transfer */
3800Sstevel@tonic-gate #define	USB_EP_ATTR_INTR	0x03		/* interrupt transfer */
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate /*
3830Sstevel@tonic-gate  * bmAttribute synchronization types for endpoints (isochronous only)
3840Sstevel@tonic-gate  */
3850Sstevel@tonic-gate #define	USB_EP_SYNC_MASK	0x0C		/* synchronization mask */
3860Sstevel@tonic-gate #define	USB_EP_SYNC_NONE	0x00		/* no synchronization */
3870Sstevel@tonic-gate #define	USB_EP_SYNC_ASYNC	0x04		/* asynchronous */
3880Sstevel@tonic-gate #define	USB_EP_SYNC_ADPT	0x08		/* adaptive */
3890Sstevel@tonic-gate #define	USB_EP_SYNC_SYNC	0x0C		/* synchronous */
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate /*
3920Sstevel@tonic-gate  * bmAttribute synchronization feedback types for endpoints (isochronous only)
3930Sstevel@tonic-gate  */
3940Sstevel@tonic-gate #define	USB_EP_USAGE_MASK	0x30		/* sync feedback mask */
3950Sstevel@tonic-gate #define	USB_EP_USAGE_DATA	0x00		/* data endpoint */
3960Sstevel@tonic-gate #define	USB_EP_USAGE_FEED	0x10		/* feedback endpoint */
3970Sstevel@tonic-gate #define	USB_EP_USAGE_IMPL	0x20		/* implicit feedback endpoint */
3980Sstevel@tonic-gate 
3990Sstevel@tonic-gate /*
4000Sstevel@tonic-gate  * wMaxPacketSize values for endpoints (isoch and interrupt, high speed only)
4010Sstevel@tonic-gate  */
4020Sstevel@tonic-gate #define	USB_EP_MAX_PKTSZ_MASK	0x03FF		/* Mask for packetsize bits */
4030Sstevel@tonic-gate #define	USB_EP_MAX_XACTS_MASK	0x0C00		/* Max Transactns/microframe */
4040Sstevel@tonic-gate #define	USB_EP_MAX_XACTS_SHIFT	10		/* Above is 10 bits from end */
4050Sstevel@tonic-gate 
4060Sstevel@tonic-gate /*
4070Sstevel@tonic-gate  * Ranges for endpoint parameter values.
4080Sstevel@tonic-gate  */
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate /* Min and Max NAK rates for high sped control endpoints. */
4110Sstevel@tonic-gate #define	USB_EP_MIN_HIGH_CONTROL_INTRVL	0
4120Sstevel@tonic-gate #define	USB_EP_MAX_HIGH_CONTROL_INTRVL	255
4130Sstevel@tonic-gate 
4140Sstevel@tonic-gate /* Min and Max NAK rates for high speed bulk endpoints. */
4150Sstevel@tonic-gate #define	USB_EP_MIN_HIGH_BULK_INTRVL	0
4160Sstevel@tonic-gate #define	USB_EP_MAX_HIGH_BULK_INTRVL	255
4170Sstevel@tonic-gate 
4180Sstevel@tonic-gate /* Min and Max polling intervals for low, full speed interrupt endpoints. */
4190Sstevel@tonic-gate #define	USB_EP_MIN_LOW_INTR_INTRVL	1
4200Sstevel@tonic-gate #define	USB_EP_MAX_LOW_INTR_INTRVL	255
4210Sstevel@tonic-gate #define	USB_EP_MIN_FULL_INTR_INTRVL	1
4220Sstevel@tonic-gate #define	USB_EP_MAX_FULL_INTR_INTRVL	255
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate /*
4250Sstevel@tonic-gate  * Min and Max polling intervals for high speed interrupt endpoints, and for
4260Sstevel@tonic-gate  * isochronous endpoints.
4270Sstevel@tonic-gate  * Note that the interval is 2**(value-1).  See Section 9.6.6 of USB 2.0 spec.
4280Sstevel@tonic-gate  */
4290Sstevel@tonic-gate #define	USB_EP_MIN_HIGH_INTR_INTRVL	1
4300Sstevel@tonic-gate #define	USB_EP_MAX_HIGH_INTR_INTRVL	16
4310Sstevel@tonic-gate #define	USB_EP_MIN_FULL_ISOCH_INTRVL	1
4320Sstevel@tonic-gate #define	USB_EP_MAX_FULL_ISOCH_INTRVL	16
4330Sstevel@tonic-gate #define	USB_EP_MIN_HIGH_ISOCH_INTRVL	1
4340Sstevel@tonic-gate #define	USB_EP_MAX_HIGH_ISOCH_INTRVL	16
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate /*
4370Sstevel@tonic-gate  * usb_string_descr:
4380Sstevel@tonic-gate  *	usb string descriptor, refer to	 USB 2.0/9.6.7
4390Sstevel@tonic-gate  */
4400Sstevel@tonic-gate typedef struct usb_string_descr {
4410Sstevel@tonic-gate 	uint8_t		bLength;		/* descr size */
4420Sstevel@tonic-gate 	uint8_t		bDescriptorType;	/* set to STRING */
4430Sstevel@tonic-gate 	uint8_t		bString[1];		/* variable length unicode */
4440Sstevel@tonic-gate 						/* encoded string	*/
4450Sstevel@tonic-gate } usb_string_descr_t;
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate #define	USB_MAXSTRINGLEN	255		/* max string descr length */
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate 
4500Sstevel@tonic-gate /*
4510Sstevel@tonic-gate  * ***************************************************************************
4520Sstevel@tonic-gate  * Client driver registration with USBA
4530Sstevel@tonic-gate  * ***************************************************************************
4540Sstevel@tonic-gate  *
4550Sstevel@tonic-gate  *	The client registers with USBA during attach in two steps
4560Sstevel@tonic-gate  *	using usb_client_attach() and usb_get_dev_data(). On completion, the
4570Sstevel@tonic-gate  *	registration data has been initialized.  Most data items are
4580Sstevel@tonic-gate  *	straightforward.  Among the items returned in the data is the tree of
4590Sstevel@tonic-gate  *	parsed descriptors, in dev_cfg;	 the number of configurations parsed,
4600Sstevel@tonic-gate  *	in dev_n_cfg; a pointer to the current configuration in the tree,
4610Sstevel@tonic-gate  *	in dev_curr_cfg; the index of the first valid interface in the
4620Sstevel@tonic-gate  *	tree, in dev_curr_if, and a parse level that accurately reflects what
4630Sstevel@tonic-gate  *	is in the tree, in dev_parse_level.
4640Sstevel@tonic-gate  */
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate 
4670Sstevel@tonic-gate /*
4680Sstevel@tonic-gate  * ***************************************************************************
4690Sstevel@tonic-gate  * Data structures used in the configuration tree
4700Sstevel@tonic-gate  * ***************************************************************************
4710Sstevel@tonic-gate  */
4720Sstevel@tonic-gate 
4730Sstevel@tonic-gate /*
4740Sstevel@tonic-gate  * Tree data structure for each configuration in the tree
4750Sstevel@tonic-gate  */
4760Sstevel@tonic-gate typedef struct usb_cfg_data {
4770Sstevel@tonic-gate 	struct usb_cfg_descr	cfg_descr;	/* parsed config descr */
4780Sstevel@tonic-gate 	struct usb_if_data	*cfg_if;	/* interfaces for this cfg */
4790Sstevel@tonic-gate 						/* indexed by interface num */
4800Sstevel@tonic-gate 	struct usb_cvs_data	*cfg_cvs;	/* class/vendor specific */
4810Sstevel@tonic-gate 						/* descrs mod/extend cfg */
4820Sstevel@tonic-gate 	char			*cfg_str;	/* string descriptor */
4830Sstevel@tonic-gate 	uint_t			cfg_n_if;	/* #elements in cfg_if[] */
4840Sstevel@tonic-gate 	uint_t			cfg_n_cvs;	/* #elements in cfg_cvs[] */
4850Sstevel@tonic-gate 	uint_t			cfg_strsize;	/* size of string descr */
4860Sstevel@tonic-gate } usb_cfg_data_t;
4870Sstevel@tonic-gate 
4880Sstevel@tonic-gate 
4890Sstevel@tonic-gate /*
4900Sstevel@tonic-gate  * Tree data structure for each alternate interface set
4910Sstevel@tonic-gate  * in each represented configuration
4920Sstevel@tonic-gate  */
4930Sstevel@tonic-gate typedef struct usb_if_data {
4940Sstevel@tonic-gate 	struct usb_alt_if_data	*if_alt;	/* sparse array of alts */
4950Sstevel@tonic-gate 						/* indexed by alt setting */
4960Sstevel@tonic-gate 	uint_t			if_n_alt;	/* #elements in if_alt[] */
4970Sstevel@tonic-gate } usb_if_data_t;
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate /*
5010Sstevel@tonic-gate  * Tree data structure for each alternate of each alternate interface set
5020Sstevel@tonic-gate  */
5030Sstevel@tonic-gate typedef struct usb_alt_if_data {
5040Sstevel@tonic-gate 	usb_if_descr_t		altif_descr;	/* parsed alternate if descr */
5050Sstevel@tonic-gate 	struct usb_ep_data	*altif_ep;	/* endpts for alt if */
5060Sstevel@tonic-gate 						/* (not a sparse array */
5070Sstevel@tonic-gate 	struct usb_cvs_data	*altif_cvs;	/* cvs for this alt if */
5080Sstevel@tonic-gate 	char			*altif_str;	/* string descriptor */
5090Sstevel@tonic-gate 	uint_t			altif_n_ep;	/* #elements in altif_ep[] */
5100Sstevel@tonic-gate 	uint_t			altif_n_cvs;	/* #elements in  altif_cvs[] */
5110Sstevel@tonic-gate 	uint_t			altif_strsize;	/* size of string descr */
5120Sstevel@tonic-gate } usb_alt_if_data_t;
5130Sstevel@tonic-gate 
5140Sstevel@tonic-gate 
5150Sstevel@tonic-gate /*
5160Sstevel@tonic-gate  * Tree data structure for each endpoint of each alternate
5170Sstevel@tonic-gate  */
5180Sstevel@tonic-gate typedef struct usb_ep_data {
5190Sstevel@tonic-gate 	usb_ep_descr_t		ep_descr;	/* endpoint descriptor */
5200Sstevel@tonic-gate 	struct usb_cvs_data	*ep_cvs;	/* cv mod/extending this ep */
5210Sstevel@tonic-gate 	uint_t			ep_n_cvs;	/* #elements in ep_cvs[] */
5220Sstevel@tonic-gate } usb_ep_data_t;
5230Sstevel@tonic-gate 
5240Sstevel@tonic-gate 
5250Sstevel@tonic-gate /*
5260Sstevel@tonic-gate  * Tree data structure for each class/vendor specific descriptor
5270Sstevel@tonic-gate  */
5280Sstevel@tonic-gate typedef struct usb_cvs_data {
5290Sstevel@tonic-gate 	uchar_t			*cvs_buf;	/* raw data of cvs descr */
5300Sstevel@tonic-gate 	uint_t			cvs_buf_len;	/* cvs_buf size */
5310Sstevel@tonic-gate } usb_cvs_data_t;
5320Sstevel@tonic-gate 
5330Sstevel@tonic-gate 
5340Sstevel@tonic-gate /*
5350Sstevel@tonic-gate  *	Parse_level determines the extent to which the tree is built, the amount
5360Sstevel@tonic-gate  *	of parsing usb_client_attach() is to do.  It has the following values:
5370Sstevel@tonic-gate  *
5380Sstevel@tonic-gate  *	USB_PARSE_LVL_NONE - Build no tree.  dev_n_cfg will return 0, dev_cfg
5390Sstevel@tonic-gate  *			     will return NULL, the dev_curr_xxx fields will be
5400Sstevel@tonic-gate  *			     invalid.
5410Sstevel@tonic-gate  *	USB_PARSE_LVL_IF   - Parse configured interface only, if configuration#
5420Sstevel@tonic-gate  *			     and interface properties are set (as when different
5430Sstevel@tonic-gate  *			     interfaces are viewed by the OS as different device
5440Sstevel@tonic-gate  *			     instances). If an OS device instance is set up to
5450Sstevel@tonic-gate  *			     represent an entire physical device, this works
5460Sstevel@tonic-gate  *			     like USB_PARSE_LVL_ALL.
5470Sstevel@tonic-gate  *	USB_PARSE_LVL_CFG  - Parse entire configuration of configured interface
5480Sstevel@tonic-gate  *			     only.  This is like USB_PARSE_LVL_IF except entire
5490Sstevel@tonic-gate  *			     configuration is returned.
5500Sstevel@tonic-gate  *	USB_PARSE_LVL_ALL  - Parse entire device (all configurations), even
5510Sstevel@tonic-gate  *			     when driver is bound to a single interface of a
5520Sstevel@tonic-gate  *			     single configuration.
5530Sstevel@tonic-gate  */
5540Sstevel@tonic-gate typedef enum {
5550Sstevel@tonic-gate 	USB_PARSE_LVL_NONE		= 0,
5560Sstevel@tonic-gate 	USB_PARSE_LVL_IF		= 1,
5570Sstevel@tonic-gate 	USB_PARSE_LVL_CFG		= 2,
5580Sstevel@tonic-gate 	USB_PARSE_LVL_ALL		= 3
5590Sstevel@tonic-gate } usb_reg_parse_lvl_t;
5600Sstevel@tonic-gate 
5610Sstevel@tonic-gate 
5620Sstevel@tonic-gate /*
5630Sstevel@tonic-gate  * Registration data returned by usb_get_dev_data().  Configuration tree roots
5640Sstevel@tonic-gate  * are returned in dev_cfg array.
5650Sstevel@tonic-gate  */
5660Sstevel@tonic-gate typedef struct usb_client_dev_data {
5670Sstevel@tonic-gate 	usb_pipe_handle_t	dev_default_ph;	/* default pipe handle */
5680Sstevel@tonic-gate 	ddi_iblock_cookie_t	dev_iblock_cookie; /* for mutex_init's */
5690Sstevel@tonic-gate 	struct usb_dev_descr	*dev_descr;	/* cooked device descriptor */
5700Sstevel@tonic-gate 	char			*dev_mfg;	/* manufacturing ID */
5710Sstevel@tonic-gate 	char			*dev_product;	/* product ID */
5720Sstevel@tonic-gate 	char			*dev_serial;	/* serial number */
5730Sstevel@tonic-gate 	usb_reg_parse_lvl_t	dev_parse_level; /* USB_PARSE_LVL_* flag */
5740Sstevel@tonic-gate 	struct usb_cfg_data	*dev_cfg;	/* configs for this device */
5750Sstevel@tonic-gate 						/* indexed by config index */
5760Sstevel@tonic-gate 	uint_t			dev_n_cfg;	/* #elements in dev_cfg[] */
5770Sstevel@tonic-gate 	struct usb_cfg_data	*dev_curr_cfg;	/* current cfg */
5780Sstevel@tonic-gate 	int			dev_curr_if;	/* current interface number */
5790Sstevel@tonic-gate } usb_client_dev_data_t;
5800Sstevel@tonic-gate 
5810Sstevel@tonic-gate 
5820Sstevel@tonic-gate /*
5830Sstevel@tonic-gate  * ***************************************************************************
5840Sstevel@tonic-gate  * Device configuration descriptor tree functions
5850Sstevel@tonic-gate  * ***************************************************************************
5860Sstevel@tonic-gate  */
5870Sstevel@tonic-gate 
5880Sstevel@tonic-gate /*
5890Sstevel@tonic-gate  * usb_get_dev_data:
5900Sstevel@tonic-gate  *	returns initialized registration data. 	Most data items are clear.
5910Sstevel@tonic-gate  *	Among the items returned is the tree ofparsed descriptors in dev_cfg;
5920Sstevel@tonic-gate  *	and the number of configurations parsed in dev_n_cfg.
5930Sstevel@tonic-gate  *
5940Sstevel@tonic-gate  * Arguments:
5950Sstevel@tonic-gate  *	dip		- pointer to devinfo node of the client
5960Sstevel@tonic-gate  *	dev_data	- return registration data at this address
5970Sstevel@tonic-gate  *	parse_level	- See above
5980Sstevel@tonic-gate  *	flags		- None used
5990Sstevel@tonic-gate  *
6000Sstevel@tonic-gate  * Return Values:
6010Sstevel@tonic-gate  *	USB_SUCCESS		- usb_register_client succeeded
6020Sstevel@tonic-gate  *	USB_INVALID_ARGS	- received null dip or reg argument
6030Sstevel@tonic-gate  *	USB_INVALID_CONTEXT	- called with sleep from callback context
6040Sstevel@tonic-gate  *	USB_FAILURE		- bad descriptor info or other internal failure
6050Sstevel@tonic-gate  *
6060Sstevel@tonic-gate  * Notes:
6070Sstevel@tonic-gate  * 	1) The non-standard USB descriptors are returned in RAW format.
6080Sstevel@tonic-gate  *
6090Sstevel@tonic-gate  *	2) The registration data is unshared. Each client receives its own copy.
6100Sstevel@tonic-gate  *	(The default control pipe may be shared, even though its tree
6110Sstevel@tonic-gate  *	description will be unique per device.)
6120Sstevel@tonic-gate  *
6130Sstevel@tonic-gate  */
6140Sstevel@tonic-gate int usb_get_dev_data(
6150Sstevel@tonic-gate 	dev_info_t			*dip,
6160Sstevel@tonic-gate 	usb_client_dev_data_t		**dev_data,
6170Sstevel@tonic-gate 	usb_reg_parse_lvl_t		parse_level,
6180Sstevel@tonic-gate 	usb_flags_t			flags);
6190Sstevel@tonic-gate 
6200Sstevel@tonic-gate /*
6210Sstevel@tonic-gate  * usb_free_dev_data:
6220Sstevel@tonic-gate  * undoes what usb_get_dev_data() set up.  It releases
6230Sstevel@tonic-gate  * memory for all strings, descriptors, and trees set up by usb_get_dev_data().
6240Sstevel@tonic-gate  *
6250Sstevel@tonic-gate  * Arguments:
6260Sstevel@tonic-gate  *	dip		- pointer to devinfo node of the client
6270Sstevel@tonic-gate  *	dev_data	- pointer to registration data containing the tree.
6280Sstevel@tonic-gate  */
6290Sstevel@tonic-gate void usb_free_dev_data(
6300Sstevel@tonic-gate 	dev_info_t			*dip,
6310Sstevel@tonic-gate 	usb_client_dev_data_t		*dev_data);
6320Sstevel@tonic-gate 
6330Sstevel@tonic-gate /*
6340Sstevel@tonic-gate  * usb_free_descr_tree:
6350Sstevel@tonic-gate  *	Take down the configuration tree while leaving the rest	of the
6360Sstevel@tonic-gate  *	registration intact.  This can be used, for example, after attach has
6370Sstevel@tonic-gate  *	copied any descriptors it needs from the tree, but the rest of the
6380Sstevel@tonic-gate  *	registration data needs to remain intact.
6390Sstevel@tonic-gate  *
6400Sstevel@tonic-gate  *	The following usb_client_dev_data_t fields will be modified:
6410Sstevel@tonic-gate  *		dev_cfg will be NULL
6420Sstevel@tonic-gate  *		dev_n_cfg will be 0
6430Sstevel@tonic-gate  *		dev_curr_cfg_ndx and dev_curr_if will be invalid
6440Sstevel@tonic-gate  *		dev_parse_level will be USB_REG_DESCR_NONE
6450Sstevel@tonic-gate  *
6460Sstevel@tonic-gate  * Arguments:
6470Sstevel@tonic-gate  *	dip		- pointer to devinfo node of the client
6480Sstevel@tonic-gate  *	dev_data	- pointer to registration data containing the tree.
6490Sstevel@tonic-gate  */
6500Sstevel@tonic-gate void usb_free_descr_tree(
6510Sstevel@tonic-gate 	dev_info_t			*dip,
6520Sstevel@tonic-gate 	usb_client_dev_data_t		*dev_data);
6530Sstevel@tonic-gate 
6540Sstevel@tonic-gate 
6550Sstevel@tonic-gate /*
6560Sstevel@tonic-gate  * usb_print_descr_tree:
6570Sstevel@tonic-gate  *	Dump to the screen a descriptor tree as returned by
6580Sstevel@tonic-gate  *	usbai_register_client.
6590Sstevel@tonic-gate  *
6600Sstevel@tonic-gate  * Arguments:
6610Sstevel@tonic-gate  *	dip		- pointer to devinfo of the client
6620Sstevel@tonic-gate  *	dev_data	- pointer to registration area containing the tree
6630Sstevel@tonic-gate  *
6640Sstevel@tonic-gate  * Returns:
6650Sstevel@tonic-gate  *	USB_SUCCESS		- tree successfully dumped
6660Sstevel@tonic-gate  *	USB_INVALID_CONTEXT	- called from callback context
6670Sstevel@tonic-gate  *	USB_INVALID_ARGS	- bad arguments given
6680Sstevel@tonic-gate  */
6690Sstevel@tonic-gate int usb_print_descr_tree(
6700Sstevel@tonic-gate 	dev_info_t		*dip,
6710Sstevel@tonic-gate 	usb_client_dev_data_t	*dev_data);
6720Sstevel@tonic-gate 
6730Sstevel@tonic-gate 
6740Sstevel@tonic-gate /*
6750Sstevel@tonic-gate  * ***************************************************************************
6760Sstevel@tonic-gate  * Registration and versioning
6770Sstevel@tonic-gate  * ***************************************************************************
6780Sstevel@tonic-gate  */
6790Sstevel@tonic-gate 
6800Sstevel@tonic-gate 
6810Sstevel@tonic-gate /*
6820Sstevel@tonic-gate  * USBA client drivers are required to define USBDRV_MAJOR_VER
6830Sstevel@tonic-gate  * USBDRV_MINOR_VER and pass USBDRV_VERSION as the version
6840Sstevel@tonic-gate  * number to usb_client_attach
6850Sstevel@tonic-gate  */
6860Sstevel@tonic-gate #if !defined(USBA_MAJOR_VER) || !defined(USBA_MINOR_VER)
6870Sstevel@tonic-gate #error incorrect USBA header
6880Sstevel@tonic-gate #endif
6890Sstevel@tonic-gate 
6900Sstevel@tonic-gate /*
6910Sstevel@tonic-gate  * Driver major version must be the same as USBA major version, and
6920Sstevel@tonic-gate  * driver minor version must be <= USBA minor version
6930Sstevel@tonic-gate  */
6940Sstevel@tonic-gate #if !defined(USBA_FRAMEWORK)
6950Sstevel@tonic-gate #if defined(USBDRV_MAJOR_VER) && defined(USBDRV_MINOR_VER)
6960Sstevel@tonic-gate 
6970Sstevel@tonic-gate #if (USBDRV_MAJOR_VER != USBA_MAJOR_VER)
6980Sstevel@tonic-gate #error USBA and driver major versions do not match
6990Sstevel@tonic-gate #endif
7000Sstevel@tonic-gate #if (USBDRV_MINOR_VER > USBA_MINOR_VER)
7010Sstevel@tonic-gate #error USBA and driver minor versions do not match
7020Sstevel@tonic-gate #endif
7030Sstevel@tonic-gate 
7040Sstevel@tonic-gate #endif
7050Sstevel@tonic-gate #endif
7060Sstevel@tonic-gate 
7070Sstevel@tonic-gate #define	USBA_MAKE_VER(major, minor) ((major) << 8 | (minor))
7080Sstevel@tonic-gate #define	USBA_GET_MAJOR(ver) ((ver) >> 8)
7090Sstevel@tonic-gate #define	USBA_GET_MINOR(ver) ((ver) & 0xff)
7100Sstevel@tonic-gate 
7110Sstevel@tonic-gate #define	USBDRV_VERSION	USBA_MAKE_VER(USBDRV_MAJOR_VER, USBDRV_MINOR_VER)
7120Sstevel@tonic-gate 
7130Sstevel@tonic-gate 
7140Sstevel@tonic-gate /*
7150Sstevel@tonic-gate  * usb_client_attach:
7160Sstevel@tonic-gate  *
7170Sstevel@tonic-gate  * Arguments:
7180Sstevel@tonic-gate  *	dip		- pointer to devinfo node of the client
7190Sstevel@tonic-gate  *	version 	- USBA registration version number
7200Sstevel@tonic-gate  *	flags		- None used
7210Sstevel@tonic-gate  *
7220Sstevel@tonic-gate  * Return Values:
7230Sstevel@tonic-gate  *	USB_SUCCESS		- attach succeeded
7240Sstevel@tonic-gate  *	USB_INVALID_ARGS	- received null dip or reg argument
7250Sstevel@tonic-gate  *	USB_INVALID_CONTEXT	- called with sleep from callback context
7260Sstevel@tonic-gate  *				  or not at attach time
7270Sstevel@tonic-gate  *	USB_INVALID_VERSION	- version argument is incorrect.
7280Sstevel@tonic-gate  *	USB_FAILURE		- other internal failure
7290Sstevel@tonic-gate  */
7300Sstevel@tonic-gate int usb_client_attach(
7310Sstevel@tonic-gate 	dev_info_t			*dip,
7320Sstevel@tonic-gate 	uint_t				version,
7330Sstevel@tonic-gate 	usb_flags_t			flags);
7340Sstevel@tonic-gate 
7350Sstevel@tonic-gate /*
7360Sstevel@tonic-gate  * usb_client_detach:
7370Sstevel@tonic-gate  *
7380Sstevel@tonic-gate  * Arguments:
7390Sstevel@tonic-gate  *	dip		- pointer to devinfo node of the client
7400Sstevel@tonic-gate  *	dev_data	- pointer to data to free. may be NULL
7410Sstevel@tonic-gate  */
7420Sstevel@tonic-gate void usb_client_detach(
7430Sstevel@tonic-gate 	dev_info_t			*dip,
7440Sstevel@tonic-gate 	struct usb_client_dev_data	*dev_data);
7450Sstevel@tonic-gate 
7460Sstevel@tonic-gate /*
7470Sstevel@tonic-gate  * ***************************************************************************
7480Sstevel@tonic-gate  * Functions for parsing / retrieving data from the descriptor tree
7490Sstevel@tonic-gate  * ***************************************************************************
7500Sstevel@tonic-gate  */
7510Sstevel@tonic-gate 
7520Sstevel@tonic-gate /*
7530Sstevel@tonic-gate  * Function for unpacking any kind of little endian data, usually desriptors
7540Sstevel@tonic-gate  *
7550Sstevel@tonic-gate  * Arguments:
7560Sstevel@tonic-gate  *	format		- string indicating the format in c, s, w, eg. "2c4ws"
7570Sstevel@tonic-gate  *			  which describes 2 bytes, 4 int, one short.
7580Sstevel@tonic-gate  *			  The number prefix parses the number of items of
7590Sstevel@tonic-gate  *			  the following type.
7600Sstevel@tonic-gate  *	data		- pointer to the LE data buffer
7610Sstevel@tonic-gate  *	datalen		- length of the data
7620Sstevel@tonic-gate  *	structure	- pointer to return structure where the unpacked data
7630Sstevel@tonic-gate  *			  will be written
7640Sstevel@tonic-gate  *	structlen	- length of the return structure
7650Sstevel@tonic-gate  *
7660Sstevel@tonic-gate  * return value:
7670Sstevel@tonic-gate  *	total number of bytes of the original data that was unpacked
7680Sstevel@tonic-gate  *	or USB_PARSE_ERROR
7690Sstevel@tonic-gate  */
7700Sstevel@tonic-gate #define	USB_PARSE_ERROR	0
7710Sstevel@tonic-gate 
7720Sstevel@tonic-gate size_t usb_parse_data(
7730Sstevel@tonic-gate 	char			*format,
7740Sstevel@tonic-gate 	uchar_t 		*data,
7750Sstevel@tonic-gate 	size_t			datalen,
7760Sstevel@tonic-gate 	void			*structure,
7770Sstevel@tonic-gate 	size_t			structlen);
7780Sstevel@tonic-gate 
7790Sstevel@tonic-gate /*
7800Sstevel@tonic-gate  * usb_lookup_ep_data:
7810Sstevel@tonic-gate  *	Function to get specific endpoint data
7820Sstevel@tonic-gate  *	This function will not access the device.
7830Sstevel@tonic-gate  *
7840Sstevel@tonic-gate  * Arguments:
7850Sstevel@tonic-gate  *	dip		- pointer to dev info
7860Sstevel@tonic-gate  *	dev_datap	- pointer to registration data
7870Sstevel@tonic-gate  *	interface	- requested interface
7880Sstevel@tonic-gate  *	alternate	- requested alternate
7890Sstevel@tonic-gate  *	skip		- number of endpoints which match the requested type and
7900Sstevel@tonic-gate  *			  direction to skip before finding one to retrieve
7910Sstevel@tonic-gate  *	type		- endpoint type
7920Sstevel@tonic-gate  *	direction	- endpoint direction: USB_EP_DIR_IN/OUT or none
7930Sstevel@tonic-gate  *
7940Sstevel@tonic-gate  * Return Values:
7950Sstevel@tonic-gate  *	NULL or an endpoint data pointer
7960Sstevel@tonic-gate  */
7970Sstevel@tonic-gate usb_ep_data_t *usb_lookup_ep_data(
7980Sstevel@tonic-gate 	dev_info_t		*dip,
7990Sstevel@tonic-gate 	usb_client_dev_data_t	*dev_datap,
8000Sstevel@tonic-gate 	uint_t			interface,
8010Sstevel@tonic-gate 	uint_t			alternate,
8020Sstevel@tonic-gate 	uint_t			skip,
8030Sstevel@tonic-gate 	uint_t			type,
8040Sstevel@tonic-gate 	uint_t			direction);
8050Sstevel@tonic-gate 
8060Sstevel@tonic-gate 
8070Sstevel@tonic-gate /* Language ID for string descriptors. */
8080Sstevel@tonic-gate #define	USB_LANG_ID		0x0409		/* English, US */
8090Sstevel@tonic-gate 
8100Sstevel@tonic-gate /*
8110Sstevel@tonic-gate  * usb_get_string_descr:
8120Sstevel@tonic-gate  *	Reads the string descriptor.  This function access the device and
8130Sstevel@tonic-gate  *	blocks.
8140Sstevel@tonic-gate  *
8150Sstevel@tonic-gate  * Arguments:
8160Sstevel@tonic-gate  *	dip		- pointer to devinfo of the client.
8170Sstevel@tonic-gate  *	langid		- LANGID to read different LOCALEs.
8180Sstevel@tonic-gate  *	index		- index to the string.
8190Sstevel@tonic-gate  *	buf		- user provided buffer for string descriptor.
8200Sstevel@tonic-gate  *	buflen		- user provided length of the buffer.
8210Sstevel@tonic-gate  *
8220Sstevel@tonic-gate  * Return Values:
8230Sstevel@tonic-gate  *	USB_SUCCESS	- descriptor is valid.
8240Sstevel@tonic-gate  *	USB_FAILURE	- full descriptor could not be retrieved.
8250Sstevel@tonic-gate  */
8260Sstevel@tonic-gate int usb_get_string_descr(
8270Sstevel@tonic-gate 	dev_info_t		*dip,
8280Sstevel@tonic-gate 	uint16_t		langid,
8290Sstevel@tonic-gate 	uint8_t			index,
8300Sstevel@tonic-gate 	char			*buf,
8310Sstevel@tonic-gate 	size_t			buflen);
8320Sstevel@tonic-gate 
8330Sstevel@tonic-gate 
8340Sstevel@tonic-gate /*
8350Sstevel@tonic-gate  * ***************************************************************************
8360Sstevel@tonic-gate  * Addressing utility functions
8370Sstevel@tonic-gate  * ***************************************************************************
8380Sstevel@tonic-gate  */
8390Sstevel@tonic-gate 
8400Sstevel@tonic-gate /*
8410Sstevel@tonic-gate  * usb_get_addr returns the current usb address, mostly for debugging
8420Sstevel@tonic-gate  * purposes. The address may change after hotremove/insert.
8430Sstevel@tonic-gate  * This address will not change on a disconnect/reconnect of open device.
8440Sstevel@tonic-gate  */
8450Sstevel@tonic-gate int usb_get_addr(dev_info_t *dip);
8460Sstevel@tonic-gate 
8470Sstevel@tonic-gate 
8480Sstevel@tonic-gate /*
8490Sstevel@tonic-gate  * usb_get_if_number returns USB_COMBINED_NODE or USB_DEVICE_NODE
8500Sstevel@tonic-gate  * if the driver is responsible for the entire device.
8510Sstevel@tonic-gate  * Otherwise it returns the interface number.
8520Sstevel@tonic-gate  */
8530Sstevel@tonic-gate #define	USB_COMBINED_NODE	-1
8540Sstevel@tonic-gate #define	USB_DEVICE_NODE		-2
8550Sstevel@tonic-gate 
8560Sstevel@tonic-gate int usb_get_if_number(
8570Sstevel@tonic-gate 	dev_info_t		*dip);
8580Sstevel@tonic-gate 
8590Sstevel@tonic-gate boolean_t usb_owns_device(
8600Sstevel@tonic-gate 	dev_info_t		*dip);
8610Sstevel@tonic-gate 
8620Sstevel@tonic-gate 
8630Sstevel@tonic-gate /*
8640Sstevel@tonic-gate  * ***************************************************************************
8650Sstevel@tonic-gate  * Pipe	Management definitions and functions
8660Sstevel@tonic-gate  * ***************************************************************************
8670Sstevel@tonic-gate  */
8680Sstevel@tonic-gate 
8690Sstevel@tonic-gate 
8700Sstevel@tonic-gate /*
8710Sstevel@tonic-gate  *
8720Sstevel@tonic-gate  * usb_pipe_state:
8730Sstevel@tonic-gate  *
8740Sstevel@tonic-gate  * PIPE_STATE_IDLE:
8750Sstevel@tonic-gate  *	The pipe's policy is set, but the pipe currently isn't transferring
8760Sstevel@tonic-gate  *	data.
8770Sstevel@tonic-gate  *
8780Sstevel@tonic-gate  * PIPE_STATE_ACTIVE:
8790Sstevel@tonic-gate  *	The pipe's policy has been set, and the pipe is able to transmit data.
8800Sstevel@tonic-gate  *	When a control or bulk pipe is opened, the pipe's state is
8810Sstevel@tonic-gate  *	automatically set to PIPE_STATE_ACTIVE.  For an interrupt or
8820Sstevel@tonic-gate  *	isochronous pipe, the pipe state becomes PIPE_STATE_ACTIVE once
8830Sstevel@tonic-gate  *	the polling on the pipe has been initiated.
8840Sstevel@tonic-gate  *
8850Sstevel@tonic-gate  * PIPE_STATE_ERROR:
8860Sstevel@tonic-gate  *	The device has generated a error on the pipe.  The client driver
8870Sstevel@tonic-gate  *	must call usb_pipe_reset() to clear any leftover state that's associated
8880Sstevel@tonic-gate  *	with the pipe, clear the data toggle, and reset the state of the pipe.
8890Sstevel@tonic-gate  *
8900Sstevel@tonic-gate  *	Calling usb_pipe_reset() on a control or bulk pipe resets the state to
8910Sstevel@tonic-gate  *	PIPE_STATE_ACTIVE.  Calling usb_pipe_reset() on an interrupt or
8920Sstevel@tonic-gate  *	isochronous pipe, resets the state to PIPE_STATE_IDLE.
8930Sstevel@tonic-gate  *
8940Sstevel@tonic-gate  * State Diagram for Bulk/Control
8950Sstevel@tonic-gate  *
8960Sstevel@tonic-gate  *			+-<--normal completion------------------<-------^
8970Sstevel@tonic-gate  *			|						|
8980Sstevel@tonic-gate  *			V						|
8990Sstevel@tonic-gate  * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE]
9000Sstevel@tonic-gate  *			^						|
9010Sstevel@tonic-gate  *			|						v
9020Sstevel@tonic-gate  *			- usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error
9030Sstevel@tonic-gate  *
9040Sstevel@tonic-gate  * State Diagram for Interrupt/Isochronous IN
9050Sstevel@tonic-gate  *
9060Sstevel@tonic-gate  *			+-<--usb_pipe_stop_isoc/intr_polling----<-------^
9070Sstevel@tonic-gate  *			|						|
9080Sstevel@tonic-gate  *			V						|
9090Sstevel@tonic-gate  * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE]
9100Sstevel@tonic-gate  *			^						|
9110Sstevel@tonic-gate  *			|						v
9120Sstevel@tonic-gate  *			+ usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error
9130Sstevel@tonic-gate  *
9140Sstevel@tonic-gate  * State Diagram for Interrupt/Isochronous OUT
9150Sstevel@tonic-gate  *
9160Sstevel@tonic-gate  *			+-<--normal completion------------------<-------^
9170Sstevel@tonic-gate  *			|						|
9180Sstevel@tonic-gate  *			V						|
9190Sstevel@tonic-gate  * usb_pipe_open-->[PIPE_STATE_IDLE]-usb_pipe_*_xfer->[PIPE_STATE_ACTIVE]
9200Sstevel@tonic-gate  *			^						|
9210Sstevel@tonic-gate  *			|						v
9220Sstevel@tonic-gate  *			+ usb_pipe_reset<-[PIPE_STATE_ERROR]<-device error
9230Sstevel@tonic-gate  *
9240Sstevel@tonic-gate  *
9250Sstevel@tonic-gate  * The following table indicates which operations are allowed with each
9260Sstevel@tonic-gate  * pipe state:
9270Sstevel@tonic-gate  *
9280Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9290Sstevel@tonic-gate  * ctrl/bulk	| idle	| active     | error  | sync closing | async closing|
9300Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9310Sstevel@tonic-gate  * pipe xfer	|  OK	|queue (USBA)| reject | reject	     | reject	    |
9320Sstevel@tonic-gate  * pipe reset	| no-op | OK	     |	OK    | reject	     | reject	    |
9330Sstevel@tonic-gate  * pipe close	|  OK	| wait&close |	OK    | no-op	     | no-op	    |
9340Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9350Sstevel@tonic-gate  *
9360Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9370Sstevel@tonic-gate  * intr/isoc IN | idle	| active     | error  | sync closing | async closing|
9380Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9390Sstevel@tonic-gate  * pipe xfer	|  OK	| reject     | reject | reject	     | reject	    |
9400Sstevel@tonic-gate  * pipe stoppoll| no-op | OK	     | no-op  | reject	     | reject	    |
9410Sstevel@tonic-gate  * pipe reset	| no-op | OK	     |	OK    | reject	     | reject	    |
9420Sstevel@tonic-gate  * pipe close	|  OK	| wait&close |	OK    | no-op	     | no-op	    |
9430Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9440Sstevel@tonic-gate  *
9450Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9460Sstevel@tonic-gate  * intr/isoc OUT| idle	| active     | error  | sync closing | async closing|
9470Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9480Sstevel@tonic-gate  * pipe xfer	|  OK	|queue (HCD) | reject | reject	     | reject	    |
9490Sstevel@tonic-gate  * pipe stoppoll| reject| reject     | reject | reject	     | reject	    |
9500Sstevel@tonic-gate  * pipe reset	| no-op | OK	     |	OK    | reject	     | reject	    |
9510Sstevel@tonic-gate  * pipe close	|  OK	| wait&close |	OK    | no-op	     | no-op	    |
9520Sstevel@tonic-gate  * -------------------------------------------------------------------------+
9530Sstevel@tonic-gate  */
9540Sstevel@tonic-gate typedef enum {
9550Sstevel@tonic-gate 	USB_PIPE_STATE_CLOSED		= 0,
9560Sstevel@tonic-gate 	USB_PIPE_STATE_IDLE		= 1,
9570Sstevel@tonic-gate 	USB_PIPE_STATE_ACTIVE		= 2,
9580Sstevel@tonic-gate 	USB_PIPE_STATE_ERROR		= 3,
9590Sstevel@tonic-gate 	USB_PIPE_STATE_CLOSING		= 4
9600Sstevel@tonic-gate } usb_pipe_state_t;
9610Sstevel@tonic-gate 
9620Sstevel@tonic-gate 
9630Sstevel@tonic-gate /*
9640Sstevel@tonic-gate  * pipe state control:
9650Sstevel@tonic-gate  *
9660Sstevel@tonic-gate  * return values:
9670Sstevel@tonic-gate  *	USB_SUCCESS	 - success
9680Sstevel@tonic-gate  *	USB_FAILURE	 - unspecified failure
9690Sstevel@tonic-gate  */
9700Sstevel@tonic-gate int usb_pipe_get_state(
9710Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
9720Sstevel@tonic-gate 	usb_pipe_state_t	*pipe_state,
9730Sstevel@tonic-gate 	usb_flags_t		flags);
9740Sstevel@tonic-gate 
9750Sstevel@tonic-gate 
9760Sstevel@tonic-gate /*
9770Sstevel@tonic-gate  * usb_pipe_policy
9780Sstevel@tonic-gate  *
9790Sstevel@tonic-gate  *	Pipe policy specifies how a pipe to an endpoint	should be used
9800Sstevel@tonic-gate  *	by the client driver and the HCD.
9810Sstevel@tonic-gate  */
9820Sstevel@tonic-gate typedef struct usb_pipe_policy {
9830Sstevel@tonic-gate 	/*
9840Sstevel@tonic-gate 	 * This is a hint indicating how many asynchronous operations
9850Sstevel@tonic-gate 	 * requiring a kernel thread will be concurrently active.
9860Sstevel@tonic-gate 	 * Allow at least one for synch exception callback handling
9870Sstevel@tonic-gate 	 * and another for asynchronous closing of pipes.
9880Sstevel@tonic-gate 	 */
9890Sstevel@tonic-gate 	uchar_t		pp_max_async_reqs;
9900Sstevel@tonic-gate } usb_pipe_policy_t;
9910Sstevel@tonic-gate 
9920Sstevel@tonic-gate 
9930Sstevel@tonic-gate /*
9940Sstevel@tonic-gate  * usb_pipe_open():
9950Sstevel@tonic-gate  *
9960Sstevel@tonic-gate  * Before using any pipe including the default pipe, it must be opened.
9970Sstevel@tonic-gate  * On success, a pipe handle is returned for use in other usb_pipe_*()
9980Sstevel@tonic-gate  * functions.
9990Sstevel@tonic-gate  *
10000Sstevel@tonic-gate  * The default pipe can only be opened by the hub driver.
10010Sstevel@tonic-gate  *
10020Sstevel@tonic-gate  * For isochronous and interrupt pipes, bandwidth has been allocated and
10030Sstevel@tonic-gate  * guaranteed.
10040Sstevel@tonic-gate  *
10050Sstevel@tonic-gate  * Only the default pipe can be shared.  All other control pipes are
10060Sstevel@tonic-gate  * excusively opened by default.  A pipe policy and endpoint descriptor
10070Sstevel@tonic-gate  * must always be provided except for default pipe.
10080Sstevel@tonic-gate  *
10090Sstevel@tonic-gate  * Arguments:
10100Sstevel@tonic-gate  *	dip		- devinfo ptr.
10110Sstevel@tonic-gate  *	ep		- endpoint descriptor pointer.
10120Sstevel@tonic-gate  *	pipe_policy	- pointer to pipe policy which provides hints on how
10130Sstevel@tonic-gate  *			  the pipe will be used.
10140Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP wait for resources to become
10150Sstevel@tonic-gate  *			  available.
10160Sstevel@tonic-gate  *	pipe_handle	- a pipe handle pointer.  on a successful open,
10170Sstevel@tonic-gate  *			  a pipe_handle is returned in this pointer.
10180Sstevel@tonic-gate  *
10190Sstevel@tonic-gate  * Return values:
10200Sstevel@tonic-gate  *	USB_SUCCESS	 - open succeeded.
10210Sstevel@tonic-gate  *	USB_FAILURE	 - unspecified open failure or pipe is already open.
10220Sstevel@tonic-gate  *	USB_NO_RESOURCES - no resources were available to complete the open.
10230Sstevel@tonic-gate  *	USB_NO_BANDWIDTH - no bandwidth available (isoc/intr pipes).
10240Sstevel@tonic-gate  *	USB_*		 - refer to list of all possible return values in
10250Sstevel@tonic-gate  *			   this file
10260Sstevel@tonic-gate  */
10270Sstevel@tonic-gate int usb_pipe_open(
10280Sstevel@tonic-gate 	dev_info_t		*dip,
10290Sstevel@tonic-gate 	usb_ep_descr_t		*ep,
10300Sstevel@tonic-gate 	usb_pipe_policy_t	*pipe_policy,
10310Sstevel@tonic-gate 	usb_flags_t		flags,
10320Sstevel@tonic-gate 	usb_pipe_handle_t	*pipe_handle);
10330Sstevel@tonic-gate 
10340Sstevel@tonic-gate 
10350Sstevel@tonic-gate /*
10360Sstevel@tonic-gate  * usb_pipe_close():
10370Sstevel@tonic-gate  *
10380Sstevel@tonic-gate  * Closes the pipe, releases resources and frees the pipe_handle.
10390Sstevel@tonic-gate  * Automatic polling, if active,  will be terminated.
10400Sstevel@tonic-gate  *
10410Sstevel@tonic-gate  * Arguments:
10420Sstevel@tonic-gate  *	dip		- devinfo ptr.
10430Sstevel@tonic-gate  *	pipe_handle	- pipe handle.
10440Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
10450Sstevel@tonic-gate  *				wait for resources, pipe
10460Sstevel@tonic-gate  *				to become free, and all callbacks completed.
10470Sstevel@tonic-gate  *	cb		- If USB_FLAGS_SLEEP has not been specified, a
10480Sstevel@tonic-gate  *			  callback will be performed.
10490Sstevel@tonic-gate  *	cb_arg		- the 2nd argument of the callback. Note that the
10500Sstevel@tonic-gate  *			  pipehandle will be zeroed and therefore not passed.
10510Sstevel@tonic-gate  *
10520Sstevel@tonic-gate  * Notes:
10530Sstevel@tonic-gate  *
10540Sstevel@tonic-gate  * Pipe close always succeeds regardless whether USB_FLAGS_SLEEP has been
10550Sstevel@tonic-gate  * specified or not.  An async close will always succeed if the hint in the
10560Sstevel@tonic-gate  * pipe policy has been correct about the max number of async requests
10570Sstevel@tonic-gate  * required.
10580Sstevel@tonic-gate  * In the unlikely event that no async requests can be queued, this
10590Sstevel@tonic-gate  * function will continue retrying before returning
10600Sstevel@tonic-gate  *
10610Sstevel@tonic-gate  * USBA prevents the client from submitting subsequent requests to a pipe
10620Sstevel@tonic-gate  * that is being closed.
10630Sstevel@tonic-gate  * Additional usb_pipe_close() requests on the same pipe causes USBA to
10640Sstevel@tonic-gate  * wait for the previous close(s) to complete.
10650Sstevel@tonic-gate  *
10660Sstevel@tonic-gate  * The pipe will not be destroyed until all activity on the pipe has
10670Sstevel@tonic-gate  * been drained, including outstanding request callbacks, async requests,
10680Sstevel@tonic-gate  * and other usb_pipe_*() calls.
10690Sstevel@tonic-gate  *
10700Sstevel@tonic-gate  * Calling usb_pipe_close() from a deferred callback (in kernel context)
10710Sstevel@tonic-gate  * with USB_FLAGS_SLEEP set, will cause deadlock
10720Sstevel@tonic-gate  */
10730Sstevel@tonic-gate void usb_pipe_close(
10740Sstevel@tonic-gate 	dev_info_t		*dip,
10750Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
10760Sstevel@tonic-gate 	usb_flags_t		flags,
10770Sstevel@tonic-gate 	void			(*cb)(
10780Sstevel@tonic-gate 				    usb_pipe_handle_t	ph,
10790Sstevel@tonic-gate 				    usb_opaque_t	arg,	/* cb arg */
10800Sstevel@tonic-gate 				    int			rval,
10810Sstevel@tonic-gate 				    usb_cb_flags_t	flags),
10820Sstevel@tonic-gate 	usb_opaque_t		cb_arg);
10830Sstevel@tonic-gate 
10840Sstevel@tonic-gate 
10850Sstevel@tonic-gate /*
10860Sstevel@tonic-gate  * usb_pipe_drain_reqs
10870Sstevel@tonic-gate  *	this function blocks until there are no more requests
10880Sstevel@tonic-gate  *	owned by this dip on the pipe
10890Sstevel@tonic-gate  *
10900Sstevel@tonic-gate  * Arguments:
10910Sstevel@tonic-gate  *	dip		- devinfo pointer
10920Sstevel@tonic-gate  *	pipe_handle	- opaque pipe handle
10930Sstevel@tonic-gate  *	timeout 	- timeout in seconds
10940Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
10950Sstevel@tonic-gate  *				wait for completion.
10960Sstevel@tonic-gate  *	cb		- if USB_FLAGS_SLEEP has not been specified
10970Sstevel@tonic-gate  *			  this callback function will be called on
10980Sstevel@tonic-gate  *			  completion. This callback may be NULL
10990Sstevel@tonic-gate  *			  and no notification of completion will then
11000Sstevel@tonic-gate  *			  be provided.
11010Sstevel@tonic-gate  *	cb_arg		- 2nd argument to callback function.
11020Sstevel@tonic-gate  *
11030Sstevel@tonic-gate  * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has
11040Sstevel@tonic-gate  * been specified
11050Sstevel@tonic-gate  *
11060Sstevel@tonic-gate  * Returns:
11070Sstevel@tonic-gate  *	USB_SUCCESS	- pipe successfully reset or request queued
11080Sstevel@tonic-gate  *	USB_FAILURE	- timeout
11090Sstevel@tonic-gate  *	USB_INVALID_PIPE - pipe is invalid or already closed
11100Sstevel@tonic-gate  *	USB_INVALID_CONTEXT - called from interrupt context
11110Sstevel@tonic-gate  *	USB_INVALID_ARGS - invalid arguments
11120Sstevel@tonic-gate  *	USB_*		- refer to return values defines in this file
11130Sstevel@tonic-gate  */
11140Sstevel@tonic-gate int usb_pipe_drain_reqs(
11150Sstevel@tonic-gate 	dev_info_t		*dip,
11160Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
11170Sstevel@tonic-gate 	uint_t			time,
11180Sstevel@tonic-gate 	usb_flags_t		flags,
11190Sstevel@tonic-gate 	void			(*cb)(
11200Sstevel@tonic-gate 				    usb_pipe_handle_t	ph,
11210Sstevel@tonic-gate 				    usb_opaque_t	arg,	/* cb arg */
11220Sstevel@tonic-gate 				    int			rval,
11230Sstevel@tonic-gate 				    usb_cb_flags_t	flags),
11240Sstevel@tonic-gate 	usb_opaque_t		cb_arg);
11250Sstevel@tonic-gate 
11260Sstevel@tonic-gate 
11270Sstevel@tonic-gate /*
11280Sstevel@tonic-gate  * Resetting a pipe: Refer to USB 2.0/10.5.2.2
11290Sstevel@tonic-gate  *	The pipe's requests are retired and the pipe is cleared.  The host state
11300Sstevel@tonic-gate  *	is moved to active. If the reflected endpoint state needs to be changed,
11310Sstevel@tonic-gate  *	that must be explicitly requested by the client driver.  The reset
11320Sstevel@tonic-gate  *	completes after all request callbacks have been completed.
11330Sstevel@tonic-gate  *
11340Sstevel@tonic-gate  * Arguments:
11350Sstevel@tonic-gate  *	dip		- devinfo pointer.
11360Sstevel@tonic-gate  *	pipe_handle	- pipe handle.
11370Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
11380Sstevel@tonic-gate  *				wait for completion.
11390Sstevel@tonic-gate  *	cb		- if USB_FLAGS_SLEEP has not been specified
11400Sstevel@tonic-gate  *			  this callback function will be called on
11410Sstevel@tonic-gate  *			  completion. This callback may be NULL
11420Sstevel@tonic-gate  *			  and no notification of completion will then
11430Sstevel@tonic-gate  *			  be provided.
11440Sstevel@tonic-gate  *	cb_arg		- 2nd argument to callback function.
11450Sstevel@tonic-gate  *
11460Sstevel@tonic-gate  * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has
11470Sstevel@tonic-gate  * been specified
11480Sstevel@tonic-gate  *
11490Sstevel@tonic-gate  * Note: Completion notification may be *before* all async request threads
11500Sstevel@tonic-gate  *	have completed but *after* all immediate callbacks have completed.
11510Sstevel@tonic-gate  */
11520Sstevel@tonic-gate void usb_pipe_reset(
11530Sstevel@tonic-gate 	dev_info_t		*dip,
11540Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
11550Sstevel@tonic-gate 	usb_flags_t		usb_flags,
11560Sstevel@tonic-gate 	void			(*cb)(
11570Sstevel@tonic-gate 					usb_pipe_handle_t ph,
11580Sstevel@tonic-gate 					usb_opaque_t	arg,
11590Sstevel@tonic-gate 					int		rval,
11600Sstevel@tonic-gate 					usb_cb_flags_t	flags),
11610Sstevel@tonic-gate 	usb_opaque_t		cb_arg);
11620Sstevel@tonic-gate 
11630Sstevel@tonic-gate 
11640Sstevel@tonic-gate /*
11650Sstevel@tonic-gate  * The client driver can store a private data pointer in the
11660Sstevel@tonic-gate  * pipe_handle.
11670Sstevel@tonic-gate  *
11680Sstevel@tonic-gate  * return values:
11690Sstevel@tonic-gate  *	USB_SUCCESS	 - success
11700Sstevel@tonic-gate  *	USB_FAILURE	 - unspecified failure
11710Sstevel@tonic-gate  */
11720Sstevel@tonic-gate int usb_pipe_set_private(
11730Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
11740Sstevel@tonic-gate 	usb_opaque_t		data);
11750Sstevel@tonic-gate 
11760Sstevel@tonic-gate 
11770Sstevel@tonic-gate usb_opaque_t usb_pipe_get_private(
11780Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle);
11790Sstevel@tonic-gate 
11800Sstevel@tonic-gate 
11810Sstevel@tonic-gate /*
11820Sstevel@tonic-gate  * ***************************************************************************
11830Sstevel@tonic-gate  * Transfer request definitions and functions
11840Sstevel@tonic-gate  * ***************************************************************************
11850Sstevel@tonic-gate  */
11860Sstevel@tonic-gate 
11870Sstevel@tonic-gate 
11880Sstevel@tonic-gate /*
11890Sstevel@tonic-gate  * USB xfer request attributes.
11900Sstevel@tonic-gate  * Set by the client driver, more than one may be set
11910Sstevel@tonic-gate  *
11920Sstevel@tonic-gate  * SHORT_XFER_OK if less data is transferred than specified, no error is
11930Sstevel@tonic-gate  *		returned.
11940Sstevel@tonic-gate  * AUTOCLEARING	if there is an exception, the pipe will be reset first
11950Sstevel@tonic-gate  *		and a functional stall cleared before a callback is done.
11960Sstevel@tonic-gate  * PIPE_RESET	if there is an exception, the pipe will be reset only
11970Sstevel@tonic-gate  * ONE_XFER	polling will automatically stop on the first callback.
11980Sstevel@tonic-gate  * ISOC_START_FRAME use startframe specified.
11990Sstevel@tonic-gate  * USB_ATTRS_ISOC_XFER_ASAP let the host controller decide on the first
12000Sstevel@tonic-gate  *		available frame.
12010Sstevel@tonic-gate  *
12020Sstevel@tonic-gate  * USB_ATTRS_ISOC_START_FRAME and USB_ATTRS_ISOC_XFER_ASAP are mutually
12030Sstevel@tonic-gate  * exclusive
12040Sstevel@tonic-gate  *
12050Sstevel@tonic-gate  * combinations of flag and attributes:
12060Sstevel@tonic-gate  *
12070Sstevel@tonic-gate  * usb_flags	usb_req_attrs			semantics
12080Sstevel@tonic-gate  * ---------------------------------------------------------
12090Sstevel@tonic-gate  * SLEEP	USB_ATTRS_SHORT_XFER_OK		legal for IN pipes
12100Sstevel@tonic-gate  * SLEEP	USB_ATTRS_AUTOCLEARING		legal
12110Sstevel@tonic-gate  * SLEEP	USB_ATTRS_PIPE_RESET		legal
12120Sstevel@tonic-gate  * SLEEP	USB_ATTRS_ONE_XFER		legal for interrupt IN pipes
12130Sstevel@tonic-gate  * SLEEP	USB_ATTRS_ISOC_START_FRAME	illegal
12140Sstevel@tonic-gate  * SLEEP	USB_ATTRS_ISOC_XFER_ASAP	illegal
12150Sstevel@tonic-gate  *
12160Sstevel@tonic-gate  * noSLEEP	USB_ATTRS_SHORT_XFER_OK		legal for all IN pipes
12170Sstevel@tonic-gate  * noSLEEP	USB_ATTRS_AUTOCLEARING		legal
12180Sstevel@tonic-gate  * noSLEEP	USB_ATTRS_PIPE_RESET		legal
12190Sstevel@tonic-gate  * noSLEEP	USB_ATTRS_ONE_XFER		legal
12200Sstevel@tonic-gate  * noSLEEP	USB_ATTRS_ISOC_START_FRAME	legal
12210Sstevel@tonic-gate  * noSLEEP	USB_ATTRS_ISOC_XFER_ASAP	legal
12220Sstevel@tonic-gate  */
12230Sstevel@tonic-gate typedef enum {
12240Sstevel@tonic-gate 	USB_ATTRS_NONE			= 0,
12250Sstevel@tonic-gate 
12260Sstevel@tonic-gate 	/* only ctrl/bulk/intr IN pipes */
12270Sstevel@tonic-gate 	USB_ATTRS_SHORT_XFER_OK		= 0x01,	/* short data xfer is ok */
12280Sstevel@tonic-gate 	USB_ATTRS_PIPE_RESET		= 0x02,	/* reset pipe only on exc */
12290Sstevel@tonic-gate 	USB_ATTRS_AUTOCLEARING		= 0x12, /* autoclear STALLs */
12300Sstevel@tonic-gate 
12310Sstevel@tonic-gate 	/* intr pipes only: one poll with data */
12320Sstevel@tonic-gate 	USB_ATTRS_ONE_XFER		= 0x100,
12330Sstevel@tonic-gate 
12340Sstevel@tonic-gate 	/* only for isoch pipe */
12350Sstevel@tonic-gate 	USB_ATTRS_ISOC_START_FRAME	= 0x200, /* Starting frame# specified */
12360Sstevel@tonic-gate 	USB_ATTRS_ISOC_XFER_ASAP	= 0x400	/* HCD decides START_FRAME#  */
12370Sstevel@tonic-gate } usb_req_attrs_t;
12380Sstevel@tonic-gate 
12390Sstevel@tonic-gate 
12400Sstevel@tonic-gate /*
12410Sstevel@tonic-gate  * Note: client drivers are required to provide data buffers (mblks) for most
12420Sstevel@tonic-gate  * requests
12430Sstevel@tonic-gate  *			IN		OUT
12440Sstevel@tonic-gate  * ctlr request		if wLength > 0	if wLength > 0
12450Sstevel@tonic-gate  * bulk request		yes		yes
12460Sstevel@tonic-gate  * intr request		no		yes
12470Sstevel@tonic-gate  * isoc request		no		yes
12480Sstevel@tonic-gate  */
12490Sstevel@tonic-gate 
12500Sstevel@tonic-gate /*
12510Sstevel@tonic-gate  * ===========================================================================
12520Sstevel@tonic-gate  * USB control request management
12530Sstevel@tonic-gate  * ===========================================================================
12540Sstevel@tonic-gate  */
12550Sstevel@tonic-gate 
12560Sstevel@tonic-gate /*
12570Sstevel@tonic-gate  * A client driver allocates and uses the usb_ctrl_req_t for all control
12580Sstevel@tonic-gate  * pipe requests.
12590Sstevel@tonic-gate  *
12600Sstevel@tonic-gate  * Direction of the xfer will be determined based on the bmRequestType.
12610Sstevel@tonic-gate  *
12620Sstevel@tonic-gate  * NULL callbacks are permitted, timeout = 0 indicates infinite timeout.
12630Sstevel@tonic-gate  * All timeouts are in seconds.
12640Sstevel@tonic-gate  *
12650Sstevel@tonic-gate  * All fields are initialized by client except for data on IN request
12660Sstevel@tonic-gate  * in which case the client is responsible for deallocating.
12670Sstevel@tonic-gate  *
12680Sstevel@tonic-gate  * Control requests may be reused.  The client driver is responsible
12690Sstevel@tonic-gate  * for reinitializing some fields, eg data read/write pointers.
12700Sstevel@tonic-gate  *
12710Sstevel@tonic-gate  * Control requests can be queued.
12720Sstevel@tonic-gate  */
12730Sstevel@tonic-gate typedef struct usb_ctrl_req {
12740Sstevel@tonic-gate 	uint8_t		ctrl_bmRequestType; /* characteristics of request */
12750Sstevel@tonic-gate 	uint8_t		ctrl_bRequest;	/* specific request		*/
12760Sstevel@tonic-gate 	uint16_t	ctrl_wValue;	/* varies according to request	*/
12770Sstevel@tonic-gate 	uint16_t	ctrl_wIndex;	/* index or offset		*/
12780Sstevel@tonic-gate 	uint16_t	ctrl_wLength;	/* number of bytes to xfer	*/
12790Sstevel@tonic-gate 
12800Sstevel@tonic-gate 	mblk_t		*ctrl_data;	/* the data for the data phase	*/
12810Sstevel@tonic-gate 					/* IN: allocated by HCD		*/
12820Sstevel@tonic-gate 					/* OUT: allocated by client	*/
12830Sstevel@tonic-gate 	uint_t		ctrl_timeout;	/* how long before HCD retires req */
12840Sstevel@tonic-gate 	usb_opaque_t	ctrl_client_private; /* for client private info	*/
12850Sstevel@tonic-gate 	usb_req_attrs_t ctrl_attributes; /* attributes for this req */
12860Sstevel@tonic-gate 
12870Sstevel@tonic-gate 	/*
12880Sstevel@tonic-gate 	 * callback function for control pipe requests
12890Sstevel@tonic-gate 	 *
12900Sstevel@tonic-gate 	 * a normal callback will be done upon:
12910Sstevel@tonic-gate 	 *	- successful completion of a control pipe request
12920Sstevel@tonic-gate 	 *
12930Sstevel@tonic-gate 	 * callback arguments are:
12940Sstevel@tonic-gate 	 *	- the pipe_handle
12950Sstevel@tonic-gate 	 *	- usb_ctrl_req_t pointer
12960Sstevel@tonic-gate 	 */
12970Sstevel@tonic-gate 	void		(*ctrl_cb)(usb_pipe_handle_t ph,
12980Sstevel@tonic-gate 				struct usb_ctrl_req *req);
12990Sstevel@tonic-gate 
13000Sstevel@tonic-gate 	/*
13010Sstevel@tonic-gate 	 * exception callback function for control pipe
13020Sstevel@tonic-gate 	 *
13030Sstevel@tonic-gate 	 * a exception callback will be done upon:
13040Sstevel@tonic-gate 	 *	- an exception/error (all types)
13050Sstevel@tonic-gate 	 *	- partial xfer of data unless SHORT_XFER_OK has been set
13060Sstevel@tonic-gate 	 *
13070Sstevel@tonic-gate 	 * callback arguments are:
13080Sstevel@tonic-gate 	 *	- the pipe_handle
13090Sstevel@tonic-gate 	 *	- usb_ctrl_req_t pointer
13100Sstevel@tonic-gate 	 *
13110Sstevel@tonic-gate 	 * if USB_ATTRS_AUTOCLEARING was set, autoclearing will be attempted
13120Sstevel@tonic-gate 	 * and usb_cb_flags_t in usb_ctrl_req may indicate what was done
13130Sstevel@tonic-gate 	 */
13140Sstevel@tonic-gate 	void		(*ctrl_exc_cb)(usb_pipe_handle_t ph,
13150Sstevel@tonic-gate 				struct usb_ctrl_req *req);
13160Sstevel@tonic-gate 
13170Sstevel@tonic-gate 	/* set by USBA/HCD on completion */
13180Sstevel@tonic-gate 	usb_cr_t	ctrl_completion_reason;	/* set by HCD */
13190Sstevel@tonic-gate 	usb_cb_flags_t	ctrl_cb_flags;  /* Callback context / handling flgs */
13200Sstevel@tonic-gate } usb_ctrl_req_t;
13210Sstevel@tonic-gate 
13220Sstevel@tonic-gate 
13230Sstevel@tonic-gate /*
13240Sstevel@tonic-gate  * In the setup packet, the descriptor type is passed in the high byte of the
13250Sstevel@tonic-gate  * wValue field.
13260Sstevel@tonic-gate  * descriptor types:
13270Sstevel@tonic-gate  */
13280Sstevel@tonic-gate #define	USB_DESCR_TYPE_SETUP_DEV		0x0100
13290Sstevel@tonic-gate #define	USB_DESCR_TYPE_SETUP_CFG		0x0200
13300Sstevel@tonic-gate #define	USB_DESCR_TYPE_SETUP_STRING		0x0300
13310Sstevel@tonic-gate #define	USB_DESCR_TYPE_SETUP_IF			0x0400
13320Sstevel@tonic-gate #define	USB_DESCR_TYPE_SETUP_EP			0x0500
13330Sstevel@tonic-gate #define	USB_DESCR_TYPE_SETUP_DEV_QLF		0x0600
13340Sstevel@tonic-gate #define	USB_DESCR_TYPE_SETUP_OTHER_SPEED_CFG	0x0700
13350Sstevel@tonic-gate #define	USB_DESCR_TYPE_SETUP_IF_PWR		0x0800
13360Sstevel@tonic-gate 
13370Sstevel@tonic-gate #define	USB_DESCR_TYPE_DEV			0x01
13380Sstevel@tonic-gate #define	USB_DESCR_TYPE_CFG			0x02
13390Sstevel@tonic-gate #define	USB_DESCR_TYPE_STRING			0x03
13400Sstevel@tonic-gate #define	USB_DESCR_TYPE_IF			0x04
13410Sstevel@tonic-gate #define	USB_DESCR_TYPE_EP			0x05
13420Sstevel@tonic-gate #define	USB_DESCR_TYPE_DEV_QLF			0x06
13430Sstevel@tonic-gate #define	USB_DESCR_TYPE_OTHER_SPEED_CFG		0x07
13440Sstevel@tonic-gate #define	USB_DESCR_TYPE_IF_PWR			0x08
1345*3341Sgc161489 #define	USB_DESCR_TYPE_IA			0x0B
13460Sstevel@tonic-gate 
13470Sstevel@tonic-gate /*
13480Sstevel@tonic-gate  * device request type
13490Sstevel@tonic-gate  */
13500Sstevel@tonic-gate #define	USB_DEV_REQ_HOST_TO_DEV		0x00
13510Sstevel@tonic-gate #define	USB_DEV_REQ_DEV_TO_HOST		0x80
13520Sstevel@tonic-gate #define	USB_DEV_REQ_DIR_MASK		0x80
13530Sstevel@tonic-gate 
13540Sstevel@tonic-gate #define	USB_DEV_REQ_TYPE_STANDARD	0x00
13550Sstevel@tonic-gate #define	USB_DEV_REQ_TYPE_CLASS		0x20
13560Sstevel@tonic-gate #define	USB_DEV_REQ_TYPE_VENDOR		0x40
13570Sstevel@tonic-gate #define	USB_DEV_REQ_TYPE_MASK		0x60
13580Sstevel@tonic-gate 
13590Sstevel@tonic-gate #define	USB_DEV_REQ_RCPT_DEV		0x00
13600Sstevel@tonic-gate #define	USB_DEV_REQ_RCPT_IF		0x01
13610Sstevel@tonic-gate #define	USB_DEV_REQ_RCPT_EP		0x02
13620Sstevel@tonic-gate #define	USB_DEV_REQ_RCPT_OTHER		0x03
13630Sstevel@tonic-gate #define	USB_DEV_REQ_RCPT_MASK		0x03
13640Sstevel@tonic-gate 
13650Sstevel@tonic-gate /*
13660Sstevel@tonic-gate  * device request
13670Sstevel@tonic-gate  */
13680Sstevel@tonic-gate #define	USB_REQ_GET_STATUS		0x00
13690Sstevel@tonic-gate #define	USB_REQ_CLEAR_FEATURE		0x01
13700Sstevel@tonic-gate #define	USB_REQ_SET_FEATURE		0x03
13710Sstevel@tonic-gate #define	USB_REQ_SET_ADDRESS		0x05
13720Sstevel@tonic-gate #define	USB_REQ_GET_DESCR		0x06
13730Sstevel@tonic-gate #define	USB_REQ_SET_DESCR		0x07
13740Sstevel@tonic-gate #define	USB_REQ_GET_CFG			0x08
13750Sstevel@tonic-gate #define	USB_REQ_SET_CFG			0x09
13760Sstevel@tonic-gate #define	USB_REQ_GET_IF			0x0a
13770Sstevel@tonic-gate #define	USB_REQ_SET_IF			0x0b
13780Sstevel@tonic-gate #define	USB_REQ_SYNC_FRAME		0x0c
13790Sstevel@tonic-gate 
13800Sstevel@tonic-gate /* language ID for string descriptors */
13810Sstevel@tonic-gate #define	USB_LANG_ID			0x0409
13820Sstevel@tonic-gate 
13830Sstevel@tonic-gate /*
13840Sstevel@tonic-gate  * Standard Feature Selectors
13850Sstevel@tonic-gate  */
13860Sstevel@tonic-gate #define	USB_EP_HALT			0x0000
13870Sstevel@tonic-gate #define	USB_DEV_REMOTE_WAKEUP		0x0001
13880Sstevel@tonic-gate #define	USB_DEV_TEST_MODE		0x0002
13890Sstevel@tonic-gate 
13900Sstevel@tonic-gate 
13910Sstevel@tonic-gate /*
13920Sstevel@tonic-gate  * Allocate usb control request
13930Sstevel@tonic-gate  *
13940Sstevel@tonic-gate  * Arguments:
13950Sstevel@tonic-gate  *	dip	- dev_info pointer of the client driver
13960Sstevel@tonic-gate  *	len	- length of "data" for this control request.
13970Sstevel@tonic-gate  *		  if 0, no mblk is alloc'ed
13980Sstevel@tonic-gate  *	flags	- USB_FLAGS_SLEEP: Sleep if resources are not available
13990Sstevel@tonic-gate  *
14000Sstevel@tonic-gate  * Return Values:
14010Sstevel@tonic-gate  *	usb_ctrl_req_t pointer on success, NULL on failure
14020Sstevel@tonic-gate  *
14030Sstevel@tonic-gate  * Implementation NOTE: the dip allows checking on detach for memory leaks
14040Sstevel@tonic-gate  */
14050Sstevel@tonic-gate usb_ctrl_req_t *usb_alloc_ctrl_req(
14060Sstevel@tonic-gate 	dev_info_t		*dip,
14070Sstevel@tonic-gate 	size_t			len,
14080Sstevel@tonic-gate 	usb_flags_t		flags);
14090Sstevel@tonic-gate 
14100Sstevel@tonic-gate 
14110Sstevel@tonic-gate /*
14120Sstevel@tonic-gate  * free USB control request
14130Sstevel@tonic-gate  */
14140Sstevel@tonic-gate void usb_free_ctrl_req(
14150Sstevel@tonic-gate 	usb_ctrl_req_t	*reqp);
14160Sstevel@tonic-gate 
14170Sstevel@tonic-gate 
14180Sstevel@tonic-gate /*
14190Sstevel@tonic-gate  * usb_pipe_ctrl_xfer();
14200Sstevel@tonic-gate  *	Client driver calls this function to issue the control
14210Sstevel@tonic-gate  *	request to the USBA which will queue or transport it to the device
14220Sstevel@tonic-gate  *
14230Sstevel@tonic-gate  * Arguments:
14240Sstevel@tonic-gate  *	pipe_handle	- control pipe pipehandle (obtained via usb_pipe_open()
14250Sstevel@tonic-gate  *	reqp		- pointer to control request
14260Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
14270Sstevel@tonic-gate  *				wait for the request to complete
14280Sstevel@tonic-gate  *
14290Sstevel@tonic-gate  * Return values:
14300Sstevel@tonic-gate  *	USB_SUCCESS	- successfully queued (no sleep) or successfully
14310Sstevel@tonic-gate  *			  completed (with sleep specified)
14320Sstevel@tonic-gate  *	USB_FAILURE	- failure
14330Sstevel@tonic-gate  *	USB_NO_RESOURCES - no resources
14340Sstevel@tonic-gate  */
14350Sstevel@tonic-gate int usb_pipe_ctrl_xfer(usb_pipe_handle_t pipe_handle,
14360Sstevel@tonic-gate 	usb_ctrl_req_t	*reqp,
14370Sstevel@tonic-gate 	usb_flags_t		flags);
14380Sstevel@tonic-gate 
14390Sstevel@tonic-gate 
14400Sstevel@tonic-gate /*
14410Sstevel@tonic-gate  * ---------------------------------------------------------------------------
14420Sstevel@tonic-gate  * Wrapper function which allocates and deallocates a request structure, and
14430Sstevel@tonic-gate  * performs a control transfer.
14440Sstevel@tonic-gate  * ---------------------------------------------------------------------------
14450Sstevel@tonic-gate  */
14460Sstevel@tonic-gate 
14470Sstevel@tonic-gate /*
14480Sstevel@tonic-gate  * Setup arguments for usb_pipe_ctrl_xfer_wait:
14490Sstevel@tonic-gate  *
14500Sstevel@tonic-gate  *	bmRequestType	- characteristics of request
14510Sstevel@tonic-gate  *	bRequest	- specific request
14520Sstevel@tonic-gate  *	wValue		- varies according to request
14530Sstevel@tonic-gate  *	wIndex		- index or offset
14540Sstevel@tonic-gate  *	wLength		- number of bytes to xfer
14550Sstevel@tonic-gate  *	attrs		- required request attributes
14560Sstevel@tonic-gate  *	data		- pointer to pointer to data
14570Sstevel@tonic-gate  *				IN: HCD will allocate data
14580Sstevel@tonic-gate  *				OUT: clients driver allocates data
14590Sstevel@tonic-gate  */
14600Sstevel@tonic-gate typedef struct usb_ctrl_setup {
14610Sstevel@tonic-gate 	uchar_t		bmRequestType;
14620Sstevel@tonic-gate 	uchar_t		bRequest;
14630Sstevel@tonic-gate 	uint16_t	wValue;
14640Sstevel@tonic-gate 	uint16_t	wIndex;
14650Sstevel@tonic-gate 	uint16_t	wLength;
14660Sstevel@tonic-gate 	usb_req_attrs_t	attrs;
14670Sstevel@tonic-gate } usb_ctrl_setup_t;
14680Sstevel@tonic-gate 
14690Sstevel@tonic-gate 
14700Sstevel@tonic-gate /*
14710Sstevel@tonic-gate  * usb_pipe_ctrl_xfer_wait():
14720Sstevel@tonic-gate  *	for simple synchronous control transactions this wrapper function
14730Sstevel@tonic-gate  *	will perform the allocation, xfer, and deallocation.
14740Sstevel@tonic-gate  *	USB_ATTRS_AUTOCLEARING will be enabled
14750Sstevel@tonic-gate  *
14760Sstevel@tonic-gate  * Arguments:
14770Sstevel@tonic-gate  *	pipe_handle	- control pipe pipehandle (obtained via usb_pipe_open())
14780Sstevel@tonic-gate  *	setup		- contains pointer to client's devinfo,
14790Sstevel@tonic-gate  *			  setup descriptor params, attributes and data
14800Sstevel@tonic-gate  *	completion_reason - completion status.
14810Sstevel@tonic-gate  *	cb_flags	- request completions flags.
14820Sstevel@tonic-gate  *	flags		- none.
14830Sstevel@tonic-gate  *
14840Sstevel@tonic-gate  * Return Values:
14850Sstevel@tonic-gate  *	USB_SUCCESS	- request successfully executed.
14860Sstevel@tonic-gate  *	USB_FAILURE	- request failed.
14870Sstevel@tonic-gate  *	USB_*		- refer to list of all possible return values in
14880Sstevel@tonic-gate  *			  this file
14890Sstevel@tonic-gate  *
14900Sstevel@tonic-gate  * NOTES:
14910Sstevel@tonic-gate  * - in the case of failure, the client should check completion_reason and
14920Sstevel@tonic-gate  *   and cb_flags and determine further recovery action
14930Sstevel@tonic-gate  * - the client should check data and if non-zero, free the data on
14940Sstevel@tonic-gate  *   completion
14950Sstevel@tonic-gate  */
14960Sstevel@tonic-gate int usb_pipe_ctrl_xfer_wait(
14970Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
14980Sstevel@tonic-gate 	usb_ctrl_setup_t	*setup,
14990Sstevel@tonic-gate 	mblk_t			**data,
15000Sstevel@tonic-gate 	usb_cr_t		*completion_reason,
15010Sstevel@tonic-gate 	usb_cb_flags_t		*cb_flags,
15020Sstevel@tonic-gate 	usb_flags_t		flags);
15030Sstevel@tonic-gate 
15040Sstevel@tonic-gate 
15050Sstevel@tonic-gate /*
15060Sstevel@tonic-gate  * ---------------------------------------------------------------------------
15070Sstevel@tonic-gate  * Some utility defines and wrapper functions for standard control requests.
15080Sstevel@tonic-gate  * ---------------------------------------------------------------------------
15090Sstevel@tonic-gate  */
15100Sstevel@tonic-gate 
15110Sstevel@tonic-gate /*
15120Sstevel@tonic-gate  *
15130Sstevel@tonic-gate  * Status bits returned by a usb_get_status().
15140Sstevel@tonic-gate  */
15150Sstevel@tonic-gate #define	USB_DEV_SLF_PWRD_STATUS	1	/* Supports Self Power	 */
15160Sstevel@tonic-gate #define	USB_DEV_RWAKEUP_STATUS	2	/* Remote Wakeup Enabled */
15170Sstevel@tonic-gate #define	USB_EP_HALT_STATUS	1	/* Endpoint is Halted	 */
15180Sstevel@tonic-gate #define	USB_IF_STATUS		0	/* Interface Status is 0 */
15190Sstevel@tonic-gate 
15200Sstevel@tonic-gate /* length of data returned by USB_REQ_GET_STATUS */
15210Sstevel@tonic-gate #define	USB_GET_STATUS_LEN		2
15220Sstevel@tonic-gate 
15230Sstevel@tonic-gate /*
15240Sstevel@tonic-gate  * wrapper function returning status of device, interface, or endpoint
15250Sstevel@tonic-gate  *
15260Sstevel@tonic-gate  * Arguments:
15270Sstevel@tonic-gate  *	dip		- devinfo pointer.
15280Sstevel@tonic-gate  *	ph		- pipe handle
15290Sstevel@tonic-gate  *	type		- bmRequestType to be used
15300Sstevel@tonic-gate  *	what		- 0 for device, otherwise interface or ep number
15310Sstevel@tonic-gate  *	status		- pointer to returned status.
15320Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP (mandatory)
15330Sstevel@tonic-gate  *
15340Sstevel@tonic-gate  * Return Values:
15350Sstevel@tonic-gate  *	valid usb_status_t	or USB_FAILURE
15360Sstevel@tonic-gate  *
15370Sstevel@tonic-gate  */
15380Sstevel@tonic-gate int usb_get_status(
15390Sstevel@tonic-gate 	dev_info_t		*dip,
15400Sstevel@tonic-gate 	usb_pipe_handle_t	ph,
15410Sstevel@tonic-gate 	uint_t			type,	/* bmRequestType */
15420Sstevel@tonic-gate 	uint_t			what,	/* 0, interface, endpoint number */
15430Sstevel@tonic-gate 	uint16_t		*status,
15440Sstevel@tonic-gate 	usb_flags_t		flags);
15450Sstevel@tonic-gate 
15460Sstevel@tonic-gate 
15470Sstevel@tonic-gate /*
15480Sstevel@tonic-gate  * function for clearing feature of device, interface, or endpoint
15490Sstevel@tonic-gate  *
15500Sstevel@tonic-gate  * Arguments:
15510Sstevel@tonic-gate  *	dip		- devinfo pointer.
15520Sstevel@tonic-gate  *	type		- bmRequestType to be used
15530Sstevel@tonic-gate  *	feature		- feature to be cleared
15540Sstevel@tonic-gate  *	what		- 0 for device, otherwise interface or ep number
15550Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP (mandatory)
15560Sstevel@tonic-gate  *	cb		- if USB_FLAGS_SLEEP has not been specified
15570Sstevel@tonic-gate  *			  this callback function will be called on
15580Sstevel@tonic-gate  *			  completion. This callback may be NULL
15590Sstevel@tonic-gate  *			  and no notification of completion will then
15600Sstevel@tonic-gate  *			  be provided.
15610Sstevel@tonic-gate  *	cb_arg		- 2nd argument to callback function.
15620Sstevel@tonic-gate  *
15630Sstevel@tonic-gate  * Return Values:
15640Sstevel@tonic-gate  *	USB_SUCCESS	clearing feature succeeded
15650Sstevel@tonic-gate  *	USB_FAILURE	clearing feature failed
15660Sstevel@tonic-gate  *	USB_*		refer to list of all possible return values in
15670Sstevel@tonic-gate  *			this file
15680Sstevel@tonic-gate  */
15690Sstevel@tonic-gate int usb_clr_feature(
15700Sstevel@tonic-gate 	dev_info_t		*dip,
15710Sstevel@tonic-gate 	uint_t			type,	/* bmRequestType */
15720Sstevel@tonic-gate 	uint_t			feature,
15730Sstevel@tonic-gate 	uint_t			what,	/* 0, interface, endpoint number */
15740Sstevel@tonic-gate 	usb_flags_t		flags,
15750Sstevel@tonic-gate 	void			(*cb)(
15760Sstevel@tonic-gate 					usb_pipe_handle_t ph,
15770Sstevel@tonic-gate 					usb_opaque_t	arg,
15780Sstevel@tonic-gate 					int		rval,
15790Sstevel@tonic-gate 					usb_cb_flags_t	flags),
15800Sstevel@tonic-gate 	usb_opaque_t		cb_arg);
15810Sstevel@tonic-gate 
15820Sstevel@tonic-gate 
15830Sstevel@tonic-gate /*
15840Sstevel@tonic-gate  * usb_set_cfg():
15850Sstevel@tonic-gate  *	Sets the configuration.  Use this function with caution as
15860Sstevel@tonic-gate  *	the framework is normally responsible for configuration changes.
15870Sstevel@tonic-gate  *	Changing configuration will fail if pipes are still open or
15880Sstevel@tonic-gate  *	when invoked from a driver bound to an interface on a composite
15890Sstevel@tonic-gate  *	device. This function access the device and blocks.
15900Sstevel@tonic-gate  *
15910Sstevel@tonic-gate  * Arguments:
15920Sstevel@tonic-gate  *	dip		- devinfo pointer.
15930Sstevel@tonic-gate  *	cfg_index	- Index of configuration to set.  Corresponds to
15940Sstevel@tonic-gate  *			  index in the usb_client_dev_data_t tree of
15950Sstevel@tonic-gate  *			  configurations.  See usb_client_dev_data_t(9F).
15960Sstevel@tonic-gate  *	usb_flags	- USB_FLAGS_SLEEP:
15970Sstevel@tonic-gate  *				wait for completion.
15980Sstevel@tonic-gate  *	cb		- if USB_FLAGS_SLEEP has not been specified
15990Sstevel@tonic-gate  *			  this callback function will be called on
16000Sstevel@tonic-gate  *			  completion. This callback may be NULL
16010Sstevel@tonic-gate  *			  and no notification of completion will then
16020Sstevel@tonic-gate  *			  be provided.
16030Sstevel@tonic-gate  *	cb_arg		- 2nd argument to callback function.
16040Sstevel@tonic-gate  *
16050Sstevel@tonic-gate  * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has
16060Sstevel@tonic-gate  * been specified
16070Sstevel@tonic-gate  *
16080Sstevel@tonic-gate  * Return Values:
16090Sstevel@tonic-gate  *	USB_SUCCESS:	new configuration was set or async request
16100Sstevel@tonic-gate  *			submitted successfully.
16110Sstevel@tonic-gate  *	USB_FAILURE:	new configuration could not be set because
16120Sstevel@tonic-gate  *			it may been illegal configuration or this
16130Sstevel@tonic-gate  *			caller was not allowed to change configs or
16140Sstevel@tonic-gate  *			pipes were still open or async request
16150Sstevel@tonic-gate  *			could not be submitted.
16160Sstevel@tonic-gate  *	USB_*		refer to list of all possible return values in
16170Sstevel@tonic-gate  *			this file
16180Sstevel@tonic-gate  *
16190Sstevel@tonic-gate  * the pipe handle argument in the callback will be the default pipe handle
16200Sstevel@tonic-gate  */
16210Sstevel@tonic-gate int usb_set_cfg(
16220Sstevel@tonic-gate 	dev_info_t		*dip,
16230Sstevel@tonic-gate 	uint_t			cfg_index,
16240Sstevel@tonic-gate 	usb_flags_t		usb_flags,
16250Sstevel@tonic-gate 	void			(*cb)(
16260Sstevel@tonic-gate 					usb_pipe_handle_t ph,
16270Sstevel@tonic-gate 					usb_opaque_t	arg,
16280Sstevel@tonic-gate 					int		rval,
16290Sstevel@tonic-gate 					usb_cb_flags_t	flags),
16300Sstevel@tonic-gate 	usb_opaque_t		cb_arg);
16310Sstevel@tonic-gate 
16320Sstevel@tonic-gate 
16330Sstevel@tonic-gate /*
16340Sstevel@tonic-gate  * usb_get_cfg:
16350Sstevel@tonic-gate  *	dip		- pointer to devinfo node
16360Sstevel@tonic-gate  *	cfgval		- pointer to cfgval
16370Sstevel@tonic-gate  *	usb_flags	- none, will always block
16380Sstevel@tonic-gate  *
16390Sstevel@tonic-gate  * return values:
16400Sstevel@tonic-gate  *	USB_SUCCESS	- current cfg value is returned to cfgval
16410Sstevel@tonic-gate  *	USB_*		- refer to list of all possible return values in
16420Sstevel@tonic-gate  *			  this file
16430Sstevel@tonic-gate  */
16440Sstevel@tonic-gate int usb_get_cfg(
16450Sstevel@tonic-gate 	dev_info_t		*dip,
16460Sstevel@tonic-gate 	uint_t			*cfgval,
16470Sstevel@tonic-gate 	usb_flags_t		usb_flags);
16480Sstevel@tonic-gate 
16490Sstevel@tonic-gate 
16500Sstevel@tonic-gate /*
16510Sstevel@tonic-gate  * The following functions set or get the alternate interface
16520Sstevel@tonic-gate  * setting.
16530Sstevel@tonic-gate  *
16540Sstevel@tonic-gate  * usb_set_alt_if:
16550Sstevel@tonic-gate  *	dip		- pointer to devinfo node
16560Sstevel@tonic-gate  *	interface	- interface
16570Sstevel@tonic-gate  *	alt_number	- alternate to set to
16580Sstevel@tonic-gate  *	usb_flags	- USB_FLAGS_SLEEP:
16590Sstevel@tonic-gate  *				wait for completion.
16600Sstevel@tonic-gate  *	cb		- if USB_FLAGS_SLEEP has not been specified
16610Sstevel@tonic-gate  *			  this callback function will be called on
16620Sstevel@tonic-gate  *			  completion. This callback may be NULL
16630Sstevel@tonic-gate  *			  and no notification of completion will then
16640Sstevel@tonic-gate  *			  be provided.
16650Sstevel@tonic-gate  *	cb_arg		- 2nd argument to callback function.
16660Sstevel@tonic-gate  *
16670Sstevel@tonic-gate  * callback and callback_arg should be NULL if USB_FLAGS_SLEEP has
16680Sstevel@tonic-gate  * been specified
16690Sstevel@tonic-gate  *
16700Sstevel@tonic-gate  * the pipe handle argument in the callback will be the default pipe handle
16710Sstevel@tonic-gate  *
16720Sstevel@tonic-gate  * return values:
16730Sstevel@tonic-gate  *	USB_SUCCESS:	alternate was set or async request was
16740Sstevel@tonic-gate  *			submitted.
16750Sstevel@tonic-gate  *	USB_FAILURE:	alternate could not be set because pipes
16760Sstevel@tonic-gate  *			were still open or some access error occurred
16770Sstevel@tonic-gate  *			or an invalid alt if value was passed or
16780Sstevel@tonic-gate  *			async request could not be submitted
16790Sstevel@tonic-gate  *	USB_INVALID_PERM the driver does not own the device or the interface
16800Sstevel@tonic-gate  *	USB_*		refer to list of all possible return values in
16810Sstevel@tonic-gate  *			this file
16820Sstevel@tonic-gate  */
16830Sstevel@tonic-gate int usb_set_alt_if(
16840Sstevel@tonic-gate 	dev_info_t		*dip,
16850Sstevel@tonic-gate 	uint_t			interface,
16860Sstevel@tonic-gate 	uint_t			alt_number,
16870Sstevel@tonic-gate 	usb_flags_t		usb_flags,
16880Sstevel@tonic-gate 	void			(*cb)(
16890Sstevel@tonic-gate 					usb_pipe_handle_t ph,
16900Sstevel@tonic-gate 					usb_opaque_t	arg,
16910Sstevel@tonic-gate 					int		rval,
16920Sstevel@tonic-gate 					usb_cb_flags_t	flags),
16930Sstevel@tonic-gate 	usb_opaque_t		cb_arg);
16940Sstevel@tonic-gate 
16950Sstevel@tonic-gate 
16960Sstevel@tonic-gate 
16970Sstevel@tonic-gate /* flags must be USB_FLAGS_SLEEP, and this function will block */
16980Sstevel@tonic-gate int usb_get_alt_if(
16990Sstevel@tonic-gate 	dev_info_t		*dip,
17000Sstevel@tonic-gate 	uint_t			if_number,
17010Sstevel@tonic-gate 	uint_t			*alt_number,
17020Sstevel@tonic-gate 	usb_flags_t		flags);
17030Sstevel@tonic-gate 
17040Sstevel@tonic-gate 
17050Sstevel@tonic-gate /*
17060Sstevel@tonic-gate  * ===========================================================================
17070Sstevel@tonic-gate  * USB bulk request management
17080Sstevel@tonic-gate  * ===========================================================================
17090Sstevel@tonic-gate  */
17100Sstevel@tonic-gate 
17110Sstevel@tonic-gate /*
17120Sstevel@tonic-gate  * A client driver allocates/uses the usb_bulk_req_t for bulk pipe xfers.
17130Sstevel@tonic-gate  *
17140Sstevel@tonic-gate  * NOTES:
17150Sstevel@tonic-gate  * - bulk pipe sharing is not supported
17160Sstevel@tonic-gate  * - semantics of combinations of flag and attributes:
17170Sstevel@tonic-gate  *
17180Sstevel@tonic-gate  * flags     Type  attributes	data	timeout semantics
17190Sstevel@tonic-gate  * ----------------------------------------------------------------
17200Sstevel@tonic-gate  *  x	      x    x		== NULL    x	   illegal
17210Sstevel@tonic-gate  *
17220Sstevel@tonic-gate  * no sleep  IN    x		!= NULL    0	   fill buffer, no timeout
17230Sstevel@tonic-gate  *						   callback when xfer-len has
17240Sstevel@tonic-gate  *						   been xferred
17250Sstevel@tonic-gate  * no sleep  IN    x		!= NULL    > 0	   fill buffer, with timeout
17260Sstevel@tonic-gate  *						   callback when xfer-len has
17270Sstevel@tonic-gate  *						   been xferred
17280Sstevel@tonic-gate  *
17290Sstevel@tonic-gate  * sleep     IN    x		!= NULL    0	   fill buffer, no timeout
17300Sstevel@tonic-gate  *						   unblock when xfer-len has
17310Sstevel@tonic-gate  *						   been xferred
17320Sstevel@tonic-gate  *						   no callback
17330Sstevel@tonic-gate  * sleep     IN    x		!= NULL    > 0	   fill buffer, with timeout
17340Sstevel@tonic-gate  *						   unblock when xfer-len has
17350Sstevel@tonic-gate  *						   been xferred or timeout
17360Sstevel@tonic-gate  *						   no callback
17370Sstevel@tonic-gate  *
17380Sstevel@tonic-gate  *  X	     OUT SHORT_XFER_OK	  x	   x	   illegal
17390Sstevel@tonic-gate  *
17400Sstevel@tonic-gate  * no sleep  OUT   x		!= NULL    0	   empty buffer, no timeout
17410Sstevel@tonic-gate  *						   callback when xfer-len has
17420Sstevel@tonic-gate  *						   been xferred
17430Sstevel@tonic-gate  * no sleep  OUT   x		!= NULL    > 0	   empty buffer, with timeout
17440Sstevel@tonic-gate  *						   callback when xfer-len has
17450Sstevel@tonic-gate  *						   been xferred or timeout
17460Sstevel@tonic-gate  *
17470Sstevel@tonic-gate  * sleep     OUT   x		!= NULL    0	   empty buffer, no timeout
17480Sstevel@tonic-gate  *						   unblock when xfer-len has
17490Sstevel@tonic-gate  *						   been xferred
17500Sstevel@tonic-gate  *						   no callback
17510Sstevel@tonic-gate  * sleep     OUT   x		!= NULL    > 0	   empty buffer, with timeout
17520Sstevel@tonic-gate  *						   unblock when xfer-len has
17530Sstevel@tonic-gate  *						   been xferred or timeout
17540Sstevel@tonic-gate  *						   no callback
17550Sstevel@tonic-gate  *
17560Sstevel@tonic-gate  * - bulk_len and bulk_data must be > 0.  SHORT_XFER_OK is not applicable.
17570Sstevel@tonic-gate  *
17580Sstevel@tonic-gate  * - multiple bulk requests can be queued
17590Sstevel@tonic-gate  *
17600Sstevel@tonic-gate  * - Splitting large Bulk xfer:
17610Sstevel@tonic-gate  * The HCD driver, due to internal constraints, can only do a limited size bulk
17620Sstevel@tonic-gate  * data xfer per request.  The current limitations are 32K for UHCI and 128K
17630Sstevel@tonic-gate  * for OHCI.  So, a client driver may first determine this limitation (by
17640Sstevel@tonic-gate  * calling the USBA interface usb_pipe_bulk_transfer_size()); and restrict
17650Sstevel@tonic-gate  * itself to doing xfers in multiples of this fixed size.  This forces a client
17660Sstevel@tonic-gate  * driver to do data xfers in a loop for a large request, splitting it into
17670Sstevel@tonic-gate  * multiple chunks of fixed size.
17680Sstevel@tonic-gate  */
17690Sstevel@tonic-gate typedef struct usb_bulk_req {
17700Sstevel@tonic-gate 	uint_t		bulk_len;	/* number of bytes to xfer	*/
17710Sstevel@tonic-gate 	mblk_t		*bulk_data;	/* the data for the data phase	*/
17720Sstevel@tonic-gate 					/* IN: allocated by HCD		*/
17730Sstevel@tonic-gate 					/* OUT: allocated by client	*/
17740Sstevel@tonic-gate 	uint_t		bulk_timeout;	/* xfer timeout value in secs	*/
17750Sstevel@tonic-gate 	usb_opaque_t	bulk_client_private; /* Client specific information */
17760Sstevel@tonic-gate 	usb_req_attrs_t bulk_attributes; /* xfer-attributes	*/
17770Sstevel@tonic-gate 
17780Sstevel@tonic-gate 	/* Normal Callback function (For synch xfers) */
17790Sstevel@tonic-gate 	void		(*bulk_cb)(usb_pipe_handle_t ph,
17800Sstevel@tonic-gate 				struct usb_bulk_req *req);
17810Sstevel@tonic-gate 
17820Sstevel@tonic-gate 	/* Exception Callback function (For asynch xfers) */
17830Sstevel@tonic-gate 	void		(*bulk_exc_cb)(usb_pipe_handle_t ph,
17840Sstevel@tonic-gate 				struct usb_bulk_req *req);
17850Sstevel@tonic-gate 
17860Sstevel@tonic-gate 	/* set by USBA/HCD on completion */
17870Sstevel@tonic-gate 	usb_cr_t	bulk_completion_reason;	/* set by HCD		*/
17880Sstevel@tonic-gate 	usb_cb_flags_t	bulk_cb_flags;  /* Callback context / handling flgs */
17890Sstevel@tonic-gate } usb_bulk_req_t;
17900Sstevel@tonic-gate 
17910Sstevel@tonic-gate 
17920Sstevel@tonic-gate /*
17930Sstevel@tonic-gate  * Allocate/free usb bulk request
17940Sstevel@tonic-gate  *
17950Sstevel@tonic-gate  * Arguments:
17960Sstevel@tonic-gate  *	dip		- pointer to dev_info_t of the client driver
17970Sstevel@tonic-gate  *	len		- 0 or length of mblk to be allocated
17980Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
17990Sstevel@tonic-gate  *				wait for resources
18000Sstevel@tonic-gate  *
18010Sstevel@tonic-gate  * Return Values:
18020Sstevel@tonic-gate  *	usb_bulk_req_t on success, NULL on failure
18030Sstevel@tonic-gate  */
18040Sstevel@tonic-gate usb_bulk_req_t *usb_alloc_bulk_req(
18050Sstevel@tonic-gate 	dev_info_t		*dip,
18060Sstevel@tonic-gate 	size_t			len,
18070Sstevel@tonic-gate 	usb_flags_t		flags);
18080Sstevel@tonic-gate 
18090Sstevel@tonic-gate 
18100Sstevel@tonic-gate void usb_free_bulk_req(
18110Sstevel@tonic-gate 	usb_bulk_req_t	*reqp);
18120Sstevel@tonic-gate 
18130Sstevel@tonic-gate 
18140Sstevel@tonic-gate /*
18150Sstevel@tonic-gate  * usb_pipe_bulk_xfer():
18160Sstevel@tonic-gate  *
18170Sstevel@tonic-gate  * Client drivers call this function to issue the bulk xfer to the USBA
18180Sstevel@tonic-gate  * which will queue or transfer it to the device
18190Sstevel@tonic-gate  *
18200Sstevel@tonic-gate  * Arguments:
18210Sstevel@tonic-gate  *	pipe_handle	- bulk pipe handle (obtained via usb_pipe_open()
18220Sstevel@tonic-gate  *	reqp		- pointer to bulk data xfer request (IN or OUT)
18230Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
18240Sstevel@tonic-gate  *				wait for the request to complete
18250Sstevel@tonic-gate  *
18260Sstevel@tonic-gate  * Return Values:
18270Sstevel@tonic-gate  *	USB_SUCCESS	- success
18280Sstevel@tonic-gate  *	USB_FAILURE	- unspecified failure
18290Sstevel@tonic-gate  *	USB_NO_RESOURCES - no resources
18300Sstevel@tonic-gate  *
18310Sstevel@tonic-gate  */
18320Sstevel@tonic-gate int usb_pipe_bulk_xfer(
18330Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
18340Sstevel@tonic-gate 	usb_bulk_req_t		*reqp,
18350Sstevel@tonic-gate 	usb_flags_t		flags);
18360Sstevel@tonic-gate 
18370Sstevel@tonic-gate /* Get maximum bulk transfer size */
18380Sstevel@tonic-gate int usb_pipe_get_max_bulk_transfer_size(
18390Sstevel@tonic-gate 	dev_info_t		*dip,
18400Sstevel@tonic-gate 	size_t			*size);
18410Sstevel@tonic-gate 
18420Sstevel@tonic-gate 
18430Sstevel@tonic-gate /*
18440Sstevel@tonic-gate  * ===========================================================================
18450Sstevel@tonic-gate  * USB interrupt pipe request management
18460Sstevel@tonic-gate  * ===========================================================================
18470Sstevel@tonic-gate  */
18480Sstevel@tonic-gate 
18490Sstevel@tonic-gate /*
18500Sstevel@tonic-gate  * A client driver allocates and uses the usb_intr_req_t for
18510Sstevel@tonic-gate  * all interrupt pipe transfers.
18520Sstevel@tonic-gate  *
18530Sstevel@tonic-gate  * USB_FLAGS_SLEEP indicates here just to wait for resources except
18540Sstevel@tonic-gate  * for ONE_XFER where we also wait for completion
18550Sstevel@tonic-gate  *
18560Sstevel@tonic-gate  * semantics flags and attribute combinations:
18570Sstevel@tonic-gate  *
18580Sstevel@tonic-gate  * Notes:
18590Sstevel@tonic-gate  * none attributes indicates neither ONE_XFER nor SHORT_XFER_OK
18600Sstevel@tonic-gate  *
18610Sstevel@tonic-gate  * flags     Type  attributes	   data    timeout semantics
18620Sstevel@tonic-gate  * ----------------------------------------------------------------
18630Sstevel@tonic-gate  *  x	     IN      x		   != NULL  x	    illegal
18640Sstevel@tonic-gate  *  x	     IN   ONE_XFER=0	   x	   !=0	    illegal
18650Sstevel@tonic-gate  *
18660Sstevel@tonic-gate  *  x	     IN   ONE_XFER=0	   NULL     0	   continuous polling,
18670Sstevel@tonic-gate  *						   many callbacks
18680Sstevel@tonic-gate  *						   request is returned on
18690Sstevel@tonic-gate  *						   stop polling
18700Sstevel@tonic-gate  *
18710Sstevel@tonic-gate  * no sleep  IN   ONE_XFER	   NULL     0	   one time poll, no timeout,
18720Sstevel@tonic-gate  *						   one callback
18730Sstevel@tonic-gate  * no sleep  IN   ONE_XFER	   NULL    !=0	   one time poll, with
18740Sstevel@tonic-gate  *						   timeout, one callback
18750Sstevel@tonic-gate  *
18760Sstevel@tonic-gate  * sleep     IN   ONE_XFER	   NULL     0	   one time poll, no timeout,
18770Sstevel@tonic-gate  *						   no callback,
18780Sstevel@tonic-gate  *						   block for completion
18790Sstevel@tonic-gate  * sleep     IN   ONE_XFER	   NULL    !=0	   one time poll, with timeout,
18800Sstevel@tonic-gate  *						   no callback
18810Sstevel@tonic-gate  *						   block for completion
18820Sstevel@tonic-gate  *
18830Sstevel@tonic-gate  *  x	     OUT     x		   NULL    x	   illegal
18840Sstevel@tonic-gate  *  x	     OUT  ONE_XFER	   x	   x	   illegal
18850Sstevel@tonic-gate  *  x	     OUT  SHORT_XFER_OK    x	   x	   illegal
18860Sstevel@tonic-gate  *
18870Sstevel@tonic-gate  *  x	     OUT   none		   != NULL 0	   xfer until data exhausted,
18880Sstevel@tonic-gate  *						   no timeout,	one callback
18890Sstevel@tonic-gate  *  x	     OUT   none		   != NULL !=0	   xfer until data exhausted,
18900Sstevel@tonic-gate  *						   with timeout, one callback
18910Sstevel@tonic-gate  *
18920Sstevel@tonic-gate  * - Reads (IN):
18930Sstevel@tonic-gate  *
18940Sstevel@tonic-gate  * The client driver does *not* provide a data buffer.
18950Sstevel@tonic-gate  * By default, a READ request would mean continuous polling for data IN. The
18960Sstevel@tonic-gate  * HCD typically reads "wMaxPacketSize" amount of 'periodic data'. A client
18970Sstevel@tonic-gate  * driver may force the HCD to read instead intr_len
18980Sstevel@tonic-gate  * amount of 'periodic data' (See section 1).
18990Sstevel@tonic-gate  *
19000Sstevel@tonic-gate  * The HCD issues a callback to the client after each polling interval if
19010Sstevel@tonic-gate  * it has read in some data. Note that the amount of data read IN is either
19020Sstevel@tonic-gate  * intr_len or 'wMaxPacketSize' in length.
19030Sstevel@tonic-gate  *
19040Sstevel@tonic-gate  * Normally, the HCD keeps polling interrupt pipe forever even if there is
19050Sstevel@tonic-gate  * no data to be read IN.  A client driver may stop this polling by
19060Sstevel@tonic-gate  * calling usb_pipe_stop_intr_polling().
19070Sstevel@tonic-gate  *
19080Sstevel@tonic-gate  * If a client driver chooses to pass USB_ATTRS_ONE_XFER as
19090Sstevel@tonic-gate  * 'xfer_attributes' the HCD will poll for data until some data is received.
19100Sstevel@tonic-gate  * HCD reads in the data and does a callback and stops polling for any more
19110Sstevel@tonic-gate  * data.  In this case, the client driver need not explicitly call
19120Sstevel@tonic-gate  * usb_pipe_stop_intr_polling().
19130Sstevel@tonic-gate  *
19140Sstevel@tonic-gate  * When continuous polling is stopped, the original request is returned with
19150Sstevel@tonic-gate  * USB_CR_STOPPED_POLLING.
19160Sstevel@tonic-gate  *
19170Sstevel@tonic-gate  * - Writes (OUT):
19180Sstevel@tonic-gate  *
19190Sstevel@tonic-gate  * A client driver provides the data buffer, and data, needed for intr write.
19200Sstevel@tonic-gate  * There is no continuous write mode, a la  read (See previous section).
19210Sstevel@tonic-gate  * The USB_ATTRS_ONE_XFER attribute is illegal.
19220Sstevel@tonic-gate  * By default USBA keeps writing intr data until the provided data buffer
19230Sstevel@tonic-gate  * has been written out. The HCD does ONE callback to the client driver.
19240Sstevel@tonic-gate  * Queueing is supported.
19250Sstevel@tonic-gate  * Max size is 8k
19260Sstevel@tonic-gate  */
19270Sstevel@tonic-gate typedef struct usb_intr_req {
19280Sstevel@tonic-gate 	uint_t		intr_len;	/* OUT: size of total xfer */
19290Sstevel@tonic-gate 					/* IN : packet size */
19300Sstevel@tonic-gate 	mblk_t		*intr_data;	/* the data for the data phase	*/
19310Sstevel@tonic-gate 					/* IN: allocated by HCD		*/
19320Sstevel@tonic-gate 					/* OUT: allocated by client	*/
19330Sstevel@tonic-gate 	usb_opaque_t	intr_client_private; /* Client specific information  */
19340Sstevel@tonic-gate 	uint_t		intr_timeout;	/* only with ONE TIME POLL, in secs */
19350Sstevel@tonic-gate 	usb_req_attrs_t	intr_attributes;
19360Sstevel@tonic-gate 
19370Sstevel@tonic-gate 	/* Normal callback function (For synch transfers) */
19380Sstevel@tonic-gate 	void		(*intr_cb)(usb_pipe_handle_t ph,
19390Sstevel@tonic-gate 				struct usb_intr_req *req);
19400Sstevel@tonic-gate 
19410Sstevel@tonic-gate 	/* Exception callback function (For asynch transfers) */
19420Sstevel@tonic-gate 	void		(*intr_exc_cb)(usb_pipe_handle_t ph,
19430Sstevel@tonic-gate 				struct usb_intr_req *req);
19440Sstevel@tonic-gate 
19450Sstevel@tonic-gate 	/* set by USBA/HCD on completion */
19460Sstevel@tonic-gate 	usb_cr_t	intr_completion_reason;	/* set by HCD */
19470Sstevel@tonic-gate 	usb_cb_flags_t	intr_cb_flags;  /* Callback context / handling flgs */
19480Sstevel@tonic-gate } usb_intr_req_t;
19490Sstevel@tonic-gate 
19500Sstevel@tonic-gate 
19510Sstevel@tonic-gate /*
19520Sstevel@tonic-gate  * Allocate/free usb interrupt pipe request
19530Sstevel@tonic-gate  *
19540Sstevel@tonic-gate  * Arguments:
19550Sstevel@tonic-gate  *	dip		- pointer to dev_info_t of the client driver
19560Sstevel@tonic-gate  *	reqp		- pointer to request structure
19570Sstevel@tonic-gate  *	len		- 0 or length of mblk for this interrupt request
19580Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
19590Sstevel@tonic-gate  *				Sleep if resources are not available
19600Sstevel@tonic-gate  *
19610Sstevel@tonic-gate  * Return Values:
19620Sstevel@tonic-gate  *	usb_intr_req_t on success, NULL on failure
19630Sstevel@tonic-gate  */
19640Sstevel@tonic-gate usb_intr_req_t *usb_alloc_intr_req(
19650Sstevel@tonic-gate 	dev_info_t		*dip,
19660Sstevel@tonic-gate 	size_t			len,
19670Sstevel@tonic-gate 	usb_flags_t		flags);
19680Sstevel@tonic-gate 
19690Sstevel@tonic-gate 
19700Sstevel@tonic-gate void usb_free_intr_req(
19710Sstevel@tonic-gate 	usb_intr_req_t	*reqp);
19720Sstevel@tonic-gate 
19730Sstevel@tonic-gate 
19740Sstevel@tonic-gate /*
19750Sstevel@tonic-gate  * usb_pipe_intr_xfer():
19760Sstevel@tonic-gate  *
19770Sstevel@tonic-gate  * Client drivers call this function to issue the intr xfer to USBA/HCD
19780Sstevel@tonic-gate  * which starts polling the device
19790Sstevel@tonic-gate  *
19800Sstevel@tonic-gate  * Arguments:
19810Sstevel@tonic-gate  *	pipe_handle	- interrupt pipe handle (obtained via usb_pipe_open()
19820Sstevel@tonic-gate  *	reqp		- pointer tothe interrupt pipe xfer request (IN or OUT)
19830Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
19840Sstevel@tonic-gate  *				wait for resources to be available
19850Sstevel@tonic-gate  *
19860Sstevel@tonic-gate  * return values:
19870Sstevel@tonic-gate  *	USB_SUCCESS	- success
19880Sstevel@tonic-gate  *	USB_FAILURE	- unspecified failure
19890Sstevel@tonic-gate  *	USB_NO_RESOURCES  - no resources
19900Sstevel@tonic-gate  *
19910Sstevel@tonic-gate  * NOTE: start polling on an IN pipe that is already being polled is a NOP.
19920Sstevel@tonic-gate  *	 We don't queue requests on OUT pipe
19930Sstevel@tonic-gate  */
19940Sstevel@tonic-gate int usb_pipe_intr_xfer(
19950Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
19960Sstevel@tonic-gate 	usb_intr_req_t		*req,
19970Sstevel@tonic-gate 	usb_flags_t		flags);
19980Sstevel@tonic-gate 
19990Sstevel@tonic-gate 
20000Sstevel@tonic-gate /*
20010Sstevel@tonic-gate  * usb_pipe_stop_intr_polling():
20020Sstevel@tonic-gate  *
20030Sstevel@tonic-gate  * Client drivers call this function to stop the automatic data-in/out transfers
20040Sstevel@tonic-gate  * without closing the pipe.
20050Sstevel@tonic-gate  *
20060Sstevel@tonic-gate  * If USB_FLAGS_SLEEP  has been specified then this function will block until
20070Sstevel@tonic-gate  * polling has been stopped and all callbacks completed. If USB_FLAGS_SLEEP
20080Sstevel@tonic-gate  * has NOT been specified then polling is terminated when the original
20090Sstevel@tonic-gate  * request that started the polling has been returned with
20100Sstevel@tonic-gate  * USB_CR_STOPPED_POLLING
20110Sstevel@tonic-gate  *
20120Sstevel@tonic-gate  * Stop polling should never fail.
20130Sstevel@tonic-gate  *
20140Sstevel@tonic-gate  * Args:-
20150Sstevel@tonic-gate  *	pipe_handle	- interrupt pipe handle (obtained via usb_pipe_open()).
20160Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
20170Sstevel@tonic-gate  *				wait for the resources to be available.
20180Sstevel@tonic-gate  */
20190Sstevel@tonic-gate void usb_pipe_stop_intr_polling(
20200Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
20210Sstevel@tonic-gate 	usb_flags_t		flags);
20220Sstevel@tonic-gate 
20230Sstevel@tonic-gate 
20240Sstevel@tonic-gate /*
20250Sstevel@tonic-gate  * ===========================================================================
20260Sstevel@tonic-gate  * USB isochronous xfer management
20270Sstevel@tonic-gate  * ===========================================================================
20280Sstevel@tonic-gate  */
20290Sstevel@tonic-gate 
20300Sstevel@tonic-gate /*
20310Sstevel@tonic-gate  * The usb frame number is an absolute number since boot and incremented
20320Sstevel@tonic-gate  * every 1 ms.
20330Sstevel@tonic-gate  */
20340Sstevel@tonic-gate typedef	uint64_t	usb_frame_number_t;
20350Sstevel@tonic-gate 
20360Sstevel@tonic-gate /*
20370Sstevel@tonic-gate  * USB ischronous packet descriptor
20380Sstevel@tonic-gate  *
20390Sstevel@tonic-gate  * An array of structures of type usb_isoc_pkt_descr_t must be allocated and
20400Sstevel@tonic-gate  * initialized by the client driver using usb_alloc_isoc_req(). The client
20410Sstevel@tonic-gate  * driver must set isoc_pkt_length in each packet descriptor before submitting
20420Sstevel@tonic-gate  * the request.
20430Sstevel@tonic-gate  */
20440Sstevel@tonic-gate typedef struct usb_isoc_pkt_descr {
20450Sstevel@tonic-gate 	/*
20460Sstevel@tonic-gate 	 * Set by the client driver, for all isochronous requests, to the
20470Sstevel@tonic-gate 	 * number of bytes to transfer in a frame.
20480Sstevel@tonic-gate 	 */
20490Sstevel@tonic-gate 	ushort_t	isoc_pkt_length;
20500Sstevel@tonic-gate 
20510Sstevel@tonic-gate 	/*
20520Sstevel@tonic-gate 	 * Set by HCD to actual number of bytes sent/received in frame.
20530Sstevel@tonic-gate 	 */
20540Sstevel@tonic-gate 	ushort_t	isoc_pkt_actual_length;
20550Sstevel@tonic-gate 
20560Sstevel@tonic-gate 	/*
20570Sstevel@tonic-gate 	 * Per frame status set by HCD both for the isochronous IN and OUT
20580Sstevel@tonic-gate 	 * requests.  If any status is non-zero then isoc_error_count in the
20590Sstevel@tonic-gate 	 * isoc_req will be non-zero.
20600Sstevel@tonic-gate 	 */
20610Sstevel@tonic-gate 	usb_cr_t	isoc_pkt_status;
20620Sstevel@tonic-gate } usb_isoc_pkt_descr_t;
20630Sstevel@tonic-gate 
20640Sstevel@tonic-gate 
20650Sstevel@tonic-gate /*
20660Sstevel@tonic-gate  * USB isochronous request
20670Sstevel@tonic-gate  *
20680Sstevel@tonic-gate  * The client driver allocates the usb_isoc_req_t before sending an
20690Sstevel@tonic-gate  * isochronous requests.
20700Sstevel@tonic-gate  *
20710Sstevel@tonic-gate  * USB_FLAGS_SLEEP indicates here just to wait for resources but not
20720Sstevel@tonic-gate  * to wait for completion
20730Sstevel@tonic-gate  *
20740Sstevel@tonic-gate  * Semantics of various combinations for data xfers:
20750Sstevel@tonic-gate  *
20760Sstevel@tonic-gate  * Note: attributes considered in this table are ONE_XFER, START_FRAME,
20770Sstevel@tonic-gate  *	XFER_ASAP, SHORT_XFER
20780Sstevel@tonic-gate  *
20790Sstevel@tonic-gate  *
20800Sstevel@tonic-gate  * flags     Type  attributes		   data    semantics
20810Sstevel@tonic-gate  * ---------------------------------------------------------------------
20820Sstevel@tonic-gate  * x	     x	   x			NULL	   illegal
20830Sstevel@tonic-gate  *
20840Sstevel@tonic-gate  * x	     x	   ONE_XFER		 x	   illegal
20850Sstevel@tonic-gate  *
20860Sstevel@tonic-gate  * x	     IN    x			!=NULL	   continuous polling,
20870Sstevel@tonic-gate  *						   many callbacks
20880Sstevel@tonic-gate  *
20890Sstevel@tonic-gate  * x	     IN    ISOC_START_FRAME	!=NULL	   invalid if Current_frame# >
20900Sstevel@tonic-gate  *						   "isoc_frame_no"
20910Sstevel@tonic-gate  * x	     IN    ISOC_XFER_ASAP	!=NULL	   "isoc_frame_no" ignored.
20920Sstevel@tonic-gate  *						   HCD determines when to
20930Sstevel@tonic-gate  *						   insert xfer
20940Sstevel@tonic-gate  *
20950Sstevel@tonic-gate  * x	     OUT   ONE_XFER		x	   illegal
20960Sstevel@tonic-gate  * x	     OUT   SHORT_XFER_OK	x	   illegal
20970Sstevel@tonic-gate  *
20980Sstevel@tonic-gate  * x	     OUT   ISOC_START_FRAME	!=NULL	   invalid if Current_frame# >
20990Sstevel@tonic-gate  *						   "isoc_frame_no"
21000Sstevel@tonic-gate  * x	     OUT   ISOC_XFER_ASAP	!=NULL	   "isoc_frame_no" ignored.
21010Sstevel@tonic-gate  *						    HCD determines when to
21020Sstevel@tonic-gate  *						   insert xfer
21030Sstevel@tonic-gate  */
21040Sstevel@tonic-gate typedef struct usb_isoc_req {
21050Sstevel@tonic-gate 	/*
21060Sstevel@tonic-gate 	 * Starting frame number will be set by the client driver in which
21070Sstevel@tonic-gate 	 * to begin this request. This frame number is used to synchronize
21080Sstevel@tonic-gate 	 * requests queued to different isochronous pipes. The frame number
21090Sstevel@tonic-gate 	 * is optional and client driver can skip starting frame number by
21100Sstevel@tonic-gate 	 * setting USB_ISOC_ATTRS_ASAP. In this case, HCD will decide starting
21110Sstevel@tonic-gate 	 * frame number for this isochronous request.  If this field is 0,
21120Sstevel@tonic-gate 	 * then this indicates an invalid frame number.
21130Sstevel@tonic-gate 	 */
21140Sstevel@tonic-gate 	usb_frame_number_t	isoc_frame_no;
21150Sstevel@tonic-gate 
21160Sstevel@tonic-gate 	/*
21173255Slg150142 	 * Number of isochronous data packets.
21180Sstevel@tonic-gate 	 * The first field is set by client  driver and may not exceed
21190Sstevel@tonic-gate 	 * the maximum number of entries in the usb isochronous packet
21200Sstevel@tonic-gate 	 * descriptors.
21210Sstevel@tonic-gate 	 */
21220Sstevel@tonic-gate 	ushort_t		isoc_pkts_count;
21233255Slg150142 
21243255Slg150142 	/*
21253255Slg150142 	 * The sum of all pkt lengths in the isoc request. Recommend to
21263255Slg150142 	 * set it to zero, so the sum of isoc_pkt_length in the
21273255Slg150142 	 * isoc_pkt_descr list will be used automatically and no check
21283255Slg150142 	 * will be apply to this element.
21293255Slg150142 	 */
21300Sstevel@tonic-gate 	ushort_t		isoc_pkts_length;
21310Sstevel@tonic-gate 
21320Sstevel@tonic-gate 	/*
21330Sstevel@tonic-gate 	 * This field will be set by HCD and this field indicates the number
21340Sstevel@tonic-gate 	 * of packets that completed with errors.
21350Sstevel@tonic-gate 	 */
21360Sstevel@tonic-gate 	ushort_t		isoc_error_count;
21370Sstevel@tonic-gate 
21380Sstevel@tonic-gate 	/*
21390Sstevel@tonic-gate 	 * Attributes specific to particular usb isochronous request.
21400Sstevel@tonic-gate 	 * Supported values are: USB_ATTRS_ISOC_START_FRAME,
21410Sstevel@tonic-gate 	 * USB_ATTRS_ISOC_XFER_ASAP.
21420Sstevel@tonic-gate 	 */
21430Sstevel@tonic-gate 	usb_req_attrs_t 	isoc_attributes;
21440Sstevel@tonic-gate 
21450Sstevel@tonic-gate 	/*
21460Sstevel@tonic-gate 	 * Isochronous OUT:
21470Sstevel@tonic-gate 	 *	allocated and set by client driver, freed and zeroed by HCD
21480Sstevel@tonic-gate 	 *	on successful completion
21490Sstevel@tonic-gate 	 * Isochronous IN:
21500Sstevel@tonic-gate 	 *	allocated and set by HCD, freed by client driver
21510Sstevel@tonic-gate 	 */
21520Sstevel@tonic-gate 	mblk_t			*isoc_data;
21530Sstevel@tonic-gate 
21540Sstevel@tonic-gate 	/*
21550Sstevel@tonic-gate 	 * The client driver specific private information.
21560Sstevel@tonic-gate 	 */
21570Sstevel@tonic-gate 	usb_opaque_t		isoc_client_private;
21580Sstevel@tonic-gate 
21590Sstevel@tonic-gate 	/*
21600Sstevel@tonic-gate 	 * Isochronous OUT:
21610Sstevel@tonic-gate 	 *	must be allocated & initialized by client driver
21620Sstevel@tonic-gate 	 * Isochronous IN:
21630Sstevel@tonic-gate 	 *	must be allocated by client driver
21640Sstevel@tonic-gate 	 */
21650Sstevel@tonic-gate 	struct usb_isoc_pkt_descr *isoc_pkt_descr;
21660Sstevel@tonic-gate 
21670Sstevel@tonic-gate 	/* Normal callback function (For synch transfers) */
21680Sstevel@tonic-gate 	void			(*isoc_cb)(usb_pipe_handle_t ph,
21690Sstevel@tonic-gate 					struct usb_isoc_req *req);
21700Sstevel@tonic-gate 
21710Sstevel@tonic-gate 	/* Exception callback function (For asynch transfers) */
21720Sstevel@tonic-gate 	void			(*isoc_exc_cb)(usb_pipe_handle_t ph,
21730Sstevel@tonic-gate 					struct usb_isoc_req *req);
21740Sstevel@tonic-gate 
21750Sstevel@tonic-gate 	/* set by USBA/HCD on completion */
21760Sstevel@tonic-gate 	usb_cr_t		isoc_completion_reason;	/* set by HCD */
21770Sstevel@tonic-gate 					/* Callback context / handling flgs */
21780Sstevel@tonic-gate 	usb_cb_flags_t		isoc_cb_flags;
21790Sstevel@tonic-gate } usb_isoc_req_t;
21800Sstevel@tonic-gate 
21810Sstevel@tonic-gate 
21820Sstevel@tonic-gate /*
21830Sstevel@tonic-gate  * Allocate/free usb isochronous resources
21840Sstevel@tonic-gate  *
21850Sstevel@tonic-gate  * isoc_pkts_count must be > 0
21860Sstevel@tonic-gate  *
21870Sstevel@tonic-gate  * Arguments:
21880Sstevel@tonic-gate  *	dip		- client driver's devinfo pointer
21890Sstevel@tonic-gate  *	isoc_pkts_count - number of pkts required
21900Sstevel@tonic-gate  *	len		- 0 or size of mblk to allocate
21910Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
21920Sstevel@tonic-gate  *				wait for resources
21930Sstevel@tonic-gate  *
21940Sstevel@tonic-gate  * Return Values:
21950Sstevel@tonic-gate  *	usb_isoc_req pointer or NULL
21960Sstevel@tonic-gate  */
21970Sstevel@tonic-gate usb_isoc_req_t *usb_alloc_isoc_req(
21980Sstevel@tonic-gate 	dev_info_t		*dip,
21990Sstevel@tonic-gate 	uint_t			isoc_pkts_count,
22000Sstevel@tonic-gate 	size_t			len,
22010Sstevel@tonic-gate 	usb_flags_t		flags);
22020Sstevel@tonic-gate 
22030Sstevel@tonic-gate void	usb_free_isoc_req(
22040Sstevel@tonic-gate 	usb_isoc_req_t		*usb_isoc_req);
22050Sstevel@tonic-gate 
22060Sstevel@tonic-gate /*
22070Sstevel@tonic-gate  * Returns current usb frame number.
22080Sstevel@tonic-gate  */
22090Sstevel@tonic-gate usb_frame_number_t usb_get_current_frame_number(
22100Sstevel@tonic-gate 	dev_info_t		*dip);
22110Sstevel@tonic-gate 
22120Sstevel@tonic-gate /*
22130Sstevel@tonic-gate  * Get maximum isochronous packets per usb isochronous request
22140Sstevel@tonic-gate  */
22150Sstevel@tonic-gate uint_t usb_get_max_pkts_per_isoc_request(
22160Sstevel@tonic-gate 	dev_info_t		*dip);
22170Sstevel@tonic-gate 
22180Sstevel@tonic-gate /*
22190Sstevel@tonic-gate  * usb_pipe_isoc_xfer()
22200Sstevel@tonic-gate  *
22210Sstevel@tonic-gate  * Client drivers call this to issue the isoch xfer (IN and OUT) to the USBA
22220Sstevel@tonic-gate  * which starts polling the device.
22230Sstevel@tonic-gate  *
22240Sstevel@tonic-gate  * Arguments:
22250Sstevel@tonic-gate  *	pipe_handle	- isoc pipe handle (obtained via usb_pipe_open().
22260Sstevel@tonic-gate  *	reqp		- pointer to the isochronous pipe IN xfer request
22270Sstevel@tonic-gate  *			  allocated by the client driver.
22280Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
22290Sstevel@tonic-gate  *				wait for the resources to be available.
22300Sstevel@tonic-gate  *
22310Sstevel@tonic-gate  * return values:
22320Sstevel@tonic-gate  *	USB_SUCCESS	- success.
22330Sstevel@tonic-gate  *	USB_FAILURE	- unspecified failure.
22340Sstevel@tonic-gate  *	USB_NO_RESOURCES  - no resources.
22350Sstevel@tonic-gate  *	USB_NO_FRAME_NUMBER - START_FRAME, ASAP flags not specified.
22360Sstevel@tonic-gate  *	USB_INVALID_START_FRAME	- Starting USB frame number invalid.
22370Sstevel@tonic-gate  *
22380Sstevel@tonic-gate  * Notes:
22390Sstevel@tonic-gate  * - usb_pipe_isoc_xfer on an IN pipe that is already being polled is a NOP.
22400Sstevel@tonic-gate  * - requests can be queued on an OUT pipe.
22410Sstevel@tonic-gate  */
22420Sstevel@tonic-gate int usb_pipe_isoc_xfer(
22430Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
22440Sstevel@tonic-gate 	usb_isoc_req_t		*reqp,
22450Sstevel@tonic-gate 	usb_flags_t		flags);
22460Sstevel@tonic-gate 
22470Sstevel@tonic-gate /*
22480Sstevel@tonic-gate  * usb_pipe_stop_isoc_polling():
22490Sstevel@tonic-gate  *
22500Sstevel@tonic-gate  * Client drivers call this function to stop the automatic data-in/out
22510Sstevel@tonic-gate  * transfers without closing the isoc pipe.
22520Sstevel@tonic-gate  *
22530Sstevel@tonic-gate  * If USB_FLAGS_SLEEP  has been specified then this function will block until
22540Sstevel@tonic-gate  * polling has been stopped and all callbacks completed. If USB_FLAGS_SLEEP
22550Sstevel@tonic-gate  * has NOT been specified then polling is terminated when the original
22560Sstevel@tonic-gate  * request that started the polling has been returned with
22570Sstevel@tonic-gate  * USB_CR_STOPPED_POLLING
22580Sstevel@tonic-gate  *
22590Sstevel@tonic-gate  * Stop polling should never fail.
22600Sstevel@tonic-gate  *
22610Sstevel@tonic-gate  * Arguments:
22620Sstevel@tonic-gate  *	pipe_handle	- isoc pipe handle (obtained via usb_pipe_open().
22630Sstevel@tonic-gate  *	flags		- USB_FLAGS_SLEEP:
22640Sstevel@tonic-gate  *				wait for polling to be stopped and all
22650Sstevel@tonic-gate  *				callbacks completed.
22660Sstevel@tonic-gate  */
22670Sstevel@tonic-gate void usb_pipe_stop_isoc_polling(
22680Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
22690Sstevel@tonic-gate 	usb_flags_t		flags);
22700Sstevel@tonic-gate 
22710Sstevel@tonic-gate /*
22720Sstevel@tonic-gate  * ***************************************************************************
22730Sstevel@tonic-gate  * USB device power management:
22740Sstevel@tonic-gate  * ***************************************************************************
22750Sstevel@tonic-gate  */
22760Sstevel@tonic-gate 
22770Sstevel@tonic-gate /*
22780Sstevel@tonic-gate  *
22790Sstevel@tonic-gate  * As any usb device will have a max of 4 possible power states
22800Sstevel@tonic-gate  * the #define	for them are provided below with mapping to the
22810Sstevel@tonic-gate  * corresponding OS power levels.
22820Sstevel@tonic-gate  */
22830Sstevel@tonic-gate #define	USB_DEV_PWR_D0		USB_DEV_OS_FULL_PWR
22840Sstevel@tonic-gate #define	USB_DEV_PWR_D1		5
22850Sstevel@tonic-gate #define	USB_DEV_PWR_D2		6
22860Sstevel@tonic-gate #define	USB_DEV_PWR_D3		USB_DEV_OS_PWR_OFF
22870Sstevel@tonic-gate 
22880Sstevel@tonic-gate #define	USB_DEV_OS_PWR_0	0
22890Sstevel@tonic-gate #define	USB_DEV_OS_PWR_1	1
22900Sstevel@tonic-gate #define	USB_DEV_OS_PWR_2	2
22910Sstevel@tonic-gate #define	USB_DEV_OS_PWR_3	3
22920Sstevel@tonic-gate #define	USB_DEV_OS_PWR_OFF	USB_DEV_OS_PWR_0
22930Sstevel@tonic-gate #define	USB_DEV_OS_FULL_PWR	USB_DEV_OS_PWR_3
22940Sstevel@tonic-gate 
22950Sstevel@tonic-gate /* Bit Masks for Power States */
22960Sstevel@tonic-gate #define	USB_DEV_OS_PWRMASK_D0	1
22970Sstevel@tonic-gate #define	USB_DEV_OS_PWRMASK_D1	2
22980Sstevel@tonic-gate #define	USB_DEV_OS_PWRMASK_D2	4
22990Sstevel@tonic-gate #define	USB_DEV_OS_PWRMASK_D3	8
23000Sstevel@tonic-gate 
23010Sstevel@tonic-gate /* conversion for OS to Dx levels */
23020Sstevel@tonic-gate #define	USB_DEV_OS_PWR2USB_PWR(l)	(USB_DEV_OS_FULL_PWR - (l))
23030Sstevel@tonic-gate 
23040Sstevel@tonic-gate /* from OS level to Dx mask */
23050Sstevel@tonic-gate #define	USB_DEV_PWRMASK(l)	(1 << (USB_DEV_OS_FULL_PWR - (l)))
23060Sstevel@tonic-gate 
23070Sstevel@tonic-gate /* Macro to check valid power level */
23080Sstevel@tonic-gate #define	USB_DEV_PWRSTATE_OK(state, level) \
23090Sstevel@tonic-gate 		(((state) & USB_DEV_PWRMASK((level))) == 0)
23100Sstevel@tonic-gate 
23110Sstevel@tonic-gate int usb_handle_remote_wakeup(
23120Sstevel@tonic-gate 	dev_info_t	*dip,
23130Sstevel@tonic-gate 	int		cmd);
23140Sstevel@tonic-gate 
23150Sstevel@tonic-gate /* argument to usb_handle_remote wakeup function */
23160Sstevel@tonic-gate #define	USB_REMOTE_WAKEUP_ENABLE	1
23170Sstevel@tonic-gate #define	USB_REMOTE_WAKEUP_DISABLE	2
23180Sstevel@tonic-gate 
23190Sstevel@tonic-gate int usb_create_pm_components(
23200Sstevel@tonic-gate 	dev_info_t	*dip,
23210Sstevel@tonic-gate 	uint_t		*pwrstates);
23220Sstevel@tonic-gate 
23230Sstevel@tonic-gate /*
23240Sstevel@tonic-gate  * ***************************************************************************
23250Sstevel@tonic-gate  * System event registration
23260Sstevel@tonic-gate  * ***************************************************************************
23270Sstevel@tonic-gate  */
23280Sstevel@tonic-gate 
23290Sstevel@tonic-gate /* Functions for registering hotplug callback functions. */
23300Sstevel@tonic-gate 
23310Sstevel@tonic-gate int usb_register_hotplug_cbs(
23320Sstevel@tonic-gate 	dev_info_t	*dip,
23330Sstevel@tonic-gate 	int		(*disconnect_event_handler)(dev_info_t *dip),
23340Sstevel@tonic-gate 	int		(*reconnect_event_handler)(dev_info_t *dip));
23350Sstevel@tonic-gate 
23360Sstevel@tonic-gate void usb_unregister_hotplug_cbs(dev_info_t *dip);
23370Sstevel@tonic-gate 
23380Sstevel@tonic-gate 
23390Sstevel@tonic-gate /*
23400Sstevel@tonic-gate  * ***************************************************************************
23410Sstevel@tonic-gate  * USB Device and interface class, subclass and protocol codes
23420Sstevel@tonic-gate  * ***************************************************************************
23430Sstevel@tonic-gate  */
23440Sstevel@tonic-gate 
23450Sstevel@tonic-gate /*
23460Sstevel@tonic-gate  * Available device and interface class codes.
23470Sstevel@tonic-gate  * Those which are device class codes are noted.
23480Sstevel@tonic-gate  */
23490Sstevel@tonic-gate 
23500Sstevel@tonic-gate #define	USB_CLASS_AUDIO		1
23510Sstevel@tonic-gate #define	USB_CLASS_COMM		2	/* Communication device class and */
23520Sstevel@tonic-gate #define	USB_CLASS_CDC_CTRL	2	/* CDC-control iface class, also 2 */
23530Sstevel@tonic-gate #define	USB_CLASS_HID		3
23540Sstevel@tonic-gate #define	USB_CLASS_PHYSICAL	5
2355*3341Sgc161489 #define	USB_CLASS_IMAGE		6
23560Sstevel@tonic-gate #define	USB_CLASS_PRINTER	7
23570Sstevel@tonic-gate #define	USB_CLASS_MASS_STORAGE	8
23580Sstevel@tonic-gate #define	USB_CLASS_HUB		9	/* Device class */
23590Sstevel@tonic-gate #define	USB_CLASS_CDC_DATA	10
23600Sstevel@tonic-gate #define	USB_CLASS_CCID		11
23610Sstevel@tonic-gate #define	USB_CLASS_SECURITY	13
2362*3341Sgc161489 #define	USB_CLASS_VIDEO		14
23630Sstevel@tonic-gate #define	USB_CLASS_DIAG		220	/* Device class */
2364*3341Sgc161489 #define	USB_CLASS_WIRELESS	224
23650Sstevel@tonic-gate #define	USB_CLASS_MISC		239	/* Device class */
23660Sstevel@tonic-gate #define	USB_CLASS_APP		254
23670Sstevel@tonic-gate #define	USB_CLASS_VENDOR_SPEC	255	/* Device class */
23680Sstevel@tonic-gate 
23690Sstevel@tonic-gate #define	USB_CLASS_PER_INTERFACE	0	/* Class info is at interface level */
23700Sstevel@tonic-gate 
23710Sstevel@tonic-gate /* Audio subclass. */
23720Sstevel@tonic-gate #define	USB_SUBCLS_AUD_CONTROL		0x01
23730Sstevel@tonic-gate #define	USB_SUBCLS_AUD_STREAMING	0x02
23740Sstevel@tonic-gate #define	USB_SUBCLS_AUD_MIDI_STREAMING	0x03
23750Sstevel@tonic-gate 
23760Sstevel@tonic-gate /* Comms  subclass. */
23770Sstevel@tonic-gate #define	USB_SUBCLS_CDCC_DIRECT_LINE	0x01
23780Sstevel@tonic-gate #define	USB_SUBCLS_CDCC_ABSTRCT_CTRL	0x02
23790Sstevel@tonic-gate #define	USB_SUBCLS_CDCC_PHONE_CTRL	0x03
23800Sstevel@tonic-gate #define	USB_SUBCLS_CDCC_MULTCNL_ISDN	0x04
23810Sstevel@tonic-gate #define	USB_SUBCLS_CDCC_ISDN		0x05
23820Sstevel@tonic-gate #define	USB_SUBCLS_CDCC_ETHERNET	0x06
23830Sstevel@tonic-gate #define	USB_SUBCLS_CDCC_ATM_NETWORK	0x07
23840Sstevel@tonic-gate 
23850Sstevel@tonic-gate /* HID subclass and protocols. */
23860Sstevel@tonic-gate #define	USB_SUBCLS_HID_1		1
23870Sstevel@tonic-gate 
23880Sstevel@tonic-gate #define	USB_PROTO_HID_KEYBOARD		0x01	/* legacy keyboard */
23890Sstevel@tonic-gate #define	USB_PROTO_HID_MOUSE		0x02	/* legacy mouse */
23900Sstevel@tonic-gate 
23910Sstevel@tonic-gate /* Printer subclass and protocols. */
23920Sstevel@tonic-gate #define	USB_SUBCLS_PRINTER_1		1
23930Sstevel@tonic-gate 
23940Sstevel@tonic-gate #define	USB_PROTO_PRINTER_UNI		0x01	/* Unidirectional interface */
23950Sstevel@tonic-gate #define	USB_PROTO_PRINTER_BI		0x02	/* Bidirectional interface */
23960Sstevel@tonic-gate 
23970Sstevel@tonic-gate /* Mass storage subclasses and protocols. */
23980Sstevel@tonic-gate #define	USB_SUBCLS_MS_RBC_T10		0x1	/* flash */
23990Sstevel@tonic-gate #define	USB_SUBCLS_MS_SFF8020I		0x2	/* CD-ROM */
24000Sstevel@tonic-gate #define	USB_SUBCLS_MS_QIC_157		0x3	/* tape */
24010Sstevel@tonic-gate #define	USB_SUBCLS_MS_UFI		0x4	/* USB Floppy Disk Drive   */
24020Sstevel@tonic-gate #define	USB_SUBCLS_MS_SFF8070I		0x5	/* floppy */
24030Sstevel@tonic-gate #define	USB_SUBCLS_MS_SCSI		0x6	/* transparent scsi */
24040Sstevel@tonic-gate 
24050Sstevel@tonic-gate #define	USB_PROTO_MS_CBI_WC		0x00	/* USB CBI Proto w/cmp intr */
24060Sstevel@tonic-gate #define	USB_PROTO_MS_CBI		0x01    /* USB CBI Protocol */
24070Sstevel@tonic-gate #define	USB_PROTO_MS_ISD_1999_SILICN	0x02    /* ZIP Protocol */
24080Sstevel@tonic-gate #define	USB_PROTO_MS_BULK_ONLY		0x50    /* USB Bulk Only Protocol */
24090Sstevel@tonic-gate 
24100Sstevel@tonic-gate /* Application subclasses. */
24110Sstevel@tonic-gate #define	USB_SUBCLS_APP_FIRMWARE		0x01	/* app spec f/w subclass */
24120Sstevel@tonic-gate #define	USB_SUBCLS_APP_IRDA		0x02	/* app spec IrDa subclass */
24130Sstevel@tonic-gate #define	USB_SUBCLS_APP_TEST		0x03	/* app spec test subclass */
24140Sstevel@tonic-gate 
2415*3341Sgc161489 /* Video subclasses */
2416*3341Sgc161489 #define	USB_SUBCLS_VIDEO_CONTROL	0x01	/* video control */
2417*3341Sgc161489 #define	USB_SUBCLS_VIDEO_STREAM		0x02	/* video stream */
2418*3341Sgc161489 #define	USB_SUBCLS_VIDEO_COLLECTION	0x03	/* video interface collection */
24190Sstevel@tonic-gate 
2420*3341Sgc161489 /* Wireless controller subclasses and protocols */
2421*3341Sgc161489 #define	USB_SUBCLS_WUSB_1		0x01
2422*3341Sgc161489 #define	USB_SUBCLS_WUSB_2		0x02
2423*3341Sgc161489 #define	USB_PROTO_WUSB_HWA		0x01	/* host wire adapter */
2424*3341Sgc161489 #define	USB_PROTO_WUSB_DWA		0x02	/* device wire adapter */
2425*3341Sgc161489 #define	USB_PROTO_WUSB_DWA_ISO		0x03	/* device wire adapter isoc */
24260Sstevel@tonic-gate 
24270Sstevel@tonic-gate #ifdef __cplusplus
24280Sstevel@tonic-gate }
24290Sstevel@tonic-gate #endif
24300Sstevel@tonic-gate 
24310Sstevel@tonic-gate #endif /* _SYS_USB_USBAI_H */
2432