]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/usb/mxc/v2_0/include/usbp-chap9.h
Initial revision
[karo-tx-redboot.git] / packages / devs / usb / mxc / v2_0 / include / usbp-chap9.h
1 /*
2  * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
3  */
4
5 /* Modified from Belcarra Linux USB driver by Yi Li */
6
7 /*
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:
11  *
12  * http://www.opensource.org/licenses/gpl-license.html
13  * http://www.gnu.org/copyleft/gpl.html
14  */
15
16 #define USB_DIR_OUT                     0
17 #define USB_DIR_IN                      0x80
18
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
24
25 #define USB_ENDPOINT_NUMBER_MASK        0x0f            
26 #define USB_ENDPOINT_DIR_MASK           0x80
27
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
33
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
44
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
56
57 #define USB_REQ_DIRECTION_MASK          0x80
58 #define USB_REQ_TYPE_MASK               0x60
59 #define USB_REQ_RECIPIENT_MASK          0x1f
60
61 #define USB_REQ_DEVICE2HOST             0x80
62 #define USB_REQ_HOST2DEVICE             0x00
63
64 #define USB_REQ_TYPE_STANDARD           0x00
65 #define USB_REQ_TYPE_CLASS              0x20
66 #define USB_REQ_TYPE_VENDOR             0x40
67
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
72
73 #define USB_STATUS_SELFPOWERED          0x01
74 #define USB_STATUS_REMOTEWAKEUP         0x02
75
76 #define USB_STATUS_HALT                 0x01
77
78 #define FEATURE(f)                      (1 << f)
79
80 #define USB_ENDPOINT_HALT               0x00
81 #define USB_DEVICE_REMOTE_WAKEUP        0x01
82
83 struct usbd_device_request {
84     u8 bmRequestType;
85     u8 bRequest;
86     u16 wValue;
87     u16 wIndex;
88     u16 wLength;
89 };
90
91 struct usbd_endpoint_descriptor {
92     u8 bLength;
93     u8 bDescriptorType;   // 0x5
94     u8 bEndpointAddress;
95     u8 bmAttributes;
96     u16 wMaxPacketSize;
97     u8 bInterval;
98 };
99
100 struct usbd_interface_descriptor {
101     u8 bLength;
102     u8 bDescriptorType;   // 0x04
103     u8 bInterfaceNumber;
104     u8 bAlternateSetting;
105     u8 bNumEndpoints;
106     u8 bInterfaceClass;
107     u8 bInterfaceSubClass;
108     u8 bInterfaceProtocol;
109     u8 iInterface;
110 };
111
112 struct usbd_configuration_descriptor {
113     u8 bLength;
114     u8 bDescriptorType;   // 0x2
115     u16 wTotalLength;
116     u8 bNumInterfaces;
117     u8 bConfigurationValue;
118     u8 iConfiguration;
119     u8 bmAttributes;
120     u8 bMaxPower;
121 };
122
123 struct usbd_device_descriptor {
124     u8 bLength;
125     u8 bDescriptorType;   // 0x01
126     u16 bcdUSB;
127     u8 bDeviceClass;
128     u8 bDeviceSubClass;
129     u8 bDeviceProtocol;
130     u8 bMaxPacketSize0;
131     u16 idVendor;
132     u16 idProduct;
133     u16 bcdDevice;
134     u8 iManufacturer;
135     u8 iProduct;
136     u8 iSerialNumber;
137     u8 bNumConfigurations;
138 };
139
140 struct usbd_langid_descriptor {
141     u8 bLength;
142     u8 bDescriptorType;   // 0x03
143     u8 bData[2];
144 };
145
146 typedef enum usbd_urb_status {
147     USBD_URB_OK = 0,
148     USBD_URB_IN_QUEUE,
149     USBD_URB_ACTIVE,
150     USBD_URB_CANCELLED,
151     USBD_URB_ERROR,
152     USBD_URB_STALLED,
153     USBD_URB_RESET,
154     USBD_URB_NOT_READY,
155     USBD_URB_DISABLED,
156 } usbd_urb_status_t;
157
158 #define USBD_URB_SENDZLP        0x01    /* send a Zero Length Packet when urb is finished */
159
160 /* definition of the structure itself */
161 struct usbd_urb {
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)
166     u32                             flags;
167     usbd_urb_status_t               status;         // what is the current status of the urb
168 };
169
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 
176 };