revert between 56095 -> 55830 in arch
[AROS.git] / compiler / include / devices / usb.h
blob3e5430b8276642d83e28881aac5ca23e3bee8662
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
12 #include <exec/types.h>
14 #if defined(__GNUC__)
15 # pragma pack(1)
16 #endif
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 */
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
42 #ifdef AROS_USB30_CODE
43 #define USR_SET_SEL 0x30
44 #define USR_SET_ISOCH_DELAY 0x31
45 #endif
47 /* Usb Standard Feature Selectors */
48 #define UFS_DEVICE_REMOTE_WAKEUP 0x01 /* Recipient: Device */
49 #define UFS_ENDPOINT_HALT 0x00 /* Recipient: Endpoint */
50 #define UFS_TEST_MODE 0x02 /* Recipient: Device */
51 /* OTG Set Feature */
52 #define UFS_B_HNP_ENABLE 0x03 /* Setting this feature indicates to the B-device that it has been enabled to perform HNP. */
53 #define UFS_A_HNP_SUPPORT 0x04 /* Setting this feature indicates to the B-device that it is directly connected to an A-device port that supports HNP. */
54 #define UFS_A_ALT_HNP_SUPPORT 0x05 /*
55 Setting this feature indicates to the B-device that it is connected to an A-device port that is not capable of HNP,
56 but that the A-device does have an alternate port that is capable of HNP.
57 */
59 /* Usb GetStatus() data bits (LE-UWORD) */
60 #define U_GSB_SELF_POWERED 8
61 #define U_GSB_REMOTE_WAKEUP 9
63 #define U_GSF_SELF_POWERED (1<<U_GSB_SELF_POWERED)
64 #define U_GSF_REMOTE_WAKEUP (1<<U_GSB_REMOTE_WAKEUP)
66 /* Usb Descriptor Types */
67 #define UDT_DEVICE 0x01
68 #define UDT_CONFIGURATION 0x02
69 #define UDT_STRING 0x03
70 #define UDT_INTERFACE 0x04
71 #define UDT_ENDPOINT 0x05
73 #define UDT_DEVICE_QUALIFIER 0x06
74 #define UDT_OTHERSPEED_QUALIFIER 0x07
75 #define UDT_INTERFACE_POWER 0x08
76 #define UDT_OTG 0x09
77 #define UDT_DEBUG 0x0a
78 #define UDT_INTERFACE_ASSOCIATION 0x0b
79 #define UDT_SECURITY 0x0c
80 #define UDT_ENCRYPTION_TYPE 0x0e
81 #define UDT_BOS 0x0f
82 #define UDT_DEVICE_CAPABILITY 0x10
83 #define UDT_WIRELESS_EP_COMP 0x11 /* Wireless endpoint companion descriptor */
85 /* common class specific descriptors */
86 #define UDT_CS_UNDEFINED 0x20
87 #define UDT_CS_DEVICE 0x21
88 #define UDT_CS_CONFIGURATION 0x22
89 #define UDT_CS_STRING 0x23
90 #define UDT_CS_INTERFACE 0x24
91 #define UDT_CS_ENDPOINT 0x25
93 /* SMARTCARD class specific descriptors */
94 #define UDT_CCID 0x21 /* Smart card CCID functional descriptor */
96 /* Device Wire Adapter class specific descriptors */
97 #define UDT_WIREADAPTER_CLASS 0x21 /* Wire Adapter class descriptor */
98 #define UDT_WIREADAPTER_RPIPE 0x22 /* Wire Adapter RPipe descriptor */
99 #define UDT_RADIO_CONTROL_IF 0x23 /* Radio Control Interface Class descriptor */
101 /* Format of 8-bytes setup packet */
102 struct UsbSetupData
104 UBYTE bmRequestType; /* Request type and direction */
105 UBYTE bRequest; /* Request identifier */
106 UWORD wValue; /* request specific value, little endian! */
107 UWORD wIndex; /* request specific index, little endian! */
108 UWORD wLength; /* length of data to transfer, little endian! */
111 /* Usb Standard Device Descriptor */
112 struct UsbStdDevDesc
114 UBYTE bLength; /* Size of this descriptor in bytes */
115 UBYTE bDescriptorType; /* UDT_DEVICE Descriptor Type */
116 UWORD bcdUSB; /* USB Specification Release Number */
117 UBYTE bDeviceClass; /* Class code (assigned by the USB). */
118 UBYTE bDeviceSubClass; /* Subclass code (assigned by the USB). */
119 UBYTE bDeviceProtocol; /* Protocol code (assigned by the USB). */
120 UBYTE bMaxPacketSize0; /* Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid) */
121 UWORD idVendor; /* Vendor ID (assigned by the USB) */
122 UWORD idProduct; /* Product ID (assigned by the manufacturer) */
123 UWORD bcdDevice; /* Device release number in binary-coded decimal */
124 UBYTE iManufacturer; /* Index of string descriptor describing manufacturer */
125 UBYTE iProduct; /* Index of string descriptor describing product */
126 UBYTE iSerialNumber; /* Index of string descriptor describing the device's serial number */
127 UBYTE bNumConfigurations; /* Number of possible configurations */
130 /* Usb Standard Configuration Descriptor */
131 struct UsbStdCfgDesc
133 UBYTE bLength; /* Size of this descriptor in bytes */
134 UBYTE bDescriptorType; /* UDT_CONFIGURATION Descriptor Type */
135 UWORD wTotalLength; /* Total length of data returned for this configuration. */
136 UBYTE bNumInterfaces; /* Number of interfaces supported by this configuration. */
137 UBYTE bConfigurationValue; /* Value to use as an argument to the SetConfiguration() request */
138 UBYTE iConfiguration; /* Index of string descriptor describing this configuration */
139 UBYTE bmAttributes; /* Configuration characteristics */
140 UBYTE bMaxPower; /* Maximum power consumption of the USB device (2mA units) */
143 /* Flags for bmAttributes */
144 #define USCAF_ONE 0x80
145 #define USCAF_SELF_POWERED 0x40
146 #define USCAF_REMOTE_WAKEUP 0x20
148 struct UsbStdIfDesc
150 UBYTE bLength; /* Size of this descriptor in bytes */
151 UBYTE bDescriptorType; /* UDT_INTERFACE Descriptor Type */
152 UBYTE bInterfaceNumber; /* Number of interface. */
153 UBYTE bAlternateSetting; /* Value used to select alternate setting */
154 UBYTE bNumEndpoints; /* Number of endpoints used by this interface (excluding endpoint zero). */
155 UBYTE bInterfaceClass; /* Class code (assigned by the USB). */
156 UBYTE bInterfaceSubClass; /* Subclass code (assigned by the USB). */
157 UBYTE bInterfaceProtocol; /* Protocol code (assigned by the USB). */
158 UBYTE iInterface; /* Index of string descriptor describing this interface */
161 /* Usb Standard Endpoint Descriptor */
163 struct UsbStdEPDesc
165 UBYTE bLength; /* Size of this descriptor in bytes */
166 UBYTE bDescriptorType; /* UDT_ENDPOINT Descriptor Type */
167 UBYTE bEndpointAddress; /* The address of the endpoint on the USB, MSB holds direction */
168 UBYTE bmAttributes; /* TransferType (00=Control, 01=Iso, 10=Bulk, 11=Interrupt */
169 UWORD wMaxPacketSize; /* Maximum packet size this endpoint is capable of sending or receiving */
170 UBYTE bInterval; /* Interval for polling endpoint for data transfers in ms */
173 /* Usb Standard String Descriptors */
174 struct UsbStdStrDesc
176 UBYTE bLength; /* Size of this descriptor in bytes */
177 UBYTE bDescriptorType; /* UDT_STRING Descriptor Type */
178 UWORD bString[1]; /* UNICODE encoded string */
181 /* Usb Standard Binary Device Object Store (BOS) */
182 struct UsbStdBOSDesc
184 UBYTE bLength;
185 UBYTE bDescriptorType;
186 UWORD wTotalLength;
187 UBYTE bNumDeviceCaps;
190 /* Usb 2.0 Extension Descriptor */
191 struct Usb20ExtDesc
193 UBYTE bLength;
194 UBYTE bDescriptorType;
195 UBYTE bDevCapabilityType;
196 ULONG bmAttributes;
199 /* Usb SuperSpeed Device Capability Descriptor */
200 struct UsbSSDevCapDesc
202 UBYTE bLength;
203 UBYTE bDescriptorType;
204 UBYTE bDevCapabilityType;
205 UBYTE bmAttributes;
206 UWORD wSpeedSupported;
207 UBYTE bFunctionalitySupport;
208 UBYTE bU1DevExitLat;
209 UWORD bU2DevExitLat;
213 The OTG supplement introduces the OTG Descriptor. This descriptor is sent by the B-Device
214 after a Get_Descriptor(config) request (for example inserted between the configuration and the
215 first interface descriptors).
217 struct UsbStdOTGDesc
219 UBYTE bLength;
220 UBYTE bDescriptorType;
221 UBYTE bInterfaceNumber;
225 The HNP Support bit is set if the device supports HNP. (Host Negotiation Protocol)
226 The SRP Support bit is set if the device supports SRP. (Session Request Protocol)
228 #define OTGB_SRP_SUPPORT 0
229 #define OTGB_HNP_SUPPORT 1
231 #define OTGF_SRP_SUPPORT (1<<OTGB_SRP_SUPPORT)
232 #define OTGF_HNP_SUPPORT (1<<OTGB_HNP_SUPPORT)
234 /* Flags for bmAttributes */
235 #define USEAF_CONTROL 0x00
236 #define USEAF_ISOCHRONOUS 0x01
237 #define USEAF_BULK 0x02
238 #define USEAF_INTERRUPT 0x03
240 /* Flags for Synchronization Type (already shifted right by 2) */
241 #define USEAF_NOSYNC 0x00
242 #define USEAF_ASYNC 0x01
243 #define USEAF_ADAPTIVE 0x02
244 #define USEAF_SYNC 0x03
246 /* Flags for Usage Type (already shifted right by 2) */
247 #define USEAF_DATA 0x00
248 #define USEAF_FEEDBACK 0x01
249 #define USEAF_IMPLFEEDBACK 0x02
251 /* Standard classes */
252 #define AUDIO_CLASSCODE 0x01
253 #define CDCCTRL_CLASSCODE 0x02
254 #define CDCDATA_CLASSCODE 0x0a
255 #define HID_CLASSCODE 0x03
256 #define PHYSICAL_CLASSCODE 0x05
257 #define STILLIMG_CLASSCODE 0x06
258 #define PRINTER_CLASSCODE 0x07
259 #define MASSSTORE_CLASSCODE 0x08
260 #define HUB_CLASSCODE 0x09
261 #define HUB_SUBCLASS 0x00
262 #define SMARTCARD_CLASSCODE 0x0b
263 #define SECURITY_CLASSCODE 0x0d
264 #define VIDEO_CLASSCODE 0x0e
265 #define BLUETOOTH_CLASSCODE 0xe0
266 #define MISC_CLASSCODE 0xef
267 #define FWUPGRADE_CLASSCODE 0xfe
268 #define VENDOR_CLASSCODE 0xff
270 /* Misc Subclasses */
271 #define MISC_COMMON_SUBCLASS 0x02
273 /* Misc Subclass Common protocols */
274 #define MISC_PROTO_WUSB_WAMP 0x02 /* Wire Adapter Multifunction Peripheral */
276 /* Bluetooth subclasses */
277 #define BLUETOOTH_RF_SUBCLASS 0x01
278 #define BLUETOOTH_WUSB_SUBCLASS 0x02 /* Wireless USB Wire Adapter */
280 /* Bluetooth RF protocols */
281 #define BLUETOOTH_PROTO_PRG 0x01
282 #define BLUETOOTH_PROTO_UWB 0x02 /* UWB Radio Control Interface Programming Interface */
284 /* Wireless WUSB protocols */
285 #define BLUETOOTH_PROTO_HWA 0x01 /* Host Wire Adapter Control */
287 #if defined(__GNUC__)
288 # pragma pack()
289 #endif
291 #endif /* DEVICES_USB_H */