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