Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / hif / usb / src / usb_std.h
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 #ifndef USB_STD_H
36 #define USB_STD_H
37
38 #define mDEV_REQ_REQ_DIR()      (ControlCmd.Direction)
39 #define mDEV_REQ_REQ_TYPE()     (ControlCmd.Type)
40 #define mDEV_REQ_REQ_RECI()     (ControlCmd.Object)
41 #define mDEV_REQ_REQ()          (ControlCmd.Request)
42 #define mDEV_REQ_VALUE()        (ControlCmd.Value)
43 #define mDEV_REQ_VALUE_LOW()    (mLOW_BYTE(mDEV_REQ_VALUE()))
44 #define mDEV_REQ_VALUE_HIGH()   (mHIGH_BYTE(mDEV_REQ_VALUE()))
45 #define mDEV_REQ_INDEX()        (ControlCmd.Index)
46 #define mDEV_REQ_LENGTH()       (ControlCmd.Length)
47
48 /******************** USB Protocol Definition *************************/
49 /* Standard Request Code (Table 9-4) */
50 #define USB_GET_STATUS          0
51 #define USB_CLEAR_FEATURE       1
52 #define USB_SET_FEATURE         3
53 #define USB_SET_ADDRESS         5
54 #define USB_GET_DESCRIPTOR      6
55 #define USB_SET_DESCRIPTOR      7
56 #define USB_GET_CONFIGURATION   8
57 #define USB_SET_CONFIGURATION   9
58 #define USB_GET_INTERFACE       10
59 #define USB_SET_INTERFACE       11
60 #define USB_SYNCH_FRAME         12
61
62 /* Descriptor Type (Table 9-5) */
63 #define USB_DESC_TYPE_DEVICE    1
64 #define USB_DESC_TYPE_CONFIG    2
65 #define USB_DESC_TYPE_STRING    3
66 #define USB_DESC_TYPE_INTERFACE 4
67 #define USB_DESC_TYPE_ENDPOINT  5
68
69 /* Endpoint Attribute (Table 9-10) */
70 #define USB_EP_ATTR_CTRL        0
71 #define USB_EP_ATTR_ISOCH       1
72 #define USB_EP_ATTR_BULK        2
73 #define USB_EP_ATTR_INTRPT      3
74
75 /*********************** for USB 2.0 **********************************/
76 // Table 9-5. Descriptor Types
77 #define DT_DEVICE                       1
78 #define DT_CONFIGURATION                2
79 #define DT_STRING                       3
80 #define DT_INTERFACE                    4
81 #define DT_ENDPOINT                     5
82 #define DT_DEVICE_QUALIFIER             6
83 #define DT_OTHER_SPEED_CONFIGURATION    7
84 #define DT_INTERFACE_POWER              8
85
86 /**********************************************************************/
87 // Values for bmAttributes Field in USB_CONFIGURATION_DESCRIPTOR
88 #define USB_BUS_POWERED         0x80
89 #define USB_SELF_POWERED        0x40
90 #define USB_REMOTE_WAKEUP       0x20
91
92 #define cUSB_REQTYPE_DIR_POS    7
93 #define cUSB_REQTYPE_DIR_LEN    1
94 #define cUSB_REQTYPE_TYPE_POS   5
95 #define cUSB_REQTYPE_TYPE_LEN   2
96 #define cUSB_REQTYPE_RX_POS     0
97 #define cUSB_REQTYPE_RX_LEN     5
98
99 /* for USB State */
100 #define cUSB_DEFAULT_STATE      0
101 #define cUSB_ADDRESS_STATE      1
102 #define cUSB_CONFIG_STATE       2
103
104 /* for Data transfer direction */
105 #define bmUSB_HOST_DIR          7     /* Bit 7 */
106 #define cUSB_DIR_HOST_OUT       0
107 #define cUSB_DIR_HOST_IN        1
108
109 /* for Type */
110 #define cUSB_REQTYPE_STD        0
111 #define cUSB_REQTYPE_CLASS      1
112 #define cUSB_REQTYPE_VENDOR     2
113
114 /* for Recipient */
115 #define cUSB_REQTYPE_DEVICE     0
116 #define cUSB_REQTYPE_INTERFACE  1
117 #define cUSB_REQTYPE_ENDPOINT   2
118 #define cUSB_REQTYPE_OTHER      3
119
120 /* for Descriptor Type */
121 #define cUSB_DESTYPE_DEVICE     1
122 #define cUSB_DESTYPE_CONFIG     2
123 #define cUSB_DESTYPE_STRING     3
124 #define cUSB_DESTYPE_INTERFACE  4
125 #define cUSB_DESTYPE_ENDPOINT   5
126 #define cUSB_DESTYPE_END        cUSB_DESTYPE_ENDPOINT   // for range check
127
128 /* for Feature selector */
129 #define cUSB_FEATSEL_RMWAKEUP   0
130 #define cUSB_FEATSEL_EPHAL      1
131 #define cUSB_FEATSEL_END        cUSB_FEATSEL_EPHAL      // for range check
132
133 #define bmREQ_RECI              0
134 #define bmwREQ_RECI             5           // mMASKS(bmwREQ_RECI, bmREQ_RECI)
135 #define bmREQ_TYPE              5
136 #define bmwREQ_TYPE             2           // mMASKS(bmwREQ_TYPE, bmREQ_TYPE)
137 #define bmREQ_DIR               7
138 #define bmwREQ_DIR              1
139
140 #endif