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