Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 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 | * |
Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 14 | ******************************************************************************/ |
| 15 | #ifndef __RTW_EFUSE_H__ |
| 16 | #define __RTW_EFUSE_H__ |
| 17 | |
| 18 | #include <osdep_service.h> |
| 19 | |
| 20 | #define EFUSE_ERROE_HANDLE 1 |
| 21 | |
| 22 | #define PG_STATE_HEADER 0x01 |
| 23 | #define PG_STATE_WORD_0 0x02 |
| 24 | #define PG_STATE_WORD_1 0x04 |
| 25 | #define PG_STATE_WORD_2 0x08 |
| 26 | #define PG_STATE_WORD_3 0x10 |
| 27 | #define PG_STATE_DATA 0x20 |
| 28 | |
| 29 | #define PG_SWBYTE_H 0x01 |
| 30 | #define PG_SWBYTE_L 0x02 |
| 31 | |
| 32 | #define PGPKT_DATA_SIZE 8 |
| 33 | |
| 34 | #define EFUSE_WIFI 0 |
| 35 | #define EFUSE_BT 1 |
| 36 | |
| 37 | enum _EFUSE_DEF_TYPE { |
| 38 | TYPE_EFUSE_MAX_SECTION = 0, |
| 39 | TYPE_EFUSE_REAL_CONTENT_LEN = 1, |
| 40 | TYPE_AVAILABLE_EFUSE_BYTES_BANK = 2, |
| 41 | TYPE_AVAILABLE_EFUSE_BYTES_TOTAL = 3, |
| 42 | TYPE_EFUSE_MAP_LEN = 4, |
| 43 | TYPE_EFUSE_PROTECT_BYTES_BANK = 5, |
| 44 | TYPE_EFUSE_CONTENT_LEN_BANK = 6, |
| 45 | }; |
| 46 | |
| 47 | /* E-Fuse */ |
| 48 | #define EFUSE_MAP_SIZE 512 |
| 49 | #define EFUSE_MAX_SIZE 256 |
| 50 | /* end of E-Fuse */ |
| 51 | |
Larry Finger | 40fac5a | 2013-08-28 21:12:25 -0500 | [diff] [blame] | 52 | #define EFUSE_MAX_MAP_LEN 512 |
Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 53 | #define EFUSE_MAX_HW_SIZE 512 |
| 54 | #define EFUSE_MAX_SECTION_BASE 16 |
| 55 | |
| 56 | #define EXT_HEADER(header) ((header & 0x1F) == 0x0F) |
| 57 | #define ALL_WORDS_DISABLED(wde) ((wde & 0x0F) == 0x0F) |
| 58 | #define GET_HDR_OFFSET_2_0(header) ((header & 0xE0) >> 5) |
| 59 | |
| 60 | #define EFUSE_REPEAT_THRESHOLD_ 3 |
| 61 | |
| 62 | /* The following is for BT Efuse definition */ |
| 63 | #define EFUSE_BT_MAX_MAP_LEN 1024 |
| 64 | #define EFUSE_MAX_BANK 4 |
| 65 | #define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK-1) |
| 66 | /*--------------------------Define Parameters-------------------------------*/ |
| 67 | #define EFUSE_MAX_WORD_UNIT 4 |
| 68 | |
| 69 | /*------------------------------Define structure----------------------------*/ |
| 70 | struct pgpkt { |
| 71 | u8 offset; |
| 72 | u8 word_en; |
| 73 | u8 data[8]; |
| 74 | u8 word_cnts; |
| 75 | }; |
| 76 | |
| 77 | /*------------------------------Define structure----------------------------*/ |
| 78 | struct efuse_hal { |
| 79 | u8 fakeEfuseBank; |
| 80 | u32 fakeEfuseUsedBytes; |
| 81 | u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE]; |
| 82 | u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN]; |
| 83 | u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN]; |
| 84 | |
| 85 | u16 BTEfuseUsedBytes; |
| 86 | u8 BTEfuseUsedPercentage; |
| 87 | u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; |
| 88 | u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]; |
| 89 | u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]; |
| 90 | |
| 91 | u16 fakeBTEfuseUsedBytes; |
| 92 | u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; |
| 93 | u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]; |
| 94 | u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]; |
| 95 | }; |
| 96 | |
Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 97 | u8 Efuse_CalculateWordCnts(u8 word_en); |
Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 98 | void EFUSE_GetEfuseDefinition(struct adapter *adapt, u8 type, u8 type1, |
navin patidar | 9dec254 | 2014-06-20 20:29:18 +0530 | [diff] [blame] | 99 | void *out); |
navin patidar | 7881055 | 2014-06-20 20:29:33 +0530 | [diff] [blame] | 100 | u8 efuse_OneByteRead(struct adapter *adapter, u16 addr, u8 *data); |
navin patidar | 20f3b6c | 2014-06-20 20:29:34 +0530 | [diff] [blame] | 101 | u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data); |
Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 102 | |
navin patidar | 93282a6 | 2014-06-20 20:29:23 +0530 | [diff] [blame] | 103 | void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, |
navin patidar | 142547b | 2014-06-20 20:29:35 +0530 | [diff] [blame] | 104 | u16 _size_byte, u8 *pbuf); |
Tim Jester-Pfadt | 3f35c7f | 2014-01-12 00:55:25 +0100 | [diff] [blame] | 105 | void Efuse_PowerSwitch(struct adapter *adapt, u8 bWrite, u8 PwrState); |
navin patidar | e9ecc553 | 2014-06-20 20:29:41 +0530 | [diff] [blame] | 106 | int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data); |
| 107 | bool Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data); |
Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 108 | void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata); |
| 109 | u8 Efuse_WordEnableDataWrite(struct adapter *adapter, u16 efuse_addr, |
navin patidar | b09d7549 | 2014-06-20 20:29:39 +0530 | [diff] [blame] | 110 | u8 word_en, u8 *data); |
Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 111 | |
navin patidar | b0d255c | 2014-06-20 20:29:38 +0530 | [diff] [blame] | 112 | void EFUSE_ShadowMapUpdate(struct adapter *adapter, u8 efusetype); |
Larry Finger | 475b922e | 2013-08-21 22:34:08 -0500 | [diff] [blame] | 113 | #endif |