carl9170 firmware: import 1.7.0
[carl9170fw.git] / carlfw / include / usb_fifo.h
1 /*
2  * carl9170 firmware - used by the ar9170 wireless device
3  *
4  * USB definitions
5  *
6  * Copyright (c) 2000-2005 ZyDAS Technology Corporation
7  * Copyright (c) 2007-2009 Atheros Communications, Inc.
8  * Copyright    2009    Johannes Berg <johannes@sipsolutions.net>
9  * Copyright 2009, 2010 Christian Lamparter <chunkeey@googlemail.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #ifndef __CARL9170FW_USB_FIFO_H
27 #define __CARL9170FW_USB_FIFO_H
28
29 #include "config.h"
30
31 #define MASK_F0             0xf0
32
33 /* Block Size define */
34 #define BLK512BYTE      1
35 #define BLK1024BYTE     2
36
37 #define BLK64BYTE       1
38 #define BLK128BYTE      2
39
40 /* Block toggle number define */
41 #define SINGLE_BLK      1
42 #define DOUBLE_BLK      2
43 #define TRIBLE_BLK      3
44
45 /* Endpoint transfer type */
46 #define TF_TYPE_ISOCHRONOUS     1
47 #define TF_TYPE_BULK            2
48 #define TF_TYPE_INTERRUPT       3
49
50 /* Endpoint or FIFO direction define */
51 #define DIRECTION_IN    0
52 #define DIRECTION_OUT   1
53
54 #define HS_C1_I0_A0_EP1_MAX_PACKET              512
55 #define HS_C1_I0_A0_EP1_bInterval               0
56
57 #define HS_C1_I0_A0_EP_NUMBER                   0x04
58 #define HS_C1_I0_A0_EP_LENGTH                   (EP_LENGTH * HS_C1_I0_A0_EP_NUMBER)
59 #define HS_C1_I0_ALT_LENGTH                     (HS_C1_I0_A0_EP_LENGTH)
60 #define HS_C1_INTERFACE_LENGTH                  (HS_C1_I0_ALT_LENGTH)
61
62 #define HS_C1_CONFIG_TOTAL_LENGTH               (CONFIG_LENGTH + INTERFACE_LENGTH +  HS_C1_INTERFACE_LENGTH)
63 #define FS_C1_CONFIG_TOTAL_LENGTH               (CONFIG_LENGTH + INTERFACE_LENGTH +  FS_C1_INTERFACE_LENGTH)
64
65 #define FS_C1_I0_A0_EP1_MAX_PACKET              64
66 /* #define FS_C1_I0_A0_EP1_bInterval               HS_C1_I0_A0_EP1_bInterval */
67
68 #define HS_CONFIGURATION_NUMBER                 1
69 #define FS_CONFIGURATION_NUMBER                 1
70
71 #define fDOUBLE_BUF                             1
72 #define fDOUBLE_BUF_IN                          0
73
74 #define fFLASH_DISK                             0
75 #define fENABLE_ISO                             0
76
77 #define HS_C1_INTERFACE_NUMBER  0x01
78 #define HS_C1                   0x01
79 #define HS_C1_iConfiguration    0x00
80 #define HS_C1_bmAttribute       0x80
81
82 #define HS_C1_iMaxPower         0xFA
83
84 /* Interface 0 */
85 #define HS_C1_I0_ALT_NUMBER    0X01
86 /* AlternateSetting 0 */
87 #define HS_C1_I0_A0_bInterfaceNumber    0x00
88 #define HS_C1_I0_A0_bAlternateSetting   0x00
89 /* JWEI 2003/07/14 */
90 #define HS_C1_I0_A0_EP_NUMBER           0x04
91 #define HS_C1_I0_A0_bInterfaceClass     0xff
92 #define HS_C1_I0_A0_bInterfaceSubClass  0x00
93 #define HS_C1_I0_A0_bInterfaceProtocol  0x00
94 #define HS_C1_I0_A0_iInterface          0x00
95
96 /* EP 1 */
97 #define HS_C1_I0_A0_EP1_BLKSIZE    512
98 #define HS_C1_I0_A0_EP1_BLKNO      DOUBLE_BLK
99 #define HS_C1_I0_A0_EP1_DIRECTION  DIRECTION_OUT
100 #define HS_C1_I0_A0_EP1_TYPE       TF_TYPE_BULK
101
102 #define HS_C1_I0_A0_EP1_MAX_PACKET 512
103 #define HS_C1_I0_A0_EP1_bInterval  0
104
105 /* EP 2 */
106 #define HS_C1_I0_A0_EP2_BLKSIZE    512
107 /* JWEI 2003/08/20 */
108 #define HS_C1_I0_A0_EP2_BLKNO      SINGLE_BLK
109 #define HS_C1_I0_A0_EP2_DIRECTION  DIRECTION_IN
110 #define HS_C1_I0_A0_EP2_TYPE       TF_TYPE_BULK
111 #define HS_C1_I0_A0_EP2_MAX_PACKET 512
112 #define HS_C1_I0_A0_EP2_bInterval  0
113
114 /* EP 3 */
115 #define HS_C1_I0_A0_EP3_BLKSIZE    64
116 #define HS_C1_I0_A0_EP3_BLKNO      SINGLE_BLK
117 #define HS_C1_I0_A0_EP3_DIRECTION  DIRECTION_IN
118 #define HS_C1_I0_A0_EP3_TYPE       TF_TYPE_INTERRUPT
119 #define HS_C1_I0_A0_EP3_MAX_PACKET 0x0040
120 #define HS_C1_I0_A0_EP3_bInterval  01
121
122 /*
123  * Note: HS Bulk type require max pkt size = 512
124  *       ==> must use Interrupt type for max pkt size = 64
125  */
126
127 /* EP 4 */
128 #define HS_C1_I0_A0_EP4_BLKSIZE    64
129 #define HS_C1_I0_A0_EP4_BLKNO      SINGLE_BLK
130 #define HS_C1_I0_A0_EP4_DIRECTION  DIRECTION_OUT
131 #define HS_C1_I0_A0_EP4_TYPE       TF_TYPE_INTERRUPT
132 #define HS_C1_I0_A0_EP4_MAX_PACKET 0x0040
133 #define HS_C1_I0_A0_EP4_bInterval  01
134
135 #define HS_C1_I0_A0_EP_LENGTH           (EP_LENGTH * HS_C1_I0_A0_EP_NUMBER)
136 /* EP 1 */
137 #define HS_C1_I0_A0_EP1_FIFO_START  0
138 #define HS_C1_I0_A0_EP1_FIFO_NO     (HS_C1_I0_A0_EP1_BLKNO * HS_C1_I0_A0_EP1_BLKSIZE)
139 #define HS_C1_I0_A0_EP1_FIFO_CONFIG (uint8_t)(0x80 | ((HS_C1_I0_A0_EP1_BLKSIZE - 1) << 4) | ((HS_C1_I0_A0_EP1_BLKNO - 1) << 2) | HS_C1_I0_A0_EP1_TYPE)
140 #define HS_C1_I0_A0_EP1_FIFO_MAP    (((1 - HS_C1_I0_A0_EP1_DIRECTION) << 4) | 1)
141 #define HS_C1_I0_A0_EP1_MAP         (HS_C1_I0_A0_EP1_FIFO_START |   (HS_C1_I0_A0_EP1_FIFO_START << 4)   | (MASK_F0 >> (4*HS_C1_I0_A0_EP1_DIRECTION)))
142
143 /* EP 2 */
144 #define HS_C1_I0_A0_EP2_FIFO_START  (uint8_t)(HS_C1_I0_A0_EP1_FIFO_START + HS_C1_I0_A0_EP1_FIFO_NO)
145 #define HS_C1_I0_A0_EP2_FIFO_NO     (uint8_t)(HS_C1_I0_A0_EP2_BLKNO * HS_C1_I0_A0_EP2_BLKSIZE)
146 #define HS_C1_I0_A0_EP2_FIFO_CONFIG (uint8_t)(0x80 | ((HS_C1_I0_A0_EP2_BLKSIZE - 1) << 4) | ((HS_C1_I0_A0_EP2_BLKNO - 1) << 2) | HS_C1_I0_A0_EP2_TYPE)
147 #define HS_C1_I0_A0_EP2_FIFO_MAP    (uint8_t)(((1 - HS_C1_I0_A0_EP2_DIRECTION) << 4) | 2)
148 #define HS_C1_I0_A0_EP2_MAP         (uint8_t)(HS_C1_I0_A0_EP2_FIFO_START |   (HS_C1_I0_A0_EP2_FIFO_START << 4)   | (MASK_F0 >> (4*HS_C1_I0_A0_EP2_DIRECTION)))
149
150 /* EP 3 */
151 #define HS_C1_I0_A0_EP3_FIFO_START  14
152 #define HS_C1_I0_A0_EP3_FIFO_NO     (HS_C1_I0_A0_EP3_BLKNO * HS_C1_I0_A0_EP3_BLKSIZE)
153 #define HS_C1_I0_A0_EP3_FIFO_CONFIG (uint8_t)(0x80 | ((HS_C1_I0_A0_EP3_BLKSIZE - 1) << 4) | ((HS_C1_I0_A0_EP3_BLKNO - 1) << 2) | HS_C1_I0_A0_EP3_TYPE)
154 #define HS_C1_I0_A0_EP3_FIFO_MAP    (uint8_t)(((1 - HS_C1_I0_A0_EP3_DIRECTION) << 4) | 3)
155 #define HS_C1_I0_A0_EP3_MAP         (uint8_t)(HS_C1_I0_A0_EP3_FIFO_START |   (HS_C1_I0_A0_EP3_FIFO_START << 4)   | (MASK_F0 >> (4*HS_C1_I0_A0_EP3_DIRECTION)))
156
157 /* EP 4 */
158 #define HS_C1_I0_A0_EP4_FIFO_START  (HS_C1_I0_A0_EP3_FIFO_START + HS_C1_I0_A0_EP3_FIFO_NO)
159 #define HS_C1_I0_A0_EP4_FIFO_NO     (HS_C1_I0_A0_EP4_BLKNO * HS_C1_I0_A0_EP4_BLKSIZE)
160 #define HS_C1_I0_A0_EP4_FIFO_CONFIG (uint8_t)(0x80 | ((HS_C1_I0_A0_EP4_BLKSIZE - 1) << 4) | ((HS_C1_I0_A0_EP4_BLKNO - 1) << 2) | HS_C1_I0_A0_EP4_TYPE)
161 #define HS_C1_I0_A0_EP4_FIFO_MAP    (((1 - HS_C1_I0_A0_EP4_DIRECTION) << 4) | 4)
162 #define HS_C1_I0_A0_EP4_MAP         (uint8_t)(HS_C1_I0_A0_EP4_FIFO_START |   (HS_C1_I0_A0_EP4_FIFO_START << 4)   | (MASK_F0 >> (4*HS_C1_I0_A0_EP4_DIRECTION)))
163
164 /* Configuration 1 */
165 #define FS_C1_INTERFACE_NUMBER          0x01
166 #define FS_C1                           0x01
167 #define FS_C1_iConfiguration            0x00
168 #define FS_C1_bmAttribute               0x80
169 #define FS_C1_iMaxPower                 0xfa
170
171 /* Interface 0 */
172 #define FS_C1_I0_ALT_NUMBER             0x01
173 /* AlternateSetting 0x00 */
174 #define FS_C1_I0_A0_bInterfaceNumber    0x00
175 #define FS_C1_I0_A0_bAlternateSetting   0x00
176 #define FS_C1_I0_A0_EP_NUMBER           0x04
177 #define FS_C1_I0_A0_bInterfaceClass     0xff
178 #define FS_C1_I0_A0_bInterfaceSubClass  0x00
179 #define FS_C1_I0_A0_bInterfaceProtocol  0x00
180
181 /* EP 1 */
182 #define FS_C1_I0_A0_EP1_BLKSIZE    512
183 /* JWEI 2003/05/19 */
184 #define FS_C1_I0_A0_EP1_BLKNO      DOUBLE_BLK
185 #define FS_C1_I0_A0_EP1_DIRECTION  DIRECTION_OUT
186 #define FS_C1_I0_A0_EP1_TYPE       TF_TYPE_BULK
187 #define FS_C1_I0_A0_EP1_MAX_PACKET 64
188 #define FS_C1_I0_A0_EP1_bInterval  0
189
190 /* EP 2 */
191 #define FS_C1_I0_A0_EP2_BLKSIZE    512
192 /* JWEI 2003/08/20 */
193 #define FS_C1_I0_A0_EP2_BLKNO      SINGLE_BLK
194 #define FS_C1_I0_A0_EP2_DIRECTION  DIRECTION_IN
195 #define FS_C1_I0_A0_EP2_TYPE       TF_TYPE_BULK
196 #define FS_C1_I0_A0_EP2_MAX_PACKET 64
197 #define FS_C1_I0_A0_EP2_bInterval  0
198
199 /* EP 3 */
200 #define FS_C1_I0_A0_EP3_BLKSIZE    64
201 #define FS_C1_I0_A0_EP3_BLKNO      SINGLE_BLK
202 #define FS_C1_I0_A0_EP3_DIRECTION  DIRECTION_IN
203 #define FS_C1_I0_A0_EP3_TYPE       TF_TYPE_INTERRUPT
204 #define FS_C1_I0_A0_EP3_MAX_PACKET 0x0040
205 #define FS_C1_I0_A0_EP3_bInterval  1
206
207 /* EP 4 */
208 #define FS_C1_I0_A0_EP4_BLKSIZE    64
209 #define FS_C1_I0_A0_EP4_BLKNO      SINGLE_BLK
210 #define FS_C1_I0_A0_EP4_DIRECTION  DIRECTION_OUT
211 #define FS_C1_I0_A0_EP4_TYPE       TF_TYPE_BULK
212 #define FS_C1_I0_A0_EP4_MAX_PACKET 0x0040
213 #define FS_C1_I0_A0_EP4_bInterval  0
214
215 #define FS_C1_I0_A0_EP_LENGTH           (EP_LENGTH * FS_C1_I0_A0_EP_NUMBER)
216 /* EP 1 */
217 #define FS_C1_I0_A0_EP1_FIFO_START  0
218 #define FS_C1_I0_A0_EP1_FIFO_NO     (uint8_t)(FS_C1_I0_A0_EP1_BLKNO * FS_C1_I0_A0_EP1_BLKSIZE)
219 #define FS_C1_I0_A0_EP1_FIFO_CONFIG (uint8_t)(0x80 | ((FS_C1_I0_A0_EP1_BLKSIZE - 1) << 4) | ((FS_C1_I0_A0_EP1_BLKNO - 1) << 2) | FS_C1_I0_A0_EP1_TYPE)
220 #define FS_C1_I0_A0_EP1_FIFO_MAP    (uint8_t)(((1 - FS_C1_I0_A0_EP1_DIRECTION) << 4) | 1)
221 #define FS_C1_I0_A0_EP1_MAP         (uint8_t)(FS_C1_I0_A0_EP1_FIFO_START |   (FS_C1_I0_A0_EP1_FIFO_START << 4)   | (MASK_F0 >> (4*FS_C1_I0_A0_EP1_DIRECTION)))
222
223 /* EP 2 */
224 #define FS_C1_I0_A0_EP2_FIFO_START  (uint8_t)(FS_C1_I0_A0_EP1_FIFO_START + FS_C1_I0_A0_EP1_FIFO_NO)
225 #define FS_C1_I0_A0_EP2_FIFO_NO     (uint8_t)(FS_C1_I0_A0_EP2_BLKNO * FS_C1_I0_A0_EP2_BLKSIZE)
226 #define FS_C1_I0_A0_EP2_FIFO_CONFIG (uint8_t)(0x80 | ((FS_C1_I0_A0_EP2_BLKSIZE - 1) << 4) | ((FS_C1_I0_A0_EP2_BLKNO - 1) << 2) | FS_C1_I0_A0_EP2_TYPE)
227 #define FS_C1_I0_A0_EP2_FIFO_MAP    (uint8_t)(((1 - FS_C1_I0_A0_EP2_DIRECTION) << 4) | 2)
228 #define FS_C1_I0_A0_EP2_MAP         (uint8_t)(FS_C1_I0_A0_EP2_FIFO_START |   (FS_C1_I0_A0_EP2_FIFO_START << 4)   | (MASK_F0 >> (4*FS_C1_I0_A0_EP2_DIRECTION)))
229
230 /* EP 3 */
231 #define FS_C1_I0_A0_EP3_FIFO_START  14
232 #define FS_C1_I0_A0_EP3_FIFO_NO     (uint8_t)(FS_C1_I0_A0_EP3_BLKNO * FS_C1_I0_A0_EP3_BLKSIZE)
233 #define FS_C1_I0_A0_EP3_FIFO_CONFIG (uint8_t)(0x80 | ((FS_C1_I0_A0_EP3_BLKSIZE - 1) << 4) | ((FS_C1_I0_A0_EP3_BLKNO - 1) << 2) | FS_C1_I0_A0_EP3_TYPE)
234 #define FS_C1_I0_A0_EP3_FIFO_MAP    (uint8_t)(((1 - FS_C1_I0_A0_EP3_DIRECTION) << 4) | 3)
235 #define FS_C1_I0_A0_EP3_MAP         (uint8_t)(FS_C1_I0_A0_EP3_FIFO_START |   (FS_C1_I0_A0_EP3_FIFO_START << 4)   | (MASK_F0 >> (4*FS_C1_I0_A0_EP3_DIRECTION)))
236
237 /* EP 4 */
238 #define FS_C1_I0_A0_EP4_FIFO_START  (uint8_t)(FS_C1_I0_A0_EP3_FIFO_START + FS_C1_I0_A0_EP3_FIFO_NO)
239 #define FS_C1_I0_A0_EP4_FIFO_NO     (uint8_t)(FS_C1_I0_A0_EP4_BLKNO * FS_C1_I0_A0_EP4_BLKSIZE)
240 #define FS_C1_I0_A0_EP4_FIFO_CONFIG (uint8_t)(0x80 | ((FS_C1_I0_A0_EP4_BLKSIZE - 1) << 4) | ((FS_C1_I0_A0_EP4_BLKNO - 1) << 2) | FS_C1_I0_A0_EP4_TYPE)
241 #define FS_C1_I0_A0_EP4_FIFO_MAP    (uint8_t)(((1 - FS_C1_I0_A0_EP4_DIRECTION) << 4) | 4)
242 #define FS_C1_I0_A0_EP4_MAP         (uint8_t)(FS_C1_I0_A0_EP4_FIFO_START |   (FS_C1_I0_A0_EP4_FIFO_START << 4)   | (MASK_F0 >> (4*FS_C1_I0_A0_EP4_DIRECTION)))
243
244 #endif /* __CARL9170FW_USB_FIFO_H */