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
15 ******************************************************************************/
16 #ifndef __RTW_EFUSE_H__
17 #define __RTW_EFUSE_H__
19 #include <osdep_service.h>
21 #define EFUSE_ERROE_HANDLE 1
23 #define PG_STATE_HEADER 0x01
24 #define PG_STATE_WORD_0 0x02
25 #define PG_STATE_WORD_1 0x04
26 #define PG_STATE_WORD_2 0x08
27 #define PG_STATE_WORD_3 0x10
28 #define PG_STATE_DATA 0x20
30 #define PG_SWBYTE_H 0x01
31 #define PG_SWBYTE_L 0x02
33 #define PGPKT_DATA_SIZE 8
38 enum _EFUSE_DEF_TYPE {
39 TYPE_EFUSE_MAX_SECTION = 0,
40 TYPE_EFUSE_REAL_CONTENT_LEN = 1,
41 TYPE_AVAILABLE_EFUSE_BYTES_BANK = 2,
42 TYPE_AVAILABLE_EFUSE_BYTES_TOTAL = 3,
43 TYPE_EFUSE_MAP_LEN = 4,
44 TYPE_EFUSE_PROTECT_BYTES_BANK = 5,
45 TYPE_EFUSE_CONTENT_LEN_BANK = 6,
49 #define EFUSE_MAP_SIZE 256
51 #define EFUSE_MAX_SIZE 512
54 #define EFUSE_MAX_MAP_LEN 256
55 #define EFUSE_MAX_HW_SIZE 512
56 #define EFUSE_MAX_SECTION_BASE 16
58 #define EXT_HEADER(header) ((header & 0x1F) == 0x0F)
59 #define ALL_WORDS_DISABLED(wde) ((wde & 0x0F) == 0x0F)
60 #define GET_HDR_OFFSET_2_0(header) ( (header & 0xE0) >> 5)
62 #define EFUSE_REPEAT_THRESHOLD_ 3
65 /* The following is for BT Efuse definition */
67 #define EFUSE_BT_MAX_MAP_LEN 1024
68 #define EFUSE_MAX_BANK 4
69 #define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK-1)
71 /*--------------------------Define Parameters-------------------------------*/
72 #define EFUSE_MAX_WORD_UNIT 4
74 /*------------------------------Define structure----------------------------*/
75 struct pg_pkt_struct {
82 /*------------------------Export global variable----------------------------*/
84 u16 efuse_GetMaxSize23a(struct rtw_adapter *padapter);
85 int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bRead, u16 start_addr, u16 cnts, u8 *data);
86 int rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
87 u8 rtw_efuse_map_write(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
88 int rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
89 u8 rtw_BT_efuse_map_write(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
91 u16 Efuse_GetCurrentSize23a(struct rtw_adapter *pAdapter, u8 efuseType);
92 u8 Efuse_CalculateWordCnts23a(u8 word_en);
93 void ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf);
94 void EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, u8 type, void *pOut);
95 int efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data);
96 int efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data);
98 void Efuse_PowerSwitch23a(struct rtw_adapter *pAdapter, u8 bWrite,
100 int Efuse_PgPacketRead23a(struct rtw_adapter *pAdapter, u8 offset, u8 *data);
101 int Efuse_PgPacketWrite23a(struct rtw_adapter *pAdapter, u8 offset, u8 word_en, u8 *data);
102 void efuse_WordEnableDataRead23a(u8 word_en, u8 *sourdata, u8 *targetdata);
103 u8 Efuse_WordEnableDataWrite23a(struct rtw_adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data);
105 u8 EFUSE_Read1Byte23a(struct rtw_adapter *pAdapter, u16 Address);
106 void EFUSE_ShadowMapUpdate23a(struct rtw_adapter *pAdapter, u8 efuseType);
107 void EFUSE_ShadowRead23a(struct rtw_adapter *pAdapter, u8 Type, u16 Offset, u32 *Value);