1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
23 #include <osdep_service.h>
24 #include <drv_types.h>
26 #include <rtw_efuse.h>
28 /*------------------------Define local variable------------------------------*/
30 u32 fakeEfuseUsedBytes=0;
31 u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE]={0};
32 u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN]={0};
33 u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN]={0};
35 u32 BTEfuseUsedBytes=0;
36 u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
37 u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0};
38 u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0};
40 u32 fakeBTEfuseUsedBytes=0;
41 u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
42 u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0};
43 u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0};
44 /*------------------------Define local variable------------------------------*/
47 #define REG_EFUSE_CTRL 0x0030
48 #define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */
52 Efuse_Read1ByteFromFakeContent(
57 Efuse_Read1ByteFromFakeContent(
62 if(Offset >= EFUSE_MAX_HW_SIZE)
66 /* DbgPrint("Read fake content, offset = %d\n", Offset); */
67 if(fakeEfuseBank == 0)
68 *Value = fakeEfuseContent[Offset];
70 *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset];
75 Efuse_Write1ByteToFakeContent(
80 Efuse_Write1ByteToFakeContent(
85 if(Offset >= EFUSE_MAX_HW_SIZE)
89 if(fakeEfuseBank == 0)
90 fakeEfuseContent[Offset] = Value;
93 fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value;
98 /*-----------------------------------------------------------------------------
99 * Function: Efuse_PowerSwitch
101 * Overview: When we want to enable write operation, we should change to
102 * pwr on state. When we stop write, we should switch to 500k mode
103 * and disable LDO 2.5V.
113 * 11/17/2008 MHC Create Version 0.
115 *---------------------------------------------------------------------------*/
122 pAdapter->HalFunc.EfusePowerSwitch(pAdapter, bWrite, PwrState);
125 /*-----------------------------------------------------------------------------
126 * Function: efuse_GetCurrentSize
128 * Overview: Get current efuse size!!!
138 * 11/16/2008 MHC Create Version 0.
140 *---------------------------------------------------------------------------*/
142 Efuse_GetCurrentSize(
149 ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType, bPseudoTest);
154 /* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */
156 Efuse_CalculateWordCnts(u8 word_en)
159 if(!(word_en & BIT(0))) word_cnts++; /* 0 : write enable */
160 if(!(word_en & BIT(1))) word_cnts++;
161 if(!(word_en & BIT(2))) word_cnts++;
162 if(!(word_en & BIT(3))) word_cnts++;
168 /* Execute E-Fuse read byte operation. */
169 /* Refered from SD1 Richard. */
172 /* 1. Boot from E-Fuse and successfully auto-load. */
173 /* 2. PASSIVE_LEVEL (USB interface) */
175 /* Created by Roger, 2008.10.21. */
187 /* u32 start=rtw_get_current_time(); */
191 Efuse_Read1ByteFromFakeContent(Adapter, _offset, pbuf);
196 rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff));
197 readbyte = rtw_read8(Adapter, EFUSE_CTRL+2);
198 rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc));
201 readbyte = rtw_read8(Adapter, EFUSE_CTRL+3);
202 rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f));
204 /* Check bit 32 read-ready */
206 value32 = rtw_read32(Adapter, EFUSE_CTRL);
207 /* while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10)) */
208 while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10000))
210 value32 = rtw_read32(Adapter, EFUSE_CTRL);
214 /* 20100205 Joseph: Add delay suggested by SD1 Victor. */
215 /* This fix the problem that Efuse read error in high temperature condition. */
216 /* Designer says that there shall be some delay after ready bit is set, or the */
217 /* result will always stay on last data we read. */
219 value32 = rtw_read32(Adapter, EFUSE_CTRL);
221 *pbuf = (u8)(value32 & 0xff);
222 /* DBG_8723A("ReadEFuseByte _offset:%08u, in %d ms\n",_offset ,rtw_get_passing_time_ms(start)); */
227 /* 1. Execute E-Fuse read byte operation according as map offset and */
228 /* save to E-Fuse table. */
229 /* 2. Refered from SD1 Richard. */
232 /* 1. Boot from E-Fuse and successfully auto-load. */
233 /* 2. PASSIVE_LEVEL (USB interface) */
235 /* Created by Roger, 2008.10.21. */
237 /* 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description. */
238 /* 2. Add efuse utilization collect. */
239 /* 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1 */
240 /* write addr must be after sec5. */
262 Adapter->HalFunc.ReadEFuse(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest);
266 EFUSE_GetEfuseDefinition(
274 pAdapter->HalFunc.EFUSEGetEfuseDefinition(pAdapter, efuseType, type, pOut, bPseudoTest);
277 /*-----------------------------------------------------------------------------
278 * Function: EFUSE_Read1Byte
280 * Overview: Copy from WMAC fot EFUSE read 1 byte.
290 * 09/23/2008 MHC Copy from WMAC.
292 *---------------------------------------------------------------------------*/
299 u8 Bytetemp = {0x00};
304 EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, _FALSE);
306 if (Address < contentLen) /* E-fuse 512Byte */
308 /* Write E-fuse Register address bit0~7 */
309 temp = Address & 0xFF;
310 rtw_write8(Adapter, EFUSE_CTRL+1, temp);
311 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2);
312 /* Write E-fuse Register address bit8~9 */
313 temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
314 rtw_write8(Adapter, EFUSE_CTRL+2, temp);
316 /* Write 0x30[31]=0 */
317 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
318 temp = Bytetemp & 0x7F;
319 rtw_write8(Adapter, EFUSE_CTRL+3, temp);
321 /* Wait Write-ready (0x30[31]=1) */
322 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
323 while(!(Bytetemp & 0x80))
325 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
333 data=rtw_read8(Adapter, EFUSE_CTRL);
338 }/* EFUSE_Read1Byte */
340 /*-----------------------------------------------------------------------------
341 * Function: EFUSE_Write1Byte
343 * Overview: Copy from WMAC fot EFUSE write 1 byte.
353 * 09/23/2008 MHC Copy from WMAC.
355 *---------------------------------------------------------------------------*/
368 u8 Bytetemp = {0x00};
373 /* RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr=%x Data =%x\n", Address, Value)); */
374 EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, _FALSE);
376 if( Address < contentLen) /* E-fuse 512Byte */
378 rtw_write8(Adapter, EFUSE_CTRL, Value);
380 /* Write E-fuse Register address bit0~7 */
381 temp = Address & 0xFF;
382 rtw_write8(Adapter, EFUSE_CTRL+1, temp);
383 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2);
385 /* Write E-fuse Register address bit8~9 */
386 temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
387 rtw_write8(Adapter, EFUSE_CTRL+2, temp);
389 /* Write 0x30[31]=1 */
390 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
391 temp = Bytetemp | 0x80;
392 rtw_write8(Adapter, EFUSE_CTRL+3, temp);
394 /* Wait Write-ready (0x30[31]=0) */
395 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
396 while(Bytetemp & 0x80)
398 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
407 }/* EFUSE_Write1Byte */
409 /* 11/16/2008 MH Read one byte from real Efuse. */
422 bResult = Efuse_Read1ByteFromFakeContent(pAdapter, addr, data);
425 /* -----------------e-fuse reg ctrl --------------------------------- */
427 rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff));
428 rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03) ) |
429 (rtw_read8(pAdapter, EFUSE_CTRL+2)&0xFC ));
431 rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */
433 while(!(0x80 &rtw_read8(pAdapter, EFUSE_CTRL+3))&&(tmpidx<100))
439 *data=rtw_read8(pAdapter, EFUSE_CTRL);
450 /* 11/16/2008 MH Write one byte to reald Efuse. */
463 bResult = Efuse_Write1ByteToFakeContent(pAdapter, addr, data);
466 /* RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr = %x Data=%x\n", addr, data)); */
470 /* -----------------e-fuse reg ctrl --------------------------------- */
472 rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff));
473 rtw_write8(pAdapter, EFUSE_CTRL+2,
474 (rtw_read8(pAdapter, EFUSE_CTRL+2)&0xFC )|(u8)((addr>>8)&0x03) );
475 rtw_write8(pAdapter, EFUSE_CTRL, data);/* data */
477 rtw_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */
479 while((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100) ){
496 Efuse_PgPacketRead( PADAPTER pAdapter,
503 ret = pAdapter->HalFunc.Efuse_PgPacketRead(pAdapter, offset, data, bPseudoTest);
509 Efuse_PgPacketWrite(PADAPTER pAdapter,
517 ret = pAdapter->HalFunc.Efuse_PgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest);
523 Efuse_PgPacketWrite_BT(PADAPTER pAdapter,
531 ret = pAdapter->HalFunc.Efuse_PgPacketWrite_BT(pAdapter, offset, word_en, data, bPseudoTest);
536 /*-----------------------------------------------------------------------------
537 * Function: efuse_WordEnableDataRead
539 * Overview: Read allowed word in current efuse section data.
549 * 11/16/2008 MHC Create Version 0.
550 * 11/21/2008 MHC Fix Write bug when we only enable late word.
552 *---------------------------------------------------------------------------*/
554 efuse_WordEnableDataRead(u8 word_en,
558 if (!(word_en&BIT(0)))
560 targetdata[0] = sourdata[0];
561 targetdata[1] = sourdata[1];
563 if (!(word_en&BIT(1)))
565 targetdata[2] = sourdata[2];
566 targetdata[3] = sourdata[3];
568 if (!(word_en&BIT(2)))
570 targetdata[4] = sourdata[4];
571 targetdata[5] = sourdata[5];
573 if (!(word_en&BIT(3)))
575 targetdata[6] = sourdata[6];
576 targetdata[7] = sourdata[7];
581 Efuse_WordEnableDataWrite( PADAPTER pAdapter,
589 ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest);
594 static u8 efuse_read8(PADAPTER padapter, u16 address, u8 *value)
596 return efuse_OneByteRead(padapter,address, value, _FALSE);
599 static u8 efuse_write8(PADAPTER padapter, u16 address, u8 *value)
601 return efuse_OneByteWrite(padapter,address, *value, _FALSE);
605 * read/wirte raw efuse data
607 u8 rtw_efuse_access(PADAPTER padapter, u8 bWrite, u16 start_addr, u16 cnts, u8 *data)
610 u16 real_content_len = 0, max_available_size = 0;
612 u8 (*rw8)(PADAPTER, u16, u8*);
614 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&real_content_len, _FALSE);
615 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, _FALSE);
617 if (start_addr > real_content_len)
620 if (_TRUE == bWrite) {
621 if ((start_addr + cnts) > max_available_size)
627 Efuse_PowerSwitch(padapter, bWrite, _TRUE);
629 /* e-fuse one byte read / write */
630 for (i = 0; i < cnts; i++) {
631 if (start_addr >= real_content_len) {
636 res = rw8(padapter, start_addr++, data++);
637 if (_FAIL == res) break;
640 Efuse_PowerSwitch(padapter, bWrite, _FALSE);
645 u16 efuse_GetMaxSize(PADAPTER padapter)
648 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI , TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_size, _FALSE);
652 u8 efuse_GetCurrentSize(PADAPTER padapter, u16 *size)
654 Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
655 *size = Efuse_GetCurrentSize(padapter, EFUSE_WIFI, _FALSE);
656 Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
661 u8 rtw_efuse_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
665 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, _FALSE);
667 if ((addr + cnts) > mapLen)
670 Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
672 efuse_ReadEFuse(padapter, EFUSE_WIFI, addr, cnts, data, _FALSE);
674 Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
679 u8 rtw_BT_efuse_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
683 EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, _FALSE);
685 if ((addr + cnts) > mapLen)
688 Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
690 efuse_ReadEFuse(padapter, EFUSE_BT, addr, cnts, data, _FALSE);
692 Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
697 u8 rtw_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
701 u8 newdata[PGPKT_DATA_SIZE + 1];
706 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, _FALSE);
708 if ((addr + cnts) > mapLen)
711 map = rtw_zmalloc(mapLen);
716 ret = rtw_efuse_map_read(padapter, 0, mapLen, map);
717 if (ret == _FAIL) goto exit;
719 Efuse_PowerSwitch(padapter, _TRUE, _TRUE);
721 offset = (addr >> 3);
723 memset(newdata, 0xFF, PGPKT_DATA_SIZE);
724 i = addr & 0x7; /* index of one package */
725 j = 0; /* index of new package */
726 idx = 0; /* data index */
730 if (data[idx] != map[addr+idx]) {
731 word_en &= ~BIT(i >> 1);
732 newdata[i-1] = map[addr+idx-1];
733 newdata[i] = data[idx];
739 for (; i < PGPKT_DATA_SIZE; i += 2)
741 if (cnts == idx) break;
742 if ((cnts - idx) == 1) {
743 if (data[idx] != map[addr+idx]) {
744 word_en &= ~BIT(i >> 1);
745 newdata[i] = data[idx];
746 newdata[i+1] = map[addr+idx+1];
751 if ((data[idx] != map[addr+idx]) ||
752 (data[idx+1] != map[addr+idx+1]))
754 word_en &= ~BIT(i >> 1);
755 newdata[i] = data[idx];
756 newdata[i+1] = data[idx + 1];
760 if (idx == cnts) break;
763 if (word_en != 0xF) {
764 ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, _FALSE);
765 DBG_8723A("offset=%x \n",offset);
766 DBG_8723A("word_en=%x \n",word_en);
768 for(i=0;i<PGPKT_DATA_SIZE;i++)
770 DBG_8723A("data=%x \t",newdata[i]);
772 if (ret == _FAIL) break;
775 if (idx == cnts) break;
781 memset(newdata, 0xFF, PGPKT_DATA_SIZE);
784 Efuse_PowerSwitch(padapter, _TRUE, _FALSE);
788 rtw_mfree(map, mapLen);
794 u8 rtw_BT_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
798 u8 newdata[PGPKT_DATA_SIZE + 1];
803 EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, _FALSE);
805 if ((addr + cnts) > mapLen)
808 map = rtw_zmalloc(mapLen);
813 ret = rtw_BT_efuse_map_read(padapter, 0, mapLen, map);
814 if (ret == _FAIL) goto exit;
816 Efuse_PowerSwitch(padapter, _TRUE, _TRUE);
818 offset = (addr >> 3);
820 memset(newdata, 0xFF, PGPKT_DATA_SIZE);
821 i = addr & 0x7; /* index of one package */
822 j = 0; /* index of new package */
823 idx = 0; /* data index */
827 if (data[idx] != map[addr+idx]) {
828 word_en &= ~BIT(i >> 1);
829 newdata[i-1] = map[addr+idx-1];
830 newdata[i] = data[idx];
836 for (; i < PGPKT_DATA_SIZE; i += 2)
838 if (cnts == idx) break;
839 if ((cnts - idx) == 1) {
840 if (data[idx] != map[addr+idx]) {
841 word_en &= ~BIT(i >> 1);
842 newdata[i] = data[idx];
843 newdata[i+1] = map[addr+idx+1];
848 if ((data[idx] != map[addr+idx]) ||
849 (data[idx+1] != map[addr+idx+1]))
851 word_en &= ~BIT(i >> 1);
852 newdata[i] = data[idx];
853 newdata[i+1] = data[idx + 1];
857 if (idx == cnts) break;
862 DBG_8723A("%s: offset=%#X\n", __FUNCTION__, offset);
863 DBG_8723A("%s: word_en=%#X\n", __FUNCTION__, word_en);
864 DBG_8723A("%s: data=", __FUNCTION__);
865 for (i=0; i<PGPKT_DATA_SIZE; i++)
867 DBG_8723A("0x%02X ", newdata[i]);
871 ret = Efuse_PgPacketWrite_BT(padapter, offset, word_en, newdata, _FALSE);
872 if (ret == _FAIL) break;
875 if (idx == cnts) break;
881 memset(newdata, 0xFF, PGPKT_DATA_SIZE);
884 Efuse_PowerSwitch(padapter, _TRUE, _FALSE);
888 rtw_mfree(map, mapLen);
893 /*-----------------------------------------------------------------------------
894 * Function: Efuse_ReadAllMap
896 * Overview: Read All Efuse content
906 * 11/11/2008 MHC Create Version 0.
908 *---------------------------------------------------------------------------*/
924 Efuse_PowerSwitch(pAdapter,_FALSE, _TRUE);
926 EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, bPseudoTest);
928 efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, bPseudoTest);
930 Efuse_PowerSwitch(pAdapter,_FALSE, _FALSE);
933 /*-----------------------------------------------------------------------------
934 * Function: efuse_ShadowRead1Byte
935 * efuse_ShadowRead2Byte
936 * efuse_ShadowRead4Byte
938 * Overview: Read from efuse init map by one/two/four bytes !!!!!
948 * 11/12/2008 MHC Create Version 0.
950 *---------------------------------------------------------------------------*/
952 efuse_ShadowRead1Byte(
957 EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
959 *Value = pEEPROM->efuse_eeprom_data[Offset];
960 } /* EFUSE_ShadowRead1Byte */
964 efuse_ShadowRead2Byte(
969 EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
971 *Value = pEEPROM->efuse_eeprom_data[Offset];
972 *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8;
973 } /* EFUSE_ShadowRead2Byte */
975 /* Read Four Bytes */
977 efuse_ShadowRead4Byte(
982 EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
984 *Value = pEEPROM->efuse_eeprom_data[Offset];
985 *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8;
986 *Value |= pEEPROM->efuse_eeprom_data[Offset+2]<<16;
987 *Value |= pEEPROM->efuse_eeprom_data[Offset+3]<<24;
988 } /* efuse_ShadowRead4Byte */
990 /*-----------------------------------------------------------------------------
991 * Function: efuse_ShadowWrite1Byte
992 * efuse_ShadowWrite2Byte
993 * efuse_ShadowWrite4Byte
995 * Overview: Write efuse modify map by one/two/four byte.
1005 * 11/12/2008 MHC Create Version 0.
1007 *---------------------------------------------------------------------------*/
1010 efuse_ShadowWrite1Byte(
1014 #endif /* PLATFORM */
1016 efuse_ShadowWrite1Byte(
1021 EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
1023 pEEPROM->efuse_eeprom_data[Offset] = Value;
1024 } /* efuse_ShadowWrite1Byte */
1026 /* Write Two Bytes */
1028 efuse_ShadowWrite2Byte(
1033 EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
1035 pEEPROM->efuse_eeprom_data[Offset] = Value&0x00FF;
1036 pEEPROM->efuse_eeprom_data[Offset+1] = Value>>8;
1037 } /* efuse_ShadowWrite1Byte */
1039 /* Write Four Bytes */
1041 efuse_ShadowWrite4Byte(
1046 EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
1048 pEEPROM->efuse_eeprom_data[Offset] = (u8)(Value&0x000000FF);
1049 pEEPROM->efuse_eeprom_data[Offset+1] = (u8)((Value>>8)&0x0000FF);
1050 pEEPROM->efuse_eeprom_data[Offset+2] = (u8)((Value>>16)&0x00FF);
1051 pEEPROM->efuse_eeprom_data[Offset+3] = (u8)((Value>>24)&0xFF);
1052 } /* efuse_ShadowWrite1Byte */
1054 /*-----------------------------------------------------------------------------
1055 * Function: EFUSE_ShadowMapUpdate
1057 * Overview: Transfer current EFUSE content to shadow init and modify map.
1067 * 11/13/2008 MHC Create Version 0.
1069 *---------------------------------------------------------------------------*/
1070 void EFUSE_ShadowMapUpdate(
1075 EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
1078 EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, bPseudoTest);
1080 if (pEEPROM->bautoload_fail_flag == _TRUE)
1082 memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen);
1086 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
1087 if(_SUCCESS != retriveAdaptorInfoFile(pAdapter->registrypriv.adaptor_info_caching_file_path, pEEPROM)) {
1090 Efuse_ReadAllMap(pAdapter, efuseType, pEEPROM->efuse_eeprom_data, bPseudoTest);
1092 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
1093 storeAdaptorInfoFile(pAdapter->registrypriv.adaptor_info_caching_file_path, pEEPROM);
1098 /* PlatformMoveMemory((void *)&pHalData->EfuseMap[EFUSE_MODIFY_MAP][0], */
1099 /* void *)&pHalData->EfuseMap[EFUSE_INIT_MAP][0], mapLen); */
1100 }/* EFUSE_ShadowMapUpdate */
1102 /*-----------------------------------------------------------------------------
1103 * Function: EFUSE_ShadowRead
1105 * Overview: Read from efuse init map !!!!!
1115 * 11/12/2008 MHC Create Version 0.
1117 *---------------------------------------------------------------------------*/
1126 efuse_ShadowRead1Byte(pAdapter, Offset, (u8 *)Value);
1128 efuse_ShadowRead2Byte(pAdapter, Offset, (u16 *)Value);
1130 efuse_ShadowRead4Byte(pAdapter, Offset, (u32 *)Value);
1131 } /* EFUSE_ShadowRead */
1133 /*-----------------------------------------------------------------------------
1134 * Function: EFUSE_ShadowWrite
1136 * Overview: Write efuse modify map for later update operation to use!!!!!
1146 * 11/12/2008 MHC Create Version 0.
1148 *---------------------------------------------------------------------------*/
1163 } /* EFUSE_ShadowWrite */
1176 memset(&fakeEfuseContent[0], 0xff, EFUSE_MAX_HW_SIZE);
1177 memset(&fakeEfuseInitMap[0], 0xff, EFUSE_MAX_MAP_LEN);
1178 memset(&fakeEfuseModifiedMap[0], 0xff, EFUSE_MAX_MAP_LEN);
1180 for(i=0; i<EFUSE_MAX_BT_BANK; i++)
1182 memset(&BTEfuseContent[i][0], EFUSE_MAX_HW_SIZE, 0xff);
1184 memset(&BTEfuseInitMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
1185 memset(&BTEfuseModifiedMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
1187 for(i=0; i<EFUSE_MAX_BT_BANK; i++)
1189 memset(&fakeBTEfuseContent[i][0], 0xff, EFUSE_MAX_HW_SIZE);
1191 memset(&fakeBTEfuseInitMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
1192 memset(&fakeBTEfuseModifiedMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
1195 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
1196 /* include <rtw_eeprom.h> */
1198 int isAdaptorInfoFileValid(void)
1203 int storeAdaptorInfoFile(char *path, struct eeprom_priv * eeprom_priv)
1207 if(path && eeprom_priv) {
1208 ret = rtw_store_to_file(path, eeprom_priv->efuse_eeprom_data, EEPROM_MAX_SIZE_512);
1209 if(ret == EEPROM_MAX_SIZE)
1214 DBG_8723A("%s NULL pointer\n",__FUNCTION__);
1220 int retriveAdaptorInfoFile(char *path, struct eeprom_priv * eeprom_priv)
1226 if(path && eeprom_priv) {
1228 ret = rtw_retrive_from_file(path, eeprom_priv->efuse_eeprom_data, EEPROM_MAX_SIZE);
1230 if(ret == EEPROM_MAX_SIZE)
1236 if(isAdaptorInfoFileValid()) {
1244 DBG_8723A("%s NULL pointer\n",__FUNCTION__);
1249 #endif /* CONFIG_ADAPTOR_INFO_CACHING_FILE */