2 * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
5 /* Modified from Belcarra Linux USB driver by Yi Li */
8 * The code contained herein is licensed under the GNU General Public
9 * License. You may obtain a copy of the GNU General Public License
10 * Version 2 or later at the following locations:
12 * http://www.opensource.org/licenses/gpl-license.html
13 * http://www.gnu.org/copyleft/gpl.html
17 #define USB_DIR_IN 0x80
19 #define USB_DT_DEVICE 1
20 #define USB_DT_CONFIGURATION 2
21 #define USB_DT_STRING 3
22 #define USB_DT_INTERFACE 4
23 #define USB_DT_ENDPOINT 5
25 #define USB_ENDPOINT_NUMBER_MASK 0x0f
26 #define USB_ENDPOINT_DIR_MASK 0x80
28 #define USB_ENDPOINT_MASK 0x03
29 #define USB_ENDPOINT_CONTROL 0x00
30 #define USB_ENDPOINT_ISOCHRONOUS 0x01
31 #define USB_ENDPOINT_BULK 0x02
32 #define USB_ENDPOINT_INTERRUPT 0x03
34 #define USB_PID_OUT 0xe1
35 #define USB_PID_ACK 0xd2
36 #define USB_PID_DATA0 0xc3
37 #define USB_PID_SOF 0xa5
38 #define USB_PID_IN 0x69
39 #define USB_PID_NAK 0x5a
40 #define USB_PID_DATA1 0x4b
41 #define USB_PID_ERR 0x3c
42 #define USB_PID_SETUP 0x2d
43 #define USB_PID_STALL 0x1e
45 #define USB_REQ_GET_STATUS 0x00
46 #define USB_REQ_CLEAR_FEATURE 0x01
47 #define USB_REQ_SET_FEATURE 0x03
48 #define USB_REQ_SET_ADDRESS 0x05
49 #define USB_REQ_GET_DESCRIPTOR 0x06
50 #define USB_REQ_SET_DESCRIPTOR 0x07
51 #define USB_REQ_GET_CONFIGURATION 0x08
52 #define USB_REQ_SET_CONFIGURATION 0x09
53 #define USB_REQ_GET_INTERFACE 0x0A
54 #define USB_REQ_SET_INTERFACE 0x0B
55 #define USB_REQ_SYNCH_FRAME 0x0C
57 #define USB_REQ_DIRECTION_MASK 0x80
58 #define USB_REQ_TYPE_MASK 0x60
59 #define USB_REQ_RECIPIENT_MASK 0x1f
61 #define USB_REQ_DEVICE2HOST 0x80
62 #define USB_REQ_HOST2DEVICE 0x00
64 #define USB_REQ_TYPE_STANDARD 0x00
65 #define USB_REQ_TYPE_CLASS 0x20
66 #define USB_REQ_TYPE_VENDOR 0x40
68 #define USB_REQ_RECIPIENT_DEVICE 0x00
69 #define USB_REQ_RECIPIENT_INTERFACE 0x01
70 #define USB_REQ_RECIPIENT_ENDPOINT 0x02
71 #define USB_REQ_RECIPIENT_OTHER 0x03
73 #define USB_STATUS_SELFPOWERED 0x01
74 #define USB_STATUS_REMOTEWAKEUP 0x02
76 #define USB_STATUS_HALT 0x01
78 #define FEATURE(f) (1 << f)
80 #define USB_ENDPOINT_HALT 0x00
81 #define USB_DEVICE_REMOTE_WAKEUP 0x01
83 struct usbd_device_request {
91 struct usbd_endpoint_descriptor {
93 u8 bDescriptorType; // 0x5
100 struct usbd_interface_descriptor {
102 u8 bDescriptorType; // 0x04
104 u8 bAlternateSetting;
107 u8 bInterfaceSubClass;
108 u8 bInterfaceProtocol;
112 struct usbd_configuration_descriptor {
114 u8 bDescriptorType; // 0x2
117 u8 bConfigurationValue;
123 struct usbd_device_descriptor {
125 u8 bDescriptorType; // 0x01
137 u8 bNumConfigurations;
140 struct usbd_langid_descriptor {
142 u8 bDescriptorType; // 0x03
146 typedef enum usbd_urb_status {
158 #define USBD_URB_SENDZLP 0x01 /* send a Zero Length Packet when urb is finished */
160 /* definition of the structure itself */
162 struct usbd_endpoint_instance *endpoint;
163 u8 *buffer; // data received (OUT) or being sent (IN)
164 u32 buffer_length; // maximum data expected for OUT
165 u32 actual_length; // actual data received (OUT or being sent (IN)
167 usbd_urb_status_t status; // what is the current status of the urb
170 struct usbd_endpoint_instance {
171 u8 bEndpointAddress; // logical endpoint address
172 int bmAttributes; // endpoint type
173 u16 wMaxPacketSize; // packet size for requested endpoint
174 struct usbd_urb *urb; // active urb
175 u32 planed; // data will be sent in planed packet