Home | History | Annotate | Line # | Download | only in usb
usb.h revision 1.18.4.2
      1  1.18.4.2   thorpej /*	$NetBSD: usb.h,v 1.18.4.2 1999/07/01 23:40:23 thorpej Exp $	*/
      2       1.1  augustss 
      3       1.1  augustss /*
      4       1.1  augustss  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5       1.1  augustss  * All rights reserved.
      6       1.1  augustss  *
      7       1.4  augustss  * This code is derived from software contributed to The NetBSD Foundation
      8       1.4  augustss  * by Lennart Augustsson (augustss (at) carlstedt.se) at
      9       1.4  augustss  * Carlstedt Research & Technology.
     10       1.1  augustss  *
     11       1.1  augustss  * Redistribution and use in source and binary forms, with or without
     12       1.1  augustss  * modification, are permitted provided that the following conditions
     13       1.1  augustss  * are met:
     14       1.1  augustss  * 1. Redistributions of source code must retain the above copyright
     15       1.1  augustss  *    notice, this list of conditions and the following disclaimer.
     16       1.1  augustss  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1  augustss  *    notice, this list of conditions and the following disclaimer in the
     18       1.1  augustss  *    documentation and/or other materials provided with the distribution.
     19       1.1  augustss  * 3. All advertising materials mentioning features or use of this software
     20       1.1  augustss  *    must display the following acknowledgement:
     21       1.1  augustss  *        This product includes software developed by the NetBSD
     22       1.1  augustss  *        Foundation, Inc. and its contributors.
     23       1.1  augustss  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24       1.1  augustss  *    contributors may be used to endorse or promote products derived
     25       1.1  augustss  *    from this software without specific prior written permission.
     26       1.1  augustss  *
     27       1.1  augustss  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28       1.1  augustss  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29       1.1  augustss  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30       1.1  augustss  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31       1.1  augustss  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32       1.1  augustss  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33       1.1  augustss  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34       1.1  augustss  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35       1.1  augustss  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36       1.1  augustss  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37       1.1  augustss  * POSSIBILITY OF SUCH DAMAGE.
     38       1.1  augustss  */
     39       1.1  augustss 
     40       1.1  augustss 
     41       1.1  augustss #ifndef _USB_H_
     42       1.1  augustss #define _USB_H_
     43       1.1  augustss 
     44       1.1  augustss #include <sys/types.h>
     45       1.8  augustss #if defined(__NetBSD__)
     46       1.1  augustss #include <sys/ioctl.h>
     47       1.8  augustss #endif
     48       1.8  augustss 
     49       1.8  augustss #if defined(__NetBSD__)
     50       1.8  augustss #if defined(_KERNEL)
     51       1.8  augustss #include <dev/usb/usb_port.h>
     52       1.8  augustss #endif /* _KERNEL */
     53       1.8  augustss 
     54       1.8  augustss #elif defined(__FreeBSD__)
     55       1.8  augustss #include <sys/malloc.h>
     56       1.8  augustss 
     57       1.8  augustss #if defined(KERNEL)
     58       1.8  augustss MALLOC_DECLARE(M_USB);
     59       1.8  augustss MALLOC_DECLARE(M_USBDEV);
     60  1.18.4.2   thorpej MALLOC_DECLARE(M_USBHC);
     61       1.8  augustss 
     62       1.8  augustss #include <dev/usb/usb_port.h>
     63       1.8  augustss #endif /* KERNEL */
     64       1.8  augustss #endif /* __FreeBSD__ */
     65       1.8  augustss 
     66       1.1  augustss 
     67       1.1  augustss #define USB_MAX_DEVICES 128
     68       1.1  augustss #define USB_START_ADDR 0
     69       1.1  augustss 
     70       1.1  augustss #define USB_CONTROL_ENDPOINT 0
     71       1.1  augustss #define USB_MAX_ENDPOINTS 16
     72       1.1  augustss 
     73      1.10  augustss #define USB_FRAMES_PER_SECOND 1000
     74      1.10  augustss 
     75       1.1  augustss /*
     76       1.1  augustss  * The USB records contain some unaligned little-endian word
     77       1.1  augustss  * components.  The U[SG]ETW macros take care of both the alignment
     78       1.1  augustss  * and endian problem and should always be used to access 16 bit
     79       1.1  augustss  * values.
     80       1.1  augustss  */
     81       1.1  augustss typedef u_int8_t uByte;
     82       1.1  augustss typedef u_int8_t uWord[2];
     83       1.1  augustss #define UGETW(w) ((w)[0] | ((w)[1] << 8))
     84       1.1  augustss #define USETW(w,v) ((w)[0] = (u_int8_t)(v), (w)[1] = (u_int8_t)((v) >> 8))
     85       1.1  augustss #define USETW2(w,h,l) ((w)[0] = (u_int8_t)(l), (w)[1] = (u_int8_t)(h))
     86      1.16  augustss typedef u_int8_t uDWord[4];
     87      1.16  augustss #define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24))
     88      1.16  augustss #define USETDW(w,v) ((w)[0] = (u_int8_t)(v), \
     89      1.16  augustss 		     (w)[1] = (u_int8_t)((v) >> 8), \
     90      1.16  augustss 		     (w)[2] = (u_int8_t)((v) >> 16), \
     91      1.16  augustss 		     (w)[3] = (u_int8_t)((v) >> 24))
     92       1.1  augustss /*
     93       1.1  augustss  * On little-endian machines that can handle unanliged accesses
     94       1.1  augustss  * (e.g. i386) these macros can be replaced by the following.
     95       1.1  augustss  */
     96       1.1  augustss #if 0
     97       1.1  augustss #define UGETW(w) (*(u_int16_t *)(w))
     98       1.1  augustss #define USETW(w,v) (*(u_int16_t *)(w) = (v))
     99       1.1  augustss #endif
    100       1.1  augustss 
    101       1.1  augustss typedef struct {
    102       1.1  augustss 	uByte		bmRequestType;
    103       1.1  augustss 	uByte		bRequest;
    104       1.1  augustss 	uWord		wValue;
    105       1.1  augustss 	uWord		wIndex;
    106       1.1  augustss 	uWord		wLength;
    107       1.1  augustss } usb_device_request_t;
    108       1.1  augustss 
    109       1.1  augustss #define UT_WRITE		0x00
    110       1.1  augustss #define UT_READ			0x80
    111       1.1  augustss #define UT_STANDARD		0x00
    112       1.1  augustss #define UT_CLASS		0x20
    113       1.1  augustss #define UT_VENDOR		0x40
    114       1.1  augustss #define UT_DEVICE		0x00
    115       1.1  augustss #define UT_INTERFACE		0x01
    116       1.1  augustss #define UT_ENDPOINT		0x02
    117       1.1  augustss #define UT_OTHER		0x03
    118       1.1  augustss 
    119       1.1  augustss #define UT_READ_DEVICE		(UT_READ  | UT_STANDARD | UT_DEVICE)
    120       1.1  augustss #define UT_READ_INTERFACE	(UT_READ  | UT_STANDARD | UT_INTERFACE)
    121       1.1  augustss #define UT_READ_ENDPOINT	(UT_READ  | UT_STANDARD | UT_ENDPOINT)
    122       1.1  augustss #define UT_WRITE_DEVICE		(UT_WRITE | UT_STANDARD | UT_DEVICE)
    123       1.1  augustss #define UT_WRITE_INTERFACE	(UT_WRITE | UT_STANDARD | UT_INTERFACE)
    124       1.1  augustss #define UT_WRITE_ENDPOINT	(UT_WRITE | UT_STANDARD | UT_ENDPOINT)
    125       1.1  augustss #define UT_READ_CLASS_DEVICE	(UT_READ  | UT_CLASS | UT_DEVICE)
    126       1.1  augustss #define UT_READ_CLASS_INTERFACE	(UT_READ  | UT_CLASS | UT_INTERFACE)
    127       1.1  augustss #define UT_READ_CLASS_OTHER	(UT_READ  | UT_CLASS | UT_OTHER)
    128       1.1  augustss #define UT_WRITE_CLASS_DEVICE	(UT_WRITE | UT_CLASS | UT_DEVICE)
    129       1.1  augustss #define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE)
    130       1.1  augustss #define UT_WRITE_CLASS_OTHER	(UT_WRITE | UT_CLASS | UT_OTHER)
    131      1.13  augustss #define UT_READ_VENDOR_DEVICE	(UT_READ  | UT_VENDOR | UT_DEVICE)
    132      1.13  augustss #define UT_READ_VENDOR_INTERFACE (UT_READ  | UT_VENDOR | UT_INTERFACE)
    133      1.13  augustss #define UT_READ_VENDOR_OTHER	(UT_READ  | UT_VENDOR | UT_OTHER)
    134      1.13  augustss #define UT_WRITE_VENDOR_DEVICE	(UT_WRITE | UT_VENDOR | UT_DEVICE)
    135      1.13  augustss #define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE)
    136      1.13  augustss #define UT_WRITE_VENDOR_OTHER	(UT_WRITE | UT_VENDOR | UT_OTHER)
    137       1.1  augustss 
    138       1.1  augustss /* Requests */
    139       1.1  augustss #define UR_GET_STATUS		0x00
    140       1.1  augustss #define UR_CLEAR_FEATURE	0x01
    141       1.1  augustss #define UR_SET_FEATURE		0x03
    142       1.1  augustss #define UR_SET_ADDRESS		0x05
    143       1.1  augustss #define UR_GET_DESCRIPTOR	0x06
    144       1.1  augustss #define  UDESC_DEVICE		1
    145       1.1  augustss #define  UDESC_CONFIG		2
    146       1.1  augustss #define  UDESC_STRING		3
    147       1.1  augustss #define  UDESC_INTERFACE	4
    148       1.1  augustss #define  UDESC_ENDPOINT		5
    149       1.1  augustss #define UR_SET_DESCRIPTOR	0x07
    150       1.1  augustss #define UR_GET_CONFIG		0x08
    151       1.1  augustss #define UR_SET_CONFIG		0x09
    152       1.1  augustss #define UR_GET_INTERFACE	0x0a
    153       1.1  augustss #define UR_SET_INTERFACE	0x0b
    154       1.1  augustss #define UR_SYNCH_FRAME		0x0c
    155       1.1  augustss 
    156       1.1  augustss /* Feature numbers */
    157       1.8  augustss #define UF_ENDPOINT_HALT	0
    158       1.1  augustss #define UF_DEVICE_REMOTE_WAKEUP	1
    159       1.1  augustss 
    160       1.1  augustss #define USB_MAX_IPACKET		8 /* maximum size of the initial packet */
    161       1.1  augustss 
    162       1.1  augustss typedef struct {
    163       1.1  augustss 	uByte		bLength;
    164       1.1  augustss 	uByte		bDescriptorType;
    165       1.1  augustss 	uByte		bDescriptorSubtype;
    166       1.1  augustss } usb_descriptor_t;
    167       1.1  augustss 
    168       1.1  augustss typedef struct {
    169       1.1  augustss 	uByte		bLength;
    170       1.1  augustss 	uByte		bDescriptorType;
    171       1.1  augustss 	uWord		bcdUSB;
    172       1.1  augustss 	uByte		bDeviceClass;
    173       1.1  augustss 	uByte		bDeviceSubClass;
    174       1.1  augustss 	uByte		bDeviceProtocol;
    175       1.1  augustss 	uByte		bMaxPacketSize;
    176       1.1  augustss 	/* The fields below are not part of the initial descriptor. */
    177       1.1  augustss 	uWord		idVendor;
    178       1.1  augustss 	uWord		idProduct;
    179       1.1  augustss 	uWord		bcdDevice;
    180       1.1  augustss 	uByte		iManufacturer;
    181       1.1  augustss 	uByte		iProduct;
    182       1.1  augustss 	uByte		iSerialNumber;
    183       1.1  augustss 	uByte		bNumConfigurations;
    184       1.1  augustss } usb_device_descriptor_t;
    185       1.1  augustss #define USB_DEVICE_DESCRIPTOR_SIZE 18
    186       1.1  augustss 
    187       1.1  augustss typedef struct {
    188       1.1  augustss 	uByte		bLength;
    189       1.1  augustss 	uByte		bDescriptorType;
    190       1.1  augustss 	uWord		wTotalLength;
    191       1.1  augustss 	uByte		bNumInterface;
    192       1.1  augustss 	uByte		bConfigurationValue;
    193       1.1  augustss 	uByte		iConfiguration;
    194       1.1  augustss 	uByte		bmAttributes;
    195       1.1  augustss #define UC_BUS_POWERED		0x80
    196       1.1  augustss #define UC_SELF_POWERED		0x40
    197       1.1  augustss #define UC_REMOTE_WAKEUP	0x20
    198       1.1  augustss 	uByte		bMaxPower; /* max current in 2 mA units */
    199       1.1  augustss #define UC_POWER_FACTOR 2
    200       1.1  augustss } usb_config_descriptor_t;
    201       1.1  augustss #define USB_CONFIG_DESCRIPTOR_SIZE 9
    202       1.1  augustss 
    203       1.1  augustss typedef struct {
    204       1.1  augustss 	uByte		bLength;
    205       1.1  augustss 	uByte		bDescriptorType;
    206       1.1  augustss 	uByte		bInterfaceNumber;
    207       1.1  augustss 	uByte		bAlternateSetting;
    208       1.1  augustss 	uByte		bNumEndpoints;
    209       1.1  augustss 	uByte		bInterfaceClass;
    210       1.1  augustss 	uByte		bInterfaceSubClass;
    211       1.1  augustss 	uByte		bInterfaceProtocol;
    212       1.1  augustss 	uByte		iInterface;
    213       1.1  augustss } usb_interface_descriptor_t;
    214       1.1  augustss #define USB_INTERFACE_DESCRIPTOR_SIZE 9
    215       1.1  augustss 
    216       1.1  augustss typedef struct {
    217       1.1  augustss 	uByte		bLength;
    218       1.1  augustss 	uByte		bDescriptorType;
    219       1.1  augustss 	uByte		bEndpointAddress;
    220       1.1  augustss #define UE_IN		0x80
    221       1.1  augustss #define UE_OUT		0x00
    222       1.1  augustss #define UE_ADDR		0x0f
    223       1.6  augustss #define UE_GET_ADDR(a)	((a) & UE_ADDR)
    224       1.1  augustss #define UE_GET_IN(a)	(((a) >> 7) & 1)
    225       1.1  augustss 	uByte		bmAttributes;
    226       1.1  augustss #define UE_XFERTYPE	0x03
    227      1.10  augustss #define  UE_CONTROL	0x00
    228      1.10  augustss #define  UE_ISOCHRONOUS	0x01
    229      1.10  augustss #define  UE_BULK	0x02
    230      1.10  augustss #define  UE_INTERRUPT	0x03
    231      1.10  augustss #define UE_ISO_TYPE	0x0c
    232      1.10  augustss #define  UE_ISO_ASYNC	0x04
    233      1.10  augustss #define  UE_ISO_ADAPT	0x08
    234      1.10  augustss #define  UE_ISO_SYNC	0x0c
    235       1.1  augustss 	uWord		wMaxPacketSize;
    236       1.1  augustss 	uByte		bInterval;
    237       1.1  augustss } usb_endpoint_descriptor_t;
    238       1.1  augustss #define USB_ENDPOINT_DESCRIPTOR_SIZE 7
    239       1.1  augustss 
    240       1.1  augustss typedef struct {
    241       1.1  augustss 	uByte		bLength;
    242       1.1  augustss 	uByte		bDescriptorType;
    243       1.1  augustss 	uWord		bString[127];
    244       1.1  augustss } usb_string_descriptor_t;
    245       1.1  augustss #define USB_MAX_STRING_LEN 128
    246      1.15  augustss #define USB_LANGUAGE_TABLE 0	/* # of the string language id table */
    247       1.1  augustss 
    248       1.1  augustss /* Hub specific request */
    249       1.1  augustss #define UR_GET_BUS_STATE	0x02
    250       1.1  augustss 
    251       1.1  augustss /* Hub features */
    252       1.1  augustss #define UHF_C_HUB_LOCAL_POWER	0
    253       1.1  augustss #define UHF_C_HUB_OVER_CURRENT	1
    254       1.1  augustss #define UHF_PORT_CONNECTION	0
    255       1.1  augustss #define UHF_PORT_ENABLE		1
    256       1.1  augustss #define UHF_PORT_SUSPEND	2
    257       1.1  augustss #define UHF_PORT_OVER_CURRENT	3
    258       1.1  augustss #define UHF_PORT_RESET		4
    259       1.1  augustss #define UHF_PORT_POWER		8
    260       1.1  augustss #define UHF_PORT_LOW_SPEED	9
    261       1.1  augustss #define UHF_C_PORT_CONNECTION	16
    262       1.1  augustss #define UHF_C_PORT_ENABLE	17
    263       1.1  augustss #define UHF_C_PORT_SUSPEND	18
    264       1.1  augustss #define UHF_C_PORT_OVER_CURRENT	19
    265       1.1  augustss #define UHF_C_PORT_RESET	20
    266       1.1  augustss 
    267       1.1  augustss typedef struct {
    268       1.1  augustss 	uByte		bDescLength;
    269       1.1  augustss 	uByte		bDescriptorType;
    270       1.1  augustss 	uByte		bNbrPorts;
    271       1.8  augustss 	uWord		wHubCharacteristics;
    272       1.1  augustss #define UHD_PWR			0x03
    273       1.1  augustss #define UHD_PWR_GANGED		0x00
    274       1.1  augustss #define UHD_PWR_INDIVIDUAL	0x01
    275       1.1  augustss #define UHD_PWR_NO_SWITCH	0x02
    276       1.1  augustss #define UHD_COMPOUND		0x04
    277       1.1  augustss #define UHD_OC			0x18
    278       1.1  augustss #define UHD_OC_GLOBAL		0x00
    279       1.1  augustss #define UHD_OC_INDIVIDUAL	0x08
    280       1.1  augustss #define UHD_OC_NONE		0x10
    281       1.1  augustss 	uByte		bPwrOn2PwrGood;	/* delay in 2 ms units */
    282       1.1  augustss #define UHD_PWRON_FACTOR 2
    283       1.1  augustss 	uByte		bHubContrCurrent;
    284       1.8  augustss 	uByte		DeviceRemovable[32]; /* max 255 ports */
    285       1.8  augustss #define UHD_NOT_REMOV(desc, i) \
    286       1.8  augustss     (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
    287       1.8  augustss 	/* deprecated uByte		PortPowerCtrlMask[]; */
    288       1.1  augustss } usb_hub_descriptor_t;
    289       1.8  augustss #define USB_HUB_DESCRIPTOR_SIZE 8
    290       1.1  augustss 
    291       1.1  augustss typedef struct {
    292       1.1  augustss 	uWord		wStatus;
    293       1.1  augustss /* Device status flags */
    294       1.1  augustss #define UDS_SELF_POWERED		0x0001
    295       1.1  augustss #define UDS_REMOTE_WAKEUP		0x0002
    296       1.8  augustss /* Endpoint status flags */
    297       1.8  augustss #define UES_HALT			0x0001
    298       1.1  augustss } usb_status_t;
    299       1.1  augustss 
    300       1.1  augustss typedef struct {
    301       1.1  augustss 	uWord		wHubStatus;
    302       1.1  augustss #define UHS_LOCAL_POWER			0x0001
    303       1.1  augustss #define UHS_OVER_CURRENT		0x0002
    304       1.1  augustss 	uWord		wHubChange;
    305       1.1  augustss } usb_hub_status_t;
    306       1.1  augustss 
    307       1.1  augustss typedef struct {
    308       1.1  augustss 	uWord		wPortStatus;
    309       1.1  augustss #define UPS_CURRENT_CONNECT_STATUS	0x0001
    310       1.1  augustss #define UPS_PORT_ENABLED		0x0002
    311       1.1  augustss #define UPS_SUSPEND			0x0004
    312       1.1  augustss #define UPS_OVERCURRENT_INDICATOR	0x0008
    313       1.1  augustss #define UPS_RESET			0x0010
    314       1.1  augustss #define UPS_PORT_POWER			0x0100
    315       1.1  augustss #define UPS_LOW_SPEED			0x0200
    316       1.1  augustss 	uWord		wPortChange;
    317       1.1  augustss #define UPS_C_CONNECT_STATUS		0x0001
    318       1.1  augustss #define UPS_C_PORT_ENABLED		0x0002
    319       1.1  augustss #define UPS_C_SUSPEND			0x0004
    320       1.1  augustss #define UPS_C_OVERCURRENT_INDICATOR	0x0008
    321       1.1  augustss #define UPS_C_PORT_RESET		0x0010
    322       1.1  augustss } usb_port_status_t;
    323       1.1  augustss 
    324       1.1  augustss #define UDESC_CS_DEVICE		0x21
    325       1.1  augustss #define UDESC_CS_CONFIG		0x22
    326       1.1  augustss #define UDESC_CS_STRING		0x23
    327       1.1  augustss #define UDESC_CS_INTERFACE	0x24
    328       1.1  augustss #define UDESC_CS_ENDPOINT	0x25
    329       1.1  augustss 
    330       1.1  augustss #define UDESC_HUB		0x29
    331       1.1  augustss 
    332       1.1  augustss #define UCLASS_UNSPEC		0
    333       1.1  augustss #define UCLASS_AUDIO		1
    334       1.1  augustss #define  USUBCLASS_AUDIOCONTROL	1
    335       1.1  augustss #define  USUBCLASS_AUDIOSTREAM	2
    336      1.16  augustss #define UCLASS_CDC		2 /* communication */
    337  1.18.4.1   thorpej #define	 USUBCLASS_DIRECT_LINE_CONTROL_MODEL	1
    338       1.7  augustss #define  USUBCLASS_ABSTRACT_CONTROL_MODEL	2
    339  1.18.4.1   thorpej #define	 USUBCLASS_TELEPHONE_CONTROL_MODEL	3
    340  1.18.4.1   thorpej #define	 USUBCLASS_MULTICHANNEL_CONTROL_MODEL	4
    341  1.18.4.1   thorpej #define	 USUBCLASS_CAPI_CONTROLMODEL		5
    342  1.18.4.1   thorpej #define	 USUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
    343  1.18.4.1   thorpej #define	 USUBCLASS_ATM_NETWORKING_CONTROL_MODEL	7
    344       1.7  augustss #define   UPROTO_CDC_AT		1
    345       1.1  augustss #define UCLASS_HID		3
    346       1.1  augustss #define  USUBCLASS_BOOT	 	1
    347       1.1  augustss #define UCLASS_PRINTER		7
    348       1.1  augustss #define  USUBCLASS_PRINTER	1
    349       1.1  augustss #define  UPROTO_PRINTER_UNI	1
    350       1.1  augustss #define  UPROTO_PRINTER_BI	2
    351  1.18.4.1   thorpej #define UCLASS_MASS		8
    352  1.18.4.1   thorpej #define  USUBCLASS_RBC		1
    353  1.18.4.1   thorpej #define  USUBCLASS_SFF8020I	2
    354  1.18.4.1   thorpej #define  USUBCLASS_QIC157	3
    355  1.18.4.1   thorpej #define  USUBCLASS_UFI		4
    356  1.18.4.1   thorpej #define  USUBCLASS_SFF8070I	5
    357  1.18.4.1   thorpej #define  USUBCLASS_SCSI		6
    358  1.18.4.1   thorpej #define  UPROTO_MASS_CBI_C	0
    359  1.18.4.1   thorpej #define  UPROTO_MASS_CBI_NC	1
    360       1.1  augustss #define UCLASS_HUB		9
    361       1.8  augustss #define  USUBCLASS_HUB		0
    362       1.6  augustss #define UCLASS_DATA		10
    363       1.1  augustss 
    364       1.1  augustss #define USB_HUB_MAX_DEPTH 5
    365       1.1  augustss 
    366       1.6  augustss /*
    367       1.6  augustss  * Minimum time a device needs to be powered down to go through
    368      1.11  augustss  * a power cycle.  XXX Are these time in the spec?
    369       1.6  augustss  */
    370      1.11  augustss #define USB_POWER_DOWN_TIME	200 /* ms */
    371       1.9  augustss #define USB_PORT_POWER_DOWN_TIME	100 /* ms */
    372       1.6  augustss 
    373       1.8  augustss #if 0
    374       1.9  augustss /* These are the values from the spec. */
    375       1.1  augustss #define USB_PORT_RESET_DELAY	10  /* ms */
    376       1.8  augustss #define USB_PORT_RESET_SETTLE	10  /* ms */
    377       1.1  augustss #define USB_PORT_POWERUP_DELAY	100 /* ms */
    378       1.8  augustss #define USB_SET_ADDRESS_SETTLE	2   /* ms */
    379  1.18.4.2   thorpej #define USB_RESUME_TIME		(20*5)  /* ms */
    380  1.18.4.2   thorpej #define USB_RESUME_WAIT		10  /* ms */
    381  1.18.4.2   thorpej #define USB_RESUME_RECOVERY	10  /* ms */
    382       1.8  augustss #else
    383       1.9  augustss /* Allow for marginal (i.e. non-conforming) devices. */
    384      1.18  augustss #define USB_PORT_RESET_DELAY	50  /* ms */
    385      1.11  augustss #define USB_PORT_RESET_RECOVERY	50  /* ms */
    386       1.8  augustss #define USB_PORT_POWERUP_DELAY	200 /* ms */
    387       1.8  augustss #define USB_SET_ADDRESS_SETTLE	10  /* ms */
    388  1.18.4.2   thorpej #define USB_RESUME_DELAY	(50*5)  /* ms */
    389  1.18.4.2   thorpej #define USB_RESUME_WAIT		50  /* ms */
    390  1.18.4.2   thorpej #define USB_RESUME_RECOVERY	50  /* ms */
    391       1.8  augustss #endif
    392       1.1  augustss 
    393       1.1  augustss #define USB_MIN_POWER		100 /* mA */
    394       1.1  augustss #define USB_MAX_POWER		500 /* mA */
    395       1.1  augustss 
    396      1.11  augustss #define USB_BUS_RESET_DELAY	100 /* ms XXX?*/
    397       1.1  augustss 
    398       1.1  augustss /*** ioctl() related stuff ***/
    399       1.1  augustss 
    400       1.1  augustss struct usb_ctl_request {
    401       1.1  augustss 	int	addr;
    402       1.1  augustss 	usb_device_request_t request;
    403       1.1  augustss 	void	*data;
    404      1.12  augustss 	int	flags;
    405      1.12  augustss /* XXX must match flags in usbdi.h */
    406      1.12  augustss #define USBD_SHORT_XFER_OK	0x04
    407      1.17  augustss 	int	actlen;		/* actual length transferred */
    408       1.1  augustss };
    409       1.1  augustss 
    410       1.6  augustss struct usb_alt_interface {
    411       1.7  augustss 	int	config_index;
    412       1.6  augustss 	int	interface_index;
    413       1.6  augustss 	int	alt_no;
    414       1.6  augustss };
    415       1.6  augustss 
    416       1.6  augustss #define USB_CURRENT_CONFIG_INDEX (-1)
    417       1.6  augustss #define USB_CURRENT_ALT_INDEX (-1)
    418       1.6  augustss 
    419       1.6  augustss struct usb_config_desc {
    420       1.6  augustss 	int	config_index;
    421       1.6  augustss 	usb_config_descriptor_t desc;
    422       1.6  augustss };
    423       1.6  augustss 
    424       1.6  augustss struct usb_interface_desc {
    425       1.6  augustss 	int	config_index;
    426       1.6  augustss 	int	interface_index;
    427       1.6  augustss 	int	alt_index;
    428       1.6  augustss 	usb_interface_descriptor_t desc;
    429       1.6  augustss };
    430       1.6  augustss 
    431       1.6  augustss struct usb_endpoint_desc {
    432       1.6  augustss 	int	config_index;
    433       1.6  augustss 	int	interface_index;
    434       1.6  augustss 	int	alt_index;
    435       1.6  augustss 	int	endpoint_index;
    436       1.6  augustss 	usb_endpoint_descriptor_t desc;
    437       1.6  augustss };
    438       1.6  augustss 
    439       1.6  augustss struct usb_full_desc {
    440       1.6  augustss 	int	config_index;
    441       1.6  augustss 	u_int	size;
    442       1.6  augustss 	u_char	*data;
    443       1.1  augustss };
    444       1.1  augustss 
    445       1.7  augustss struct usb_string_desc {
    446       1.7  augustss 	int	string_index;
    447       1.7  augustss 	int	language_id;
    448       1.7  augustss 	usb_string_descriptor_t desc;
    449       1.7  augustss };
    450       1.7  augustss 
    451       1.1  augustss struct usb_ctl_report_desc {
    452       1.1  augustss 	int	size;
    453       1.1  augustss 	u_char	data[1024];	/* filled data size will vary */
    454       1.1  augustss };
    455       1.1  augustss 
    456       1.1  augustss struct usb_device_info {
    457      1.14  augustss 	u_int8_t	addr;	/* device address */
    458      1.14  augustss 	char		product[USB_MAX_STRING_LEN];
    459      1.14  augustss 	char		vendor[USB_MAX_STRING_LEN];
    460  1.18.4.1   thorpej 	char		release[8];
    461      1.14  augustss 	u_int16_t	productNo;
    462      1.14  augustss 	u_int16_t	vendorNo;
    463      1.14  augustss 	u_int8_t	class;
    464      1.14  augustss 	u_int8_t	config;
    465      1.14  augustss 	u_int8_t	lowspeed;
    466      1.14  augustss 	int		power;	/* power consumption in mA, 0 if selfpowered */
    467      1.14  augustss 	int		nports;
    468      1.14  augustss 	u_int8_t	ports[16];/* hub only: addresses of devices on ports */
    469       1.1  augustss #define USB_PORT_ENABLED 0xff
    470       1.1  augustss #define USB_PORT_SUSPENDED 0xfe
    471       1.1  augustss #define USB_PORT_POWERED 0xfd
    472       1.1  augustss #define USB_PORT_DISABLED 0xfc
    473       1.1  augustss };
    474       1.1  augustss 
    475       1.2  augustss struct usb_ctl_report {
    476       1.2  augustss 	int report;
    477       1.2  augustss 	u_char	data[1024];	/* filled data size will vary */
    478       1.2  augustss };
    479       1.2  augustss 
    480       1.3  augustss struct usb_device_stats {
    481       1.3  augustss 	u_long	requests[4];	/* indexed by transfer type UE_* */
    482       1.3  augustss };
    483       1.3  augustss 
    484       1.1  augustss /* USB controller */
    485       1.1  augustss #define USB_REQUEST		_IOWR('U', 1, struct usb_ctl_request)
    486       1.1  augustss #define USB_SETDEBUG		_IOW ('U', 2, int)
    487       1.1  augustss #define USB_DISCOVER		_IO  ('U', 3)
    488       1.1  augustss #define USB_DEVICEINFO		_IOWR('U', 4, struct usb_device_info)
    489       1.3  augustss #define USB_DEVICESTATS		_IOR ('U', 5, struct usb_device_stats)
    490       1.1  augustss 
    491       1.1  augustss /* Generic HID device */
    492       1.1  augustss #define USB_GET_REPORT_DESC	_IOR ('U', 21, struct usb_ctl_report_desc)
    493       1.2  augustss #define USB_SET_IMMED		_IOW ('U', 22, int)
    494       1.2  augustss #define USB_GET_REPORT		_IOWR('U', 23, struct usb_ctl_report)
    495       1.1  augustss 
    496       1.1  augustss /* Generic USB device */
    497       1.6  augustss #define USB_GET_CONFIG		_IOR ('U', 100, int)
    498       1.6  augustss #define USB_SET_CONFIG		_IOW ('U', 101, int)
    499       1.6  augustss #define USB_GET_ALTINTERFACE	_IOWR('U', 102, struct usb_alt_interface)
    500       1.7  augustss #define USB_SET_ALTINTERFACE	_IOWR('U', 103, struct usb_alt_interface)
    501       1.6  augustss #define USB_GET_NO_ALT		_IOWR('U', 104, struct usb_alt_interface)
    502       1.6  augustss #define USB_GET_DEVICE_DESC	_IOR ('U', 105, usb_device_descriptor_t)
    503       1.7  augustss #define USB_GET_CONFIG_DESC	_IOWR('U', 106, struct usb_config_desc)
    504       1.6  augustss #define USB_GET_INTERFACE_DESC	_IOWR('U', 107, struct usb_interface_desc)
    505       1.6  augustss #define USB_GET_ENDPOINT_DESC	_IOWR('U', 108, struct usb_endpoint_desc)
    506       1.7  augustss #define USB_GET_FULL_DESC	_IOWR('U', 109, struct usb_full_desc)
    507       1.7  augustss #define USB_GET_STRING_DESC	_IOWR('U', 110, struct usb_string_desc)
    508       1.7  augustss #define USB_DO_REQUEST		_IOWR('U', 111, struct usb_ctl_request)
    509       1.7  augustss #define USB_GET_DEVICEINFO	_IOR ('U', 112, struct usb_device_info)
    510      1.16  augustss #define USB_SET_SHORT_XFER	_IOW ('U', 113, int)
    511       1.1  augustss 
    512       1.1  augustss #endif /* _USB_H_ */
    513