1 #ifndef DEVICES_USB_H
    2 #define DEVICES_USB_H
    3 /*
    4 **	$VER: usb.h 2.0 (15.12.07)
    5 **
    6 **	usb definitions include file
    7 **
    8 **	(C) Copyright 2002-2007 Chris Hodges
    9 **	    All Rights Reserved
   10 */
   11 
   12 #include <exec/types.h>
   13 
   14 #if defined(__GNUC__)
   15 # pragma pack(1)
   16 #endif
   17 
   18 /* Flags for bmRequestType */
   19 #define URTF_OUT              0x00      /* direction: host to device */
   20 #define URTF_IN               0x80      /* direction: device to host */
   21 #define URTF_STANDARD         0x00      /* type: usb standard request */
   22 #define URTF_CLASS            0x20      /* type: class request */
   23 #define URTF_VENDOR           0x40      /* type: vendor specific request */
   24 #define URTF_DEVICE           0x00      /* target: device */
   25 #define URTF_INTERFACE        0x01      /* target: interface */
   26 #define URTF_ENDPOINT         0x02      /* target: endpoint */
   27 #define URTF_OTHER            0x03      /* target: other */
   28 
   29 /* Usb Standard Requests (only for URTF_STANDARD) */
   30 #define USR_GET_STATUS        0x00
   31 #define USR_CLEAR_FEATURE     0x01
   32 #define USR_SET_FEATURE       0x03
   33 #define USR_SET_ADDRESS       0x05
   34 #define USR_GET_DESCRIPTOR    0x06
   35 #define USR_SET_DESCRIPTOR    0x07
   36 #define USR_GET_CONFIGURATION 0x08
   37 #define USR_SET_CONFIGURATION 0x09
   38 #define USR_GET_INTERFACE     0x0a
   39 #define USR_SET_INTERFACE     0x0b
   40 #define USR_SYNCH_FRAME       0x0c
   41 
   42 /* Usb Standard Feature Selectors */
   43 #define UFS_DEVICE_REMOTE_WAKEUP  0x01 /* Recipient: Device */
   44 #define UFS_ENDPOINT_HALT         0x00 /* Recipient: Endpoint */
   45 #define UFS_TEST_MODE             0x02 /* Recipient: Device */
   46 
   47 /* Usb GetStatus() data bits (LE-UWORD) */
   48 #define U_GSB_SELF_POWERED        8
   49 #define U_GSB_REMOTE_WAKEUP       9
   50 
   51 #define U_GSF_SELF_POWERED        (1<<U_GSB_SELF_POWERED)
   52 #define U_GSF_REMOTE_WAKEUP       (1<<U_GSB_REMOTE_WAKEUP)
   53 
   54 /* Usb Descriptor Types */
   55 #define UDT_DEVICE                0x01
   56 #define UDT_CONFIGURATION         0x02
   57 #define UDT_STRING                0x03
   58 #define UDT_INTERFACE             0x04
   59 #define UDT_ENDPOINT              0x05
   60 
   61 #define UDT_DEVICE_QUALIFIER      0x06
   62 #define UDT_OTHERSPEED_QUALIFIER  0x07
   63 #define UDT_INTERFACE_POWER       0x08
   64 #define UDT_OTG                   0x09
   65 #define UDT_DEBUG                 0x0a
   66 #define UDT_INTERFACE_ASSOCIATION 0x0b
   67 #define UDT_SECURITY              0x0c
   68 #define UDT_ENCRYPTION_TYPE       0x0e
   69 #define UDT_BOS                   0x0f
   70 #define UDT_DEVICE_CAPABILITY     0x10
   71 #define UDT_WIRELESS_EP_COMP      0x11 /* Wireless endpoint companion descriptor */
   72 
   73 /* common class specific descriptors */
   74 #define UDT_CS_UNDEFINED      0x20
   75 #define UDT_CS_DEVICE         0x21
   76 #define UDT_CS_CONFIGURATION  0x22
   77 #define UDT_CS_STRING         0x23
   78 #define UDT_CS_INTERFACE      0x24
   79 #define UDT_CS_ENDPOINT       0x25
   80 
   81 /* SMARTCARD class specific descriptors */
   82 #define UDT_CCID              0x21 /* Smart card CCID functional descriptor */
   83 
   84 /* Device Wire Adapter class specific descriptors */
   85 #define UDT_WIREADAPTER_CLASS 0x21 /* Wire Adapter class descriptor */
   86 #define UDT_WIREADAPTER_RPIPE 0x22 /* Wire Adapter RPipe descriptor */
   87 #define UDT_RADIO_CONTROL_IF  0x23 /* Radio Control Interface Class descriptor */
   88 
   89 /* Format of 8-bytes setup packet */
   90 struct UsbSetupData
   91 {
   92     UBYTE bmRequestType;       /* Request type and direction */
   93     UBYTE bRequest;            /* Request identifier */
   94     UWORD wValue;              /* request specific value, little endian! */
   95     UWORD wIndex;              /* request specific index, little endian! */
   96     UWORD wLength;             /* length of data to transfer, little endian! */
   97 };
   98 
   99 /* Usb Standard Device Descriptor */
  100 struct UsbStdDevDesc
  101 {
  102     UBYTE bLength;             /* Size of this descriptor in bytes */
  103     UBYTE bDescriptorType;     /* UDT_DEVICE Descriptor Type */
  104     UWORD bcdUSB;              /* USB Specification Release Number */
  105     UBYTE bDeviceClass;        /* Class code (assigned by the USB). */
  106     UBYTE bDeviceSubClass;     /* Subclass code (assigned by the USB). */
  107     UBYTE bDeviceProtocol;     /* Protocol code (assigned by the USB). */
  108     UBYTE bMaxPacketSize0;     /* Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid) */
  109     UWORD idVendor;            /* Vendor ID (assigned by the USB) */
  110     UWORD idProduct;           /* Product ID (assigned by the manufacturer) */
  111     UWORD bcdDevice;           /* Device release number in binary-coded decimal */
  112     UBYTE iManufacturer;       /* Index of string descriptor describing manufacturer */
  113     UBYTE iProduct;            /* Index of string descriptor describing product */
  114     UBYTE iSerialNumber;       /* Index of string descriptor describing the device's serial number */
  115     UBYTE bNumConfigurations;  /* Number of possible configurations */
  116 };
  117 
  118 /* Usb Standard Configuration Descriptor */
  119 struct UsbStdCfgDesc
  120 {
  121     UBYTE bLength;             /* Size of this descriptor in bytes */
  122     UBYTE bDescriptorType;     /* UDT_CONFIGURATION Descriptor Type */
  123     UWORD wTotalLength;        /* Total length of data returned for this configuration. */
  124     UBYTE bNumInterfaces;      /* Number of interfaces supported by this configuration. */
  125     UBYTE bConfigurationValue; /* Value to use as an argument to the SetConfiguration() request */
  126     UBYTE iConfiguration;      /* Index of string descriptor describing this configuration */
  127     UBYTE bmAttributes;        /* Configuration characteristics */
  128     UBYTE bMaxPower;           /* Maximum power consumption of the USB device (2mA units) */
  129 };
  130 
  131 /* Flags for bmAttributes */
  132 #define USCAF_ONE             0x80
  133 #define USCAF_SELF_POWERED    0x40
  134 #define USCAF_REMOTE_WAKEUP   0x20
  135 
  136 struct UsbStdIfDesc
  137 {
  138     UBYTE bLength;             /* Size of this descriptor in bytes */
  139     UBYTE bDescriptorType;     /* UDT_INTERFACE Descriptor Type */
  140     UBYTE bInterfaceNumber;    /* Number of interface. */
  141     UBYTE bAlternateSetting;   /* Value used to select alternate setting */
  142     UBYTE bNumEndpoints;       /* Number of endpoints used by this interface (excluding endpoint zero). */
  143     UBYTE bInterfaceClass;     /* Class code (assigned by the USB). */
  144     UBYTE bInterfaceSubClass;  /* Subclass code (assigned by the USB). */
  145     UBYTE bInterfaceProtocol;  /* Protocol code (assigned by the USB). */
  146     UBYTE iInterface;          /* Index of string descriptor describing this interface */
  147 };
  148 
  149 /* Usb Standard Endpoint Descriptor */
  150 
  151 struct UsbStdEPDesc
  152 {
  153     UBYTE bLength;             /* Size of this descriptor in bytes */
  154     UBYTE bDescriptorType;     /* UDT_ENDPOINT Descriptor Type */
  155     UBYTE bEndpointAddress;    /* The address of the endpoint on the USB, MSB holds direction */
  156     UBYTE bmAttributes;        /* TransferType (00=Control, 01=Iso, 10=Bulk, 11=Interrupt */
  157     UWORD wMaxPacketSize;      /* Maximum packet size this endpoint is capable of sending or receiving */
  158     UBYTE bInterval;           /* Interval for polling endpoint for data transfers in ms */
  159 };
  160 
  161 /* Usb Standard String Descriptors */
  162 struct UsbStdStrDesc
  163 {
  164     UBYTE bLength;             /* Size of this descriptor in bytes */
  165     UBYTE bDescriptorType;     /* UDT_STRING Descriptor Type */
  166     UWORD bString[1];          /* UNICODE encoded string */
  167 };
  168 
  169 /* Flags for bmAttributes */
  170 #define USEAF_CONTROL         0x00
  171 #define USEAF_ISOCHRONOUS     0x01
  172 #define USEAF_BULK            0x02
  173 #define USEAF_INTERRUPT       0x03
  174 
  175 /* Flags for Synchronization Type (already shifted right by 2) */
  176 #define USEAF_NOSYNC          0x00
  177 #define USEAF_ASYNC           0x01
  178 #define USEAF_ADAPTIVE        0x02
  179 #define USEAF_SYNC            0x03
  180 
  181 /* Flags for Usage Type (already shifted right by 2) */
  182 #define USEAF_DATA            0x00
  183 #define USEAF_FEEDBACK        0x01
  184 #define USEAF_IMPLFEEDBACK    0x02
  185 
  186 /* Standard classes */
  187 #define AUDIO_CLASSCODE       0x01
  188 #define CDCCTRL_CLASSCODE     0x02
  189 #define CDCDATA_CLASSCODE     0x0a
  190 #define HID_CLASSCODE         0x03
  191 #define PHYSICAL_CLASSCODE    0x05
  192 #define STILLIMG_CLASSCODE    0x06
  193 #define PRINTER_CLASSCODE     0x07
  194 #define MASSSTORE_CLASSCODE   0x08
  195 #define HUB_CLASSCODE         0x09
  196 #define SMARTCARD_CLASSCODE   0x0b
  197 #define SECURITY_CLASSCODE    0x0d
  198 #define VIDEO_CLASSCODE       0x0e
  199 #define BLUETOOTH_CLASSCODE   0xe0
  200 #define MISC_CLASSCODE        0xef
  201 #define FWUPGRADE_CLASSCODE   0xfe
  202 #define VENDOR_CLASSCODE      0xff
  203 
  204 /* Misc Subclasses */
  205 #define MISC_COMMON_SUBCLASS  0x02
  206 
  207 /* Misc Subclass Common protocols */
  208 #define MISC_PROTO_WUSB_WAMP  0x02 /* Wire Adapter Multifunction Peripheral */
  209 
  210 /* Bluetooth subclasses */
  211 #define BLUETOOTH_RF_SUBCLASS 0x01
  212 #define BLUETOOTH_WUSB_SUBCLASS 0x02 /* Wireless USB Wire Adapter */
  213 
  214 /* Bluetooth RF protocols */
  215 #define BLUETOOTH_PROTO_PRG   0x01
  216 #define BLUETOOTH_PROTO_UWB   0x02 /* UWB Radio Control Interface Programming Interface */
  217 
  218 /* Wireless WUSB protocols */
  219 #define BLUETOOTH_PROTO_HWA   0x01 /* Host Wire Adapter Control */
  220 
  221 #if defined(__GNUC__)
  222 # pragma pack()
  223 #endif
  224 
  225 #endif /* DEVICES_USB_H */