Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / k2 / usb_std.h
1 #ifndef USB_STD_H
2 #define USB_STD_H
3
4 #define mDEV_REQ_REQ_DIR()      (ControlCmd.Direction)
5 #define mDEV_REQ_REQ_TYPE()     (ControlCmd.Type)
6 #define mDEV_REQ_REQ_RECI()     (ControlCmd.Object)
7 #define mDEV_REQ_REQ()          (ControlCmd.Request)
8 #define mDEV_REQ_VALUE()        (ControlCmd.Value)
9 #define mDEV_REQ_VALUE_LOW()    (mLOW_BYTE(mDEV_REQ_VALUE()))
10 #define mDEV_REQ_VALUE_HIGH()   (mHIGH_BYTE(mDEV_REQ_VALUE()))
11 #define mDEV_REQ_INDEX()        (ControlCmd.Index)
12 #define mDEV_REQ_LENGTH()       (ControlCmd.Length)
13
14 /******************** USB Protocol Definition *************************/
15 /* Standard Request Code (Table 9-4) */
16 #define USB_GET_STATUS          0
17 #define USB_CLEAR_FEATURE       1
18 #define USB_SET_FEATURE         3
19 #define USB_SET_ADDRESS         5
20 #define USB_GET_DESCRIPTOR      6
21 #define USB_SET_DESCRIPTOR      7
22 #define USB_GET_CONFIGURATION   8
23 #define USB_SET_CONFIGURATION   9
24 #define USB_GET_INTERFACE       10
25 #define USB_SET_INTERFACE       11
26 #define USB_SYNCH_FRAME         12
27
28 /* Descriptor Type (Table 9-5) */
29 #define USB_DESC_TYPE_DEVICE    1
30 #define USB_DESC_TYPE_CONFIG    2
31 #define USB_DESC_TYPE_STRING    3
32 #define USB_DESC_TYPE_INTERFACE 4
33 #define USB_DESC_TYPE_ENDPOINT  5
34
35 /* Endpoint Attribute (Table 9-10) */
36 #define USB_EP_ATTR_CTRL        0
37 #define USB_EP_ATTR_ISOCH       1
38 #define USB_EP_ATTR_BULK        2
39 #define USB_EP_ATTR_INTRPT      3
40
41 /*********************** for USB 2.0 **********************************/
42 // Table 9-5. Descriptor Types
43 #define DT_DEVICE                       1
44 #define DT_CONFIGURATION                2
45 #define DT_STRING                       3
46 #define DT_INTERFACE                    4
47 #define DT_ENDPOINT                     5
48 #define DT_DEVICE_QUALIFIER             6
49 #define DT_OTHER_SPEED_CONFIGURATION    7
50 #define DT_INTERFACE_POWER              8
51
52 /**********************************************************************/
53 // Values for bmAttributes Field in USB_CONFIGURATION_DESCRIPTOR
54 #define USB_BUS_POWERED         0x80
55 #define USB_SELF_POWERED        0x40
56 #define USB_REMOTE_WAKEUP       0x20
57
58 #define cUSB_REQTYPE_DIR_POS    7
59 #define cUSB_REQTYPE_DIR_LEN    1
60 #define cUSB_REQTYPE_TYPE_POS   5
61 #define cUSB_REQTYPE_TYPE_LEN   2
62 #define cUSB_REQTYPE_RX_POS     0
63 #define cUSB_REQTYPE_RX_LEN     5
64
65 /* for USB State */
66 #define cUSB_DEFAULT_STATE      0
67 #define cUSB_ADDRESS_STATE      1
68 #define cUSB_CONFIG_STATE       2
69
70 /* for Data transfer direction */
71 #define bmUSB_HOST_DIR          7     /* Bit 7 */
72 #define cUSB_DIR_HOST_OUT       0
73 #define cUSB_DIR_HOST_IN        1
74
75 /* for Type */
76 #define cUSB_REQTYPE_STD        0
77 #define cUSB_REQTYPE_CLASS      1
78 #define cUSB_REQTYPE_VENDOR     2
79
80 /* for Recipient */
81 #define cUSB_REQTYPE_DEVICE     0
82 #define cUSB_REQTYPE_INTERFACE  1
83 #define cUSB_REQTYPE_ENDPOINT   2
84 #define cUSB_REQTYPE_OTHER      3
85
86 /* for Descriptor Type */
87 #define cUSB_DESTYPE_DEVICE     1
88 #define cUSB_DESTYPE_CONFIG     2
89 #define cUSB_DESTYPE_STRING     3
90 #define cUSB_DESTYPE_INTERFACE  4
91 #define cUSB_DESTYPE_ENDPOINT   5
92 #define cUSB_DESTYPE_END        cUSB_DESTYPE_ENDPOINT   // for range check
93
94 /* for Feature selector */
95 #define cUSB_FEATSEL_RMWAKEUP   0
96 #define cUSB_FEATSEL_EPHAL      1
97 #define cUSB_FEATSEL_END        cUSB_FEATSEL_EPHAL      // for range check
98
99 #define bmREQ_RECI              0
100 #define bmwREQ_RECI             5           // mMASKS(bmwREQ_RECI, bmREQ_RECI)
101 #define bmREQ_TYPE              5
102 #define bmwREQ_TYPE             2           // mMASKS(bmwREQ_TYPE, bmREQ_TYPE)
103 #define bmREQ_DIR               7
104 #define bmwREQ_DIR              1
105
106 #endif