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