Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 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 | |
| 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; |
Aya Mahfouz | 5092450 | 2015-02-26 11:30:50 +0200 | [diff] [blame] | 33 | cond >>= 8; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 34 | if ((_interface & cond) == 0 && cond != 0x07) |
| 35 | return false; |
| 36 | |
| 37 | cond = Condition & 0x00FF0000; |
Aya Mahfouz | 5092450 | 2015-02-26 11:30:50 +0200 | [diff] [blame] | 38 | cond >>= 16; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 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 | |
| 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; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 147 | u8 board = pDM_Odm->BoardType; |
Janani Ravichandran | 993c0a0 | 2016-02-11 18:50:40 -0500 | [diff] [blame] | 148 | u32 ArrayLen = ARRAY_SIZE(Array_MAC_REG_8723A); |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 149 | u32 *Array = Array_MAC_REG_8723A; |
| 150 | |
| 151 | hex += board; |
Jes Sorensen | 9d693e3 | 2015-03-02 15:24:52 -0500 | [diff] [blame] | 152 | hex += ODM_ITRF_USB << 8; |
Larry Finger | f7c92d2 | 2014-03-28 21:37:39 -0500 | [diff] [blame] | 153 | hex += platform << 16; |
| 154 | hex += 0xFF000000; |
| 155 | for (i = 0; i < ArrayLen; i += 2) { |
| 156 | u32 v1 = Array[i]; |
| 157 | u32 v2 = Array[i+1]; |
| 158 | |
| 159 | /* This (offset, data) pair meets the condition. */ |
| 160 | if (v1 < 0xCDCDCDCD) { |
| 161 | odm_ConfigMAC_8723A(pDM_Odm, v1, (u8)v2); |
| 162 | continue; |
| 163 | } else { |
| 164 | if (!CheckCondition(Array[i], hex)) { |
| 165 | /* Discard the following (offset, data) pairs. */ |
| 166 | READ_NEXT_PAIR(v1, v2, i); |
| 167 | while (v2 != 0xDEAD && |
| 168 | v2 != 0xCDEF && |
| 169 | v2 != 0xCDCD && i < ArrayLen - 2) |
| 170 | READ_NEXT_PAIR(v1, v2, i); |
| 171 | i -= 2; /* prevent from for-loop += 2 */ |
| 172 | } else { |
| 173 | /* Configure matched pairs and skip to end of if-else. */ |
| 174 | READ_NEXT_PAIR(v1, v2, i); |
| 175 | while (v2 != 0xDEAD && |
| 176 | v2 != 0xCDEF && |
| 177 | v2 != 0xCDCD && i < ArrayLen - 2) { |
| 178 | odm_ConfigMAC_8723A(pDM_Odm, v1, (u8)v2); |
| 179 | READ_NEXT_PAIR(v1, v2, i); |
| 180 | } |
| 181 | |
| 182 | while (v2 != 0xDEAD && i < ArrayLen - 2) |
| 183 | READ_NEXT_PAIR(v1, v2, i); |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | } |