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 ******************************************************************************/
22 #include <drv_types.h>
25 #include "../hal/efuse/efuse_mask.h"
27 /*------------------------Define local variable------------------------------*/
29 u32 fakeEfuseUsedBytes=0;
30 u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE]={0};
31 u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN]={0};
32 u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN]={0};
34 u32 BTEfuseUsedBytes=0;
35 u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
36 u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0};
37 u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0};
39 u32 fakeBTEfuseUsedBytes=0;
40 u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
41 u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0};
42 u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0};
44 u8 maskfileBuffer[32];
45 /*------------------------Define local variable------------------------------*/
47 //------------------------------------------------------------------------------
48 #define REG_EFUSE_CTRL 0x0030
49 #define EFUSE_CTRL REG_EFUSE_CTRL // E-Fuse Control.
50 //------------------------------------------------------------------------------
53 Efuse_Read1ByteFromFakeContent(
58 Efuse_Read1ByteFromFakeContent(
63 if(Offset >= EFUSE_MAX_HW_SIZE)
67 //DbgPrint("Read fake content, offset = %d\n", Offset);
68 if(fakeEfuseBank == 0)
69 *Value = fakeEfuseContent[Offset];
71 *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset];
76 Efuse_Write1ByteToFakeContent(
81 Efuse_Write1ByteToFakeContent(
86 if(Offset >= EFUSE_MAX_HW_SIZE)
90 if(fakeEfuseBank == 0)
91 fakeEfuseContent[Offset] = Value;
94 fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value;
99 /*-----------------------------------------------------------------------------
100 * Function: Efuse_PowerSwitch
102 * Overview: When we want to enable write operation, we should change to
103 * pwr on state. When we stop write, we should switch to 500k mode
104 * and disable LDO 2.5V.
114 * 11/17/2008 MHC Create Version 0.
116 *---------------------------------------------------------------------------*/
119 IN PADAPTER pAdapter,
123 pAdapter->HalFunc.EfusePowerSwitch(pAdapter, bWrite, PwrState);
128 IN PADAPTER pAdapter,
132 if(pAdapter->HalFunc.BTEfusePowerSwitch)
133 pAdapter->HalFunc.BTEfusePowerSwitch(pAdapter, bWrite, PwrState);
136 /*-----------------------------------------------------------------------------
137 * Function: efuse_GetCurrentSize
139 * Overview: Get current efuse size!!!
149 * 11/16/2008 MHC Create Version 0.
151 *---------------------------------------------------------------------------*/
153 Efuse_GetCurrentSize(
154 IN PADAPTER pAdapter,
156 IN BOOLEAN bPseudoTest)
160 ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType, bPseudoTest);
165 /* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */
167 Efuse_CalculateWordCnts(IN u8 word_en)
170 if(!(word_en & BIT(0))) word_cnts++; // 0 : write enable
171 if(!(word_en & BIT(1))) word_cnts++;
172 if(!(word_en & BIT(2))) word_cnts++;
173 if(!(word_en & BIT(3))) word_cnts++;
179 // Execute E-Fuse read byte operation.
180 // Refered from SD1 Richard.
183 // 1. Boot from E-Fuse and successfully auto-load.
184 // 2. PASSIVE_LEVEL (USB interface)
186 // Created by Roger, 2008.10.21.
193 IN BOOLEAN bPseudoTest)
198 //u32 start=rtw_get_current_time();
202 Efuse_Read1ByteFromFakeContent(Adapter, _offset, pbuf);
205 if (IS_HARDWARE_TYPE_8723B(Adapter))
207 // <20130121, Kordan> For SMIC S55 EFUSE specificatoin.
208 //0x34[11]: SW force PGMEN input of efuse to high. (for the bank selected by 0x34[9:8])
209 PHY_SetMacReg(Adapter, EFUSE_TEST, BIT11, 0);
212 rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff));
213 readbyte = rtw_read8(Adapter, EFUSE_CTRL+2);
214 rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc));
217 readbyte = rtw_read8(Adapter, EFUSE_CTRL+3);
218 rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f));
220 //Check bit 32 read-ready
222 value32 = rtw_read32(Adapter, EFUSE_CTRL);
223 //while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10))
224 while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10000))
226 value32 = rtw_read32(Adapter, EFUSE_CTRL);
230 // 20100205 Joseph: Add delay suggested by SD1 Victor.
231 // This fix the problem that Efuse read error in high temperature condition.
232 // Designer says that there shall be some delay after ready bit is set, or the
233 // result will always stay on last data we read.
235 value32 = rtw_read32(Adapter, EFUSE_CTRL);
237 *pbuf = (u8)(value32 & 0xff);
238 //DBG_871X("ReadEFuseByte _offset:%08u, in %d ms\n",_offset ,rtw_get_passing_time_ms(start));
244 // 1. Execute E-Fuse read byte operation according as map offset and
245 // save to E-Fuse table.
246 // 2. Refered from SD1 Richard.
249 // 1. Boot from E-Fuse and successfully auto-load.
250 // 2. PASSIVE_LEVEL (USB interface)
252 // Created by Roger, 2008.10.21.
254 // 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description.
255 // 2. Add efuse utilization collect.
256 // 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1
257 // write addr must be after sec5.
267 IN BOOLEAN bPseudoTest
276 IN BOOLEAN bPseudoTest
279 Adapter->HalFunc.ReadEFuse(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest);
283 EFUSE_GetEfuseDefinition(
284 IN PADAPTER pAdapter,
288 IN BOOLEAN bPseudoTest
291 pAdapter->HalFunc.EFUSEGetEfuseDefinition(pAdapter, efuseType, type, pOut, bPseudoTest);
294 /*-----------------------------------------------------------------------------
295 * Function: EFUSE_Read1Byte
297 * Overview: Copy from WMAC fot EFUSE read 1 byte.
307 * 09/23/2008 MHC Copy from WMAC.
309 *---------------------------------------------------------------------------*/
316 u8 Bytetemp = {0x00};
321 EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (PVOID)&contentLen, _FALSE);
323 if (Address < contentLen) //E-fuse 512Byte
325 //Write E-fuse Register address bit0~7
326 temp = Address & 0xFF;
327 rtw_write8(Adapter, EFUSE_CTRL+1, temp);
328 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2);
329 //Write E-fuse Register address bit8~9
330 temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
331 rtw_write8(Adapter, EFUSE_CTRL+2, temp);
334 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
335 temp = Bytetemp & 0x7F;
336 rtw_write8(Adapter, EFUSE_CTRL+3, temp);
338 //Wait Write-ready (0x30[31]=1)
339 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
340 while(!(Bytetemp & 0x80))
342 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
350 data=rtw_read8(Adapter, EFUSE_CTRL);
356 }/* EFUSE_Read1Byte */
358 /*-----------------------------------------------------------------------------
359 * Function: EFUSE_Write1Byte
361 * Overview: Copy from WMAC fot EFUSE write 1 byte.
371 * 09/23/2008 MHC Copy from WMAC.
373 *---------------------------------------------------------------------------*/
386 u8 Bytetemp = {0x00};
391 //RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr=%x Data =%x\n", Address, Value));
392 EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (PVOID)&contentLen, _FALSE);
394 if( Address < contentLen) //E-fuse 512Byte
396 rtw_write8(Adapter, EFUSE_CTRL, Value);
398 //Write E-fuse Register address bit0~7
399 temp = Address & 0xFF;
400 rtw_write8(Adapter, EFUSE_CTRL+1, temp);
401 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2);
403 //Write E-fuse Register address bit8~9
404 temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
405 rtw_write8(Adapter, EFUSE_CTRL+2, temp);
408 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
409 temp = Bytetemp | 0x80;
410 rtw_write8(Adapter, EFUSE_CTRL+3, temp);
412 //Wait Write-ready (0x30[31]=0)
413 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
414 while(Bytetemp & 0x80)
416 Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
425 }/* EFUSE_Write1Byte */
428 /* 11/16/2008 MH Read one byte from real Efuse. */
431 IN PADAPTER pAdapter,
434 IN BOOLEAN bPseudoTest)
439 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
441 //DBG_871X("===> EFUSE_OneByteRead(), addr = %x\n", addr);
442 //DBG_871X("===> EFUSE_OneByteRead() start, 0x34 = 0x%X\n", rtw_read32(pAdapter, EFUSE_TEST));
446 bResult = Efuse_Read1ByteFromFakeContent(pAdapter, addr, data);
450 if( IS_HARDWARE_TYPE_8723B(pAdapter) ||
451 (IS_HARDWARE_TYPE_8192E(pAdapter) && (!IS_A_CUT(pHalData->VersionID))) ||
452 (IS_VENDOR_8188E_I_CUT_SERIES(pAdapter)) || (IS_CHIP_VENDOR_SMIC(pHalData->VersionID))
455 // <20130121, Kordan> For SMIC EFUSE specificatoin.
456 //0x34[11]: SW force PGMEN input of efuse to high. (for the bank selected by 0x34[9:8])
457 //PHY_SetMacReg(pAdapter, 0x34, BIT11, 0);
458 rtw_write16(pAdapter, 0x34, rtw_read16(pAdapter,0x34)& (~BIT11) );
461 // -----------------e-fuse reg ctrl ---------------------------------
463 rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff));
464 rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03) ) |
465 (rtw_read8(pAdapter, EFUSE_CTRL+2)&0xFC ));
467 //rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);//read cmd
469 readbyte = rtw_read8(pAdapter, EFUSE_CTRL+3);
470 rtw_write8(pAdapter, EFUSE_CTRL+3, (readbyte & 0x7f));
472 while(!(0x80 &rtw_read8(pAdapter, EFUSE_CTRL+3))&&(tmpidx<1000))
479 *data=rtw_read8(pAdapter, EFUSE_CTRL);
486 DBG_871X("%s: [ERROR] addr=0x%x bResult=%d time out 1s !!!\n", __FUNCTION__, addr, bResult);
487 DBG_871X("%s: [ERROR] EFUSE_CTRL =0x%08x !!!\n", __FUNCTION__, rtw_read32(pAdapter, EFUSE_CTRL));
493 /* 11/16/2008 MH Write one byte to reald Efuse. */
496 IN PADAPTER pAdapter,
499 IN BOOLEAN bPseudoTest)
504 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
506 //DBG_871X("===> EFUSE_OneByteWrite(), addr = %x data=%x\n", addr, data);
507 //DBG_871X("===> EFUSE_OneByteWrite() start, 0x34 = 0x%X\n", rtw_read32(pAdapter, EFUSE_TEST));
511 bResult = Efuse_Write1ByteToFakeContent(pAdapter, addr, data);
515 Efuse_PowerSwitch(pAdapter, _TRUE, _TRUE);
517 // -----------------e-fuse reg ctrl ---------------------------------
521 efuseValue = rtw_read32(pAdapter, EFUSE_CTRL);
522 efuseValue |= (BIT21|BIT31);
523 efuseValue &= ~(0x3FFFF);
524 efuseValue |= ((addr<<8 | data) & 0x3FFFF);
526 // <20130227, Kordan> 8192E MP chip A-cut had better not set 0x34[11] until B-Cut.
527 if ( IS_HARDWARE_TYPE_8723B(pAdapter) ||
528 (IS_HARDWARE_TYPE_8192E(pAdapter) && (!IS_A_CUT(pHalData->VersionID))) ||
529 (IS_VENDOR_8188E_I_CUT_SERIES(pAdapter)) || (IS_CHIP_VENDOR_SMIC(pHalData->VersionID))
531 // <20130121, Kordan> For SMIC EFUSE specificatoin.
532 //0x34[11]: SW force PGMEN input of efuse to high. (for the bank selected by 0x34[9:8])
533 //PHY_SetMacReg(pAdapter, 0x34, BIT11, 1);
534 rtw_write16(pAdapter, 0x34, rtw_read16(pAdapter,0x34)| (BIT11) );
535 rtw_write32(pAdapter, EFUSE_CTRL, 0x90600000|((addr<<8 | data)) );
539 rtw_write32(pAdapter, EFUSE_CTRL, efuseValue);
542 while((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100) ){
554 DBG_871X("%s: [ERROR] addr=0x%x ,efuseValue=0x%x ,bResult=%d time out 1s !!! \n",
555 __FUNCTION__, addr, efuseValue, bResult);
556 DBG_871X("%s: [ERROR] EFUSE_CTRL =0x%08x !!!\n", __FUNCTION__, rtw_read32(pAdapter, EFUSE_CTRL));
559 // disable Efuse program enable
560 if ( IS_HARDWARE_TYPE_8723B(pAdapter) ||
561 (IS_HARDWARE_TYPE_8192E(pAdapter) && (!IS_A_CUT(pHalData->VersionID))) ||
562 (IS_VENDOR_8188E_I_CUT_SERIES(pAdapter)) || (IS_CHIP_VENDOR_SMIC(pHalData->VersionID))
564 PHY_SetMacReg(pAdapter, EFUSE_TEST, BIT(11), 0);
567 Efuse_PowerSwitch(pAdapter, _TRUE, _FALSE);
573 Efuse_PgPacketRead( IN PADAPTER pAdapter,
576 IN BOOLEAN bPseudoTest)
580 ret = pAdapter->HalFunc.Efuse_PgPacketRead(pAdapter, offset, data, bPseudoTest);
586 Efuse_PgPacketWrite(IN PADAPTER pAdapter,
590 IN BOOLEAN bPseudoTest)
594 ret = pAdapter->HalFunc.Efuse_PgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest);
601 Efuse_PgPacketWrite_BT(IN PADAPTER pAdapter,
605 IN BOOLEAN bPseudoTest)
609 ret = pAdapter->HalFunc.Efuse_PgPacketWrite_BT(pAdapter, offset, word_en, data, bPseudoTest);
614 /*-----------------------------------------------------------------------------
615 * Function: efuse_WordEnableDataRead
617 * Overview: Read allowed word in current efuse section data.
627 * 11/16/2008 MHC Create Version 0.
628 * 11/21/2008 MHC Fix Write bug when we only enable late word.
630 *---------------------------------------------------------------------------*/
632 efuse_WordEnableDataRead(IN u8 word_en,
636 if (!(word_en&BIT(0)))
638 targetdata[0] = sourdata[0];
639 targetdata[1] = sourdata[1];
641 if (!(word_en&BIT(1)))
643 targetdata[2] = sourdata[2];
644 targetdata[3] = sourdata[3];
646 if (!(word_en&BIT(2)))
648 targetdata[4] = sourdata[4];
649 targetdata[5] = sourdata[5];
651 if (!(word_en&BIT(3)))
653 targetdata[6] = sourdata[6];
654 targetdata[7] = sourdata[7];
660 Efuse_WordEnableDataWrite( IN PADAPTER pAdapter,
664 IN BOOLEAN bPseudoTest)
668 ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest);
673 static u8 efuse_read8(PADAPTER padapter, u16 address, u8 *value)
675 return efuse_OneByteRead(padapter,address, value, _FALSE);
678 static u8 efuse_write8(PADAPTER padapter, u16 address, u8 *value)
680 return efuse_OneByteWrite(padapter,address, *value, _FALSE);
684 * read/wirte raw efuse data
686 u8 rtw_efuse_access(PADAPTER padapter, u8 bWrite, u16 start_addr, u16 cnts, u8 *data)
689 u16 real_content_len = 0, max_available_size = 0;
691 u8 (*rw8)(PADAPTER, u16, u8*);
693 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (PVOID)&real_content_len, _FALSE);
694 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (PVOID)&max_available_size, _FALSE);
696 if (start_addr > real_content_len)
699 if (_TRUE == bWrite) {
700 if ((start_addr + cnts) > max_available_size)
706 Efuse_PowerSwitch(padapter, bWrite, _TRUE);
708 // e-fuse one byte read / write
709 for (i = 0; i < cnts; i++) {
710 if (start_addr >= real_content_len) {
715 res = rw8(padapter, start_addr++, data++);
716 if (_FAIL == res) break;
719 Efuse_PowerSwitch(padapter, bWrite, _FALSE);
723 //------------------------------------------------------------------------------
724 u16 efuse_GetMaxSize(PADAPTER padapter)
729 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI , TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (PVOID)&max_size, _FALSE);
732 //------------------------------------------------------------------------------
733 u8 efuse_GetCurrentSize(PADAPTER padapter, u16 *size)
735 Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
736 *size = Efuse_GetCurrentSize(padapter, EFUSE_WIFI, _FALSE);
737 Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
741 //------------------------------------------------------------------------------
742 u16 efuse_bt_GetMaxSize(PADAPTER padapter)
747 EFUSE_GetEfuseDefinition(padapter, EFUSE_BT , TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (PVOID)&max_size, _FALSE);
751 u8 efuse_bt_GetCurrentSize(PADAPTER padapter, u16 *size)
753 Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
754 *size = Efuse_GetCurrentSize(padapter, EFUSE_BT, _FALSE);
755 Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
760 u8 rtw_efuse_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
764 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
766 if ((addr + cnts) > mapLen)
769 Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
771 efuse_ReadEFuse(padapter, EFUSE_WIFI, addr, cnts, data, _FALSE);
773 Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
778 u8 rtw_BT_efuse_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
782 EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
784 if ((addr + cnts) > mapLen)
787 Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
789 efuse_ReadEFuse(padapter, EFUSE_BT, addr, cnts, data, _FALSE);
791 Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
796 BOOLEAN rtw_file_efuse_IsMasked(
802 int c = (Offset%16) / 2;
805 if(pAdapter->registrypriv.boffefusemask)
808 //DBG_871X(" %s ,Offset=%x r= %d , c=%d , maskfileBuffer[r]= %x \n",__func__,Offset,r,c,maskfileBuffer[r]);
809 if (c < 4) // Upper double word
810 result = (maskfileBuffer[r] & (0x10 << c));
812 result = (maskfileBuffer[r] & (0x01 << (c-4)));
814 return (result > 0) ? 0 : 1;
819 u8 rtw_efuse_file_read(PADAPTER padapter,u8 *filepatch,u8 *buf,u32 len)
824 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
826 ptmpbuf = rtw_zmalloc(2048);
831 _rtw_memset(ptmpbuf,'\0',2048);
833 rtStatus = rtw_retrieve_from_file(filepatch, ptmpbuf, 2048);
838 for(i=0,j=0;j<len;i+=2,j++)
840 if (( ptmpbuf[i] == ' ' ) && (ptmpbuf[i+1] != '\n' && ptmpbuf[i+1] != '\0')) {
843 if( (ptmpbuf[i+1] != '\n' && ptmpbuf[i+1] != '\0'))
845 buf[j] = simple_strtoul(&ptmpbuf[i],&ptmp, 16);
846 DBG_871X(" i=%d,j=%d, %x \n",i,j,buf[j]);
855 DBG_871X(" %s ,filepatch %s , FAIL %d\n", __func__, filepatch, rtStatus);
858 rtw_mfree(ptmpbuf, 2048);
859 DBG_871X(" %s ,filepatch %s , done %d\n", __func__, filepatch, rtStatus);
870 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
873 //if (bEfuseMaskOFF(pAdapter))
874 if(pAdapter->registrypriv.boffefusemask)
877 #if DEV_BUS_TYPE == RT_USB_INTERFACE
878 #if defined(CONFIG_RTL8188E)
879 if (IS_HARDWARE_TYPE_8188E(pAdapter))
880 return (IS_MASKED(8188E,_MUSB,Offset)) ? TRUE : FALSE;
882 #if defined(CONFIG_RTL8812A)
883 if (IS_HARDWARE_TYPE_8812(pAdapter))
884 return (IS_MASKED(8812A,_MUSB,Offset)) ? TRUE : FALSE;
886 #if defined(CONFIG_RTL8821A)
887 //if (IS_HARDWARE_TYPE_8811AU(pAdapter))
888 // return (IS_MASKED(8811A,_MUSB,Offset)) ? TRUE : FALSE;
889 if (IS_HARDWARE_TYPE_8821(pAdapter))
890 return (IS_MASKED(8821A,_MUSB,Offset)) ? TRUE : FALSE;
892 #if defined(CONFIG_RTL8192E)
893 if (IS_HARDWARE_TYPE_8192E(pAdapter))
894 return (IS_MASKED(8192E,_MUSB,Offset)) ? TRUE : FALSE;
896 #if defined(CONFIG_RTL8723B)
897 if (IS_HARDWARE_TYPE_8723B(pAdapter))
898 return (IS_MASKED(8723B,_MUSB,Offset)) ? TRUE : FALSE;
900 #if defined(CONFIG_RTL8703B)
901 if (IS_HARDWARE_TYPE_8703B(pAdapter))
902 return (IS_MASKED(8703B, _MUSB, Offset)) ? TRUE : FALSE;
904 #if defined(CONFIG_RTL8814A)
905 if (IS_HARDWARE_TYPE_8814A(pAdapter))
906 return (IS_MASKED(8814A, _MUSB, Offset)) ? TRUE : FALSE;
908 #if defined(CONFIG_RTL8188F)
909 if (IS_HARDWARE_TYPE_8188F(pAdapter))
910 return (IS_MASKED(8188F, _MUSB, Offset)) ? TRUE : FALSE;
912 #elif DEV_BUS_TYPE == RT_PCI_INTERFACE
913 #if defined(CONFIG_RTL8188E)
914 if (IS_HARDWARE_TYPE_8188E(pAdapter))
915 return (IS_MASKED(8188E,_MPCIE,Offset)) ? TRUE : FALSE;
917 #if defined(CONFIG_RTL8192E)
918 if (IS_HARDWARE_TYPE_8192E(pAdapter))
919 return (IS_MASKED(8192E,_MPCIE,Offset)) ? TRUE : FALSE;
921 #if defined(CONFIG_RTL8812A)
922 if (IS_HARDWARE_TYPE_8812(pAdapter))
923 return (IS_MASKED(8812A,_MPCIE,Offset)) ? TRUE : FALSE;
925 #if defined(CONFIG_RTL8821A)
926 if (IS_HARDWARE_TYPE_8821(pAdapter))
927 return (IS_MASKED(8821A,_MPCIE,Offset)) ? TRUE : FALSE;
929 #if defined(CONFIG_RTL8723B)
930 if (IS_HARDWARE_TYPE_8723B(pAdapter))
931 return (IS_MASKED(8723B,_MPCIE,Offset)) ? TRUE : FALSE;
933 #if defined(CONFIG_RTL8814A)
934 if (IS_HARDWARE_TYPE_8814A(pAdapter))
935 return (IS_MASKED(8814A, _MPCIE, Offset)) ? TRUE : FALSE;
937 //else if (IS_HARDWARE_TYPE_8821B(pAdapter))
938 // return (IS_MASKED(8821B,_MPCIE,Offset)) ? TRUE : FALSE;
940 #elif DEV_BUS_TYPE == RT_SDIO_INTERFACE
941 #ifdef CONFIG_RTL8188E_SDIO
942 if (IS_HARDWARE_TYPE_8188E(pAdapter))
943 return (IS_MASKED(8188E,_MSDIO,Offset)) ? TRUE : FALSE;
945 #ifdef CONFIG_RTL8188F_SDIO
946 if (IS_HARDWARE_TYPE_8188F(pAdapter))
947 return (IS_MASKED(8188F, _MSDIO, Offset)) ? TRUE : FALSE;
954 //------------------------------------------------------------------------------
955 u8 rtw_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
957 #define RT_ASSERT_RET(expr) \
959 printk( "Assertion failed! %s at ......\n", #expr); \
960 printk( " ......%s,%s,line=%d\n",__FILE__,__FUNCTION__,__LINE__); \
966 u8 newdata[PGPKT_DATA_SIZE];
970 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
972 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
974 if ((addr + cnts) > mapLen)
977 RT_ASSERT_RET(PGPKT_DATA_SIZE == 8); // have to be 8 byte alignment
978 RT_ASSERT_RET((mapLen & 0x7) == 0); // have to be PGPKT_DATA_SIZE alignment for memcpy
980 map = rtw_zmalloc(mapLen);
985 _rtw_memset(map, 0xFF, mapLen);
987 ret = rtw_efuse_map_read(padapter, 0, mapLen, map);
988 if (ret == _FAIL) goto exit;
990 if(padapter->registrypriv.boffefusemask==0)
992 for (i =0; i < cnts; i++)
994 if(padapter->registrypriv.bFileMaskEfuse==_TRUE)
996 if (rtw_file_efuse_IsMasked(padapter, addr+i)) /*use file efuse mask. */
997 data[i] = map[addr+i];
1001 if ( efuse_IsMasked(padapter, addr+i ))
1002 data[i] = map[addr+i];
1004 DBG_8192C("%s , data[%d] = %x, map[addr+i]= %x\n", __func__, i, data[i], map[addr+i]);
1007 /*Efuse_PowerSwitch(padapter, _TRUE, _TRUE);*/
1010 offset = (addr >> 3);
1014 j = (addr + idx) & 0x7;
1015 _rtw_memcpy(newdata, &map[offset << 3], PGPKT_DATA_SIZE);
1016 for (i = j; i<PGPKT_DATA_SIZE && idx < cnts; i++, idx++)
1018 if (data[idx] != map[addr + idx])
1020 word_en &= ~BIT(i >> 1);
1021 newdata[i] = data[idx];
1022 #ifdef CONFIG_RTL8723B
1023 if( addr + idx == 0x8)
1025 if (IS_C_CUT(pHalData->VersionID) || IS_B_CUT(pHalData->VersionID))
1027 if(pHalData->adjuseVoltageVal == 6)
1029 newdata[i] = map[addr + idx];
1030 DBG_8192C(" %s ,\n adjuseVoltageVal = %d ,newdata[%d] = %x \n",__func__,pHalData->adjuseVoltageVal,i,newdata[i]);
1038 if (word_en != 0xF) {
1039 ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, _FALSE);
1040 DBG_871X("offset=%x \n",offset);
1041 DBG_871X("word_en=%x \n",word_en);
1043 for(i=0;i<PGPKT_DATA_SIZE;i++)
1045 DBG_871X("data=%x \t",newdata[i]);
1047 if (ret == _FAIL) break;
1053 /*Efuse_PowerSwitch(padapter, _TRUE, _FALSE);*/
1057 rtw_mfree(map, mapLen);
1062 u8 rtw_efuse_mask_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
1065 u16 mapLen = 0, i = 0;
1067 EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
1069 ret = rtw_efuse_map_read(padapter, addr, cnts , data);
1071 if (padapter->registrypriv.boffefusemask == 0) {
1073 for (i = 0; i < cnts; i++) {
1074 if (padapter->registrypriv.bFileMaskEfuse == _TRUE) {
1075 if (rtw_file_efuse_IsMasked(padapter, addr+i)) /*use file efuse mask.*/
1078 /*DBG_8192C(" %s , data[%d] = %x\n", __func__, i, data[i]);*/
1079 if (efuse_IsMasked(padapter, addr+i)) {
1081 /*DBG_8192C(" %s ,mask data[%d] = %x\n", __func__, i, data[i]);*/
1091 u8 rtw_BT_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
1093 #define RT_ASSERT_RET(expr) \
1095 printk( "Assertion failed! %s at ......\n", #expr); \
1096 printk( " ......%s,%s,line=%d\n",__FILE__,__FUNCTION__,__LINE__); \
1102 u8 newdata[PGPKT_DATA_SIZE];
1107 EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
1109 if ((addr + cnts) > mapLen)
1112 RT_ASSERT_RET(PGPKT_DATA_SIZE == 8); // have to be 8 byte alignment
1113 RT_ASSERT_RET((mapLen & 0x7) == 0); // have to be PGPKT_DATA_SIZE alignment for memcpy
1115 map = rtw_zmalloc(mapLen);
1120 ret = rtw_BT_efuse_map_read(padapter, 0, mapLen, map);
1121 if (ret == _FAIL) goto exit;
1122 DBG_871X("OFFSET\tVALUE(hex)\n");
1123 for (i=0; i<1024; i+=16) // set 512 because the iwpriv's extra size have limit 0x7FF
1125 DBG_871X("0x%03x\t", i);
1126 for (j=0; j<8; j++) {
1127 DBG_871X("%02X ", map[i+j]);
1131 DBG_871X("%02X ", map[i+j]);
1136 Efuse_PowerSwitch(padapter, _TRUE, _TRUE);
1139 offset = (addr >> 3);
1143 j = (addr + idx) & 0x7;
1144 _rtw_memcpy(newdata, &map[offset << 3], PGPKT_DATA_SIZE);
1145 for (i = j; i<PGPKT_DATA_SIZE && idx < cnts; i++, idx++)
1147 if (data[idx] != map[addr + idx])
1149 word_en &= ~BIT(i >> 1);
1150 newdata[i] = data[idx];
1154 if (word_en != 0xF) {
1155 DBG_871X("offset=%x \n",offset);
1156 DBG_871X("word_en=%x \n",word_en);
1157 DBG_871X("%s: data=", __FUNCTION__);
1158 for(i=0;i<PGPKT_DATA_SIZE;i++)
1160 DBG_871X("0x%02X ", newdata[i]);
1163 ret = Efuse_PgPacketWrite_BT(padapter, offset, word_en, newdata, _FALSE);
1164 if (ret == _FAIL) break;
1170 Efuse_PowerSwitch(padapter, _TRUE, _FALSE);
1174 rtw_mfree(map, mapLen);
1179 /*-----------------------------------------------------------------------------
1180 * Function: Efuse_ReadAllMap
1182 * Overview: Read All Efuse content
1192 * 11/11/2008 MHC Create Version 0.
1194 *---------------------------------------------------------------------------*/
1197 IN PADAPTER pAdapter,
1200 IN BOOLEAN bPseudoTest);
1203 IN PADAPTER pAdapter,
1206 IN BOOLEAN bPseudoTest)
1210 Efuse_PowerSwitch(pAdapter,_FALSE, _TRUE);
1212 EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, bPseudoTest);
1214 efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, bPseudoTest);
1216 Efuse_PowerSwitch(pAdapter,_FALSE, _FALSE);
1219 /*-----------------------------------------------------------------------------
1220 * Function: efuse_ShadowRead1Byte
1221 * efuse_ShadowRead2Byte
1222 * efuse_ShadowRead4Byte
1224 * Overview: Read from efuse init map by one/two/four bytes !!!!!
1234 * 11/12/2008 MHC Create Version 0.
1236 *---------------------------------------------------------------------------*/
1238 efuse_ShadowRead1Byte(
1239 IN PADAPTER pAdapter,
1243 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1245 *Value = pHalData->efuse_eeprom_data[Offset];
1247 } // EFUSE_ShadowRead1Byte
1249 //---------------Read Two Bytes
1251 efuse_ShadowRead2Byte(
1252 IN PADAPTER pAdapter,
1256 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1258 *Value = pHalData->efuse_eeprom_data[Offset];
1259 *Value |= pHalData->efuse_eeprom_data[Offset+1]<<8;
1261 } // EFUSE_ShadowRead2Byte
1263 //---------------Read Four Bytes
1265 efuse_ShadowRead4Byte(
1266 IN PADAPTER pAdapter,
1270 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1272 *Value = pHalData->efuse_eeprom_data[Offset];
1273 *Value |= pHalData->efuse_eeprom_data[Offset+1]<<8;
1274 *Value |= pHalData->efuse_eeprom_data[Offset+2]<<16;
1275 *Value |= pHalData->efuse_eeprom_data[Offset+3]<<24;
1277 } // efuse_ShadowRead4Byte
1280 /*-----------------------------------------------------------------------------
1281 * Function: efuse_ShadowWrite1Byte
1282 * efuse_ShadowWrite2Byte
1283 * efuse_ShadowWrite4Byte
1285 * Overview: Write efuse modify map by one/two/four byte.
1295 * 11/12/2008 MHC Create Version 0.
1297 *---------------------------------------------------------------------------*/
1300 efuse_ShadowWrite1Byte(
1301 IN PADAPTER pAdapter,
1306 efuse_ShadowWrite1Byte(
1307 IN PADAPTER pAdapter,
1311 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1313 pHalData->efuse_eeprom_data[Offset] = Value;
1315 } // efuse_ShadowWrite1Byte
1317 //---------------Write Two Bytes
1319 efuse_ShadowWrite2Byte(
1320 IN PADAPTER pAdapter,
1325 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1328 pHalData->efuse_eeprom_data[Offset] = Value&0x00FF;
1329 pHalData->efuse_eeprom_data[Offset+1] = Value>>8;
1331 } // efuse_ShadowWrite1Byte
1333 //---------------Write Four Bytes
1335 efuse_ShadowWrite4Byte(
1336 IN PADAPTER pAdapter,
1340 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1342 pHalData->efuse_eeprom_data[Offset] = (u8)(Value&0x000000FF);
1343 pHalData->efuse_eeprom_data[Offset+1] = (u8)((Value>>8)&0x0000FF);
1344 pHalData->efuse_eeprom_data[Offset+2] = (u8)((Value>>16)&0x00FF);
1345 pHalData->efuse_eeprom_data[Offset+3] = (u8)((Value>>24)&0xFF);
1347 } // efuse_ShadowWrite1Byte
1349 /*-----------------------------------------------------------------------------
1350 * Function: EFUSE_ShadowMapUpdate
1352 * Overview: Transfer current EFUSE content to shadow init and modify map.
1362 * 11/13/2008 MHC Create Version 0.
1364 *---------------------------------------------------------------------------*/
1365 void EFUSE_ShadowMapUpdate(
1366 IN PADAPTER pAdapter,
1368 IN BOOLEAN bPseudoTest)
1370 PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pAdapter);
1373 EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, bPseudoTest);
1375 if (pHalData->bautoload_fail_flag == _TRUE)
1377 _rtw_memset(pHalData->efuse_eeprom_data, 0xFF, mapLen);
1381 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
1382 if(_SUCCESS != retriveAdaptorInfoFile(pAdapter->registrypriv.adaptor_info_caching_file_path, pHalData->efuse_eeprom_data)) {
1385 Efuse_ReadAllMap(pAdapter, efuseType, pHalData->efuse_eeprom_data, bPseudoTest);
1387 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
1388 storeAdaptorInfoFile(pAdapter->registrypriv.adaptor_info_caching_file_path, pHalData->efuse_eeprom_data);
1393 //PlatformMoveMemory((PVOID)&pHalData->EfuseMap[EFUSE_MODIFY_MAP][0],
1394 //(PVOID)&pHalData->EfuseMap[EFUSE_INIT_MAP][0], mapLen);
1395 }// EFUSE_ShadowMapUpdate
1398 /*-----------------------------------------------------------------------------
1399 * Function: EFUSE_ShadowRead
1401 * Overview: Read from efuse init map !!!!!
1411 * 11/12/2008 MHC Create Version 0.
1413 *---------------------------------------------------------------------------*/
1416 IN PADAPTER pAdapter,
1422 efuse_ShadowRead1Byte(pAdapter, Offset, (u8 *)Value);
1424 efuse_ShadowRead2Byte(pAdapter, Offset, (u16 *)Value);
1426 efuse_ShadowRead4Byte(pAdapter, Offset, (u32 *)Value);
1428 } // EFUSE_ShadowRead
1430 /*-----------------------------------------------------------------------------
1431 * Function: EFUSE_ShadowWrite
1433 * Overview: Write efuse modify map for later update operation to use!!!!!
1443 * 11/12/2008 MHC Create Version 0.
1445 *---------------------------------------------------------------------------*/
1448 IN PADAPTER pAdapter,
1454 IN PADAPTER pAdapter,
1459 #if (MP_DRIVER == 0)
1462 if ( pAdapter->registrypriv.mp_mode == 0)
1467 efuse_ShadowWrite1Byte(pAdapter, Offset, (u8)Value);
1469 efuse_ShadowWrite2Byte(pAdapter, Offset, (u16)Value);
1471 efuse_ShadowWrite4Byte(pAdapter, Offset, (u32)Value);
1473 } // EFUSE_ShadowWrite
1477 IN PADAPTER pAdapter
1481 IN PADAPTER pAdapter
1486 _rtw_memset((PVOID)&fakeEfuseContent[0], 0xff, EFUSE_MAX_HW_SIZE);
1487 _rtw_memset((PVOID)&fakeEfuseInitMap[0], 0xff, EFUSE_MAX_MAP_LEN);
1488 _rtw_memset((PVOID)&fakeEfuseModifiedMap[0], 0xff, EFUSE_MAX_MAP_LEN);
1490 for(i=0; i<EFUSE_MAX_BT_BANK; i++)
1492 _rtw_memset((PVOID)&BTEfuseContent[i][0], EFUSE_MAX_HW_SIZE, 0xff);
1494 _rtw_memset((PVOID)&BTEfuseInitMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
1495 _rtw_memset((PVOID)&BTEfuseModifiedMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
1497 for(i=0; i<EFUSE_MAX_BT_BANK; i++)
1499 _rtw_memset((PVOID)&fakeBTEfuseContent[i][0], 0xff, EFUSE_MAX_HW_SIZE);
1501 _rtw_memset((PVOID)&fakeBTEfuseInitMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
1502 _rtw_memset((PVOID)&fakeBTEfuseModifiedMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
1505 const u8 _mac_hidden_max_bw_to_hal_bw_cap[MAC_HIDDEN_MAX_BW_NUM] = {
1508 (BW_CAP_160M|BW_CAP_80M|BW_CAP_40M|BW_CAP_20M|BW_CAP_10M|BW_CAP_5M),
1510 (BW_CAP_10M|BW_CAP_5M),
1511 (BW_CAP_20M|BW_CAP_10M|BW_CAP_5M),
1512 (BW_CAP_40M|BW_CAP_20M|BW_CAP_10M|BW_CAP_5M),
1513 (BW_CAP_80M|BW_CAP_40M|BW_CAP_20M|BW_CAP_10M|BW_CAP_5M),
1516 const u8 _mac_hidden_proto_to_hal_proto_cap[MAC_HIDDEN_PROTOCOL_NUM] = {
1519 (PROTO_CAP_11N|PROTO_CAP_11G|PROTO_CAP_11B),
1520 (PROTO_CAP_11AC|PROTO_CAP_11N|PROTO_CAP_11G|PROTO_CAP_11B),
1523 u8 mac_hidden_wl_func_to_hal_wl_func(u8 func)
1528 wl_func |= WL_FUNC_MIRACAST;
1530 wl_func |= WL_FUNC_P2P;
1532 wl_func |= WL_FUNC_TDLS;
1534 wl_func |= WL_FUNC_FTM;
1539 #ifdef PLATFORM_LINUX
1540 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
1541 //#include <rtw_eeprom.h>
1543 int isAdaptorInfoFileValid(void)
1548 int storeAdaptorInfoFile(char *path, u8* efuse_data)
1552 if(path && efuse_data) {
1553 ret = rtw_store_to_file(path, efuse_data, EEPROM_MAX_SIZE_512);
1554 if(ret == EEPROM_MAX_SIZE)
1559 DBG_871X("%s NULL pointer\n",__FUNCTION__);
1565 int retriveAdaptorInfoFile(char *path, u8* efuse_data)
1571 if(path && efuse_data) {
1573 ret = rtw_retrieve_from_file(path, efuse_data, EEPROM_MAX_SIZE);
1575 if(ret == EEPROM_MAX_SIZE)
1581 if(isAdaptorInfoFileValid()) {
1589 DBG_871X("%s NULL pointer\n",__FUNCTION__);
1594 #endif /* CONFIG_ADAPTOR_INFO_CACHING_FILE */
1596 #ifdef CONFIG_EFUSE_CONFIG_FILE
1597 u32 rtw_read_efuse_from_file(const char *path, u8 *buf)
1607 fp = filp_open(path, O_RDONLY, 0);
1608 if (fp == NULL || IS_ERR(fp)) {
1610 DBG_871X_LEVEL(_drv_always_, "%s open %s fail, err:%ld\n"
1611 , __func__, path, PTR_ERR(fp));
1613 DBG_871X_LEVEL(_drv_always_, "%s open %s fail, fp is NULL\n"
1619 temp[2] = 0; /* add end of string '\0' */
1624 for (i = 0 ; i < HWSET_MAX_SIZE ; i++) {
1625 vfs_read(fp, temp, 2, &pos);
1626 if (sscanf(temp, "%hhx", &buf[i]) != 1) {
1628 DBG_871X_LEVEL(_drv_err_, "%s sscanf fail\n", __func__);
1631 if ((i % EFUSE_FILE_COLUMN_NUM) == (EFUSE_FILE_COLUMN_NUM - 1)) {
1632 /* Filter the lates space char. */
1633 vfs_read(fp, temp, 1, &pos);
1634 if (strchr(temp, ' ') == NULL) {
1636 vfs_read(fp, temp, 2, &pos);
1639 pos += 1; /* Filter the space character */
1645 DBG_871X_LEVEL(_drv_always_, "efuse file: %s\n", path);
1647 for (i = 0; i < HWSET_MAX_SIZE; i++) {
1649 DBG_871X_SEL_NL(RTW_DBGDUMP, "0x%03x: ", i);
1651 DBG_871X_SEL(RTW_DBGDUMP, "%02X%s"
1653 , ((i + 1) % 16 == 0) ? "\n" : (((i + 1) % 8 == 0) ? " " : " ")
1656 DBG_871X_SEL(RTW_DBGDUMP, "\n");
1665 u32 rtw_read_macaddr_from_file(const char *path, u8 *buf)
1676 _rtw_memset(source_addr, 0, 18);
1678 fp = filp_open(path, O_RDONLY, 0);
1679 if (fp == NULL || IS_ERR(fp)) {
1681 DBG_871X_LEVEL(_drv_always_, "%s open %s fail, err:%ld\n"
1682 , __func__, path, PTR_ERR(fp));
1684 DBG_871X_LEVEL(_drv_always_, "%s open %s fail, fp is NULL\n"
1693 vfs_read(fp, source_addr, 18, &pos);
1694 source_addr[17] = ':';
1696 head = end = source_addr;
1697 for (i = 0; i < ETH_ALEN; i++) {
1698 while (end && (*end != ':'))
1701 if (end && (*end == ':'))
1704 if (sscanf(head, "%hhx", &buf[i]) != 1) {
1706 DBG_871X_LEVEL(_drv_err_, "%s sscanf fail\n", __func__);
1718 DBG_871X_LEVEL(_drv_always_, "wifi_mac file: %s\n", path);
1720 DBG_871X(MAC_FMT"\n", MAC_ARG(buf));
1728 #endif /* CONFIG_EFUSE_CONFIG_FILE */
1730 #endif /* PLATFORM_LINUX */