• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 ******************************************************************************/
15 
16 #include "odm_precomp.h"
17 
CheckCondition(const u32 Condition,const u32 Hex)18 static bool CheckCondition(const u32  Condition, const u32  Hex)
19 {
20 	u32 _board     = (Hex & 0x000000FF);
21 	u32 _interface = (Hex & 0x0000FF00) >> 8;
22 	u32 _platform  = (Hex & 0x00FF0000) >> 16;
23 	u32 cond = Condition;
24 
25 	if (Condition == 0xCDCDCDCD)
26 		return true;
27 
28 	cond = Condition & 0x000000FF;
29 	if ((_board == cond) && cond != 0x00)
30 		return false;
31 
32 	cond = Condition & 0x0000FF00;
33 	cond = cond >> 8;
34 	if ((_interface & cond) == 0 && cond != 0x07)
35 		return false;
36 
37 	cond = Condition & 0x00FF0000;
38 	cond = cond >> 16;
39 	if ((_platform & cond) == 0 && cond != 0x0F)
40 		return false;
41 	return true;
42 }
43 
44 /******************************************************************************
45 *                           MAC_REG.TXT
46 ******************************************************************************/
47 
48 static u32 Array_MAC_REG_8723A[] = {
49 		0x420, 0x00000080,
50 		0x423, 0x00000000,
51 		0x430, 0x00000000,
52 		0x431, 0x00000000,
53 		0x432, 0x00000000,
54 		0x433, 0x00000001,
55 		0x434, 0x00000004,
56 		0x435, 0x00000005,
57 		0x436, 0x00000006,
58 		0x437, 0x00000007,
59 		0x438, 0x00000000,
60 		0x439, 0x00000000,
61 		0x43A, 0x00000000,
62 		0x43B, 0x00000001,
63 		0x43C, 0x00000004,
64 		0x43D, 0x00000005,
65 		0x43E, 0x00000006,
66 		0x43F, 0x00000007,
67 		0x440, 0x0000005D,
68 		0x441, 0x00000001,
69 		0x442, 0x00000000,
70 		0x444, 0x00000015,
71 		0x445, 0x000000F0,
72 		0x446, 0x0000000F,
73 		0x447, 0x00000000,
74 		0x458, 0x00000041,
75 		0x459, 0x000000A8,
76 		0x45A, 0x00000072,
77 		0x45B, 0x000000B9,
78 		0x460, 0x00000066,
79 		0x461, 0x00000066,
80 		0x462, 0x00000008,
81 		0x463, 0x00000003,
82 		0x4C8, 0x000000FF,
83 		0x4C9, 0x00000008,
84 		0x4CC, 0x000000FF,
85 		0x4CD, 0x000000FF,
86 		0x4CE, 0x00000001,
87 		0x500, 0x00000026,
88 		0x501, 0x000000A2,
89 		0x502, 0x0000002F,
90 		0x503, 0x00000000,
91 		0x504, 0x00000028,
92 		0x505, 0x000000A3,
93 		0x506, 0x0000005E,
94 		0x507, 0x00000000,
95 		0x508, 0x0000002B,
96 		0x509, 0x000000A4,
97 		0x50A, 0x0000005E,
98 		0x50B, 0x00000000,
99 		0x50C, 0x0000004F,
100 		0x50D, 0x000000A4,
101 		0x50E, 0x00000000,
102 		0x50F, 0x00000000,
103 		0x512, 0x0000001C,
104 		0x514, 0x0000000A,
105 		0x515, 0x00000010,
106 		0x516, 0x0000000A,
107 		0x517, 0x00000010,
108 		0x51A, 0x00000016,
109 		0x524, 0x0000000F,
110 		0x525, 0x0000004F,
111 		0x546, 0x00000040,
112 		0x547, 0x00000000,
113 		0x550, 0x00000010,
114 		0x551, 0x00000010,
115 		0x559, 0x00000002,
116 		0x55A, 0x00000002,
117 		0x55D, 0x000000FF,
118 		0x605, 0x00000030,
119 		0x608, 0x0000000E,
120 		0x609, 0x0000002A,
121 		0x652, 0x00000020,
122 		0x63C, 0x0000000A,
123 		0x63D, 0x0000000A,
124 		0x63E, 0x0000000E,
125 		0x63F, 0x0000000E,
126 		0x66E, 0x00000005,
127 		0x700, 0x00000021,
128 		0x701, 0x00000043,
129 		0x702, 0x00000065,
130 		0x703, 0x00000087,
131 		0x708, 0x00000021,
132 		0x709, 0x00000043,
133 		0x70A, 0x00000065,
134 		0x70B, 0x00000087,
135 };
136 
ODM_ReadAndConfig_MAC_REG_8723A(struct dm_odm_t * pDM_Odm)137 void ODM_ReadAndConfig_MAC_REG_8723A(struct dm_odm_t *pDM_Odm)
138 {
139 	#define READ_NEXT_PAIR(v1, v2, i)			\
140 		 do {						\
141 			i += 2; v1 = Array[i]; v2 = Array[i+1];	\
142 		 } while (0)
143 
144 	u32     hex         = 0;
145 	u32     i           = 0;
146 	u8     platform    = 0x04;
147 	u8     interfaceValue   = pDM_Odm->SupportInterface;
148 	u8     board       = pDM_Odm->BoardType;
149 	u32     ArrayLen    = sizeof(Array_MAC_REG_8723A)/sizeof(u32);
150 	u32 *Array       = Array_MAC_REG_8723A;
151 
152 	hex += board;
153 	hex += interfaceValue << 8;
154 	hex += platform << 16;
155 	hex += 0xFF000000;
156 	for (i = 0; i < ArrayLen; i += 2) {
157 		u32 v1 = Array[i];
158 		u32 v2 = Array[i+1];
159 
160 		/*  This (offset, data) pair meets the condition. */
161 		if (v1 < 0xCDCDCDCD) {
162 			odm_ConfigMAC_8723A(pDM_Odm, v1, (u8)v2);
163 			continue;
164 		} else {
165 			if (!CheckCondition(Array[i], hex)) {
166 				/* Discard the following (offset, data) pairs. */
167 				READ_NEXT_PAIR(v1, v2, i);
168 				while (v2 != 0xDEAD &&
169 				       v2 != 0xCDEF &&
170 				       v2 != 0xCDCD && i < ArrayLen - 2)
171 					READ_NEXT_PAIR(v1, v2, i);
172 				i -= 2; /*  prevent from for-loop += 2 */
173 			} else {
174 				/*  Configure matched pairs and skip to end of if-else. */
175 				READ_NEXT_PAIR(v1, v2, i);
176 				while (v2 != 0xDEAD &&
177 				       v2 != 0xCDEF &&
178 				       v2 != 0xCDCD && i < ArrayLen - 2) {
179 					odm_ConfigMAC_8723A(pDM_Odm, v1, (u8)v2);
180 					READ_NEXT_PAIR(v1, v2, i);
181 				}
182 
183 				while (v2 != 0xDEAD && i < ArrayLen - 2)
184 					READ_NEXT_PAIR(v1, v2, i);
185 			}
186 		}
187 	}
188 }
189