rtw_efuse.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325
  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. * 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
  17. *
  18. *
  19. ******************************************************************************/
  20. #define _RTW_EFUSE_C_
  21. #include <drv_types.h>
  22. /*------------------------Define local variable------------------------------*/
  23. u8 fakeEfuseBank=0;
  24. u32 fakeEfuseUsedBytes=0;
  25. u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE]={0};
  26. u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN]={0};
  27. u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN]={0};
  28. u32 BTEfuseUsedBytes=0;
  29. u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
  30. u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0};
  31. u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0};
  32. u32 fakeBTEfuseUsedBytes=0;
  33. u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
  34. u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0};
  35. u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0};
  36. /*------------------------Define local variable------------------------------*/
  37. //------------------------------------------------------------------------------
  38. #define REG_EFUSE_CTRL 0x0030
  39. #define EFUSE_CTRL REG_EFUSE_CTRL // E-Fuse Control.
  40. //------------------------------------------------------------------------------
  41. BOOLEAN
  42. Efuse_Read1ByteFromFakeContent(
  43. IN PADAPTER pAdapter,
  44. IN u16 Offset,
  45. IN OUT u8 *Value );
  46. BOOLEAN
  47. Efuse_Read1ByteFromFakeContent(
  48. IN PADAPTER pAdapter,
  49. IN u16 Offset,
  50. IN OUT u8 *Value )
  51. {
  52. if(Offset >= EFUSE_MAX_HW_SIZE)
  53. {
  54. return _FALSE;
  55. }
  56. //DbgPrint("Read fake content, offset = %d\n", Offset);
  57. if(fakeEfuseBank == 0)
  58. *Value = fakeEfuseContent[Offset];
  59. else
  60. *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset];
  61. return _TRUE;
  62. }
  63. BOOLEAN
  64. Efuse_Write1ByteToFakeContent(
  65. IN PADAPTER pAdapter,
  66. IN u16 Offset,
  67. IN u8 Value );
  68. BOOLEAN
  69. Efuse_Write1ByteToFakeContent(
  70. IN PADAPTER pAdapter,
  71. IN u16 Offset,
  72. IN u8 Value )
  73. {
  74. if(Offset >= EFUSE_MAX_HW_SIZE)
  75. {
  76. return _FALSE;
  77. }
  78. if(fakeEfuseBank == 0)
  79. fakeEfuseContent[Offset] = Value;
  80. else
  81. {
  82. fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value;
  83. }
  84. return _TRUE;
  85. }
  86. /*-----------------------------------------------------------------------------
  87. * Function: Efuse_PowerSwitch
  88. *
  89. * Overview: When we want to enable write operation, we should change to
  90. * pwr on state. When we stop write, we should switch to 500k mode
  91. * and disable LDO 2.5V.
  92. *
  93. * Input: NONE
  94. *
  95. * Output: NONE
  96. *
  97. * Return: NONE
  98. *
  99. * Revised History:
  100. * When Who Remark
  101. * 11/17/2008 MHC Create Version 0.
  102. *
  103. *---------------------------------------------------------------------------*/
  104. VOID
  105. Efuse_PowerSwitch(
  106. IN PADAPTER pAdapter,
  107. IN u8 bWrite,
  108. IN u8 PwrState)
  109. {
  110. pAdapter->HalFunc.EfusePowerSwitch(pAdapter, bWrite, PwrState);
  111. }
  112. /*-----------------------------------------------------------------------------
  113. * Function: efuse_GetCurrentSize
  114. *
  115. * Overview: Get current efuse size!!!
  116. *
  117. * Input: NONE
  118. *
  119. * Output: NONE
  120. *
  121. * Return: NONE
  122. *
  123. * Revised History:
  124. * When Who Remark
  125. * 11/16/2008 MHC Create Version 0.
  126. *
  127. *---------------------------------------------------------------------------*/
  128. u16
  129. Efuse_GetCurrentSize(
  130. IN PADAPTER pAdapter,
  131. IN u8 efuseType,
  132. IN BOOLEAN bPseudoTest)
  133. {
  134. u16 ret=0;
  135. ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType, bPseudoTest);
  136. return ret;
  137. }
  138. /* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */
  139. u8
  140. Efuse_CalculateWordCnts(IN u8 word_en)
  141. {
  142. u8 word_cnts = 0;
  143. if(!(word_en & BIT(0))) word_cnts++; // 0 : write enable
  144. if(!(word_en & BIT(1))) word_cnts++;
  145. if(!(word_en & BIT(2))) word_cnts++;
  146. if(!(word_en & BIT(3))) word_cnts++;
  147. return word_cnts;
  148. }
  149. //
  150. // Description:
  151. // Execute E-Fuse read byte operation.
  152. // Refered from SD1 Richard.
  153. //
  154. // Assumption:
  155. // 1. Boot from E-Fuse and successfully auto-load.
  156. // 2. PASSIVE_LEVEL (USB interface)
  157. //
  158. // Created by Roger, 2008.10.21.
  159. //
  160. VOID
  161. ReadEFuseByte(
  162. PADAPTER Adapter,
  163. u16 _offset,
  164. u8 *pbuf,
  165. IN BOOLEAN bPseudoTest)
  166. {
  167. u32 value32;
  168. u8 readbyte;
  169. u16 retry;
  170. //u32 start=rtw_get_current_time();
  171. if(bPseudoTest)
  172. {
  173. Efuse_Read1ByteFromFakeContent(Adapter, _offset, pbuf);
  174. return;
  175. }
  176. //Write Address
  177. rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff));
  178. readbyte = rtw_read8(Adapter, EFUSE_CTRL+2);
  179. rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc));
  180. //Write bit 32 0
  181. readbyte = rtw_read8(Adapter, EFUSE_CTRL+3);
  182. rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f));
  183. //Check bit 32 read-ready
  184. retry = 0;
  185. value32 = rtw_read32(Adapter, EFUSE_CTRL);
  186. //while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10))
  187. while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10000))
  188. {
  189. value32 = rtw_read32(Adapter, EFUSE_CTRL);
  190. retry++;
  191. }
  192. // 20100205 Joseph: Add delay suggested by SD1 Victor.
  193. // This fix the problem that Efuse read error in high temperature condition.
  194. // Designer says that there shall be some delay after ready bit is set, or the
  195. // result will always stay on last data we read.
  196. rtw_udelay_os(50);
  197. value32 = rtw_read32(Adapter, EFUSE_CTRL);
  198. *pbuf = (u8)(value32 & 0xff);
  199. //DBG_871X("ReadEFuseByte _offset:%08u, in %d ms\n",_offset ,rtw_get_passing_time_ms(start));
  200. }
  201. //
  202. // Description:
  203. // 1. Execute E-Fuse read byte operation according as map offset and
  204. // save to E-Fuse table.
  205. // 2. Refered from SD1 Richard.
  206. //
  207. // Assumption:
  208. // 1. Boot from E-Fuse and successfully auto-load.
  209. // 2. PASSIVE_LEVEL (USB interface)
  210. //
  211. // Created by Roger, 2008.10.21.
  212. //
  213. // 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description.
  214. // 2. Add efuse utilization collect.
  215. // 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1
  216. // write addr must be after sec5.
  217. //
  218. VOID
  219. efuse_ReadEFuse(
  220. PADAPTER Adapter,
  221. u8 efuseType,
  222. u16 _offset,
  223. u16 _size_byte,
  224. u8 *pbuf,
  225. IN BOOLEAN bPseudoTest
  226. );
  227. VOID
  228. efuse_ReadEFuse(
  229. PADAPTER Adapter,
  230. u8 efuseType,
  231. u16 _offset,
  232. u16 _size_byte,
  233. u8 *pbuf,
  234. IN BOOLEAN bPseudoTest
  235. )
  236. {
  237. Adapter->HalFunc.ReadEFuse(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest);
  238. }
  239. VOID
  240. EFUSE_GetEfuseDefinition(
  241. IN PADAPTER pAdapter,
  242. IN u8 efuseType,
  243. IN u8 type,
  244. OUT void *pOut,
  245. IN BOOLEAN bPseudoTest
  246. )
  247. {
  248. pAdapter->HalFunc.EFUSEGetEfuseDefinition(pAdapter, efuseType, type, pOut, bPseudoTest);
  249. }
  250. /*-----------------------------------------------------------------------------
  251. * Function: EFUSE_Read1Byte
  252. *
  253. * Overview: Copy from WMAC fot EFUSE read 1 byte.
  254. *
  255. * Input: NONE
  256. *
  257. * Output: NONE
  258. *
  259. * Return: NONE
  260. *
  261. * Revised History:
  262. * When Who Remark
  263. * 09/23/2008 MHC Copy from WMAC.
  264. *
  265. *---------------------------------------------------------------------------*/
  266. u8
  267. EFUSE_Read1Byte(
  268. IN PADAPTER Adapter,
  269. IN u16 Address)
  270. {
  271. u8 data;
  272. u8 Bytetemp = {0x00};
  273. u8 temp = {0x00};
  274. u32 k=0;
  275. u16 contentLen=0;
  276. EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (PVOID)&contentLen, _FALSE);
  277. if (Address < contentLen) //E-fuse 512Byte
  278. {
  279. //Write E-fuse Register address bit0~7
  280. temp = Address & 0xFF;
  281. rtw_write8(Adapter, EFUSE_CTRL+1, temp);
  282. Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2);
  283. //Write E-fuse Register address bit8~9
  284. temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
  285. rtw_write8(Adapter, EFUSE_CTRL+2, temp);
  286. //Write 0x30[31]=0
  287. Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
  288. temp = Bytetemp & 0x7F;
  289. rtw_write8(Adapter, EFUSE_CTRL+3, temp);
  290. //Wait Write-ready (0x30[31]=1)
  291. Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
  292. while(!(Bytetemp & 0x80))
  293. {
  294. Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
  295. k++;
  296. if(k==1000)
  297. {
  298. k=0;
  299. break;
  300. }
  301. }
  302. data=rtw_read8(Adapter, EFUSE_CTRL);
  303. return data;
  304. }
  305. else
  306. return 0xFF;
  307. }/* EFUSE_Read1Byte */
  308. /*-----------------------------------------------------------------------------
  309. * Function: EFUSE_Write1Byte
  310. *
  311. * Overview: Copy from WMAC fot EFUSE write 1 byte.
  312. *
  313. * Input: NONE
  314. *
  315. * Output: NONE
  316. *
  317. * Return: NONE
  318. *
  319. * Revised History:
  320. * When Who Remark
  321. * 09/23/2008 MHC Copy from WMAC.
  322. *
  323. *---------------------------------------------------------------------------*/
  324. void
  325. EFUSE_Write1Byte(
  326. IN PADAPTER Adapter,
  327. IN u16 Address,
  328. IN u8 Value);
  329. void
  330. EFUSE_Write1Byte(
  331. IN PADAPTER Adapter,
  332. IN u16 Address,
  333. IN u8 Value)
  334. {
  335. u8 Bytetemp = {0x00};
  336. u8 temp = {0x00};
  337. u32 k=0;
  338. u16 contentLen=0;
  339. //RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr=%x Data =%x\n", Address, Value));
  340. EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (PVOID)&contentLen, _FALSE);
  341. if( Address < contentLen) //E-fuse 512Byte
  342. {
  343. rtw_write8(Adapter, EFUSE_CTRL, Value);
  344. //Write E-fuse Register address bit0~7
  345. temp = Address & 0xFF;
  346. rtw_write8(Adapter, EFUSE_CTRL+1, temp);
  347. Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2);
  348. //Write E-fuse Register address bit8~9
  349. temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
  350. rtw_write8(Adapter, EFUSE_CTRL+2, temp);
  351. //Write 0x30[31]=1
  352. Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
  353. temp = Bytetemp | 0x80;
  354. rtw_write8(Adapter, EFUSE_CTRL+3, temp);
  355. //Wait Write-ready (0x30[31]=0)
  356. Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
  357. while(Bytetemp & 0x80)
  358. {
  359. Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
  360. k++;
  361. if(k==100)
  362. {
  363. k=0;
  364. break;
  365. }
  366. }
  367. }
  368. }/* EFUSE_Write1Byte */
  369. /* 11/16/2008 MH Read one byte from real Efuse. */
  370. u8
  371. efuse_OneByteRead(
  372. IN PADAPTER pAdapter,
  373. IN u16 addr,
  374. IN u8 *data,
  375. IN BOOLEAN bPseudoTest)
  376. {
  377. u8 tmpidx = 0;
  378. u8 bResult;
  379. //DBG_871X("===> EFUSE_OneByteRead(), addr = %x\n", addr);
  380. //DBG_871X("===> EFUSE_OneByteRead() start, 0x34 = 0x%X\n", rtw_read32(pAdapter, EFUSE_TEST));
  381. if(bPseudoTest)
  382. {
  383. bResult = Efuse_Read1ByteFromFakeContent(pAdapter, addr, data);
  384. return bResult;
  385. }
  386. // <20130227, Kordan> 8192E MP chip A-cut had better not set 0x34[11] until B-Cut.
  387. /*
  388. if ( IS_HARDWARE_TYPE_8723B(pAdapter))
  389. {
  390. // <20130121, Kordan> For SMIC EFUSE specificatoin.
  391. //0x34[11]: SW force PGMEN input of efuse to high. (for the bank selected by 0x34[9:8])
  392. //PHY_SetMacReg(pAdapter, 0x34, BIT11, 0);
  393. rtw_write16(pAdapter, 0x34, rtw_read16(pAdapter,0x34)& (~BIT11) );
  394. }
  395. */
  396. // -----------------e-fuse reg ctrl ---------------------------------
  397. //address
  398. rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff));
  399. rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03) ) |
  400. (rtw_read8(pAdapter, EFUSE_CTRL+2)&0xFC ));
  401. rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);//read cmd
  402. while(!(0x80 &rtw_read8(pAdapter, EFUSE_CTRL+3))&&(tmpidx<1000))
  403. {
  404. rtw_mdelay_os(1);
  405. tmpidx++;
  406. }
  407. if(tmpidx<1000)
  408. {
  409. *data=rtw_read8(pAdapter, EFUSE_CTRL);
  410. bResult = _TRUE;
  411. }
  412. else
  413. {
  414. *data = 0xff;
  415. bResult = _FALSE;
  416. }
  417. return bResult;
  418. }
  419. /* 11/16/2008 MH Write one byte to reald Efuse. */
  420. u8
  421. efuse_OneByteWrite(
  422. IN PADAPTER pAdapter,
  423. IN u16 addr,
  424. IN u8 data,
  425. IN BOOLEAN bPseudoTest)
  426. {
  427. u8 tmpidx = 0;
  428. u8 bResult=_FALSE;
  429. u32 efuseValue = 0;
  430. //DBG_871X("===> EFUSE_OneByteWrite(), addr = %x data=%x\n", addr, data);
  431. //DBG_871X("===> EFUSE_OneByteWrite() start, 0x34 = 0x%X\n", rtw_read32(pAdapter, EFUSE_TEST));
  432. if(bPseudoTest)
  433. {
  434. bResult = Efuse_Write1ByteToFakeContent(pAdapter, addr, data);
  435. return bResult;
  436. }
  437. // -----------------e-fuse reg ctrl ---------------------------------
  438. //address
  439. // <20121213, Kordan> 8723BE SMIC TestChip workaround.
  440. /*
  441. if (IS_HARDWARE_TYPE_8723B(pAdapter) && ! pHalData->bIsMPChip)
  442. {
  443. //PlatformEFIOWrite1Byte(pAdapter, REG_MULTI_FUNC_CTRL+1, 0x69); // Turn off EFUSE protection.
  444. rtw_write16(pAdapter, REG_SYS_ISO_CTRL, rtw_read16(pAdapter, REG_SYS_ISO_CTRL)| BIT14); // Turn on power cut
  445. EFUSE_PowerSwitch(pAdapter,TRUE, TRUE); // LDO 2.6V, this must follows after power cut.
  446. }
  447. */
  448. efuseValue = rtw_read32(pAdapter, EFUSE_CTRL);
  449. efuseValue |= (BIT21|BIT31);
  450. efuseValue &= ~(0x3FFFF);
  451. efuseValue |= ((addr<<8 | data) & 0x3FFFF);
  452. /*
  453. // <20130227, Kordan> 8192E MP chip A-cut had better not set 0x34[11] until B-Cut.
  454. if (IS_HARDWARE_TYPE_8723B(pAdapter) && pHalData->bIsMPChip)
  455. {
  456. // <20130121, Kordan> For SMIC EFUSE specificatoin.
  457. //0x34[11]: SW force PGMEN input of efuse to high. (for the bank selected by 0x34[9:8])
  458. PHY_SetMacReg(pAdapter, 0x34, BIT11, 1);
  459. PlatformEFIOWrite4Byte(pAdapter, EFUSE_CTRL, 0x90600000|((addr<<8 | data)) );
  460. }
  461. else
  462. */
  463. {
  464. rtw_write32(pAdapter, EFUSE_CTRL, efuseValue);
  465. }
  466. while((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100) ){
  467. rtw_mdelay_os(1);
  468. tmpidx++;
  469. }
  470. if(tmpidx<100)
  471. {
  472. bResult = _TRUE;
  473. }
  474. else
  475. {
  476. bResult = _FALSE;
  477. }
  478. return bResult;
  479. }
  480. int
  481. Efuse_PgPacketRead( IN PADAPTER pAdapter,
  482. IN u8 offset,
  483. IN u8 *data,
  484. IN BOOLEAN bPseudoTest)
  485. {
  486. int ret=0;
  487. ret = pAdapter->HalFunc.Efuse_PgPacketRead(pAdapter, offset, data, bPseudoTest);
  488. return ret;
  489. }
  490. int
  491. Efuse_PgPacketWrite(IN PADAPTER pAdapter,
  492. IN u8 offset,
  493. IN u8 word_en,
  494. IN u8 *data,
  495. IN BOOLEAN bPseudoTest)
  496. {
  497. int ret;
  498. ret = pAdapter->HalFunc.Efuse_PgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest);
  499. return ret;
  500. }
  501. int
  502. Efuse_PgPacketWrite_BT(IN PADAPTER pAdapter,
  503. IN u8 offset,
  504. IN u8 word_en,
  505. IN u8 *data,
  506. IN BOOLEAN bPseudoTest)
  507. {
  508. int ret;
  509. ret = pAdapter->HalFunc.Efuse_PgPacketWrite_BT(pAdapter, offset, word_en, data, bPseudoTest);
  510. return ret;
  511. }
  512. /*-----------------------------------------------------------------------------
  513. * Function: efuse_WordEnableDataRead
  514. *
  515. * Overview: Read allowed word in current efuse section data.
  516. *
  517. * Input: NONE
  518. *
  519. * Output: NONE
  520. *
  521. * Return: NONE
  522. *
  523. * Revised History:
  524. * When Who Remark
  525. * 11/16/2008 MHC Create Version 0.
  526. * 11/21/2008 MHC Fix Write bug when we only enable late word.
  527. *
  528. *---------------------------------------------------------------------------*/
  529. void
  530. efuse_WordEnableDataRead(IN u8 word_en,
  531. IN u8 *sourdata,
  532. IN u8 *targetdata)
  533. {
  534. if (!(word_en&BIT(0)))
  535. {
  536. targetdata[0] = sourdata[0];
  537. targetdata[1] = sourdata[1];
  538. }
  539. if (!(word_en&BIT(1)))
  540. {
  541. targetdata[2] = sourdata[2];
  542. targetdata[3] = sourdata[3];
  543. }
  544. if (!(word_en&BIT(2)))
  545. {
  546. targetdata[4] = sourdata[4];
  547. targetdata[5] = sourdata[5];
  548. }
  549. if (!(word_en&BIT(3)))
  550. {
  551. targetdata[6] = sourdata[6];
  552. targetdata[7] = sourdata[7];
  553. }
  554. }
  555. u8
  556. Efuse_WordEnableDataWrite( IN PADAPTER pAdapter,
  557. IN u16 efuse_addr,
  558. IN u8 word_en,
  559. IN u8 *data,
  560. IN BOOLEAN bPseudoTest)
  561. {
  562. u8 ret=0;
  563. ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest);
  564. return ret;
  565. }
  566. static u8 efuse_read8(PADAPTER padapter, u16 address, u8 *value)
  567. {
  568. return efuse_OneByteRead(padapter,address, value, _FALSE);
  569. }
  570. static u8 efuse_write8(PADAPTER padapter, u16 address, u8 *value)
  571. {
  572. return efuse_OneByteWrite(padapter,address, *value, _FALSE);
  573. }
  574. /*
  575. * read/wirte raw efuse data
  576. */
  577. u8 rtw_efuse_access(PADAPTER padapter, u8 bWrite, u16 start_addr, u16 cnts, u8 *data)
  578. {
  579. int i = 0;
  580. u16 real_content_len = 0, max_available_size = 0;
  581. u8 res = _FAIL ;
  582. u8 (*rw8)(PADAPTER, u16, u8*);
  583. EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (PVOID)&real_content_len, _FALSE);
  584. EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (PVOID)&max_available_size, _FALSE);
  585. if (start_addr > real_content_len)
  586. return _FAIL;
  587. if (_TRUE == bWrite) {
  588. if ((start_addr + cnts) > max_available_size)
  589. return _FAIL;
  590. rw8 = &efuse_write8;
  591. } else
  592. rw8 = &efuse_read8;
  593. Efuse_PowerSwitch(padapter, bWrite, _TRUE);
  594. // e-fuse one byte read / write
  595. for (i = 0; i < cnts; i++) {
  596. if (start_addr >= real_content_len) {
  597. res = _FAIL;
  598. break;
  599. }
  600. res = rw8(padapter, start_addr++, data++);
  601. if (_FAIL == res) break;
  602. }
  603. Efuse_PowerSwitch(padapter, bWrite, _FALSE);
  604. return res;
  605. }
  606. //------------------------------------------------------------------------------
  607. u16 efuse_GetMaxSize(PADAPTER padapter)
  608. {
  609. u16 max_size;
  610. EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI , TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (PVOID)&max_size, _FALSE);
  611. return max_size;
  612. }
  613. //------------------------------------------------------------------------------
  614. u8 efuse_GetCurrentSize(PADAPTER padapter, u16 *size)
  615. {
  616. Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
  617. *size = Efuse_GetCurrentSize(padapter, EFUSE_WIFI, _FALSE);
  618. Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
  619. return _SUCCESS;
  620. }
  621. //------------------------------------------------------------------------------
  622. u8 rtw_efuse_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
  623. {
  624. u16 mapLen=0;
  625. EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
  626. if ((addr + cnts) > mapLen)
  627. return _FAIL;
  628. Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
  629. efuse_ReadEFuse(padapter, EFUSE_WIFI, addr, cnts, data, _FALSE);
  630. Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
  631. return _SUCCESS;
  632. }
  633. u8 rtw_BT_efuse_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
  634. {
  635. u16 mapLen=0;
  636. EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
  637. if ((addr + cnts) > mapLen)
  638. return _FAIL;
  639. Efuse_PowerSwitch(padapter, _FALSE, _TRUE);
  640. efuse_ReadEFuse(padapter, EFUSE_BT, addr, cnts, data, _FALSE);
  641. Efuse_PowerSwitch(padapter, _FALSE, _FALSE);
  642. return _SUCCESS;
  643. }
  644. //------------------------------------------------------------------------------
  645. u8 rtw_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
  646. {
  647. u8 offset, word_en;
  648. u8 *map;
  649. u8 newdata[PGPKT_DATA_SIZE];
  650. s32 i, j, idx;
  651. u8 ret = _SUCCESS;
  652. u16 mapLen=0;
  653. EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
  654. if ((addr + cnts) > mapLen)
  655. return _FAIL;
  656. map = rtw_zmalloc(mapLen);
  657. if(map == NULL){
  658. return _FAIL;
  659. }
  660. ret = rtw_efuse_map_read(padapter, 0, mapLen, map);
  661. if (ret == _FAIL) goto exit;
  662. Efuse_PowerSwitch(padapter, _TRUE, _TRUE);
  663. offset = (addr >> 3);
  664. word_en = 0xF;
  665. _rtw_memset(newdata, 0xFF, PGPKT_DATA_SIZE);
  666. i = addr & 0x7; // index of one package
  667. j = 0; // index of new package
  668. idx = 0; // data index
  669. if (i & 0x1) {
  670. // odd start
  671. if (data[idx] != map[addr+idx]) {
  672. word_en &= ~BIT(i >> 1);
  673. newdata[i-1] = map[addr+idx-1];
  674. newdata[i] = data[idx];
  675. }
  676. i++;
  677. idx++;
  678. }
  679. do {
  680. for (; i < PGPKT_DATA_SIZE; i += 2)
  681. {
  682. if (cnts == idx) break;
  683. if ((cnts - idx) == 1) {
  684. if (data[idx] != map[addr+idx]) {
  685. word_en &= ~BIT(i >> 1);
  686. newdata[i] = data[idx];
  687. newdata[i+1] = map[addr+idx+1];
  688. }
  689. idx++;
  690. break;
  691. } else {
  692. if ((data[idx] != map[addr+idx]) ||
  693. (data[idx+1] != map[addr+idx+1]))
  694. {
  695. word_en &= ~BIT(i >> 1);
  696. newdata[i] = data[idx];
  697. newdata[i+1] = data[idx + 1];
  698. }
  699. idx += 2;
  700. }
  701. if (idx == cnts) break;
  702. }
  703. if (word_en != 0xF) {
  704. ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, _FALSE);
  705. DBG_871X("offset=%x \n",offset);
  706. DBG_871X("word_en=%x \n",word_en);
  707. for(i=0;i<PGPKT_DATA_SIZE;i++)
  708. {
  709. DBG_871X("data=%x \t",newdata[i]);
  710. }
  711. if (ret == _FAIL) break;
  712. }
  713. if (idx == cnts) break;
  714. offset++;
  715. i = 0;
  716. j = 0;
  717. word_en = 0xF;
  718. _rtw_memset(newdata, 0xFF, PGPKT_DATA_SIZE);
  719. } while (1);
  720. Efuse_PowerSwitch(padapter, _TRUE, _FALSE);
  721. exit:
  722. rtw_mfree(map, mapLen);
  723. return ret;
  724. }
  725. //------------------------------------------------------------------------------
  726. u8 rtw_BT_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data)
  727. {
  728. u8 offset, word_en;
  729. u8 *map;
  730. u8 newdata[PGPKT_DATA_SIZE];
  731. s32 i, j, idx;
  732. u8 ret = _SUCCESS;
  733. u16 mapLen=0;
  734. EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, _FALSE);
  735. if ((addr + cnts) > mapLen)
  736. return _FAIL;
  737. map = rtw_zmalloc(mapLen);
  738. if(map == NULL){
  739. return _FAIL;
  740. }
  741. ret = rtw_BT_efuse_map_read(padapter, 0, mapLen, map);
  742. if (ret == _FAIL) goto exit;
  743. Efuse_PowerSwitch(padapter, _TRUE, _TRUE);
  744. offset = (addr >> 3);
  745. word_en = 0xF;
  746. _rtw_memset(newdata, 0xFF, PGPKT_DATA_SIZE);
  747. i = addr & 0x7; // index of one package
  748. j = 0; // index of new package
  749. idx = 0; // data index
  750. if (i & 0x1) {
  751. // odd start
  752. if (data[idx] != map[addr+idx]) {
  753. word_en &= ~BIT(i >> 1);
  754. newdata[i-1] = map[addr+idx-1];
  755. newdata[i] = data[idx];
  756. }
  757. i++;
  758. idx++;
  759. }
  760. do {
  761. for (; i < PGPKT_DATA_SIZE; i += 2)
  762. {
  763. if (cnts == idx) break;
  764. if ((cnts - idx) == 1) {
  765. if (data[idx] != map[addr+idx]) {
  766. word_en &= ~BIT(i >> 1);
  767. newdata[i] = data[idx];
  768. newdata[i+1] = map[addr+idx+1];
  769. }
  770. idx++;
  771. break;
  772. } else {
  773. if ((data[idx] != map[addr+idx]) ||
  774. (data[idx+1] != map[addr+idx+1]))
  775. {
  776. word_en &= ~BIT(i >> 1);
  777. newdata[i] = data[idx];
  778. newdata[i+1] = data[idx + 1];
  779. }
  780. idx += 2;
  781. }
  782. if (idx == cnts) break;
  783. }
  784. if (word_en != 0xF)
  785. {
  786. DBG_871X("%s: offset=%#X\n", __FUNCTION__, offset);
  787. DBG_871X("%s: word_en=%#X\n", __FUNCTION__, word_en);
  788. DBG_871X("%s: data=", __FUNCTION__);
  789. for (i=0; i<PGPKT_DATA_SIZE; i++)
  790. {
  791. DBG_871X("0x%02X ", newdata[i]);
  792. }
  793. DBG_871X("\n");
  794. ret = Efuse_PgPacketWrite_BT(padapter, offset, word_en, newdata, _FALSE);
  795. if (ret == _FAIL) break;
  796. }
  797. if (idx == cnts) break;
  798. offset++;
  799. i = 0;
  800. j = 0;
  801. word_en = 0xF;
  802. _rtw_memset(newdata, 0xFF, PGPKT_DATA_SIZE);
  803. } while (1);
  804. Efuse_PowerSwitch(padapter, _TRUE, _FALSE);
  805. exit:
  806. rtw_mfree(map, mapLen);
  807. return ret;
  808. }
  809. /*-----------------------------------------------------------------------------
  810. * Function: Efuse_ReadAllMap
  811. *
  812. * Overview: Read All Efuse content
  813. *
  814. * Input: NONE
  815. *
  816. * Output: NONE
  817. *
  818. * Return: NONE
  819. *
  820. * Revised History:
  821. * When Who Remark
  822. * 11/11/2008 MHC Create Version 0.
  823. *
  824. *---------------------------------------------------------------------------*/
  825. VOID
  826. Efuse_ReadAllMap(
  827. IN PADAPTER pAdapter,
  828. IN u8 efuseType,
  829. IN OUT u8 *Efuse,
  830. IN BOOLEAN bPseudoTest);
  831. VOID
  832. Efuse_ReadAllMap(
  833. IN PADAPTER pAdapter,
  834. IN u8 efuseType,
  835. IN OUT u8 *Efuse,
  836. IN BOOLEAN bPseudoTest)
  837. {
  838. u16 mapLen=0;
  839. Efuse_PowerSwitch(pAdapter,_FALSE, _TRUE);
  840. EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, bPseudoTest);
  841. efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, bPseudoTest);
  842. Efuse_PowerSwitch(pAdapter,_FALSE, _FALSE);
  843. }
  844. /*-----------------------------------------------------------------------------
  845. * Function: efuse_ShadowRead1Byte
  846. * efuse_ShadowRead2Byte
  847. * efuse_ShadowRead4Byte
  848. *
  849. * Overview: Read from efuse init map by one/two/four bytes !!!!!
  850. *
  851. * Input: NONE
  852. *
  853. * Output: NONE
  854. *
  855. * Return: NONE
  856. *
  857. * Revised History:
  858. * When Who Remark
  859. * 11/12/2008 MHC Create Version 0.
  860. *
  861. *---------------------------------------------------------------------------*/
  862. static VOID
  863. efuse_ShadowRead1Byte(
  864. IN PADAPTER pAdapter,
  865. IN u16 Offset,
  866. IN OUT u8 *Value)
  867. {
  868. EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
  869. *Value = pEEPROM->efuse_eeprom_data[Offset];
  870. } // EFUSE_ShadowRead1Byte
  871. //---------------Read Two Bytes
  872. static VOID
  873. efuse_ShadowRead2Byte(
  874. IN PADAPTER pAdapter,
  875. IN u16 Offset,
  876. IN OUT u16 *Value)
  877. {
  878. EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
  879. *Value = pEEPROM->efuse_eeprom_data[Offset];
  880. *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8;
  881. } // EFUSE_ShadowRead2Byte
  882. //---------------Read Four Bytes
  883. static VOID
  884. efuse_ShadowRead4Byte(
  885. IN PADAPTER pAdapter,
  886. IN u16 Offset,
  887. IN OUT u32 *Value)
  888. {
  889. EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
  890. *Value = pEEPROM->efuse_eeprom_data[Offset];
  891. *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8;
  892. *Value |= pEEPROM->efuse_eeprom_data[Offset+2]<<16;
  893. *Value |= pEEPROM->efuse_eeprom_data[Offset+3]<<24;
  894. } // efuse_ShadowRead4Byte
  895. /*-----------------------------------------------------------------------------
  896. * Function: efuse_ShadowWrite1Byte
  897. * efuse_ShadowWrite2Byte
  898. * efuse_ShadowWrite4Byte
  899. *
  900. * Overview: Write efuse modify map by one/two/four byte.
  901. *
  902. * Input: NONE
  903. *
  904. * Output: NONE
  905. *
  906. * Return: NONE
  907. *
  908. * Revised History:
  909. * When Who Remark
  910. * 11/12/2008 MHC Create Version 0.
  911. *
  912. *---------------------------------------------------------------------------*/
  913. #ifdef PLATFORM
  914. static VOID
  915. efuse_ShadowWrite1Byte(
  916. IN PADAPTER pAdapter,
  917. IN u16 Offset,
  918. IN u8 Value);
  919. #endif //PLATFORM
  920. static VOID
  921. efuse_ShadowWrite1Byte(
  922. IN PADAPTER pAdapter,
  923. IN u16 Offset,
  924. IN u8 Value)
  925. {
  926. EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
  927. pEEPROM->efuse_eeprom_data[Offset] = Value;
  928. } // efuse_ShadowWrite1Byte
  929. //---------------Write Two Bytes
  930. static VOID
  931. efuse_ShadowWrite2Byte(
  932. IN PADAPTER pAdapter,
  933. IN u16 Offset,
  934. IN u16 Value)
  935. {
  936. EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
  937. pEEPROM->efuse_eeprom_data[Offset] = Value&0x00FF;
  938. pEEPROM->efuse_eeprom_data[Offset+1] = Value>>8;
  939. } // efuse_ShadowWrite1Byte
  940. //---------------Write Four Bytes
  941. static VOID
  942. efuse_ShadowWrite4Byte(
  943. IN PADAPTER pAdapter,
  944. IN u16 Offset,
  945. IN u32 Value)
  946. {
  947. EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
  948. pEEPROM->efuse_eeprom_data[Offset] = (u8)(Value&0x000000FF);
  949. pEEPROM->efuse_eeprom_data[Offset+1] = (u8)((Value>>8)&0x0000FF);
  950. pEEPROM->efuse_eeprom_data[Offset+2] = (u8)((Value>>16)&0x00FF);
  951. pEEPROM->efuse_eeprom_data[Offset+3] = (u8)((Value>>24)&0xFF);
  952. } // efuse_ShadowWrite1Byte
  953. /*-----------------------------------------------------------------------------
  954. * Function: EFUSE_ShadowMapUpdate
  955. *
  956. * Overview: Transfer current EFUSE content to shadow init and modify map.
  957. *
  958. * Input: NONE
  959. *
  960. * Output: NONE
  961. *
  962. * Return: NONE
  963. *
  964. * Revised History:
  965. * When Who Remark
  966. * 11/13/2008 MHC Create Version 0.
  967. *
  968. *---------------------------------------------------------------------------*/
  969. void EFUSE_ShadowMapUpdate(
  970. IN PADAPTER pAdapter,
  971. IN u8 efuseType,
  972. IN BOOLEAN bPseudoTest)
  973. {
  974. EEPROM_EFUSE_PRIV *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter);
  975. u16 mapLen=0;
  976. EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (PVOID)&mapLen, bPseudoTest);
  977. if (pEEPROM->bautoload_fail_flag == _TRUE)
  978. {
  979. _rtw_memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen);
  980. }
  981. else
  982. {
  983. #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
  984. if(_SUCCESS != retriveAdaptorInfoFile(pAdapter->registrypriv.adaptor_info_caching_file_path, pEEPROM)) {
  985. #endif
  986. Efuse_ReadAllMap(pAdapter, efuseType, pEEPROM->efuse_eeprom_data, bPseudoTest);
  987. #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
  988. storeAdaptorInfoFile(pAdapter->registrypriv.adaptor_info_caching_file_path, pEEPROM);
  989. }
  990. #endif
  991. }
  992. //PlatformMoveMemory((PVOID)&pHalData->EfuseMap[EFUSE_MODIFY_MAP][0],
  993. //(PVOID)&pHalData->EfuseMap[EFUSE_INIT_MAP][0], mapLen);
  994. }// EFUSE_ShadowMapUpdate
  995. /*-----------------------------------------------------------------------------
  996. * Function: EFUSE_ShadowRead
  997. *
  998. * Overview: Read from efuse init map !!!!!
  999. *
  1000. * Input: NONE
  1001. *
  1002. * Output: NONE
  1003. *
  1004. * Return: NONE
  1005. *
  1006. * Revised History:
  1007. * When Who Remark
  1008. * 11/12/2008 MHC Create Version 0.
  1009. *
  1010. *---------------------------------------------------------------------------*/
  1011. void
  1012. EFUSE_ShadowRead(
  1013. IN PADAPTER pAdapter,
  1014. IN u8 Type,
  1015. IN u16 Offset,
  1016. IN OUT u32 *Value )
  1017. {
  1018. if (Type == 1)
  1019. efuse_ShadowRead1Byte(pAdapter, Offset, (u8 *)Value);
  1020. else if (Type == 2)
  1021. efuse_ShadowRead2Byte(pAdapter, Offset, (u16 *)Value);
  1022. else if (Type == 4)
  1023. efuse_ShadowRead4Byte(pAdapter, Offset, (u32 *)Value);
  1024. } // EFUSE_ShadowRead
  1025. /*-----------------------------------------------------------------------------
  1026. * Function: EFUSE_ShadowWrite
  1027. *
  1028. * Overview: Write efuse modify map for later update operation to use!!!!!
  1029. *
  1030. * Input: NONE
  1031. *
  1032. * Output: NONE
  1033. *
  1034. * Return: NONE
  1035. *
  1036. * Revised History:
  1037. * When Who Remark
  1038. * 11/12/2008 MHC Create Version 0.
  1039. *
  1040. *---------------------------------------------------------------------------*/
  1041. VOID
  1042. EFUSE_ShadowWrite(
  1043. IN PADAPTER pAdapter,
  1044. IN u8 Type,
  1045. IN u16 Offset,
  1046. IN OUT u32 Value);
  1047. VOID
  1048. EFUSE_ShadowWrite(
  1049. IN PADAPTER pAdapter,
  1050. IN u8 Type,
  1051. IN u16 Offset,
  1052. IN OUT u32 Value)
  1053. {
  1054. #if (MP_DRIVER == 0)
  1055. return;
  1056. #endif
  1057. if ( pAdapter->registrypriv.mp_mode == 0)
  1058. return;
  1059. if (Type == 1)
  1060. efuse_ShadowWrite1Byte(pAdapter, Offset, (u8)Value);
  1061. else if (Type == 2)
  1062. efuse_ShadowWrite2Byte(pAdapter, Offset, (u16)Value);
  1063. else if (Type == 4)
  1064. efuse_ShadowWrite4Byte(pAdapter, Offset, (u32)Value);
  1065. } // EFUSE_ShadowWrite
  1066. VOID
  1067. Efuse_InitSomeVar(
  1068. IN PADAPTER pAdapter
  1069. );
  1070. VOID
  1071. Efuse_InitSomeVar(
  1072. IN PADAPTER pAdapter
  1073. )
  1074. {
  1075. u8 i;
  1076. _rtw_memset((PVOID)&fakeEfuseContent[0], 0xff, EFUSE_MAX_HW_SIZE);
  1077. _rtw_memset((PVOID)&fakeEfuseInitMap[0], 0xff, EFUSE_MAX_MAP_LEN);
  1078. _rtw_memset((PVOID)&fakeEfuseModifiedMap[0], 0xff, EFUSE_MAX_MAP_LEN);
  1079. for(i=0; i<EFUSE_MAX_BT_BANK; i++)
  1080. {
  1081. _rtw_memset((PVOID)&BTEfuseContent[i][0], EFUSE_MAX_HW_SIZE, 0xff);
  1082. }
  1083. _rtw_memset((PVOID)&BTEfuseInitMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
  1084. _rtw_memset((PVOID)&BTEfuseModifiedMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
  1085. for(i=0; i<EFUSE_MAX_BT_BANK; i++)
  1086. {
  1087. _rtw_memset((PVOID)&fakeBTEfuseContent[i][0], 0xff, EFUSE_MAX_HW_SIZE);
  1088. }
  1089. _rtw_memset((PVOID)&fakeBTEfuseInitMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
  1090. _rtw_memset((PVOID)&fakeBTEfuseModifiedMap[0], 0xff, EFUSE_BT_MAX_MAP_LEN);
  1091. }
  1092. #ifdef PLATFORM_LINUX
  1093. #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
  1094. //#include <rtw_eeprom.h>
  1095. int isAdaptorInfoFileValid(void)
  1096. {
  1097. return _TRUE;
  1098. }
  1099. int storeAdaptorInfoFile(char *path, struct eeprom_priv * eeprom_priv)
  1100. {
  1101. int ret =_SUCCESS;
  1102. if(path && eeprom_priv) {
  1103. ret = rtw_store_to_file(path, eeprom_priv->efuse_eeprom_data, EEPROM_MAX_SIZE_512);
  1104. if(ret == EEPROM_MAX_SIZE)
  1105. ret = _SUCCESS;
  1106. else
  1107. ret = _FAIL;
  1108. } else {
  1109. DBG_871X("%s NULL pointer\n",__FUNCTION__);
  1110. ret = _FAIL;
  1111. }
  1112. return ret;
  1113. }
  1114. int retriveAdaptorInfoFile(char *path, struct eeprom_priv * eeprom_priv)
  1115. {
  1116. int ret = _SUCCESS;
  1117. mm_segment_t oldfs;
  1118. struct file *fp;
  1119. if(path && eeprom_priv) {
  1120. ret = rtw_retrive_from_file(path, eeprom_priv->efuse_eeprom_data, EEPROM_MAX_SIZE);
  1121. if(ret == EEPROM_MAX_SIZE)
  1122. ret = _SUCCESS;
  1123. else
  1124. ret = _FAIL;
  1125. #if 0
  1126. if(isAdaptorInfoFileValid()) {
  1127. return 0;
  1128. } else {
  1129. return _FAIL;
  1130. }
  1131. #endif
  1132. } else {
  1133. DBG_871X("%s NULL pointer\n",__FUNCTION__);
  1134. ret = _FAIL;
  1135. }
  1136. return ret;
  1137. }
  1138. #endif //CONFIG_ADAPTOR_INFO_CACHING_FILE
  1139. #endif //PLATFORM_LINUX