Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -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 | #define _RTW_EFUSE_C_ |
| 16 | |
| 17 | #include <osdep_service.h> |
| 18 | #include <drv_types.h> |
| 19 | |
| 20 | #include <rtw_efuse.h> |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 21 | #include <rtl8723a_hal.h> |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 22 | #include <usb_ops_linux.h> |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 23 | |
| 24 | /*------------------------Define local variable------------------------------*/ |
| 25 | |
| 26 | /* */ |
| 27 | #define REG_EFUSE_CTRL 0x0030 |
| 28 | #define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ |
| 29 | /* */ |
| 30 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 31 | #define VOLTAGE_V25 0x03 |
| 32 | #define LDOE25_SHIFT 28 |
| 33 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 34 | /*----------------------------------------------------------------------------- |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 35 | * Function: Efuse_PowerSwitch |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 36 | * |
| 37 | * Overview: When we want to enable write operation, we should change to |
| 38 | * pwr on state. When we stop write, we should switch to 500k mode |
| 39 | * and disable LDO 2.5V. |
| 40 | * |
| 41 | * Input: NONE |
| 42 | * |
| 43 | * Output: NONE |
| 44 | * |
| 45 | * Return: NONE |
| 46 | * |
| 47 | * Revised History: |
| 48 | * When Who Remark |
| 49 | * 11/17/2008 MHC Create Version 0. |
| 50 | * |
| 51 | *---------------------------------------------------------------------------*/ |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 52 | static void Efuse_PowerSwitch(struct rtw_adapter *padapter, |
| 53 | u8 bWrite, u8 PwrState) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 54 | { |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 55 | u8 tempval; |
| 56 | u16 tmpV16; |
| 57 | |
| 58 | if (PwrState == true) { |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 59 | rtl8723au_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 60 | |
| 61 | /* 1.2V Power: From VDDON with Power |
Masanari Iida | 808bcb4 | 2014-07-22 23:42:53 +0900 | [diff] [blame] | 62 | Cut(0x0000h[15]), default valid */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 63 | tmpV16 = rtl8723au_read16(padapter, REG_SYS_ISO_CTRL); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 64 | if (!(tmpV16 & PWC_EV12V)) { |
| 65 | tmpV16 |= PWC_EV12V; |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 66 | rtl8723au_write16(padapter, REG_SYS_ISO_CTRL, tmpV16); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 67 | } |
| 68 | /* Reset: 0x0000h[28], default valid */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 69 | tmpV16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 70 | if (!(tmpV16 & FEN_ELDR)) { |
| 71 | tmpV16 |= FEN_ELDR; |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 72 | rtl8723au_write16(padapter, REG_SYS_FUNC_EN, tmpV16); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock |
| 76 | from ANA, default valid */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 77 | tmpV16 = rtl8723au_read16(padapter, REG_SYS_CLKR); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 78 | if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { |
| 79 | tmpV16 |= (LOADER_CLK_EN | ANA8M); |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 80 | rtl8723au_write16(padapter, REG_SYS_CLKR, tmpV16); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | if (bWrite == true) { |
| 84 | /* Enable LDO 2.5V before read/write action */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 85 | tempval = rtl8723au_read8(padapter, EFUSE_TEST + 3); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 86 | tempval &= 0x0F; |
| 87 | tempval |= (VOLTAGE_V25 << 4); |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 88 | rtl8723au_write8(padapter, EFUSE_TEST + 3, |
| 89 | tempval | 0x80); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 90 | } |
| 91 | } else { |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 92 | rtl8723au_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 93 | |
| 94 | if (bWrite == true) { |
| 95 | /* Disable LDO 2.5V after read/write action */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 96 | tempval = rtl8723au_read8(padapter, EFUSE_TEST + 3); |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 97 | rtl8723au_write8(padapter, EFUSE_TEST + 3, |
| 98 | tempval & 0x7F); |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 99 | } |
| 100 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 101 | } |
| 102 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 103 | u16 |
| 104 | Efuse_GetCurrentSize23a(struct rtw_adapter *pAdapter, u8 efuseType) |
| 105 | { |
| 106 | u16 ret = 0; |
| 107 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 108 | if (efuseType == EFUSE_WIFI) |
| 109 | ret = rtl8723a_EfuseGetCurrentSize_WiFi(pAdapter); |
| 110 | else |
| 111 | ret = rtl8723a_EfuseGetCurrentSize_BT(pAdapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 112 | |
| 113 | return ret; |
| 114 | } |
| 115 | |
| 116 | /* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */ |
| 117 | u8 |
| 118 | Efuse_CalculateWordCnts23a(u8 word_en) |
| 119 | { |
Tapasweni Pathak | 4ecdc38 | 2014-10-08 10:15:42 +0530 | [diff] [blame] | 120 | return hweight8((~word_en) & 0xf); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | /* */ |
| 124 | /* Description: */ |
| 125 | /* Execute E-Fuse read byte operation. */ |
Masanari Iida | 808bcb4 | 2014-07-22 23:42:53 +0900 | [diff] [blame] | 126 | /* Referred from SD1 Richard. */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 127 | /* */ |
| 128 | /* Assumption: */ |
| 129 | /* 1. Boot from E-Fuse and successfully auto-load. */ |
| 130 | /* 2. PASSIVE_LEVEL (USB interface) */ |
| 131 | /* */ |
| 132 | /* Created by Roger, 2008.10.21. */ |
| 133 | /* */ |
| 134 | void |
| 135 | ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf) |
| 136 | { |
| 137 | u32 value32; |
| 138 | u8 readbyte; |
| 139 | u16 retry; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 140 | |
| 141 | /* Write Address */ |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 142 | rtl8723au_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 143 | readbyte = rtl8723au_read8(Adapter, EFUSE_CTRL+2); |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 144 | rtl8723au_write8(Adapter, EFUSE_CTRL+2, |
| 145 | ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 146 | |
| 147 | /* Write bit 32 0 */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 148 | readbyte = rtl8723au_read8(Adapter, EFUSE_CTRL+3); |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 149 | rtl8723au_write8(Adapter, EFUSE_CTRL+3, readbyte & 0x7f); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 150 | |
| 151 | /* Check bit 32 read-ready */ |
| 152 | retry = 0; |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 153 | value32 = rtl8723au_read32(Adapter, EFUSE_CTRL); |
Andreas Schlick | 2892d39 | 2014-08-07 19:20:50 +0200 | [diff] [blame] | 154 | while (!((value32 >> 24) & 0x80) && retry < 10000) { |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 155 | value32 = rtl8723au_read32(Adapter, EFUSE_CTRL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 156 | retry++; |
| 157 | } |
| 158 | |
| 159 | /* 20100205 Joseph: Add delay suggested by SD1 Victor. */ |
| 160 | /* This fix the problem that Efuse read error in high temperature condition. */ |
| 161 | /* Designer says that there shall be some delay after ready bit is set, or the */ |
| 162 | /* result will always stay on last data we read. */ |
| 163 | udelay(50); |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 164 | value32 = rtl8723au_read32(Adapter, EFUSE_CTRL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 165 | |
| 166 | *pbuf = (u8)(value32 & 0xff); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 167 | } |
| 168 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 169 | void |
| 170 | EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 171 | u8 type, void *pOut) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 172 | { |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 173 | u8 *pu1Tmp; |
| 174 | u16 *pu2Tmp; |
| 175 | u8 *pMax_section; |
| 176 | |
| 177 | switch (type) { |
| 178 | case TYPE_EFUSE_MAX_SECTION: |
Tapasweni Pathak | ad6128a | 2014-10-30 17:03:55 +0530 | [diff] [blame] | 179 | pMax_section = pOut; |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 180 | |
| 181 | if (efuseType == EFUSE_WIFI) |
| 182 | *pMax_section = EFUSE_MAX_SECTION_8723A; |
| 183 | else |
| 184 | *pMax_section = EFUSE_BT_MAX_SECTION; |
| 185 | break; |
| 186 | |
| 187 | case TYPE_EFUSE_REAL_CONTENT_LEN: |
Tapasweni Pathak | ad6128a | 2014-10-30 17:03:55 +0530 | [diff] [blame] | 188 | pu2Tmp = pOut; |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 189 | |
| 190 | if (efuseType == EFUSE_WIFI) |
| 191 | *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A; |
| 192 | else |
| 193 | *pu2Tmp = EFUSE_BT_REAL_CONTENT_LEN; |
| 194 | break; |
| 195 | |
| 196 | case TYPE_AVAILABLE_EFUSE_BYTES_BANK: |
Tapasweni Pathak | ad6128a | 2014-10-30 17:03:55 +0530 | [diff] [blame] | 197 | pu2Tmp = pOut; |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 198 | |
| 199 | if (efuseType == EFUSE_WIFI) |
| 200 | *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A - |
| 201 | EFUSE_OOB_PROTECT_BYTES); |
| 202 | else |
| 203 | *pu2Tmp = (EFUSE_BT_REAL_BANK_CONTENT_LEN - |
| 204 | EFUSE_PROTECT_BYTES_BANK); |
| 205 | break; |
| 206 | |
| 207 | case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: |
Tapasweni Pathak | ad6128a | 2014-10-30 17:03:55 +0530 | [diff] [blame] | 208 | pu2Tmp = pOut; |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 209 | |
| 210 | if (efuseType == EFUSE_WIFI) |
| 211 | *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A - |
| 212 | EFUSE_OOB_PROTECT_BYTES); |
| 213 | else |
| 214 | *pu2Tmp = (EFUSE_BT_REAL_CONTENT_LEN - |
| 215 | (EFUSE_PROTECT_BYTES_BANK * 3)); |
| 216 | break; |
| 217 | |
| 218 | case TYPE_EFUSE_MAP_LEN: |
Tapasweni Pathak | ad6128a | 2014-10-30 17:03:55 +0530 | [diff] [blame] | 219 | pu2Tmp = pOut; |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 220 | |
| 221 | if (efuseType == EFUSE_WIFI) |
| 222 | *pu2Tmp = EFUSE_MAP_LEN_8723A; |
| 223 | else |
| 224 | *pu2Tmp = EFUSE_BT_MAP_LEN; |
| 225 | break; |
| 226 | |
| 227 | case TYPE_EFUSE_PROTECT_BYTES_BANK: |
Tapasweni Pathak | ad6128a | 2014-10-30 17:03:55 +0530 | [diff] [blame] | 228 | pu1Tmp = pOut; |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 229 | |
| 230 | if (efuseType == EFUSE_WIFI) |
| 231 | *pu1Tmp = EFUSE_OOB_PROTECT_BYTES; |
| 232 | else |
| 233 | *pu1Tmp = EFUSE_PROTECT_BYTES_BANK; |
| 234 | break; |
| 235 | |
| 236 | case TYPE_EFUSE_CONTENT_LEN_BANK: |
Tapasweni Pathak | ad6128a | 2014-10-30 17:03:55 +0530 | [diff] [blame] | 237 | pu2Tmp = pOut; |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 238 | |
| 239 | if (efuseType == EFUSE_WIFI) |
| 240 | *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A; |
| 241 | else |
| 242 | *pu2Tmp = EFUSE_BT_REAL_BANK_CONTENT_LEN; |
| 243 | break; |
| 244 | |
| 245 | default: |
Tapasweni Pathak | ad6128a | 2014-10-30 17:03:55 +0530 | [diff] [blame] | 246 | pu1Tmp = pOut; |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 247 | *pu1Tmp = 0; |
| 248 | break; |
| 249 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /*----------------------------------------------------------------------------- |
| 253 | * Function: EFUSE_Read1Byte23a |
| 254 | * |
| 255 | * Overview: Copy from WMAC fot EFUSE read 1 byte. |
| 256 | * |
| 257 | * Input: NONE |
| 258 | * |
| 259 | * Output: NONE |
| 260 | * |
| 261 | * Return: NONE |
| 262 | * |
| 263 | * Revised History: |
| 264 | * When Who Remark |
| 265 | * 09/23/2008 MHC Copy from WMAC. |
| 266 | * |
| 267 | *---------------------------------------------------------------------------*/ |
| 268 | u8 |
| 269 | EFUSE_Read1Byte23a(struct rtw_adapter *Adapter, u16 Address) |
| 270 | { |
| 271 | u8 data; |
| 272 | u8 Bytetemp = {0x00}; |
| 273 | u8 temp = {0x00}; |
| 274 | u32 k = 0; |
| 275 | u16 contentLen = 0; |
| 276 | |
| 277 | EFUSE_GetEfuseDefinition23a(Adapter, EFUSE_WIFI, |
| 278 | TYPE_EFUSE_REAL_CONTENT_LEN, |
| 279 | (void *)&contentLen); |
| 280 | |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 281 | if (Address < contentLen) { /* E-fuse 512Byte */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 282 | /* Write E-fuse Register address bit0~7 */ |
| 283 | temp = Address & 0xFF; |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 284 | rtl8723au_write8(Adapter, EFUSE_CTRL+1, temp); |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 285 | Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 286 | /* Write E-fuse Register address bit8~9 */ |
| 287 | temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 288 | rtl8723au_write8(Adapter, EFUSE_CTRL+2, temp); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 289 | |
| 290 | /* Write 0x30[31]= 0 */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 291 | Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 292 | temp = Bytetemp & 0x7F; |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 293 | rtl8723au_write8(Adapter, EFUSE_CTRL+3, temp); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 294 | |
| 295 | /* Wait Write-ready (0x30[31]= 1) */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 296 | Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 297 | while (!(Bytetemp & 0x80)) { |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 298 | Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 299 | k++; |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 300 | if (k == 1000) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 301 | k = 0; |
| 302 | break; |
| 303 | } |
| 304 | } |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 305 | data = rtl8723au_read8(Adapter, EFUSE_CTRL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 306 | return data; |
| 307 | } |
| 308 | else |
| 309 | return 0xFF; |
| 310 | }/* EFUSE_Read1Byte23a */ |
| 311 | |
| 312 | /*----------------------------------------------------------------------------- |
| 313 | * Function: EFUSE_Write1Byte |
| 314 | * |
| 315 | * Overview: Copy from WMAC fot EFUSE write 1 byte. |
| 316 | * |
| 317 | * Input: NONE |
| 318 | * |
| 319 | * Output: NONE |
| 320 | * |
| 321 | * Return: NONE |
| 322 | * |
| 323 | * Revised History: |
| 324 | * When Who Remark |
| 325 | * 09/23/2008 MHC Copy from WMAC. |
| 326 | * |
| 327 | *---------------------------------------------------------------------------*/ |
| 328 | |
| 329 | void |
| 330 | EFUSE_Write1Byte( |
| 331 | struct rtw_adapter * Adapter, |
| 332 | u16 Address, |
| 333 | u8 Value); |
| 334 | void |
| 335 | EFUSE_Write1Byte( |
| 336 | struct rtw_adapter * Adapter, |
| 337 | u16 Address, |
| 338 | u8 Value) |
| 339 | { |
| 340 | u8 Bytetemp = {0x00}; |
| 341 | u8 temp = {0x00}; |
| 342 | u32 k = 0; |
| 343 | u16 contentLen = 0; |
| 344 | |
| 345 | /* RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr =%x Data =%x\n", Address, Value)); */ |
| 346 | EFUSE_GetEfuseDefinition23a(Adapter, EFUSE_WIFI, |
| 347 | TYPE_EFUSE_REAL_CONTENT_LEN, |
| 348 | (void *)&contentLen); |
| 349 | |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 350 | if (Address < contentLen) { /* E-fuse 512Byte */ |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 351 | rtl8723au_write8(Adapter, EFUSE_CTRL, Value); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 352 | |
| 353 | /* Write E-fuse Register address bit0~7 */ |
| 354 | temp = Address & 0xFF; |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 355 | rtl8723au_write8(Adapter, EFUSE_CTRL+1, temp); |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 356 | Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 357 | |
| 358 | /* Write E-fuse Register address bit8~9 */ |
| 359 | temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 360 | rtl8723au_write8(Adapter, EFUSE_CTRL+2, temp); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 361 | |
| 362 | /* Write 0x30[31]= 1 */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 363 | Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 364 | temp = Bytetemp | 0x80; |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 365 | rtl8723au_write8(Adapter, EFUSE_CTRL+3, temp); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 366 | |
| 367 | /* Wait Write-ready (0x30[31]= 0) */ |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 368 | Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 369 | while (Bytetemp & 0x80) { |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 370 | Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 371 | k++; |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 372 | if (k == 100) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 373 | k = 0; |
| 374 | break; |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | }/* EFUSE_Write1Byte */ |
| 379 | |
| 380 | /* 11/16/2008 MH Read one byte from real Efuse. */ |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 381 | int |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 382 | efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data) |
| 383 | { |
| 384 | u8 tmpidx = 0; |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 385 | int bResult; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 386 | |
| 387 | /* -----------------e-fuse reg ctrl --------------------------------- */ |
| 388 | /* address */ |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 389 | rtl8723au_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); |
| 390 | rtl8723au_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03)) | |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 391 | (rtl8723au_read8(pAdapter, EFUSE_CTRL+2)&0xFC)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 392 | |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 393 | rtl8723au_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 394 | |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 395 | while(!(0x80 &rtl8723au_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 396 | tmpidx++; |
| 397 | if (tmpidx < 100) { |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 398 | *data = rtl8723au_read8(pAdapter, EFUSE_CTRL); |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 399 | bResult = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 400 | } else { |
| 401 | *data = 0xff; |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 402 | bResult = _FAIL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 403 | } |
| 404 | return bResult; |
| 405 | } |
| 406 | |
| 407 | /* 11/16/2008 MH Write one byte to reald Efuse. */ |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 408 | int |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 409 | efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data) |
| 410 | { |
| 411 | u8 tmpidx = 0; |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 412 | int bResult; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 413 | |
| 414 | /* RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr = %x Data =%x\n", addr, data)); */ |
| 415 | |
| 416 | /* return 0; */ |
| 417 | |
| 418 | /* -----------------e-fuse reg ctrl --------------------------------- */ |
| 419 | /* address */ |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 420 | rtl8723au_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); |
| 421 | rtl8723au_write8(pAdapter, EFUSE_CTRL+2, |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 422 | (rtl8723au_read8(pAdapter, EFUSE_CTRL+2)&0xFC)|(u8)((addr>>8)&0x03)); |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 423 | rtl8723au_write8(pAdapter, EFUSE_CTRL, data);/* data */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 424 | |
Jes Sorensen | edbfd67 | 2014-05-16 10:05:09 +0200 | [diff] [blame] | 425 | rtl8723au_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 426 | |
Jes Sorensen | 050abc4 | 2014-05-16 10:05:08 +0200 | [diff] [blame] | 427 | while((0x80 & rtl8723au_read8(pAdapter, EFUSE_CTRL+3)) && |
| 428 | (tmpidx<100)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 429 | tmpidx++; |
| 430 | } |
| 431 | |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 432 | if (tmpidx < 100) |
| 433 | bResult = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 434 | else |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 435 | bResult = _FAIL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 436 | |
| 437 | return bResult; |
| 438 | } |
| 439 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 440 | /*----------------------------------------------------------------------------- |
| 441 | * Function: efuse_WordEnableDataRead23a |
| 442 | * |
| 443 | * Overview: Read allowed word in current efuse section data. |
| 444 | * |
| 445 | * Input: NONE |
| 446 | * |
| 447 | * Output: NONE |
| 448 | * |
| 449 | * Return: NONE |
| 450 | * |
| 451 | * Revised History: |
| 452 | * When Who Remark |
| 453 | * 11/16/2008 MHC Create Version 0. |
| 454 | * 11/21/2008 MHC Fix Write bug when we only enable late word. |
| 455 | * |
| 456 | *---------------------------------------------------------------------------*/ |
| 457 | void |
| 458 | efuse_WordEnableDataRead23a(u8 word_en, |
| 459 | u8 *sourdata, |
| 460 | u8 *targetdata) |
| 461 | { |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 462 | if (!(word_en&BIT(0))) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 463 | targetdata[0] = sourdata[0]; |
| 464 | targetdata[1] = sourdata[1]; |
| 465 | } |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 466 | if (!(word_en&BIT(1))) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 467 | targetdata[2] = sourdata[2]; |
| 468 | targetdata[3] = sourdata[3]; |
| 469 | } |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 470 | if (!(word_en&BIT(2))) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 471 | targetdata[4] = sourdata[4]; |
| 472 | targetdata[5] = sourdata[5]; |
| 473 | } |
Andreas Schlick | c5081c5 | 2014-08-07 19:20:49 +0200 | [diff] [blame] | 474 | if (!(word_en&BIT(3))) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 475 | targetdata[6] = sourdata[6]; |
| 476 | targetdata[7] = sourdata[7]; |
| 477 | } |
| 478 | } |
| 479 | |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 480 | static int efuse_read8(struct rtw_adapter *padapter, u16 address, u8 *value) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 481 | { |
| 482 | return efuse_OneByteRead23a(padapter, address, value); |
| 483 | } |
| 484 | |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 485 | static int efuse_write8(struct rtw_adapter *padapter, u16 address, u8 *value) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 486 | { |
| 487 | return efuse_OneByteWrite23a(padapter, address, *value); |
| 488 | } |
| 489 | |
| 490 | /* |
Masanari Iida | 808bcb4 | 2014-07-22 23:42:53 +0900 | [diff] [blame] | 491 | * read/write raw efuse data |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 492 | */ |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 493 | int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr, |
| 494 | u16 cnts, u8 *data) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 495 | { |
| 496 | int i = 0; |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 497 | u16 real_content_len = 0, max_available_size = 0; |
| 498 | int res = _FAIL ; |
| 499 | int (*rw8)(struct rtw_adapter *, u16, u8*); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 500 | |
| 501 | EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, |
| 502 | TYPE_EFUSE_REAL_CONTENT_LEN, |
| 503 | (void *)&real_content_len); |
| 504 | EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, |
| 505 | TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, |
| 506 | (void *)&max_available_size); |
| 507 | |
| 508 | if (start_addr > real_content_len) |
| 509 | return _FAIL; |
| 510 | |
| 511 | if (true == bWrite) { |
| 512 | if ((start_addr + cnts) > max_available_size) |
| 513 | return _FAIL; |
| 514 | rw8 = &efuse_write8; |
| 515 | } else |
| 516 | rw8 = &efuse_read8; |
| 517 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 518 | Efuse_PowerSwitch(padapter, bWrite, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 519 | |
| 520 | /* e-fuse one byte read / write */ |
| 521 | for (i = 0; i < cnts; i++) { |
| 522 | if (start_addr >= real_content_len) { |
| 523 | res = _FAIL; |
| 524 | break; |
| 525 | } |
| 526 | |
| 527 | res = rw8(padapter, start_addr++, data++); |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 528 | if (res == _FAIL) |
| 529 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 530 | } |
| 531 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 532 | Efuse_PowerSwitch(padapter, bWrite, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 533 | |
| 534 | return res; |
| 535 | } |
| 536 | /* */ |
| 537 | u16 efuse_GetMaxSize23a(struct rtw_adapter *padapter) |
| 538 | { |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 539 | u16 max_size; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 540 | EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, |
| 541 | TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, |
| 542 | (void *)&max_size); |
| 543 | return max_size; |
| 544 | } |
| 545 | /* */ |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 546 | int rtw_efuse_map_read23a(struct rtw_adapter *padapter, |
| 547 | u16 addr, u16 cnts, u8 *data) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 548 | { |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 549 | u16 mapLen = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 550 | |
| 551 | EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, |
| 552 | TYPE_EFUSE_MAP_LEN, (void *)&mapLen); |
| 553 | |
| 554 | if ((addr + cnts) > mapLen) |
| 555 | return _FAIL; |
| 556 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 557 | Efuse_PowerSwitch(padapter, false, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 558 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 559 | rtl8723a_readefuse(padapter, EFUSE_WIFI, addr, cnts, data); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 560 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 561 | Efuse_PowerSwitch(padapter, false, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 562 | |
| 563 | return _SUCCESS; |
| 564 | } |
| 565 | |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 566 | int rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, |
| 567 | u16 addr, u16 cnts, u8 *data) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 568 | { |
Jes Sorensen | 44f3f16 | 2014-05-16 10:04:29 +0200 | [diff] [blame] | 569 | u16 mapLen = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 570 | |
| 571 | EFUSE_GetEfuseDefinition23a(padapter, EFUSE_BT, |
| 572 | TYPE_EFUSE_MAP_LEN, (void *)&mapLen); |
| 573 | |
| 574 | if ((addr + cnts) > mapLen) |
| 575 | return _FAIL; |
| 576 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 577 | Efuse_PowerSwitch(padapter, false, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 578 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 579 | rtl8723a_readefuse(padapter, EFUSE_BT, addr, cnts, data); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 580 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 581 | Efuse_PowerSwitch(padapter, false, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 582 | |
| 583 | return _SUCCESS; |
| 584 | } |
| 585 | |
| 586 | /*----------------------------------------------------------------------------- |
| 587 | * Function: Efuse_ReadAllMap |
| 588 | * |
| 589 | * Overview: Read All Efuse content |
| 590 | * |
| 591 | * Input: NONE |
| 592 | * |
| 593 | * Output: NONE |
| 594 | * |
| 595 | * Return: NONE |
| 596 | * |
| 597 | * Revised History: |
| 598 | * When Who Remark |
| 599 | * 11/11/2008 MHC Create Version 0. |
| 600 | * |
| 601 | *---------------------------------------------------------------------------*/ |
| 602 | void |
| 603 | Efuse_ReadAllMap(struct rtw_adapter *pAdapter, u8 efuseType, u8 *Efuse); |
| 604 | void |
| 605 | Efuse_ReadAllMap(struct rtw_adapter *pAdapter, u8 efuseType, u8 *Efuse) |
| 606 | { |
| 607 | u16 mapLen = 0; |
| 608 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 609 | Efuse_PowerSwitch(pAdapter, false, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 610 | |
| 611 | EFUSE_GetEfuseDefinition23a(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, |
| 612 | (void *)&mapLen); |
| 613 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 614 | rtl8723a_readefuse(pAdapter, efuseType, 0, mapLen, Efuse); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 615 | |
Jes Sorensen | b2e6804 | 2014-05-16 10:04:14 +0200 | [diff] [blame] | 616 | Efuse_PowerSwitch(pAdapter, false, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | /*----------------------------------------------------------------------------- |
| 620 | * Function: efuse_ShadowRead1Byte |
| 621 | * efuse_ShadowRead2Byte |
| 622 | * efuse_ShadowRead4Byte |
| 623 | * |
| 624 | * Overview: Read from efuse init map by one/two/four bytes !!!!! |
| 625 | * |
| 626 | * Input: NONE |
| 627 | * |
| 628 | * Output: NONE |
| 629 | * |
| 630 | * Return: NONE |
| 631 | * |
| 632 | * Revised History: |
| 633 | * When Who Remark |
| 634 | * 11/12/2008 MHC Create Version 0. |
| 635 | * |
| 636 | *---------------------------------------------------------------------------*/ |
| 637 | static void |
| 638 | efuse_ShadowRead1Byte( |
| 639 | struct rtw_adapter * pAdapter, |
| 640 | u16 Offset, |
| 641 | u8 *Value) |
| 642 | { |
| 643 | struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); |
| 644 | |
| 645 | *Value = pEEPROM->efuse_eeprom_data[Offset]; |
| 646 | } /* EFUSE_ShadowRead23a1Byte */ |
| 647 | |
| 648 | /* Read Two Bytes */ |
| 649 | static void |
| 650 | efuse_ShadowRead2Byte( |
| 651 | struct rtw_adapter * pAdapter, |
| 652 | u16 Offset, |
| 653 | u16 *Value) |
| 654 | { |
| 655 | struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); |
| 656 | |
| 657 | *Value = pEEPROM->efuse_eeprom_data[Offset]; |
| 658 | *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8; |
| 659 | } /* EFUSE_ShadowRead23a2Byte */ |
| 660 | |
| 661 | /* Read Four Bytes */ |
| 662 | static void |
| 663 | efuse_ShadowRead4Byte( |
| 664 | struct rtw_adapter * pAdapter, |
| 665 | u16 Offset, |
| 666 | u32 *Value) |
| 667 | { |
| 668 | struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); |
| 669 | |
| 670 | *Value = pEEPROM->efuse_eeprom_data[Offset]; |
| 671 | *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8; |
| 672 | *Value |= pEEPROM->efuse_eeprom_data[Offset+2]<<16; |
| 673 | *Value |= pEEPROM->efuse_eeprom_data[Offset+3]<<24; |
| 674 | } /* efuse_ShadowRead4Byte */ |
| 675 | |
| 676 | /*----------------------------------------------------------------------------- |
| 677 | * Function: EFUSE_ShadowMapUpdate23a |
| 678 | * |
| 679 | * Overview: Transfer current EFUSE content to shadow init and modify map. |
| 680 | * |
| 681 | * Input: NONE |
| 682 | * |
| 683 | * Output: NONE |
| 684 | * |
| 685 | * Return: NONE |
| 686 | * |
| 687 | * Revised History: |
| 688 | * When Who Remark |
| 689 | * 11/13/2008 MHC Create Version 0. |
| 690 | * |
| 691 | *---------------------------------------------------------------------------*/ |
| 692 | void EFUSE_ShadowMapUpdate23a(struct rtw_adapter *pAdapter, u8 efuseType) |
| 693 | { |
| 694 | struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); |
| 695 | u16 mapLen = 0; |
| 696 | |
| 697 | EFUSE_GetEfuseDefinition23a(pAdapter, efuseType, |
| 698 | TYPE_EFUSE_MAP_LEN, (void *)&mapLen); |
| 699 | |
| 700 | if (pEEPROM->bautoload_fail_flag == true) |
| 701 | memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen); |
| 702 | else |
| 703 | Efuse_ReadAllMap(pAdapter, efuseType, |
| 704 | pEEPROM->efuse_eeprom_data); |
| 705 | |
| 706 | }/* EFUSE_ShadowMapUpdate23a */ |
| 707 | |
| 708 | /*----------------------------------------------------------------------------- |
| 709 | * Function: EFUSE_ShadowRead23a |
| 710 | * |
| 711 | * Overview: Read from efuse init map !!!!! |
| 712 | * |
| 713 | * Input: NONE |
| 714 | * |
| 715 | * Output: NONE |
| 716 | * |
| 717 | * Return: NONE |
| 718 | * |
| 719 | * Revised History: |
| 720 | * When Who Remark |
| 721 | * 11/12/2008 MHC Create Version 0. |
| 722 | * |
| 723 | *---------------------------------------------------------------------------*/ |
| 724 | void |
| 725 | EFUSE_ShadowRead23a( |
| 726 | struct rtw_adapter * pAdapter, |
| 727 | u8 Type, |
| 728 | u16 Offset, |
Greg Donald | 1beda8d | 2014-08-22 12:58:13 -0500 | [diff] [blame] | 729 | u32 *Value) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 730 | { |
| 731 | if (Type == 1) |
| 732 | efuse_ShadowRead1Byte(pAdapter, Offset, (u8 *)Value); |
| 733 | else if (Type == 2) |
| 734 | efuse_ShadowRead2Byte(pAdapter, Offset, (u16 *)Value); |
| 735 | else if (Type == 4) |
| 736 | efuse_ShadowRead4Byte(pAdapter, Offset, (u32 *)Value); |
| 737 | } /* EFUSE_ShadowRead23a */ |