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 ******************************************************************************/
15 #ifndef __RTW_EFUSE_H__
16 #define __RTW_EFUSE_H__
19 #define EFUSE_ERROE_HANDLE 1
21 #define PG_STATE_HEADER 0x01
22 #define PG_STATE_WORD_0 0x02
23 #define PG_STATE_WORD_1 0x04
24 #define PG_STATE_WORD_2 0x08
25 #define PG_STATE_WORD_3 0x10
26 #define PG_STATE_DATA 0x20
28 #define PG_SWBYTE_H 0x01
29 #define PG_SWBYTE_L 0x02
31 #define PGPKT_DATA_SIZE 8
36 enum _EFUSE_DEF_TYPE {
37 TYPE_EFUSE_MAX_SECTION = 0,
38 TYPE_EFUSE_REAL_CONTENT_LEN = 1,
39 TYPE_AVAILABLE_EFUSE_BYTES_BANK = 2,
40 TYPE_AVAILABLE_EFUSE_BYTES_TOTAL = 3,
41 TYPE_EFUSE_MAP_LEN = 4,
42 TYPE_EFUSE_PROTECT_BYTES_BANK = 5,
43 TYPE_EFUSE_CONTENT_LEN_BANK = 6,
46 #define EFUSE_MAX_MAP_LEN 512
48 #define EFUSE_MAX_HW_SIZE 512
49 #define EFUSE_MAX_SECTION_BASE 16
51 #define EXT_HEADER(header) ((header & 0x1F) == 0x0F)
52 #define ALL_WORDS_DISABLED(wde) ((wde & 0x0F) == 0x0F)
53 #define GET_HDR_OFFSET_2_0(header) ((header & 0xE0) >> 5)
55 #define EFUSE_REPEAT_THRESHOLD_ 3
58 /* The following is for BT Efuse definition */
60 #define EFUSE_BT_MAX_MAP_LEN 1024
61 #define EFUSE_MAX_BANK 4
62 #define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK-1)
64 /*--------------------------Define Parameters-------------------------------*/
65 #define EFUSE_MAX_WORD_UNIT 4
67 /*------------------------------Define structure----------------------------*/
68 typedef struct PG_PKT_STRUCT_A{
73 }PGPKT_STRUCT,*PPGPKT_STRUCT;
75 /*------------------------------Define structure----------------------------*/
76 typedef struct _EFUSE_HAL{
78 u32 fakeEfuseUsedBytes;
79 u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE];
80 u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN];
81 u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN];
84 u8 BTEfuseUsedPercentage;
85 u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
86 u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
87 u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
89 u16 fakeBTEfuseUsedBytes;
90 u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
91 u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
92 u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
93 }EFUSE_HAL, *PEFUSE_HAL;
96 /*------------------------Export global variable----------------------------*/
97 extern u8 fakeEfuseBank;
98 extern u32 fakeEfuseUsedBytes;
99 extern u8 fakeEfuseContent[];
100 extern u8 fakeEfuseInitMap[];
101 extern u8 fakeEfuseModifiedMap[];
103 extern u32 BTEfuseUsedBytes;
104 extern u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
105 extern u8 BTEfuseInitMap[];
106 extern u8 BTEfuseModifiedMap[];
108 extern u32 fakeBTEfuseUsedBytes;
109 extern u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
110 extern u8 fakeBTEfuseInitMap[];
111 extern u8 fakeBTEfuseModifiedMap[];
112 /*------------------------Export global variable----------------------------*/
114 u16 Efuse_GetCurrentSize(struct adapter *padapter, u8 efuseType, bool bPseudoTest);
115 u8 Efuse_CalculateWordCnts(u8 word_en);
116 void EFUSE_GetEfuseDefinition(struct adapter *padapter, u8 efuseType, u8 type, void *pOut, bool bPseudoTest);
117 u8 efuse_OneByteRead(struct adapter *padapter, u16 addr, u8 *data, bool bPseudoTest);
118 u8 efuse_OneByteWrite(struct adapter *padapter, u16 addr, u8 data, bool bPseudoTest);
120 void Efuse_PowerSwitch(struct adapter *padapter, u8 bWrite, u8 PwrState);
121 int Efuse_PgPacketRead(struct adapter *padapter, u8 offset, u8 *data, bool bPseudoTest);
122 int Efuse_PgPacketWrite(struct adapter *padapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest);
123 void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata);
124 u8 Efuse_WordEnableDataWrite(struct adapter *padapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest);
126 u8 EFUSE_Read1Byte(struct adapter *padapter, u16 Address);
127 void EFUSE_ShadowMapUpdate(struct adapter *padapter, u8 efuseType, bool bPseudoTest);
128 void EFUSE_ShadowRead(struct adapter *padapter, u8 Type, u16 Offset, u32 *Value);
129 void Rtw_Hal_ReadMACAddrFromFile(struct adapter *padapter);
130 u32 Rtw_Hal_readPGDataFromConfigFile(struct adapter *padapter);