OSDN Git Service

staging: rtl8723bs: update to the latest driver
[android-x86/kernel.git] / drivers / staging / rtl8723bs / include / rtw_efuse.h
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 #ifndef __RTW_EFUSE_H__
16 #define __RTW_EFUSE_H__
17
18
19 #define EFUSE_ERROE_HANDLE              1
20
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
27
28 #define PG_SWBYTE_H                     0x01
29 #define PG_SWBYTE_L                     0x02
30
31 #define PGPKT_DATA_SIZE         8
32
33 #define EFUSE_WIFI                              0
34 #define EFUSE_BT                                1
35
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,
44 };
45
46 #define         EFUSE_MAX_MAP_LEN               512
47
48 #define         EFUSE_MAX_HW_SIZE               512
49 #define         EFUSE_MAX_SECTION_BASE  16
50
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)
54
55 #define         EFUSE_REPEAT_THRESHOLD_                 3
56
57 /*  */
58 /*      The following is for BT Efuse definition */
59 /*  */
60 #define         EFUSE_BT_MAX_MAP_LEN            1024
61 #define         EFUSE_MAX_BANK                  4
62 #define         EFUSE_MAX_BT_BANK               (EFUSE_MAX_BANK-1)
63 /*  */
64 /*--------------------------Define Parameters-------------------------------*/
65 #define         EFUSE_MAX_WORD_UNIT                     4
66
67 /*------------------------------Define structure----------------------------*/
68 typedef struct PG_PKT_STRUCT_A{
69         u8 offset;
70         u8 word_en;
71         u8 data[8];
72         u8 word_cnts;
73 }PGPKT_STRUCT,*PPGPKT_STRUCT;
74
75 /*------------------------------Define structure----------------------------*/
76 typedef struct _EFUSE_HAL{
77         u8 fakeEfuseBank;
78         u32 fakeEfuseUsedBytes;
79         u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE];
80         u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN];
81         u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN];
82
83         u16 BTEfuseUsedBytes;
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];
88
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;
94
95
96 /*------------------------Export global variable----------------------------*/
97 extern u8 fakeEfuseBank;
98 extern u32 fakeEfuseUsedBytes;
99 extern u8 fakeEfuseContent[];
100 extern u8 fakeEfuseInitMap[];
101 extern u8 fakeEfuseModifiedMap[];
102
103 extern u32 BTEfuseUsedBytes;
104 extern u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
105 extern u8 BTEfuseInitMap[];
106 extern u8 BTEfuseModifiedMap[];
107
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----------------------------*/
113
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);
119
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);
125
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);
131
132 #endif