blob: cd96366c11ffc776e0a311aa392b836d633bf7bf [file] [log] [blame]
Larry Finger475b922e2013-08-21 22:34:08 -05001/******************************************************************************
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#ifndef __RTW_EFUSE_H__
21#define __RTW_EFUSE_H__
22
23#include <osdep_service.h>
24
25#define EFUSE_ERROE_HANDLE 1
26
27#define PG_STATE_HEADER 0x01
28#define PG_STATE_WORD_0 0x02
29#define PG_STATE_WORD_1 0x04
30#define PG_STATE_WORD_2 0x08
31#define PG_STATE_WORD_3 0x10
32#define PG_STATE_DATA 0x20
33
34#define PG_SWBYTE_H 0x01
35#define PG_SWBYTE_L 0x02
36
37#define PGPKT_DATA_SIZE 8
38
39#define EFUSE_WIFI 0
40#define EFUSE_BT 1
41
42enum _EFUSE_DEF_TYPE {
43 TYPE_EFUSE_MAX_SECTION = 0,
44 TYPE_EFUSE_REAL_CONTENT_LEN = 1,
45 TYPE_AVAILABLE_EFUSE_BYTES_BANK = 2,
46 TYPE_AVAILABLE_EFUSE_BYTES_TOTAL = 3,
47 TYPE_EFUSE_MAP_LEN = 4,
48 TYPE_EFUSE_PROTECT_BYTES_BANK = 5,
49 TYPE_EFUSE_CONTENT_LEN_BANK = 6,
50};
51
52/* E-Fuse */
53#define EFUSE_MAP_SIZE 512
54#define EFUSE_MAX_SIZE 256
55/* end of E-Fuse */
56
Larry Finger40fac5a2013-08-28 21:12:25 -050057#define EFUSE_MAX_MAP_LEN 512
Larry Finger475b922e2013-08-21 22:34:08 -050058#define EFUSE_MAX_HW_SIZE 512
59#define EFUSE_MAX_SECTION_BASE 16
60
61#define EXT_HEADER(header) ((header & 0x1F) == 0x0F)
62#define ALL_WORDS_DISABLED(wde) ((wde & 0x0F) == 0x0F)
63#define GET_HDR_OFFSET_2_0(header) ((header & 0xE0) >> 5)
64
65#define EFUSE_REPEAT_THRESHOLD_ 3
66
67/* The following is for BT Efuse definition */
68#define EFUSE_BT_MAX_MAP_LEN 1024
69#define EFUSE_MAX_BANK 4
70#define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK-1)
71/*--------------------------Define Parameters-------------------------------*/
72#define EFUSE_MAX_WORD_UNIT 4
73
74/*------------------------------Define structure----------------------------*/
75struct pgpkt {
76 u8 offset;
77 u8 word_en;
78 u8 data[8];
79 u8 word_cnts;
80};
81
82/*------------------------------Define structure----------------------------*/
83struct efuse_hal {
84 u8 fakeEfuseBank;
85 u32 fakeEfuseUsedBytes;
86 u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE];
87 u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN];
88 u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN];
89
90 u16 BTEfuseUsedBytes;
91 u8 BTEfuseUsedPercentage;
92 u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
93 u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
94 u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
95
96 u16 fakeBTEfuseUsedBytes;
97 u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
98 u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
99 u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
100};
101
102/*------------------------Export global variable----------------------------*/
103extern u8 fakeEfuseBank;
104extern u32 fakeEfuseUsedBytes;
105extern u8 fakeEfuseContent[];
106extern u8 fakeEfuseInitMap[];
107extern u8 fakeEfuseModifiedMap[];
108
109extern u32 BTEfuseUsedBytes;
110extern u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
111extern u8 BTEfuseInitMap[];
112extern u8 BTEfuseModifiedMap[];
113
114extern u32 fakeBTEfuseUsedBytes;
115extern u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
116extern u8 fakeBTEfuseInitMap[];
117extern u8 fakeBTEfuseModifiedMap[];
118/*------------------------Export global variable----------------------------*/
119
120u8 efuse_GetCurrentSize(struct adapter *adapter, u16 *size);
121u16 efuse_GetMaxSize(struct adapter *adapter);
122u8 rtw_efuse_access(struct adapter *adapter, u8 read, u16 start_addr,
123 u16 cnts, u8 *data);
124u8 rtw_efuse_map_read(struct adapter *adapter, u16 addr, u16 cnts, u8 *data);
125u8 rtw_efuse_map_write(struct adapter *adapter, u16 addr, u16 cnts, u8 *data);
navin patidar1df2d1c2014-06-20 20:29:10 +0530126u16 Efuse_GetCurrentSize(struct adapter *adapter, bool test);
Larry Finger475b922e2013-08-21 22:34:08 -0500127u8 Efuse_CalculateWordCnts(u8 word_en);
Larry Finger475b922e2013-08-21 22:34:08 -0500128void EFUSE_GetEfuseDefinition(struct adapter *adapt, u8 type, u8 type1,
navin patidar9dec2542014-06-20 20:29:18 +0530129 void *out);
navin patidar78810552014-06-20 20:29:33 +0530130u8 efuse_OneByteRead(struct adapter *adapter, u16 addr, u8 *data);
navin patidar20f3b6c2014-06-20 20:29:34 +0530131u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data);
Larry Finger475b922e2013-08-21 22:34:08 -0500132
navin patidar93282a62014-06-20 20:29:23 +0530133void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset,
134 u16 _size_byte, u8 *pbuf, bool bPseudoTest);
Tim Jester-Pfadt3f35c7f2014-01-12 00:55:25 +0100135void Efuse_PowerSwitch(struct adapter *adapt, u8 bWrite, u8 PwrState);
Larry Finger475b922e2013-08-21 22:34:08 -0500136int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data, bool test);
navin patidara602fd02014-06-20 20:29:25 +0530137bool Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data,
Larry Finger475b922e2013-08-21 22:34:08 -0500138 bool test);
139void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata);
140u8 Efuse_WordEnableDataWrite(struct adapter *adapter, u16 efuse_addr,
141 u8 word_en, u8 *data, bool test);
142
Larry Finger475b922e2013-08-21 22:34:08 -0500143void EFUSE_ShadowMapUpdate(struct adapter *adapter, u8 efusetype, bool test);
144void EFUSE_ShadowRead(struct adapter *adapt, u8 type, u16 offset, u32 *val);
145
146#endif