1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
4  * All rights reserved.
5  *
6  * File: baseband.c
7  *
8  * Purpose: Implement functions to access baseband
9  *
10  * Author: Kyle Hsu
11  *
12  * Date: Aug.22, 2002
13  *
14  * Functions:
15  *      BBuGetFrameTime        - Calculate data frame transmitting time
16  *      BBvCaculateParameter   - Caculate PhyLength, PhyService and Phy Signal
17  *                               parameter for baseband Tx
18  *      BBbReadEmbedded         - Embedded read baseband register via MAC
19  *      BBbWriteEmbedded        - Embedded write baseband register via MAC
20  *      BBbVT3253Init          - VIA VT3253 baseband chip init code
21  *
22  * Revision History:
23  *      06-10-2003 Bryan YC Fan:  Re-write codes to support VT3253 spec.
24  *      08-07-2003 Bryan YC Fan:  Add MAXIM2827/2825 and RFMD2959 support.
25  *      08-26-2003 Kyle Hsu    :  Modify BBuGetFrameTime() and
26  *				  BBvCalculateParameter().
27  *                                cancel the setting of MAC_REG_SOFTPWRCTL on
28  *				  BBbVT3253Init().
29  *                                Add the comments.
30  *      09-01-2003 Bryan YC Fan:  RF & BB tables updated.
31  *                                Modified BBvLoopbackOn & BBvLoopbackOff().
32  *
33  *
34  */
35 
36 #include "tmacro.h"
37 #include "mac.h"
38 #include "baseband.h"
39 #include "srom.h"
40 #include "rf.h"
41 
42 /*---------------------  Static Classes  ----------------------------*/
43 
44 /*---------------------  Static Variables  --------------------------*/
45 
46 /*---------------------  Static Functions  --------------------------*/
47 
48 /*---------------------  Export Variables  --------------------------*/
49 
50 /*---------------------  Static Definitions -------------------------*/
51 
52 /*---------------------  Static Classes  ----------------------------*/
53 
54 /*---------------------  Static Variables  --------------------------*/
55 
56 #define CB_VT3253_INIT_FOR_RFMD 446
57 static const unsigned char byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
58 	{0x00, 0x30},
59 	{0x01, 0x00},
60 	{0x02, 0x00},
61 	{0x03, 0x00},
62 	{0x04, 0x00},
63 	{0x05, 0x00},
64 	{0x06, 0x00},
65 	{0x07, 0x00},
66 	{0x08, 0x70},
67 	{0x09, 0x45},
68 	{0x0a, 0x2a},
69 	{0x0b, 0x76},
70 	{0x0c, 0x00},
71 	{0x0d, 0x01},
72 	{0x0e, 0x80},
73 	{0x0f, 0x00},
74 	{0x10, 0x00},
75 	{0x11, 0x00},
76 	{0x12, 0x00},
77 	{0x13, 0x00},
78 	{0x14, 0x00},
79 	{0x15, 0x00},
80 	{0x16, 0x00},
81 	{0x17, 0x00},
82 	{0x18, 0x00},
83 	{0x19, 0x00},
84 	{0x1a, 0x00},
85 	{0x1b, 0x9d},
86 	{0x1c, 0x05},
87 	{0x1d, 0x00},
88 	{0x1e, 0x00},
89 	{0x1f, 0x00},
90 	{0x20, 0x00},
91 	{0x21, 0x00},
92 	{0x22, 0x00},
93 	{0x23, 0x00},
94 	{0x24, 0x00},
95 	{0x25, 0x4a},
96 	{0x26, 0x00},
97 	{0x27, 0x00},
98 	{0x28, 0x00},
99 	{0x29, 0x00},
100 	{0x2a, 0x00},
101 	{0x2b, 0x00},
102 	{0x2c, 0x00},
103 	{0x2d, 0xa8},
104 	{0x2e, 0x1a},
105 	{0x2f, 0x0c},
106 	{0x30, 0x26},
107 	{0x31, 0x5b},
108 	{0x32, 0x00},
109 	{0x33, 0x00},
110 	{0x34, 0x00},
111 	{0x35, 0x00},
112 	{0x36, 0xaa},
113 	{0x37, 0xaa},
114 	{0x38, 0xff},
115 	{0x39, 0xff},
116 	{0x3a, 0x00},
117 	{0x3b, 0x00},
118 	{0x3c, 0x00},
119 	{0x3d, 0x0d},
120 	{0x3e, 0x51},
121 	{0x3f, 0x04},
122 	{0x40, 0x00},
123 	{0x41, 0x08},
124 	{0x42, 0x00},
125 	{0x43, 0x08},
126 	{0x44, 0x06},
127 	{0x45, 0x14},
128 	{0x46, 0x05},
129 	{0x47, 0x08},
130 	{0x48, 0x00},
131 	{0x49, 0x00},
132 	{0x4a, 0x00},
133 	{0x4b, 0x00},
134 	{0x4c, 0x09},
135 	{0x4d, 0x80},
136 	{0x4e, 0x00},
137 	{0x4f, 0xc5},
138 	{0x50, 0x14},
139 	{0x51, 0x19},
140 	{0x52, 0x00},
141 	{0x53, 0x00},
142 	{0x54, 0x00},
143 	{0x55, 0x00},
144 	{0x56, 0x00},
145 	{0x57, 0x00},
146 	{0x58, 0x00},
147 	{0x59, 0xb0},
148 	{0x5a, 0x00},
149 	{0x5b, 0x00},
150 	{0x5c, 0x00},
151 	{0x5d, 0x00},
152 	{0x5e, 0x00},
153 	{0x5f, 0x00},
154 	{0x60, 0x44},
155 	{0x61, 0x04},
156 	{0x62, 0x00},
157 	{0x63, 0x00},
158 	{0x64, 0x00},
159 	{0x65, 0x00},
160 	{0x66, 0x04},
161 	{0x67, 0xb7},
162 	{0x68, 0x00},
163 	{0x69, 0x00},
164 	{0x6a, 0x00},
165 	{0x6b, 0x00},
166 	{0x6c, 0x00},
167 	{0x6d, 0x03},
168 	{0x6e, 0x01},
169 	{0x6f, 0x00},
170 	{0x70, 0x00},
171 	{0x71, 0x00},
172 	{0x72, 0x00},
173 	{0x73, 0x00},
174 	{0x74, 0x00},
175 	{0x75, 0x00},
176 	{0x76, 0x00},
177 	{0x77, 0x00},
178 	{0x78, 0x00},
179 	{0x79, 0x00},
180 	{0x7a, 0x00},
181 	{0x7b, 0x00},
182 	{0x7c, 0x00},
183 	{0x7d, 0x00},
184 	{0x7e, 0x00},
185 	{0x7f, 0x00},
186 	{0x80, 0x0b},
187 	{0x81, 0x00},
188 	{0x82, 0x3c},
189 	{0x83, 0x00},
190 	{0x84, 0x00},
191 	{0x85, 0x00},
192 	{0x86, 0x00},
193 	{0x87, 0x00},
194 	{0x88, 0x08},
195 	{0x89, 0x00},
196 	{0x8a, 0x08},
197 	{0x8b, 0xa6},
198 	{0x8c, 0x84},
199 	{0x8d, 0x47},
200 	{0x8e, 0xbb},
201 	{0x8f, 0x02},
202 	{0x90, 0x21},
203 	{0x91, 0x0c},
204 	{0x92, 0x04},
205 	{0x93, 0x22},
206 	{0x94, 0x00},
207 	{0x95, 0x00},
208 	{0x96, 0x00},
209 	{0x97, 0xeb},
210 	{0x98, 0x00},
211 	{0x99, 0x00},
212 	{0x9a, 0x00},
213 	{0x9b, 0x00},
214 	{0x9c, 0x00},
215 	{0x9d, 0x00},
216 	{0x9e, 0x00},
217 	{0x9f, 0x00},
218 	{0xa0, 0x00},
219 	{0xa1, 0x00},
220 	{0xa2, 0x00},
221 	{0xa3, 0x00},
222 	{0xa4, 0x00},
223 	{0xa5, 0x00},
224 	{0xa6, 0x10},
225 	{0xa7, 0x04},
226 	{0xa8, 0x10},
227 	{0xa9, 0x00},
228 	{0xaa, 0x8f},
229 	{0xab, 0x00},
230 	{0xac, 0x00},
231 	{0xad, 0x00},
232 	{0xae, 0x00},
233 	{0xaf, 0x80},
234 	{0xb0, 0x38},
235 	{0xb1, 0x00},
236 	{0xb2, 0x00},
237 	{0xb3, 0x00},
238 	{0xb4, 0xee},
239 	{0xb5, 0xff},
240 	{0xb6, 0x10},
241 	{0xb7, 0x00},
242 	{0xb8, 0x00},
243 	{0xb9, 0x00},
244 	{0xba, 0x00},
245 	{0xbb, 0x03},
246 	{0xbc, 0x00},
247 	{0xbd, 0x00},
248 	{0xbe, 0x00},
249 	{0xbf, 0x00},
250 	{0xc0, 0x10},
251 	{0xc1, 0x10},
252 	{0xc2, 0x18},
253 	{0xc3, 0x20},
254 	{0xc4, 0x10},
255 	{0xc5, 0x00},
256 	{0xc6, 0x22},
257 	{0xc7, 0x14},
258 	{0xc8, 0x0f},
259 	{0xc9, 0x08},
260 	{0xca, 0xa4},
261 	{0xcb, 0xa7},
262 	{0xcc, 0x3c},
263 	{0xcd, 0x10},
264 	{0xce, 0x20},
265 	{0xcf, 0x00},
266 	{0xd0, 0x00},
267 	{0xd1, 0x10},
268 	{0xd2, 0x00},
269 	{0xd3, 0x00},
270 	{0xd4, 0x10},
271 	{0xd5, 0x33},
272 	{0xd6, 0x70},
273 	{0xd7, 0x01},
274 	{0xd8, 0x00},
275 	{0xd9, 0x00},
276 	{0xda, 0x00},
277 	{0xdb, 0x00},
278 	{0xdc, 0x00},
279 	{0xdd, 0x00},
280 	{0xde, 0x00},
281 	{0xdf, 0x00},
282 	{0xe0, 0x00},
283 	{0xe1, 0x00},
284 	{0xe2, 0xcc},
285 	{0xe3, 0x04},
286 	{0xe4, 0x08},
287 	{0xe5, 0x10},
288 	{0xe6, 0x00},
289 	{0xe7, 0x0e},
290 	{0xe8, 0x88},
291 	{0xe9, 0xd4},
292 	{0xea, 0x05},
293 	{0xeb, 0xf0},
294 	{0xec, 0x79},
295 	{0xed, 0x0f},
296 	{0xee, 0x04},
297 	{0xef, 0x04},
298 	{0xf0, 0x00},
299 	{0xf1, 0x00},
300 	{0xf2, 0x00},
301 	{0xf3, 0x00},
302 	{0xf4, 0x00},
303 	{0xf5, 0x00},
304 	{0xf6, 0x00},
305 	{0xf7, 0x00},
306 	{0xf8, 0x00},
307 	{0xf9, 0x00},
308 	{0xF0, 0x00},
309 	{0xF1, 0xF8},
310 	{0xF0, 0x80},
311 	{0xF0, 0x00},
312 	{0xF1, 0xF4},
313 	{0xF0, 0x81},
314 	{0xF0, 0x01},
315 	{0xF1, 0xF0},
316 	{0xF0, 0x82},
317 	{0xF0, 0x02},
318 	{0xF1, 0xEC},
319 	{0xF0, 0x83},
320 	{0xF0, 0x03},
321 	{0xF1, 0xE8},
322 	{0xF0, 0x84},
323 	{0xF0, 0x04},
324 	{0xF1, 0xE4},
325 	{0xF0, 0x85},
326 	{0xF0, 0x05},
327 	{0xF1, 0xE0},
328 	{0xF0, 0x86},
329 	{0xF0, 0x06},
330 	{0xF1, 0xDC},
331 	{0xF0, 0x87},
332 	{0xF0, 0x07},
333 	{0xF1, 0xD8},
334 	{0xF0, 0x88},
335 	{0xF0, 0x08},
336 	{0xF1, 0xD4},
337 	{0xF0, 0x89},
338 	{0xF0, 0x09},
339 	{0xF1, 0xD0},
340 	{0xF0, 0x8A},
341 	{0xF0, 0x0A},
342 	{0xF1, 0xCC},
343 	{0xF0, 0x8B},
344 	{0xF0, 0x0B},
345 	{0xF1, 0xC8},
346 	{0xF0, 0x8C},
347 	{0xF0, 0x0C},
348 	{0xF1, 0xC4},
349 	{0xF0, 0x8D},
350 	{0xF0, 0x0D},
351 	{0xF1, 0xC0},
352 	{0xF0, 0x8E},
353 	{0xF0, 0x0E},
354 	{0xF1, 0xBC},
355 	{0xF0, 0x8F},
356 	{0xF0, 0x0F},
357 	{0xF1, 0xB8},
358 	{0xF0, 0x90},
359 	{0xF0, 0x10},
360 	{0xF1, 0xB4},
361 	{0xF0, 0x91},
362 	{0xF0, 0x11},
363 	{0xF1, 0xB0},
364 	{0xF0, 0x92},
365 	{0xF0, 0x12},
366 	{0xF1, 0xAC},
367 	{0xF0, 0x93},
368 	{0xF0, 0x13},
369 	{0xF1, 0xA8},
370 	{0xF0, 0x94},
371 	{0xF0, 0x14},
372 	{0xF1, 0xA4},
373 	{0xF0, 0x95},
374 	{0xF0, 0x15},
375 	{0xF1, 0xA0},
376 	{0xF0, 0x96},
377 	{0xF0, 0x16},
378 	{0xF1, 0x9C},
379 	{0xF0, 0x97},
380 	{0xF0, 0x17},
381 	{0xF1, 0x98},
382 	{0xF0, 0x98},
383 	{0xF0, 0x18},
384 	{0xF1, 0x94},
385 	{0xF0, 0x99},
386 	{0xF0, 0x19},
387 	{0xF1, 0x90},
388 	{0xF0, 0x9A},
389 	{0xF0, 0x1A},
390 	{0xF1, 0x8C},
391 	{0xF0, 0x9B},
392 	{0xF0, 0x1B},
393 	{0xF1, 0x88},
394 	{0xF0, 0x9C},
395 	{0xF0, 0x1C},
396 	{0xF1, 0x84},
397 	{0xF0, 0x9D},
398 	{0xF0, 0x1D},
399 	{0xF1, 0x80},
400 	{0xF0, 0x9E},
401 	{0xF0, 0x1E},
402 	{0xF1, 0x7C},
403 	{0xF0, 0x9F},
404 	{0xF0, 0x1F},
405 	{0xF1, 0x78},
406 	{0xF0, 0xA0},
407 	{0xF0, 0x20},
408 	{0xF1, 0x74},
409 	{0xF0, 0xA1},
410 	{0xF0, 0x21},
411 	{0xF1, 0x70},
412 	{0xF0, 0xA2},
413 	{0xF0, 0x22},
414 	{0xF1, 0x6C},
415 	{0xF0, 0xA3},
416 	{0xF0, 0x23},
417 	{0xF1, 0x68},
418 	{0xF0, 0xA4},
419 	{0xF0, 0x24},
420 	{0xF1, 0x64},
421 	{0xF0, 0xA5},
422 	{0xF0, 0x25},
423 	{0xF1, 0x60},
424 	{0xF0, 0xA6},
425 	{0xF0, 0x26},
426 	{0xF1, 0x5C},
427 	{0xF0, 0xA7},
428 	{0xF0, 0x27},
429 	{0xF1, 0x58},
430 	{0xF0, 0xA8},
431 	{0xF0, 0x28},
432 	{0xF1, 0x54},
433 	{0xF0, 0xA9},
434 	{0xF0, 0x29},
435 	{0xF1, 0x50},
436 	{0xF0, 0xAA},
437 	{0xF0, 0x2A},
438 	{0xF1, 0x4C},
439 	{0xF0, 0xAB},
440 	{0xF0, 0x2B},
441 	{0xF1, 0x48},
442 	{0xF0, 0xAC},
443 	{0xF0, 0x2C},
444 	{0xF1, 0x44},
445 	{0xF0, 0xAD},
446 	{0xF0, 0x2D},
447 	{0xF1, 0x40},
448 	{0xF0, 0xAE},
449 	{0xF0, 0x2E},
450 	{0xF1, 0x3C},
451 	{0xF0, 0xAF},
452 	{0xF0, 0x2F},
453 	{0xF1, 0x38},
454 	{0xF0, 0xB0},
455 	{0xF0, 0x30},
456 	{0xF1, 0x34},
457 	{0xF0, 0xB1},
458 	{0xF0, 0x31},
459 	{0xF1, 0x30},
460 	{0xF0, 0xB2},
461 	{0xF0, 0x32},
462 	{0xF1, 0x2C},
463 	{0xF0, 0xB3},
464 	{0xF0, 0x33},
465 	{0xF1, 0x28},
466 	{0xF0, 0xB4},
467 	{0xF0, 0x34},
468 	{0xF1, 0x24},
469 	{0xF0, 0xB5},
470 	{0xF0, 0x35},
471 	{0xF1, 0x20},
472 	{0xF0, 0xB6},
473 	{0xF0, 0x36},
474 	{0xF1, 0x1C},
475 	{0xF0, 0xB7},
476 	{0xF0, 0x37},
477 	{0xF1, 0x18},
478 	{0xF0, 0xB8},
479 	{0xF0, 0x38},
480 	{0xF1, 0x14},
481 	{0xF0, 0xB9},
482 	{0xF0, 0x39},
483 	{0xF1, 0x10},
484 	{0xF0, 0xBA},
485 	{0xF0, 0x3A},
486 	{0xF1, 0x0C},
487 	{0xF0, 0xBB},
488 	{0xF0, 0x3B},
489 	{0xF1, 0x08},
490 	{0xF0, 0x00},
491 	{0xF0, 0x3C},
492 	{0xF1, 0x04},
493 	{0xF0, 0xBD},
494 	{0xF0, 0x3D},
495 	{0xF1, 0x00},
496 	{0xF0, 0xBE},
497 	{0xF0, 0x3E},
498 	{0xF1, 0x00},
499 	{0xF0, 0xBF},
500 	{0xF0, 0x3F},
501 	{0xF1, 0x00},
502 	{0xF0, 0xC0},
503 	{0xF0, 0x00},
504 };
505 
506 #define CB_VT3253B0_INIT_FOR_RFMD 256
507 static const unsigned char byVT3253B0_RFMD[CB_VT3253B0_INIT_FOR_RFMD][2] = {
508 	{0x00, 0x31},
509 	{0x01, 0x00},
510 	{0x02, 0x00},
511 	{0x03, 0x00},
512 	{0x04, 0x00},
513 	{0x05, 0x81},
514 	{0x06, 0x00},
515 	{0x07, 0x00},
516 	{0x08, 0x38},
517 	{0x09, 0x45},
518 	{0x0a, 0x2a},
519 	{0x0b, 0x76},
520 	{0x0c, 0x00},
521 	{0x0d, 0x00},
522 	{0x0e, 0x80},
523 	{0x0f, 0x00},
524 	{0x10, 0x00},
525 	{0x11, 0x00},
526 	{0x12, 0x00},
527 	{0x13, 0x00},
528 	{0x14, 0x00},
529 	{0x15, 0x00},
530 	{0x16, 0x00},
531 	{0x17, 0x00},
532 	{0x18, 0x00},
533 	{0x19, 0x00},
534 	{0x1a, 0x00},
535 	{0x1b, 0x8e},
536 	{0x1c, 0x06},
537 	{0x1d, 0x00},
538 	{0x1e, 0x00},
539 	{0x1f, 0x00},
540 	{0x20, 0x00},
541 	{0x21, 0x00},
542 	{0x22, 0x00},
543 	{0x23, 0x00},
544 	{0x24, 0x00},
545 	{0x25, 0x4a},
546 	{0x26, 0x00},
547 	{0x27, 0x00},
548 	{0x28, 0x00},
549 	{0x29, 0x00},
550 	{0x2a, 0x00},
551 	{0x2b, 0x00},
552 	{0x2c, 0x00},
553 	{0x2d, 0x34},
554 	{0x2e, 0x18},
555 	{0x2f, 0x0c},
556 	{0x30, 0x26},
557 	{0x31, 0x5b},
558 	{0x32, 0x00},
559 	{0x33, 0x00},
560 	{0x34, 0x00},
561 	{0x35, 0x00},
562 	{0x36, 0xaa},
563 	{0x37, 0xaa},
564 	{0x38, 0xff},
565 	{0x39, 0xff},
566 	{0x3a, 0xf8},
567 	{0x3b, 0x00},
568 	{0x3c, 0x00},
569 	{0x3d, 0x09},
570 	{0x3e, 0x0d},
571 	{0x3f, 0x04},
572 	{0x40, 0x00},
573 	{0x41, 0x08},
574 	{0x42, 0x00},
575 	{0x43, 0x08},
576 	{0x44, 0x08},
577 	{0x45, 0x14},
578 	{0x46, 0x05},
579 	{0x47, 0x08},
580 	{0x48, 0x00},
581 	{0x49, 0x00},
582 	{0x4a, 0x00},
583 	{0x4b, 0x00},
584 	{0x4c, 0x09},
585 	{0x4d, 0x80},
586 	{0x4e, 0x00},
587 	{0x4f, 0xc5},
588 	{0x50, 0x14},
589 	{0x51, 0x19},
590 	{0x52, 0x00},
591 	{0x53, 0x00},
592 	{0x54, 0x00},
593 	{0x55, 0x00},
594 	{0x56, 0x00},
595 	{0x57, 0x00},
596 	{0x58, 0x00},
597 	{0x59, 0xb0},
598 	{0x5a, 0x00},
599 	{0x5b, 0x00},
600 	{0x5c, 0x00},
601 	{0x5d, 0x00},
602 	{0x5e, 0x00},
603 	{0x5f, 0x00},
604 	{0x60, 0x39},
605 	{0x61, 0x83},
606 	{0x62, 0x00},
607 	{0x63, 0x00},
608 	{0x64, 0x00},
609 	{0x65, 0x00},
610 	{0x66, 0xc0},
611 	{0x67, 0x49},
612 	{0x68, 0x00},
613 	{0x69, 0x00},
614 	{0x6a, 0x00},
615 	{0x6b, 0x00},
616 	{0x6c, 0x00},
617 	{0x6d, 0x03},
618 	{0x6e, 0x01},
619 	{0x6f, 0x00},
620 	{0x70, 0x00},
621 	{0x71, 0x00},
622 	{0x72, 0x00},
623 	{0x73, 0x00},
624 	{0x74, 0x00},
625 	{0x75, 0x00},
626 	{0x76, 0x00},
627 	{0x77, 0x00},
628 	{0x78, 0x00},
629 	{0x79, 0x00},
630 	{0x7a, 0x00},
631 	{0x7b, 0x00},
632 	{0x7c, 0x00},
633 	{0x7d, 0x00},
634 	{0x7e, 0x00},
635 	{0x7f, 0x00},
636 	{0x80, 0x89},
637 	{0x81, 0x00},
638 	{0x82, 0x0e},
639 	{0x83, 0x00},
640 	{0x84, 0x00},
641 	{0x85, 0x00},
642 	{0x86, 0x00},
643 	{0x87, 0x00},
644 	{0x88, 0x08},
645 	{0x89, 0x00},
646 	{0x8a, 0x0e},
647 	{0x8b, 0xa7},
648 	{0x8c, 0x88},
649 	{0x8d, 0x47},
650 	{0x8e, 0xaa},
651 	{0x8f, 0x02},
652 	{0x90, 0x23},
653 	{0x91, 0x0c},
654 	{0x92, 0x06},
655 	{0x93, 0x08},
656 	{0x94, 0x00},
657 	{0x95, 0x00},
658 	{0x96, 0x00},
659 	{0x97, 0xeb},
660 	{0x98, 0x00},
661 	{0x99, 0x00},
662 	{0x9a, 0x00},
663 	{0x9b, 0x00},
664 	{0x9c, 0x00},
665 	{0x9d, 0x00},
666 	{0x9e, 0x00},
667 	{0x9f, 0x00},
668 	{0xa0, 0x00},
669 	{0xa1, 0x00},
670 	{0xa2, 0x00},
671 	{0xa3, 0xcd},
672 	{0xa4, 0x07},
673 	{0xa5, 0x33},
674 	{0xa6, 0x18},
675 	{0xa7, 0x00},
676 	{0xa8, 0x18},
677 	{0xa9, 0x00},
678 	{0xaa, 0x28},
679 	{0xab, 0x00},
680 	{0xac, 0x00},
681 	{0xad, 0x00},
682 	{0xae, 0x00},
683 	{0xaf, 0x18},
684 	{0xb0, 0x38},
685 	{0xb1, 0x30},
686 	{0xb2, 0x00},
687 	{0xb3, 0x00},
688 	{0xb4, 0x00},
689 	{0xb5, 0x00},
690 	{0xb6, 0x84},
691 	{0xb7, 0xfd},
692 	{0xb8, 0x00},
693 	{0xb9, 0x00},
694 	{0xba, 0x00},
695 	{0xbb, 0x03},
696 	{0xbc, 0x00},
697 	{0xbd, 0x00},
698 	{0xbe, 0x00},
699 	{0xbf, 0x00},
700 	{0xc0, 0x10},
701 	{0xc1, 0x20},
702 	{0xc2, 0x18},
703 	{0xc3, 0x20},
704 	{0xc4, 0x10},
705 	{0xc5, 0x2c},
706 	{0xc6, 0x1e},
707 	{0xc7, 0x10},
708 	{0xc8, 0x12},
709 	{0xc9, 0x01},
710 	{0xca, 0x6f},
711 	{0xcb, 0xa7},
712 	{0xcc, 0x3c},
713 	{0xcd, 0x10},
714 	{0xce, 0x00},
715 	{0xcf, 0x22},
716 	{0xd0, 0x00},
717 	{0xd1, 0x10},
718 	{0xd2, 0x00},
719 	{0xd3, 0x00},
720 	{0xd4, 0x10},
721 	{0xd5, 0x33},
722 	{0xd6, 0x80},
723 	{0xd7, 0x21},
724 	{0xd8, 0x00},
725 	{0xd9, 0x00},
726 	{0xda, 0x00},
727 	{0xdb, 0x00},
728 	{0xdc, 0x00},
729 	{0xdd, 0x00},
730 	{0xde, 0x00},
731 	{0xdf, 0x00},
732 	{0xe0, 0x00},
733 	{0xe1, 0xB3},
734 	{0xe2, 0x00},
735 	{0xe3, 0x00},
736 	{0xe4, 0x00},
737 	{0xe5, 0x10},
738 	{0xe6, 0x00},
739 	{0xe7, 0x18},
740 	{0xe8, 0x08},
741 	{0xe9, 0xd4},
742 	{0xea, 0x00},
743 	{0xeb, 0xff},
744 	{0xec, 0x79},
745 	{0xed, 0x10},
746 	{0xee, 0x30},
747 	{0xef, 0x02},
748 	{0xf0, 0x00},
749 	{0xf1, 0x09},
750 	{0xf2, 0x00},
751 	{0xf3, 0x00},
752 	{0xf4, 0x00},
753 	{0xf5, 0x00},
754 	{0xf6, 0x00},
755 	{0xf7, 0x00},
756 	{0xf8, 0x00},
757 	{0xf9, 0x00},
758 	{0xfa, 0x00},
759 	{0xfb, 0x00},
760 	{0xfc, 0x00},
761 	{0xfd, 0x00},
762 	{0xfe, 0x00},
763 	{0xff, 0x00},
764 };
765 
766 #define CB_VT3253B0_AGC_FOR_RFMD2959 195
767 /* For RFMD2959 */
768 static
769 unsigned char byVT3253B0_AGC4_RFMD2959[CB_VT3253B0_AGC_FOR_RFMD2959][2] = {
770 	{0xF0, 0x00},
771 	{0xF1, 0x3E},
772 	{0xF0, 0x80},
773 	{0xF0, 0x00},
774 	{0xF1, 0x3E},
775 	{0xF0, 0x81},
776 	{0xF0, 0x01},
777 	{0xF1, 0x3E},
778 	{0xF0, 0x82},
779 	{0xF0, 0x02},
780 	{0xF1, 0x3E},
781 	{0xF0, 0x83},
782 	{0xF0, 0x03},
783 	{0xF1, 0x3B},
784 	{0xF0, 0x84},
785 	{0xF0, 0x04},
786 	{0xF1, 0x39},
787 	{0xF0, 0x85},
788 	{0xF0, 0x05},
789 	{0xF1, 0x38},
790 	{0xF0, 0x86},
791 	{0xF0, 0x06},
792 	{0xF1, 0x37},
793 	{0xF0, 0x87},
794 	{0xF0, 0x07},
795 	{0xF1, 0x36},
796 	{0xF0, 0x88},
797 	{0xF0, 0x08},
798 	{0xF1, 0x35},
799 	{0xF0, 0x89},
800 	{0xF0, 0x09},
801 	{0xF1, 0x35},
802 	{0xF0, 0x8A},
803 	{0xF0, 0x0A},
804 	{0xF1, 0x34},
805 	{0xF0, 0x8B},
806 	{0xF0, 0x0B},
807 	{0xF1, 0x34},
808 	{0xF0, 0x8C},
809 	{0xF0, 0x0C},
810 	{0xF1, 0x33},
811 	{0xF0, 0x8D},
812 	{0xF0, 0x0D},
813 	{0xF1, 0x32},
814 	{0xF0, 0x8E},
815 	{0xF0, 0x0E},
816 	{0xF1, 0x31},
817 	{0xF0, 0x8F},
818 	{0xF0, 0x0F},
819 	{0xF1, 0x30},
820 	{0xF0, 0x90},
821 	{0xF0, 0x10},
822 	{0xF1, 0x2F},
823 	{0xF0, 0x91},
824 	{0xF0, 0x11},
825 	{0xF1, 0x2F},
826 	{0xF0, 0x92},
827 	{0xF0, 0x12},
828 	{0xF1, 0x2E},
829 	{0xF0, 0x93},
830 	{0xF0, 0x13},
831 	{0xF1, 0x2D},
832 	{0xF0, 0x94},
833 	{0xF0, 0x14},
834 	{0xF1, 0x2C},
835 	{0xF0, 0x95},
836 	{0xF0, 0x15},
837 	{0xF1, 0x2B},
838 	{0xF0, 0x96},
839 	{0xF0, 0x16},
840 	{0xF1, 0x2B},
841 	{0xF0, 0x97},
842 	{0xF0, 0x17},
843 	{0xF1, 0x2A},
844 	{0xF0, 0x98},
845 	{0xF0, 0x18},
846 	{0xF1, 0x29},
847 	{0xF0, 0x99},
848 	{0xF0, 0x19},
849 	{0xF1, 0x28},
850 	{0xF0, 0x9A},
851 	{0xF0, 0x1A},
852 	{0xF1, 0x27},
853 	{0xF0, 0x9B},
854 	{0xF0, 0x1B},
855 	{0xF1, 0x26},
856 	{0xF0, 0x9C},
857 	{0xF0, 0x1C},
858 	{0xF1, 0x25},
859 	{0xF0, 0x9D},
860 	{0xF0, 0x1D},
861 	{0xF1, 0x24},
862 	{0xF0, 0x9E},
863 	{0xF0, 0x1E},
864 	{0xF1, 0x24},
865 	{0xF0, 0x9F},
866 	{0xF0, 0x1F},
867 	{0xF1, 0x23},
868 	{0xF0, 0xA0},
869 	{0xF0, 0x20},
870 	{0xF1, 0x22},
871 	{0xF0, 0xA1},
872 	{0xF0, 0x21},
873 	{0xF1, 0x21},
874 	{0xF0, 0xA2},
875 	{0xF0, 0x22},
876 	{0xF1, 0x20},
877 	{0xF0, 0xA3},
878 	{0xF0, 0x23},
879 	{0xF1, 0x20},
880 	{0xF0, 0xA4},
881 	{0xF0, 0x24},
882 	{0xF1, 0x1F},
883 	{0xF0, 0xA5},
884 	{0xF0, 0x25},
885 	{0xF1, 0x1E},
886 	{0xF0, 0xA6},
887 	{0xF0, 0x26},
888 	{0xF1, 0x1D},
889 	{0xF0, 0xA7},
890 	{0xF0, 0x27},
891 	{0xF1, 0x1C},
892 	{0xF0, 0xA8},
893 	{0xF0, 0x28},
894 	{0xF1, 0x1B},
895 	{0xF0, 0xA9},
896 	{0xF0, 0x29},
897 	{0xF1, 0x1B},
898 	{0xF0, 0xAA},
899 	{0xF0, 0x2A},
900 	{0xF1, 0x1A},
901 	{0xF0, 0xAB},
902 	{0xF0, 0x2B},
903 	{0xF1, 0x1A},
904 	{0xF0, 0xAC},
905 	{0xF0, 0x2C},
906 	{0xF1, 0x19},
907 	{0xF0, 0xAD},
908 	{0xF0, 0x2D},
909 	{0xF1, 0x18},
910 	{0xF0, 0xAE},
911 	{0xF0, 0x2E},
912 	{0xF1, 0x17},
913 	{0xF0, 0xAF},
914 	{0xF0, 0x2F},
915 	{0xF1, 0x16},
916 	{0xF0, 0xB0},
917 	{0xF0, 0x30},
918 	{0xF1, 0x15},
919 	{0xF0, 0xB1},
920 	{0xF0, 0x31},
921 	{0xF1, 0x15},
922 	{0xF0, 0xB2},
923 	{0xF0, 0x32},
924 	{0xF1, 0x15},
925 	{0xF0, 0xB3},
926 	{0xF0, 0x33},
927 	{0xF1, 0x14},
928 	{0xF0, 0xB4},
929 	{0xF0, 0x34},
930 	{0xF1, 0x13},
931 	{0xF0, 0xB5},
932 	{0xF0, 0x35},
933 	{0xF1, 0x12},
934 	{0xF0, 0xB6},
935 	{0xF0, 0x36},
936 	{0xF1, 0x11},
937 	{0xF0, 0xB7},
938 	{0xF0, 0x37},
939 	{0xF1, 0x10},
940 	{0xF0, 0xB8},
941 	{0xF0, 0x38},
942 	{0xF1, 0x0F},
943 	{0xF0, 0xB9},
944 	{0xF0, 0x39},
945 	{0xF1, 0x0E},
946 	{0xF0, 0xBA},
947 	{0xF0, 0x3A},
948 	{0xF1, 0x0D},
949 	{0xF0, 0xBB},
950 	{0xF0, 0x3B},
951 	{0xF1, 0x0C},
952 	{0xF0, 0xBC},
953 	{0xF0, 0x3C},
954 	{0xF1, 0x0B},
955 	{0xF0, 0xBD},
956 	{0xF0, 0x3D},
957 	{0xF1, 0x0B},
958 	{0xF0, 0xBE},
959 	{0xF0, 0x3E},
960 	{0xF1, 0x0A},
961 	{0xF0, 0xBF},
962 	{0xF0, 0x3F},
963 	{0xF1, 0x09},
964 	{0xF0, 0x00},
965 };
966 
967 #define CB_VT3253B0_INIT_FOR_AIROHA2230 256
968 /* For AIROHA */
969 static
970 unsigned char byVT3253B0_AIROHA2230[CB_VT3253B0_INIT_FOR_AIROHA2230][2] = {
971 	{0x00, 0x31},
972 	{0x01, 0x00},
973 	{0x02, 0x00},
974 	{0x03, 0x00},
975 	{0x04, 0x00},
976 	{0x05, 0x80},
977 	{0x06, 0x00},
978 	{0x07, 0x00},
979 	{0x08, 0x70},
980 	{0x09, 0x41},
981 	{0x0a, 0x2A},
982 	{0x0b, 0x76},
983 	{0x0c, 0x00},
984 	{0x0d, 0x00},
985 	{0x0e, 0x80},
986 	{0x0f, 0x00},
987 	{0x10, 0x00},
988 	{0x11, 0x00},
989 	{0x12, 0x00},
990 	{0x13, 0x00},
991 	{0x14, 0x00},
992 	{0x15, 0x00},
993 	{0x16, 0x00},
994 	{0x17, 0x00},
995 	{0x18, 0x00},
996 	{0x19, 0x00},
997 	{0x1a, 0x00},
998 	{0x1b, 0x8f},
999 	{0x1c, 0x09},
1000 	{0x1d, 0x00},
1001 	{0x1e, 0x00},
1002 	{0x1f, 0x00},
1003 	{0x20, 0x00},
1004 	{0x21, 0x00},
1005 	{0x22, 0x00},
1006 	{0x23, 0x00},
1007 	{0x24, 0x00},
1008 	{0x25, 0x4a},
1009 	{0x26, 0x00},
1010 	{0x27, 0x00},
1011 	{0x28, 0x00},
1012 	{0x29, 0x00},
1013 	{0x2a, 0x00},
1014 	{0x2b, 0x00},
1015 	{0x2c, 0x00},
1016 	{0x2d, 0x4a},
1017 	{0x2e, 0x00},
1018 	{0x2f, 0x0a},
1019 	{0x30, 0x26},
1020 	{0x31, 0x5b},
1021 	{0x32, 0x00},
1022 	{0x33, 0x00},
1023 	{0x34, 0x00},
1024 	{0x35, 0x00},
1025 	{0x36, 0xaa},
1026 	{0x37, 0xaa},
1027 	{0x38, 0xff},
1028 	{0x39, 0xff},
1029 	{0x3a, 0x79},
1030 	{0x3b, 0x00},
1031 	{0x3c, 0x00},
1032 	{0x3d, 0x0b},
1033 	{0x3e, 0x48},
1034 	{0x3f, 0x04},
1035 	{0x40, 0x00},
1036 	{0x41, 0x08},
1037 	{0x42, 0x00},
1038 	{0x43, 0x08},
1039 	{0x44, 0x08},
1040 	{0x45, 0x14},
1041 	{0x46, 0x05},
1042 	{0x47, 0x09},
1043 	{0x48, 0x00},
1044 	{0x49, 0x00},
1045 	{0x4a, 0x00},
1046 	{0x4b, 0x00},
1047 	{0x4c, 0x09},
1048 	{0x4d, 0x73},
1049 	{0x4e, 0x00},
1050 	{0x4f, 0xc5},
1051 	{0x50, 0x15},
1052 	{0x51, 0x19},
1053 	{0x52, 0x00},
1054 	{0x53, 0x00},
1055 	{0x54, 0x00},
1056 	{0x55, 0x00},
1057 	{0x56, 0x00},
1058 	{0x57, 0x00},
1059 	{0x58, 0x00},
1060 	{0x59, 0xb0},
1061 	{0x5a, 0x00},
1062 	{0x5b, 0x00},
1063 	{0x5c, 0x00},
1064 	{0x5d, 0x00},
1065 	{0x5e, 0x00},
1066 	{0x5f, 0x00},
1067 	{0x60, 0xe4},
1068 	{0x61, 0x80},
1069 	{0x62, 0x00},
1070 	{0x63, 0x00},
1071 	{0x64, 0x00},
1072 	{0x65, 0x00},
1073 	{0x66, 0x98},
1074 	{0x67, 0x0a},
1075 	{0x68, 0x00},
1076 	{0x69, 0x00},
1077 	{0x6a, 0x00},
1078 	{0x6b, 0x00},
1079 	{0x6c, 0x00}, /* RobertYu:20050125, request by JJSue */
1080 	{0x6d, 0x03},
1081 	{0x6e, 0x01},
1082 	{0x6f, 0x00},
1083 	{0x70, 0x00},
1084 	{0x71, 0x00},
1085 	{0x72, 0x00},
1086 	{0x73, 0x00},
1087 	{0x74, 0x00},
1088 	{0x75, 0x00},
1089 	{0x76, 0x00},
1090 	{0x77, 0x00},
1091 	{0x78, 0x00},
1092 	{0x79, 0x00},
1093 	{0x7a, 0x00},
1094 	{0x7b, 0x00},
1095 	{0x7c, 0x00},
1096 	{0x7d, 0x00},
1097 	{0x7e, 0x00},
1098 	{0x7f, 0x00},
1099 	{0x80, 0x8c},
1100 	{0x81, 0x01},
1101 	{0x82, 0x09},
1102 	{0x83, 0x00},
1103 	{0x84, 0x00},
1104 	{0x85, 0x00},
1105 	{0x86, 0x00},
1106 	{0x87, 0x00},
1107 	{0x88, 0x08},
1108 	{0x89, 0x00},
1109 	{0x8a, 0x0f},
1110 	{0x8b, 0xb7},
1111 	{0x8c, 0x88},
1112 	{0x8d, 0x47},
1113 	{0x8e, 0xaa},
1114 	{0x8f, 0x02},
1115 	{0x90, 0x22},
1116 	{0x91, 0x00},
1117 	{0x92, 0x00},
1118 	{0x93, 0x00},
1119 	{0x94, 0x00},
1120 	{0x95, 0x00},
1121 	{0x96, 0x00},
1122 	{0x97, 0xeb},
1123 	{0x98, 0x00},
1124 	{0x99, 0x00},
1125 	{0x9a, 0x00},
1126 	{0x9b, 0x00},
1127 	{0x9c, 0x00},
1128 	{0x9d, 0x00},
1129 	{0x9e, 0x00},
1130 	{0x9f, 0x01},
1131 	{0xa0, 0x00},
1132 	{0xa1, 0x00},
1133 	{0xa2, 0x00},
1134 	{0xa3, 0x00},
1135 	{0xa4, 0x00},
1136 	{0xa5, 0x00},
1137 	{0xa6, 0x10},
1138 	{0xa7, 0x00},
1139 	{0xa8, 0x18},
1140 	{0xa9, 0x00},
1141 	{0xaa, 0x00},
1142 	{0xab, 0x00},
1143 	{0xac, 0x00},
1144 	{0xad, 0x00},
1145 	{0xae, 0x00},
1146 	{0xaf, 0x18},
1147 	{0xb0, 0x38},
1148 	{0xb1, 0x30},
1149 	{0xb2, 0x00},
1150 	{0xb3, 0x00},
1151 	{0xb4, 0xff},
1152 	{0xb5, 0x0f},
1153 	{0xb6, 0xe4},
1154 	{0xb7, 0xe2},
1155 	{0xb8, 0x00},
1156 	{0xb9, 0x00},
1157 	{0xba, 0x00},
1158 	{0xbb, 0x03},
1159 	{0xbc, 0x01},
1160 	{0xbd, 0x00},
1161 	{0xbe, 0x00},
1162 	{0xbf, 0x00},
1163 	{0xc0, 0x18},
1164 	{0xc1, 0x20},
1165 	{0xc2, 0x07},
1166 	{0xc3, 0x18},
1167 	{0xc4, 0xff},
1168 	{0xc5, 0x2c},
1169 	{0xc6, 0x0c},
1170 	{0xc7, 0x0a},
1171 	{0xc8, 0x0e},
1172 	{0xc9, 0x01},
1173 	{0xca, 0x68},
1174 	{0xcb, 0xa7},
1175 	{0xcc, 0x3c},
1176 	{0xcd, 0x10},
1177 	{0xce, 0x00},
1178 	{0xcf, 0x25},
1179 	{0xd0, 0x40},
1180 	{0xd1, 0x12},
1181 	{0xd2, 0x00},
1182 	{0xd3, 0x00},
1183 	{0xd4, 0x10},
1184 	{0xd5, 0x28},
1185 	{0xd6, 0x80},
1186 	{0xd7, 0x2A},
1187 	{0xd8, 0x00},
1188 	{0xd9, 0x00},
1189 	{0xda, 0x00},
1190 	{0xdb, 0x00},
1191 	{0xdc, 0x00},
1192 	{0xdd, 0x00},
1193 	{0xde, 0x00},
1194 	{0xdf, 0x00},
1195 	{0xe0, 0x00},
1196 	{0xe1, 0xB3},
1197 	{0xe2, 0x00},
1198 	{0xe3, 0x00},
1199 	{0xe4, 0x00},
1200 	{0xe5, 0x10},
1201 	{0xe6, 0x00},
1202 	{0xe7, 0x1C},
1203 	{0xe8, 0x00},
1204 	{0xe9, 0xf4},
1205 	{0xea, 0x00},
1206 	{0xeb, 0xff},
1207 	{0xec, 0x79},
1208 	{0xed, 0x20},
1209 	{0xee, 0x30},
1210 	{0xef, 0x01},
1211 	{0xf0, 0x00},
1212 	{0xf1, 0x3e},
1213 	{0xf2, 0x00},
1214 	{0xf3, 0x00},
1215 	{0xf4, 0x00},
1216 	{0xf5, 0x00},
1217 	{0xf6, 0x00},
1218 	{0xf7, 0x00},
1219 	{0xf8, 0x00},
1220 	{0xf9, 0x00},
1221 	{0xfa, 0x00},
1222 	{0xfb, 0x00},
1223 	{0xfc, 0x00},
1224 	{0xfd, 0x00},
1225 	{0xfe, 0x00},
1226 	{0xff, 0x00},
1227 };
1228 
1229 #define CB_VT3253B0_INIT_FOR_UW2451 256
1230 /* For UW2451 */
1231 static unsigned char byVT3253B0_UW2451[CB_VT3253B0_INIT_FOR_UW2451][2] = {
1232 	{0x00, 0x31},
1233 	{0x01, 0x00},
1234 	{0x02, 0x00},
1235 	{0x03, 0x00},
1236 	{0x04, 0x00},
1237 	{0x05, 0x81},
1238 	{0x06, 0x00},
1239 	{0x07, 0x00},
1240 	{0x08, 0x38},
1241 	{0x09, 0x45},
1242 	{0x0a, 0x28},
1243 	{0x0b, 0x76},
1244 	{0x0c, 0x00},
1245 	{0x0d, 0x00},
1246 	{0x0e, 0x80},
1247 	{0x0f, 0x00},
1248 	{0x10, 0x00},
1249 	{0x11, 0x00},
1250 	{0x12, 0x00},
1251 	{0x13, 0x00},
1252 	{0x14, 0x00},
1253 	{0x15, 0x00},
1254 	{0x16, 0x00},
1255 	{0x17, 0x00},
1256 	{0x18, 0x00},
1257 	{0x19, 0x00},
1258 	{0x1a, 0x00},
1259 	{0x1b, 0x8f},
1260 	{0x1c, 0x0f},
1261 	{0x1d, 0x00},
1262 	{0x1e, 0x00},
1263 	{0x1f, 0x00},
1264 	{0x20, 0x00},
1265 	{0x21, 0x00},
1266 	{0x22, 0x00},
1267 	{0x23, 0x00},
1268 	{0x24, 0x00},
1269 	{0x25, 0x4a},
1270 	{0x26, 0x00},
1271 	{0x27, 0x00},
1272 	{0x28, 0x00},
1273 	{0x29, 0x00},
1274 	{0x2a, 0x00},
1275 	{0x2b, 0x00},
1276 	{0x2c, 0x00},
1277 	{0x2d, 0x18},
1278 	{0x2e, 0x00},
1279 	{0x2f, 0x0a},
1280 	{0x30, 0x26},
1281 	{0x31, 0x5b},
1282 	{0x32, 0x00},
1283 	{0x33, 0x00},
1284 	{0x34, 0x00},
1285 	{0x35, 0x00},
1286 	{0x36, 0xaa},
1287 	{0x37, 0xaa},
1288 	{0x38, 0xff},
1289 	{0x39, 0xff},
1290 	{0x3a, 0x00},
1291 	{0x3b, 0x00},
1292 	{0x3c, 0x00},
1293 	{0x3d, 0x03},
1294 	{0x3e, 0x1d},
1295 	{0x3f, 0x04},
1296 	{0x40, 0x00},
1297 	{0x41, 0x08},
1298 	{0x42, 0x00},
1299 	{0x43, 0x08},
1300 	{0x44, 0x08},
1301 	{0x45, 0x14},
1302 	{0x46, 0x05},
1303 	{0x47, 0x09},
1304 	{0x48, 0x00},
1305 	{0x49, 0x00},
1306 	{0x4a, 0x00},
1307 	{0x4b, 0x00},
1308 	{0x4c, 0x09},
1309 	{0x4d, 0x90},
1310 	{0x4e, 0x00},
1311 	{0x4f, 0xc5},
1312 	{0x50, 0x15},
1313 	{0x51, 0x19},
1314 	{0x52, 0x00},
1315 	{0x53, 0x00},
1316 	{0x54, 0x00},
1317 	{0x55, 0x00},
1318 	{0x56, 0x00},
1319 	{0x57, 0x00},
1320 	{0x58, 0x00},
1321 	{0x59, 0xb0},
1322 	{0x5a, 0x00},
1323 	{0x5b, 0x00},
1324 	{0x5c, 0x00},
1325 	{0x5d, 0x00},
1326 	{0x5e, 0x00},
1327 	{0x5f, 0x00},
1328 	{0x60, 0xb3},
1329 	{0x61, 0x81},
1330 	{0x62, 0x00},
1331 	{0x63, 0x00},
1332 	{0x64, 0x00},
1333 	{0x65, 0x00},
1334 	{0x66, 0x57},
1335 	{0x67, 0x6c},
1336 	{0x68, 0x00},
1337 	{0x69, 0x00},
1338 	{0x6a, 0x00},
1339 	{0x6b, 0x00},
1340 	{0x6c, 0x00}, /* RobertYu:20050125, request by JJSue */
1341 	{0x6d, 0x03},
1342 	{0x6e, 0x01},
1343 	{0x6f, 0x00},
1344 	{0x70, 0x00},
1345 	{0x71, 0x00},
1346 	{0x72, 0x00},
1347 	{0x73, 0x00},
1348 	{0x74, 0x00},
1349 	{0x75, 0x00},
1350 	{0x76, 0x00},
1351 	{0x77, 0x00},
1352 	{0x78, 0x00},
1353 	{0x79, 0x00},
1354 	{0x7a, 0x00},
1355 	{0x7b, 0x00},
1356 	{0x7c, 0x00},
1357 	{0x7d, 0x00},
1358 	{0x7e, 0x00},
1359 	{0x7f, 0x00},
1360 	{0x80, 0x8c},
1361 	{0x81, 0x00},
1362 	{0x82, 0x0e},
1363 	{0x83, 0x00},
1364 	{0x84, 0x00},
1365 	{0x85, 0x00},
1366 	{0x86, 0x00},
1367 	{0x87, 0x00},
1368 	{0x88, 0x08},
1369 	{0x89, 0x00},
1370 	{0x8a, 0x0e},
1371 	{0x8b, 0xa7},
1372 	{0x8c, 0x88},
1373 	{0x8d, 0x47},
1374 	{0x8e, 0xaa},
1375 	{0x8f, 0x02},
1376 	{0x90, 0x00},
1377 	{0x91, 0x00},
1378 	{0x92, 0x00},
1379 	{0x93, 0x00},
1380 	{0x94, 0x00},
1381 	{0x95, 0x00},
1382 	{0x96, 0x00},
1383 	{0x97, 0xe3},
1384 	{0x98, 0x00},
1385 	{0x99, 0x00},
1386 	{0x9a, 0x00},
1387 	{0x9b, 0x00},
1388 	{0x9c, 0x00},
1389 	{0x9d, 0x00},
1390 	{0x9e, 0x00},
1391 	{0x9f, 0x00},
1392 	{0xa0, 0x00},
1393 	{0xa1, 0x00},
1394 	{0xa2, 0x00},
1395 	{0xa3, 0x00},
1396 	{0xa4, 0x00},
1397 	{0xa5, 0x00},
1398 	{0xa6, 0x10},
1399 	{0xa7, 0x00},
1400 	{0xa8, 0x18},
1401 	{0xa9, 0x00},
1402 	{0xaa, 0x00},
1403 	{0xab, 0x00},
1404 	{0xac, 0x00},
1405 	{0xad, 0x00},
1406 	{0xae, 0x00},
1407 	{0xaf, 0x18},
1408 	{0xb0, 0x18},
1409 	{0xb1, 0x30},
1410 	{0xb2, 0x00},
1411 	{0xb3, 0x00},
1412 	{0xb4, 0x00},
1413 	{0xb5, 0x00},
1414 	{0xb6, 0x00},
1415 	{0xb7, 0x00},
1416 	{0xb8, 0x00},
1417 	{0xb9, 0x00},
1418 	{0xba, 0x00},
1419 	{0xbb, 0x03},
1420 	{0xbc, 0x01},
1421 	{0xbd, 0x00},
1422 	{0xbe, 0x00},
1423 	{0xbf, 0x00},
1424 	{0xc0, 0x10},
1425 	{0xc1, 0x20},
1426 	{0xc2, 0x00},
1427 	{0xc3, 0x20},
1428 	{0xc4, 0x00},
1429 	{0xc5, 0x2c},
1430 	{0xc6, 0x1c},
1431 	{0xc7, 0x10},
1432 	{0xc8, 0x10},
1433 	{0xc9, 0x01},
1434 	{0xca, 0x68},
1435 	{0xcb, 0xa7},
1436 	{0xcc, 0x3c},
1437 	{0xcd, 0x09},
1438 	{0xce, 0x00},
1439 	{0xcf, 0x20},
1440 	{0xd0, 0x40},
1441 	{0xd1, 0x10},
1442 	{0xd2, 0x00},
1443 	{0xd3, 0x00},
1444 	{0xd4, 0x20},
1445 	{0xd5, 0x28},
1446 	{0xd6, 0xa0},
1447 	{0xd7, 0x2a},
1448 	{0xd8, 0x00},
1449 	{0xd9, 0x00},
1450 	{0xda, 0x00},
1451 	{0xdb, 0x00},
1452 	{0xdc, 0x00},
1453 	{0xdd, 0x00},
1454 	{0xde, 0x00},
1455 	{0xdf, 0x00},
1456 	{0xe0, 0x00},
1457 	{0xe1, 0xd3},
1458 	{0xe2, 0xc0},
1459 	{0xe3, 0x00},
1460 	{0xe4, 0x00},
1461 	{0xe5, 0x10},
1462 	{0xe6, 0x00},
1463 	{0xe7, 0x12},
1464 	{0xe8, 0x12},
1465 	{0xe9, 0x34},
1466 	{0xea, 0x00},
1467 	{0xeb, 0xff},
1468 	{0xec, 0x79},
1469 	{0xed, 0x20},
1470 	{0xee, 0x30},
1471 	{0xef, 0x01},
1472 	{0xf0, 0x00},
1473 	{0xf1, 0x3e},
1474 	{0xf2, 0x00},
1475 	{0xf3, 0x00},
1476 	{0xf4, 0x00},
1477 	{0xf5, 0x00},
1478 	{0xf6, 0x00},
1479 	{0xf7, 0x00},
1480 	{0xf8, 0x00},
1481 	{0xf9, 0x00},
1482 	{0xfa, 0x00},
1483 	{0xfb, 0x00},
1484 	{0xfc, 0x00},
1485 	{0xfd, 0x00},
1486 	{0xfe, 0x00},
1487 	{0xff, 0x00},
1488 };
1489 
1490 #define CB_VT3253B0_AGC 193
1491 /* For AIROHA */
1492 static unsigned char byVT3253B0_AGC[CB_VT3253B0_AGC][2] = {
1493 	{0xF0, 0x00},
1494 	{0xF1, 0x00},
1495 	{0xF0, 0x80},
1496 	{0xF0, 0x01},
1497 	{0xF1, 0x00},
1498 	{0xF0, 0x81},
1499 	{0xF0, 0x02},
1500 	{0xF1, 0x02},
1501 	{0xF0, 0x82},
1502 	{0xF0, 0x03},
1503 	{0xF1, 0x04},
1504 	{0xF0, 0x83},
1505 	{0xF0, 0x03},
1506 	{0xF1, 0x04},
1507 	{0xF0, 0x84},
1508 	{0xF0, 0x04},
1509 	{0xF1, 0x06},
1510 	{0xF0, 0x85},
1511 	{0xF0, 0x05},
1512 	{0xF1, 0x06},
1513 	{0xF0, 0x86},
1514 	{0xF0, 0x06},
1515 	{0xF1, 0x06},
1516 	{0xF0, 0x87},
1517 	{0xF0, 0x07},
1518 	{0xF1, 0x08},
1519 	{0xF0, 0x88},
1520 	{0xF0, 0x08},
1521 	{0xF1, 0x08},
1522 	{0xF0, 0x89},
1523 	{0xF0, 0x09},
1524 	{0xF1, 0x0A},
1525 	{0xF0, 0x8A},
1526 	{0xF0, 0x0A},
1527 	{0xF1, 0x0A},
1528 	{0xF0, 0x8B},
1529 	{0xF0, 0x0B},
1530 	{0xF1, 0x0C},
1531 	{0xF0, 0x8C},
1532 	{0xF0, 0x0C},
1533 	{0xF1, 0x0C},
1534 	{0xF0, 0x8D},
1535 	{0xF0, 0x0D},
1536 	{0xF1, 0x0E},
1537 	{0xF0, 0x8E},
1538 	{0xF0, 0x0E},
1539 	{0xF1, 0x0E},
1540 	{0xF0, 0x8F},
1541 	{0xF0, 0x0F},
1542 	{0xF1, 0x10},
1543 	{0xF0, 0x90},
1544 	{0xF0, 0x10},
1545 	{0xF1, 0x10},
1546 	{0xF0, 0x91},
1547 	{0xF0, 0x11},
1548 	{0xF1, 0x12},
1549 	{0xF0, 0x92},
1550 	{0xF0, 0x12},
1551 	{0xF1, 0x12},
1552 	{0xF0, 0x93},
1553 	{0xF0, 0x13},
1554 	{0xF1, 0x14},
1555 	{0xF0, 0x94},
1556 	{0xF0, 0x14},
1557 	{0xF1, 0x14},
1558 	{0xF0, 0x95},
1559 	{0xF0, 0x15},
1560 	{0xF1, 0x16},
1561 	{0xF0, 0x96},
1562 	{0xF0, 0x16},
1563 	{0xF1, 0x16},
1564 	{0xF0, 0x97},
1565 	{0xF0, 0x17},
1566 	{0xF1, 0x18},
1567 	{0xF0, 0x98},
1568 	{0xF0, 0x18},
1569 	{0xF1, 0x18},
1570 	{0xF0, 0x99},
1571 	{0xF0, 0x19},
1572 	{0xF1, 0x1A},
1573 	{0xF0, 0x9A},
1574 	{0xF0, 0x1A},
1575 	{0xF1, 0x1A},
1576 	{0xF0, 0x9B},
1577 	{0xF0, 0x1B},
1578 	{0xF1, 0x1C},
1579 	{0xF0, 0x9C},
1580 	{0xF0, 0x1C},
1581 	{0xF1, 0x1C},
1582 	{0xF0, 0x9D},
1583 	{0xF0, 0x1D},
1584 	{0xF1, 0x1E},
1585 	{0xF0, 0x9E},
1586 	{0xF0, 0x1E},
1587 	{0xF1, 0x1E},
1588 	{0xF0, 0x9F},
1589 	{0xF0, 0x1F},
1590 	{0xF1, 0x20},
1591 	{0xF0, 0xA0},
1592 	{0xF0, 0x20},
1593 	{0xF1, 0x20},
1594 	{0xF0, 0xA1},
1595 	{0xF0, 0x21},
1596 	{0xF1, 0x22},
1597 	{0xF0, 0xA2},
1598 	{0xF0, 0x22},
1599 	{0xF1, 0x22},
1600 	{0xF0, 0xA3},
1601 	{0xF0, 0x23},
1602 	{0xF1, 0x24},
1603 	{0xF0, 0xA4},
1604 	{0xF0, 0x24},
1605 	{0xF1, 0x24},
1606 	{0xF0, 0xA5},
1607 	{0xF0, 0x25},
1608 	{0xF1, 0x26},
1609 	{0xF0, 0xA6},
1610 	{0xF0, 0x26},
1611 	{0xF1, 0x26},
1612 	{0xF0, 0xA7},
1613 	{0xF0, 0x27},
1614 	{0xF1, 0x28},
1615 	{0xF0, 0xA8},
1616 	{0xF0, 0x28},
1617 	{0xF1, 0x28},
1618 	{0xF0, 0xA9},
1619 	{0xF0, 0x29},
1620 	{0xF1, 0x2A},
1621 	{0xF0, 0xAA},
1622 	{0xF0, 0x2A},
1623 	{0xF1, 0x2A},
1624 	{0xF0, 0xAB},
1625 	{0xF0, 0x2B},
1626 	{0xF1, 0x2C},
1627 	{0xF0, 0xAC},
1628 	{0xF0, 0x2C},
1629 	{0xF1, 0x2C},
1630 	{0xF0, 0xAD},
1631 	{0xF0, 0x2D},
1632 	{0xF1, 0x2E},
1633 	{0xF0, 0xAE},
1634 	{0xF0, 0x2E},
1635 	{0xF1, 0x2E},
1636 	{0xF0, 0xAF},
1637 	{0xF0, 0x2F},
1638 	{0xF1, 0x30},
1639 	{0xF0, 0xB0},
1640 	{0xF0, 0x30},
1641 	{0xF1, 0x30},
1642 	{0xF0, 0xB1},
1643 	{0xF0, 0x31},
1644 	{0xF1, 0x32},
1645 	{0xF0, 0xB2},
1646 	{0xF0, 0x32},
1647 	{0xF1, 0x32},
1648 	{0xF0, 0xB3},
1649 	{0xF0, 0x33},
1650 	{0xF1, 0x34},
1651 	{0xF0, 0xB4},
1652 	{0xF0, 0x34},
1653 	{0xF1, 0x34},
1654 	{0xF0, 0xB5},
1655 	{0xF0, 0x35},
1656 	{0xF1, 0x36},
1657 	{0xF0, 0xB6},
1658 	{0xF0, 0x36},
1659 	{0xF1, 0x36},
1660 	{0xF0, 0xB7},
1661 	{0xF0, 0x37},
1662 	{0xF1, 0x38},
1663 	{0xF0, 0xB8},
1664 	{0xF0, 0x38},
1665 	{0xF1, 0x38},
1666 	{0xF0, 0xB9},
1667 	{0xF0, 0x39},
1668 	{0xF1, 0x3A},
1669 	{0xF0, 0xBA},
1670 	{0xF0, 0x3A},
1671 	{0xF1, 0x3A},
1672 	{0xF0, 0xBB},
1673 	{0xF0, 0x3B},
1674 	{0xF1, 0x3C},
1675 	{0xF0, 0xBC},
1676 	{0xF0, 0x3C},
1677 	{0xF1, 0x3C},
1678 	{0xF0, 0xBD},
1679 	{0xF0, 0x3D},
1680 	{0xF1, 0x3E},
1681 	{0xF0, 0xBE},
1682 	{0xF0, 0x3E},
1683 	{0xF1, 0x3E},
1684 	{0xF0, 0xBF},
1685 	{0xF0, 0x00},
1686 };
1687 
1688 static const unsigned short awcFrameTime[MAX_RATE] = {
1689 		10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
1690 };
1691 
1692 /*---------------------  Export Variables  --------------------------*/
1693 /*
1694  * Description: Calculate data frame transmitting time
1695  *
1696  * Parameters:
1697  *  In:
1698  *      byPreambleType  - Preamble Type
1699  *      byPktType        - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA
1700  *      cbFrameLength   - Baseband Type
1701  *      wRate           - Tx Rate
1702  *  Out:
1703  *
1704  * Return Value: FrameTime
1705  *
1706  */
1707 unsigned int
BBuGetFrameTime(unsigned char byPreambleType,unsigned char byPktType,unsigned int cbFrameLength,unsigned short wRate)1708 BBuGetFrameTime(
1709 	unsigned char byPreambleType,
1710 	unsigned char byPktType,
1711 	unsigned int cbFrameLength,
1712 	unsigned short wRate
1713 )
1714 {
1715 	unsigned int uFrameTime;
1716 	unsigned int uPreamble;
1717 	unsigned int uTmp;
1718 	unsigned int uRateIdx = (unsigned int)wRate;
1719 	unsigned int uRate = 0;
1720 
1721 	if (uRateIdx > RATE_54M)
1722 		return 0;
1723 
1724 	uRate = (unsigned int)awcFrameTime[uRateIdx];
1725 
1726 	if (uRateIdx <= 3) {          /* CCK mode */
1727 		if (byPreambleType == 1) /* Short */
1728 			uPreamble = 96;
1729 		else
1730 			uPreamble = 192;
1731 
1732 		uFrameTime = (cbFrameLength * 80) / uRate;  /* ????? */
1733 		uTmp = (uFrameTime * uRate) / 80;
1734 		if (cbFrameLength != uTmp)
1735 			uFrameTime++;
1736 
1737 		return uPreamble + uFrameTime;
1738 	}
1739 	uFrameTime = (cbFrameLength * 8 + 22) / uRate; /* ???????? */
1740 	uTmp = ((uFrameTime * uRate) - 22) / 8;
1741 	if (cbFrameLength != uTmp)
1742 		uFrameTime++;
1743 
1744 	uFrameTime = uFrameTime * 4;    /* ??????? */
1745 	if (byPktType != PK_TYPE_11A)
1746 		uFrameTime += 6;     /* ?????? */
1747 
1748 	return 20 + uFrameTime; /* ?????? */
1749 }
1750 
1751 /*
1752  * Description: Calculate Length, Service, and Signal fields of Phy for Tx
1753  *
1754  * Parameters:
1755  *  In:
1756  *      priv         - Device Structure
1757  *      frame_length   - Tx Frame Length
1758  *      tx_rate           - Tx Rate
1759  *  Out:
1760  *	struct vnt_phy_field *phy
1761  *		- pointer to Phy Length field
1762  *		- pointer to Phy Service field
1763  *		- pointer to Phy Signal field
1764  *
1765  * Return Value: none
1766  *
1767  */
vnt_get_phy_field(struct vnt_private * priv,u32 frame_length,u16 tx_rate,u8 pkt_type,struct vnt_phy_field * phy)1768 void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
1769 		       u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy)
1770 {
1771 	u32 bit_count;
1772 	u32 count = 0;
1773 	u32 tmp;
1774 	int ext_bit;
1775 	u8 preamble_type = priv->byPreambleType;
1776 
1777 	bit_count = frame_length * 8;
1778 	ext_bit = false;
1779 
1780 	switch (tx_rate) {
1781 	case RATE_1M:
1782 		count = bit_count;
1783 
1784 		phy->signal = 0x00;
1785 
1786 		break;
1787 	case RATE_2M:
1788 		count = bit_count / 2;
1789 
1790 		if (preamble_type == 1)
1791 			phy->signal = 0x09;
1792 		else
1793 			phy->signal = 0x01;
1794 
1795 		break;
1796 	case RATE_5M:
1797 		count = (bit_count * 10) / 55;
1798 		tmp = (count * 55) / 10;
1799 
1800 		if (tmp != bit_count)
1801 			count++;
1802 
1803 		if (preamble_type == 1)
1804 			phy->signal = 0x0a;
1805 		else
1806 			phy->signal = 0x02;
1807 
1808 		break;
1809 	case RATE_11M:
1810 		count = bit_count / 11;
1811 		tmp = count * 11;
1812 
1813 		if (tmp != bit_count) {
1814 			count++;
1815 
1816 			if ((bit_count - tmp) <= 3)
1817 				ext_bit = true;
1818 		}
1819 
1820 		if (preamble_type == 1)
1821 			phy->signal = 0x0b;
1822 		else
1823 			phy->signal = 0x03;
1824 
1825 		break;
1826 	case RATE_6M:
1827 		if (pkt_type == PK_TYPE_11A)
1828 			phy->signal = 0x9b;
1829 		else
1830 			phy->signal = 0x8b;
1831 
1832 		break;
1833 	case RATE_9M:
1834 		if (pkt_type == PK_TYPE_11A)
1835 			phy->signal = 0x9f;
1836 		else
1837 			phy->signal = 0x8f;
1838 
1839 		break;
1840 	case RATE_12M:
1841 		if (pkt_type == PK_TYPE_11A)
1842 			phy->signal = 0x9a;
1843 		else
1844 			phy->signal = 0x8a;
1845 
1846 		break;
1847 	case RATE_18M:
1848 		if (pkt_type == PK_TYPE_11A)
1849 			phy->signal = 0x9e;
1850 		else
1851 			phy->signal = 0x8e;
1852 
1853 		break;
1854 	case RATE_24M:
1855 		if (pkt_type == PK_TYPE_11A)
1856 			phy->signal = 0x99;
1857 		else
1858 			phy->signal = 0x89;
1859 
1860 		break;
1861 	case RATE_36M:
1862 		if (pkt_type == PK_TYPE_11A)
1863 			phy->signal = 0x9d;
1864 		else
1865 			phy->signal = 0x8d;
1866 
1867 		break;
1868 	case RATE_48M:
1869 		if (pkt_type == PK_TYPE_11A)
1870 			phy->signal = 0x98;
1871 		else
1872 			phy->signal = 0x88;
1873 
1874 		break;
1875 	case RATE_54M:
1876 		if (pkt_type == PK_TYPE_11A)
1877 			phy->signal = 0x9c;
1878 		else
1879 			phy->signal = 0x8c;
1880 		break;
1881 	default:
1882 		if (pkt_type == PK_TYPE_11A)
1883 			phy->signal = 0x9c;
1884 		else
1885 			phy->signal = 0x8c;
1886 		break;
1887 	}
1888 
1889 	if (pkt_type == PK_TYPE_11B) {
1890 		phy->service = 0x00;
1891 		if (ext_bit)
1892 			phy->service |= 0x80;
1893 		phy->len = cpu_to_le16((u16)count);
1894 	} else {
1895 		phy->service = 0x00;
1896 		phy->len = cpu_to_le16((u16)frame_length);
1897 	}
1898 }
1899 
1900 /*
1901  * Description: Read a byte from BASEBAND, by embedded programming
1902  *
1903  * Parameters:
1904  *  In:
1905  *      iobase      - I/O base address
1906  *      byBBAddr    - address of register in Baseband
1907  *  Out:
1908  *      pbyData     - data read
1909  *
1910  * Return Value: true if succeeded; false if failed.
1911  *
1912  */
BBbReadEmbedded(struct vnt_private * priv,unsigned char byBBAddr,unsigned char * pbyData)1913 bool BBbReadEmbedded(struct vnt_private *priv,
1914 		     unsigned char byBBAddr, unsigned char *pbyData)
1915 {
1916 	void __iomem *iobase = priv->PortOffset;
1917 	unsigned short ww;
1918 	unsigned char byValue;
1919 
1920 	/* BB reg offset */
1921 	VNSvOutPortB(iobase + MAC_REG_BBREGADR, byBBAddr);
1922 
1923 	/* turn on REGR */
1924 	MACvRegBitsOn(iobase, MAC_REG_BBREGCTL, BBREGCTL_REGR);
1925 	/* W_MAX_TIMEOUT is the timeout period */
1926 	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
1927 		VNSvInPortB(iobase + MAC_REG_BBREGCTL, &byValue);
1928 		if (byValue & BBREGCTL_DONE)
1929 			break;
1930 	}
1931 
1932 	/* get BB data */
1933 	VNSvInPortB(iobase + MAC_REG_BBREGDATA, pbyData);
1934 
1935 	if (ww == W_MAX_TIMEOUT) {
1936 		pr_debug(" DBG_PORT80(0x30)\n");
1937 		return false;
1938 	}
1939 	return true;
1940 }
1941 
1942 /*
1943  * Description: Write a Byte to BASEBAND, by embedded programming
1944  *
1945  * Parameters:
1946  *  In:
1947  *      iobase      - I/O base address
1948  *      byBBAddr    - address of register in Baseband
1949  *      byData      - data to write
1950  *  Out:
1951  *      none
1952  *
1953  * Return Value: true if succeeded; false if failed.
1954  *
1955  */
BBbWriteEmbedded(struct vnt_private * priv,unsigned char byBBAddr,unsigned char byData)1956 bool BBbWriteEmbedded(struct vnt_private *priv,
1957 		      unsigned char byBBAddr, unsigned char byData)
1958 {
1959 	void __iomem *iobase = priv->PortOffset;
1960 	unsigned short ww;
1961 	unsigned char byValue;
1962 
1963 	/* BB reg offset */
1964 	VNSvOutPortB(iobase + MAC_REG_BBREGADR, byBBAddr);
1965 	/* set BB data */
1966 	VNSvOutPortB(iobase + MAC_REG_BBREGDATA, byData);
1967 
1968 	/* turn on BBREGCTL_REGW */
1969 	MACvRegBitsOn(iobase, MAC_REG_BBREGCTL, BBREGCTL_REGW);
1970 	/* W_MAX_TIMEOUT is the timeout period */
1971 	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
1972 		VNSvInPortB(iobase + MAC_REG_BBREGCTL, &byValue);
1973 		if (byValue & BBREGCTL_DONE)
1974 			break;
1975 	}
1976 
1977 	if (ww == W_MAX_TIMEOUT) {
1978 		pr_debug(" DBG_PORT80(0x31)\n");
1979 		return false;
1980 	}
1981 	return true;
1982 }
1983 
1984 /*
1985  * Description: VIA VT3253 Baseband chip init function
1986  *
1987  * Parameters:
1988  *  In:
1989  *      iobase      - I/O base address
1990  *      byRevId     - Revision ID
1991  *      byRFType    - RF type
1992  *  Out:
1993  *      none
1994  *
1995  * Return Value: true if succeeded; false if failed.
1996  *
1997  */
1998 
BBbVT3253Init(struct vnt_private * priv)1999 bool BBbVT3253Init(struct vnt_private *priv)
2000 {
2001 	bool bResult = true;
2002 	int        ii;
2003 	void __iomem *iobase = priv->PortOffset;
2004 	unsigned char byRFType = priv->byRFType;
2005 	unsigned char byLocalID = priv->byLocalID;
2006 
2007 	if (byRFType == RF_RFMD2959) {
2008 		if (byLocalID <= REV_ID_VT3253_A1) {
2009 			for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++)
2010 				bResult &= BBbWriteEmbedded(priv,
2011 					byVT3253InitTab_RFMD[ii][0],
2012 					byVT3253InitTab_RFMD[ii][1]);
2013 
2014 		} else {
2015 			for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++)
2016 				bResult &= BBbWriteEmbedded(priv,
2017 					byVT3253B0_RFMD[ii][0],
2018 					byVT3253B0_RFMD[ii][1]);
2019 
2020 			for (ii = 0; ii < CB_VT3253B0_AGC_FOR_RFMD2959; ii++)
2021 				bResult &= BBbWriteEmbedded(priv,
2022 					byVT3253B0_AGC4_RFMD2959[ii][0],
2023 					byVT3253B0_AGC4_RFMD2959[ii][1]);
2024 
2025 			VNSvOutPortD(iobase + MAC_REG_ITRTMSET, 0x23);
2026 			MACvRegBitsOn(iobase, MAC_REG_PAPEDELAY, BIT(0));
2027 		}
2028 		priv->abyBBVGA[0] = 0x18;
2029 		priv->abyBBVGA[1] = 0x0A;
2030 		priv->abyBBVGA[2] = 0x0;
2031 		priv->abyBBVGA[3] = 0x0;
2032 		priv->ldBmThreshold[0] = -70;
2033 		priv->ldBmThreshold[1] = -50;
2034 		priv->ldBmThreshold[2] = 0;
2035 		priv->ldBmThreshold[3] = 0;
2036 	} else if ((byRFType == RF_AIROHA) || (byRFType == RF_AL2230S)) {
2037 		for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++)
2038 			bResult &= BBbWriteEmbedded(priv,
2039 				byVT3253B0_AIROHA2230[ii][0],
2040 				byVT3253B0_AIROHA2230[ii][1]);
2041 
2042 		for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
2043 			bResult &= BBbWriteEmbedded(priv,
2044 				byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2045 
2046 		priv->abyBBVGA[0] = 0x1C;
2047 		priv->abyBBVGA[1] = 0x10;
2048 		priv->abyBBVGA[2] = 0x0;
2049 		priv->abyBBVGA[3] = 0x0;
2050 		priv->ldBmThreshold[0] = -70;
2051 		priv->ldBmThreshold[1] = -48;
2052 		priv->ldBmThreshold[2] = 0;
2053 		priv->ldBmThreshold[3] = 0;
2054 	} else if (byRFType == RF_UW2451) {
2055 		for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++)
2056 			bResult &= BBbWriteEmbedded(priv,
2057 				byVT3253B0_UW2451[ii][0],
2058 				byVT3253B0_UW2451[ii][1]);
2059 
2060 		for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
2061 			bResult &= BBbWriteEmbedded(priv,
2062 				byVT3253B0_AGC[ii][0],
2063 				byVT3253B0_AGC[ii][1]);
2064 
2065 		VNSvOutPortB(iobase + MAC_REG_ITRTMSET, 0x23);
2066 		MACvRegBitsOn(iobase, MAC_REG_PAPEDELAY, BIT(0));
2067 
2068 		priv->abyBBVGA[0] = 0x14;
2069 		priv->abyBBVGA[1] = 0x0A;
2070 		priv->abyBBVGA[2] = 0x0;
2071 		priv->abyBBVGA[3] = 0x0;
2072 		priv->ldBmThreshold[0] = -60;
2073 		priv->ldBmThreshold[1] = -50;
2074 		priv->ldBmThreshold[2] = 0;
2075 		priv->ldBmThreshold[3] = 0;
2076 	} else if (byRFType == RF_UW2452) {
2077 		for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++)
2078 			bResult &= BBbWriteEmbedded(priv,
2079 				byVT3253B0_UW2451[ii][0],
2080 				byVT3253B0_UW2451[ii][1]);
2081 
2082 		/* Init ANT B select,
2083 		 * TX Config CR09 = 0x61->0x45,
2084 		 * 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
2085 		 */
2086 
2087 		/*bResult &= BBbWriteEmbedded(iobase,0x09,0x41);*/
2088 
2089 		/* Init ANT B select,
2090 		 * RX Config CR10 = 0x28->0x2A,
2091 		 * 0x2A->0x28(VC1/VC2 define,
2092 		 * make the ANT_A, ANT_B inverted)
2093 		 */
2094 
2095 		/*bResult &= BBbWriteEmbedded(iobase,0x0a,0x28);*/
2096 		/* Select VC1/VC2, CR215 = 0x02->0x06 */
2097 		bResult &= BBbWriteEmbedded(priv, 0xd7, 0x06);
2098 
2099 		/* {{RobertYu:20050125, request by Jack */
2100 		bResult &= BBbWriteEmbedded(priv, 0x90, 0x20);
2101 		bResult &= BBbWriteEmbedded(priv, 0x97, 0xeb);
2102 		/* }} */
2103 
2104 		/* {{RobertYu:20050221, request by Jack */
2105 		bResult &= BBbWriteEmbedded(priv, 0xa6, 0x00);
2106 		bResult &= BBbWriteEmbedded(priv, 0xa8, 0x30);
2107 		/* }} */
2108 		bResult &= BBbWriteEmbedded(priv, 0xb0, 0x58);
2109 
2110 		for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
2111 			bResult &= BBbWriteEmbedded(priv,
2112 				byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2113 
2114 		priv->abyBBVGA[0] = 0x14;
2115 		priv->abyBBVGA[1] = 0x0A;
2116 		priv->abyBBVGA[2] = 0x0;
2117 		priv->abyBBVGA[3] = 0x0;
2118 		priv->ldBmThreshold[0] = -60;
2119 		priv->ldBmThreshold[1] = -50;
2120 		priv->ldBmThreshold[2] = 0;
2121 		priv->ldBmThreshold[3] = 0;
2122 		/* }} RobertYu */
2123 
2124 	} else if (byRFType == RF_VT3226) {
2125 		for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++)
2126 			bResult &= BBbWriteEmbedded(priv,
2127 				byVT3253B0_AIROHA2230[ii][0],
2128 				byVT3253B0_AIROHA2230[ii][1]);
2129 
2130 		for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
2131 			bResult &= BBbWriteEmbedded(priv,
2132 				byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2133 
2134 		priv->abyBBVGA[0] = 0x1C;
2135 		priv->abyBBVGA[1] = 0x10;
2136 		priv->abyBBVGA[2] = 0x0;
2137 		priv->abyBBVGA[3] = 0x0;
2138 		priv->ldBmThreshold[0] = -70;
2139 		priv->ldBmThreshold[1] = -48;
2140 		priv->ldBmThreshold[2] = 0;
2141 		priv->ldBmThreshold[3] = 0;
2142 		/* Fix VT3226 DFC system timing issue */
2143 		MACvSetRFLE_LatchBase(iobase);
2144 		/* {{ RobertYu: 20050104 */
2145 	} else if (byRFType == RF_AIROHA7230) {
2146 		for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++)
2147 			bResult &= BBbWriteEmbedded(priv,
2148 				byVT3253B0_AIROHA2230[ii][0],
2149 				byVT3253B0_AIROHA2230[ii][1]);
2150 
2151 		/* {{ RobertYu:20050223, request by JerryChung */
2152 		/* Init ANT B select,TX Config CR09 = 0x61->0x45,
2153 		 * 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
2154 		 */
2155 		/*bResult &= BBbWriteEmbedded(iobase,0x09,0x41);*/
2156 		/* Init ANT B select,RX Config CR10 = 0x28->0x2A,
2157 		 * 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
2158 		 */
2159 		/*bResult &= BBbWriteEmbedded(iobase,0x0a,0x28);*/
2160 		/* Select VC1/VC2, CR215 = 0x02->0x06 */
2161 		bResult &= BBbWriteEmbedded(priv, 0xd7, 0x06);
2162 		/* }} */
2163 
2164 		for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
2165 			bResult &= BBbWriteEmbedded(priv,
2166 				byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
2167 
2168 		priv->abyBBVGA[0] = 0x1C;
2169 		priv->abyBBVGA[1] = 0x10;
2170 		priv->abyBBVGA[2] = 0x0;
2171 		priv->abyBBVGA[3] = 0x0;
2172 		priv->ldBmThreshold[0] = -70;
2173 		priv->ldBmThreshold[1] = -48;
2174 		priv->ldBmThreshold[2] = 0;
2175 		priv->ldBmThreshold[3] = 0;
2176 		/* }} RobertYu */
2177 	} else {
2178 		/* No VGA Table now */
2179 		priv->bUpdateBBVGA = false;
2180 		priv->abyBBVGA[0] = 0x1C;
2181 	}
2182 
2183 	if (byLocalID > REV_ID_VT3253_A1) {
2184 		BBbWriteEmbedded(priv, 0x04, 0x7F);
2185 		BBbWriteEmbedded(priv, 0x0D, 0x01);
2186 	}
2187 
2188 	return bResult;
2189 }
2190 
2191 /*
2192  * Description: Set ShortSlotTime mode
2193  *
2194  * Parameters:
2195  *  In:
2196  *      priv     - Device Structure
2197  *  Out:
2198  *      none
2199  *
2200  * Return Value: none
2201  *
2202  */
2203 void
BBvSetShortSlotTime(struct vnt_private * priv)2204 BBvSetShortSlotTime(struct vnt_private *priv)
2205 {
2206 	unsigned char byBBRxConf = 0;
2207 	unsigned char byBBVGA = 0;
2208 
2209 	BBbReadEmbedded(priv, 0x0A, &byBBRxConf); /* CR10 */
2210 
2211 	if (priv->bShortSlotTime)
2212 		byBBRxConf &= 0xDF; /* 1101 1111 */
2213 	else
2214 		byBBRxConf |= 0x20; /* 0010 0000 */
2215 
2216 	/* patch for 3253B0 Baseband with Cardbus module */
2217 	BBbReadEmbedded(priv, 0xE7, &byBBVGA);
2218 	if (byBBVGA == priv->abyBBVGA[0])
2219 		byBBRxConf |= 0x20; /* 0010 0000 */
2220 
2221 	BBbWriteEmbedded(priv, 0x0A, byBBRxConf); /* CR10 */
2222 }
2223 
BBvSetVGAGainOffset(struct vnt_private * priv,unsigned char byData)2224 void BBvSetVGAGainOffset(struct vnt_private *priv, unsigned char byData)
2225 {
2226 	unsigned char byBBRxConf = 0;
2227 
2228 	BBbWriteEmbedded(priv, 0xE7, byData);
2229 
2230 	BBbReadEmbedded(priv, 0x0A, &byBBRxConf); /* CR10 */
2231 	/* patch for 3253B0 Baseband with Cardbus module */
2232 	if (byData == priv->abyBBVGA[0])
2233 		byBBRxConf |= 0x20; /* 0010 0000 */
2234 	else if (priv->bShortSlotTime)
2235 		byBBRxConf &= 0xDF; /* 1101 1111 */
2236 	else
2237 		byBBRxConf |= 0x20; /* 0010 0000 */
2238 	priv->byBBVGACurrent = byData;
2239 	BBbWriteEmbedded(priv, 0x0A, byBBRxConf); /* CR10 */
2240 }
2241 
2242 /*
2243  * Description: Baseband SoftwareReset
2244  *
2245  * Parameters:
2246  *  In:
2247  *      iobase      - I/O base address
2248  *  Out:
2249  *      none
2250  *
2251  * Return Value: none
2252  *
2253  */
2254 void
BBvSoftwareReset(struct vnt_private * priv)2255 BBvSoftwareReset(struct vnt_private *priv)
2256 {
2257 	BBbWriteEmbedded(priv, 0x50, 0x40);
2258 	BBbWriteEmbedded(priv, 0x50, 0);
2259 	BBbWriteEmbedded(priv, 0x9C, 0x01);
2260 	BBbWriteEmbedded(priv, 0x9C, 0);
2261 }
2262 
2263 /*
2264  * Description: Baseband Power Save Mode ON
2265  *
2266  * Parameters:
2267  *  In:
2268  *      iobase      - I/O base address
2269  *  Out:
2270  *      none
2271  *
2272  * Return Value: none
2273  *
2274  */
2275 void
BBvPowerSaveModeON(struct vnt_private * priv)2276 BBvPowerSaveModeON(struct vnt_private *priv)
2277 {
2278 	unsigned char byOrgData;
2279 
2280 	BBbReadEmbedded(priv, 0x0D, &byOrgData);
2281 	byOrgData |= BIT(0);
2282 	BBbWriteEmbedded(priv, 0x0D, byOrgData);
2283 }
2284 
2285 /*
2286  * Description: Baseband Power Save Mode OFF
2287  *
2288  * Parameters:
2289  *  In:
2290  *      iobase      - I/O base address
2291  *  Out:
2292  *      none
2293  *
2294  * Return Value: none
2295  *
2296  */
2297 void
BBvPowerSaveModeOFF(struct vnt_private * priv)2298 BBvPowerSaveModeOFF(struct vnt_private *priv)
2299 {
2300 	unsigned char byOrgData;
2301 
2302 	BBbReadEmbedded(priv, 0x0D, &byOrgData);
2303 	byOrgData &= ~(BIT(0));
2304 	BBbWriteEmbedded(priv, 0x0D, byOrgData);
2305 }
2306 
2307 /*
2308  * Description: Set Tx Antenna mode
2309  *
2310  * Parameters:
2311  *  In:
2312  *      priv          - Device Structure
2313  *      byAntennaMode    - Antenna Mode
2314  *  Out:
2315  *      none
2316  *
2317  * Return Value: none
2318  *
2319  */
2320 
2321 void
BBvSetTxAntennaMode(struct vnt_private * priv,unsigned char byAntennaMode)2322 BBvSetTxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode)
2323 {
2324 	unsigned char byBBTxConf;
2325 
2326 	BBbReadEmbedded(priv, 0x09, &byBBTxConf); /* CR09 */
2327 	if (byAntennaMode == ANT_DIVERSITY) {
2328 		/* bit 1 is diversity */
2329 		byBBTxConf |= 0x02;
2330 	} else if (byAntennaMode == ANT_A) {
2331 		/* bit 2 is ANTSEL */
2332 		byBBTxConf &= 0xF9; /* 1111 1001 */
2333 	} else if (byAntennaMode == ANT_B) {
2334 		byBBTxConf &= 0xFD; /* 1111 1101 */
2335 		byBBTxConf |= 0x04;
2336 	}
2337 	BBbWriteEmbedded(priv, 0x09, byBBTxConf); /* CR09 */
2338 }
2339 
2340 /*
2341  * Description: Set Rx Antenna mode
2342  *
2343  * Parameters:
2344  *  In:
2345  *      priv          - Device Structure
2346  *      byAntennaMode    - Antenna Mode
2347  *  Out:
2348  *      none
2349  *
2350  * Return Value: none
2351  *
2352  */
2353 
2354 void
BBvSetRxAntennaMode(struct vnt_private * priv,unsigned char byAntennaMode)2355 BBvSetRxAntennaMode(struct vnt_private *priv, unsigned char byAntennaMode)
2356 {
2357 	unsigned char byBBRxConf;
2358 
2359 	BBbReadEmbedded(priv, 0x0A, &byBBRxConf); /* CR10 */
2360 	if (byAntennaMode == ANT_DIVERSITY) {
2361 		byBBRxConf |= 0x01;
2362 
2363 	} else if (byAntennaMode == ANT_A) {
2364 		byBBRxConf &= 0xFC; /* 1111 1100 */
2365 	} else if (byAntennaMode == ANT_B) {
2366 		byBBRxConf &= 0xFE; /* 1111 1110 */
2367 		byBBRxConf |= 0x02;
2368 	}
2369 	BBbWriteEmbedded(priv, 0x0A, byBBRxConf); /* CR10 */
2370 }
2371 
2372 /*
2373  * Description: BBvSetDeepSleep
2374  *
2375  * Parameters:
2376  *  In:
2377  *      priv          - Device Structure
2378  *  Out:
2379  *      none
2380  *
2381  * Return Value: none
2382  *
2383  */
2384 void
BBvSetDeepSleep(struct vnt_private * priv,unsigned char byLocalID)2385 BBvSetDeepSleep(struct vnt_private *priv, unsigned char byLocalID)
2386 {
2387 	BBbWriteEmbedded(priv, 0x0C, 0x17); /* CR12 */
2388 	BBbWriteEmbedded(priv, 0x0D, 0xB9); /* CR13 */
2389 }
2390 
2391 void
BBvExitDeepSleep(struct vnt_private * priv,unsigned char byLocalID)2392 BBvExitDeepSleep(struct vnt_private *priv, unsigned char byLocalID)
2393 {
2394 	BBbWriteEmbedded(priv, 0x0C, 0x00); /* CR12 */
2395 	BBbWriteEmbedded(priv, 0x0D, 0x01); /* CR13 */
2396 }
2397