Larry Finger | 0c81733 | 2010-12-08 11:12:31 -0600 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Larry Finger | a8d7606 | 2012-01-07 20:46:42 -0600 | [diff] [blame] | 3 | * Copyright(c) 2009-2012 Realtek Corporation. |
Larry Finger | 0c81733 | 2010-12-08 11:12:31 -0600 | [diff] [blame] | 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 | * The full GNU General Public License is included in this distribution in the |
| 19 | * file called LICENSE. |
| 20 | * |
| 21 | * Contact Information: |
| 22 | * wlanfae <wlanfae@realtek.com> |
| 23 | * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, |
| 24 | * Hsinchu 300, Taiwan. |
| 25 | * |
| 26 | * Larry Finger <Larry.Finger@lwfinger.net> |
| 27 | * |
| 28 | *****************************************************************************/ |
| 29 | |
| 30 | #ifndef __RTL_EFUSE_H_ |
| 31 | #define __RTL_EFUSE_H_ |
| 32 | |
Chaoming_Li | e25f51d | 2011-04-25 12:52:44 -0500 | [diff] [blame] | 33 | #define EFUSE_IC_ID_OFFSET 506 |
| 34 | |
Larry Finger | 0c81733 | 2010-12-08 11:12:31 -0600 | [diff] [blame] | 35 | #define EFUSE_MAP_LEN 128 |
Larry Finger | 0c81733 | 2010-12-08 11:12:31 -0600 | [diff] [blame] | 36 | #define EFUSE_MAX_WORD_UNIT 4 |
| 37 | |
| 38 | #define EFUSE_INIT_MAP 0 |
| 39 | #define EFUSE_MODIFY_MAP 1 |
| 40 | |
| 41 | #define PG_STATE_HEADER 0x01 |
| 42 | #define PG_STATE_WORD_0 0x02 |
| 43 | #define PG_STATE_WORD_1 0x04 |
| 44 | #define PG_STATE_WORD_2 0x08 |
| 45 | #define PG_STATE_WORD_3 0x10 |
| 46 | #define PG_STATE_DATA 0x20 |
| 47 | |
| 48 | #define PG_SWBYTE_H 0x01 |
| 49 | #define PG_SWBYTE_L 0x02 |
| 50 | |
| 51 | #define _POWERON_DELAY_ |
| 52 | #define _PRE_EXECUTE_READ_CMD_ |
| 53 | |
| 54 | #define EFUSE_REPEAT_THRESHOLD_ 3 |
Chaoming_Li | e25f51d | 2011-04-25 12:52:44 -0500 | [diff] [blame] | 55 | #define EFUSE_ERROE_HANDLE 1 |
Larry Finger | 0c81733 | 2010-12-08 11:12:31 -0600 | [diff] [blame] | 56 | |
| 57 | struct efuse_map { |
| 58 | u8 offset; |
| 59 | u8 word_start; |
| 60 | u8 byte_start; |
| 61 | u8 byte_cnts; |
| 62 | }; |
| 63 | |
| 64 | struct pgpkt_struct { |
| 65 | u8 offset; |
| 66 | u8 word_en; |
| 67 | u8 data[8]; |
| 68 | }; |
| 69 | |
| 70 | enum efuse_data_item { |
| 71 | EFUSE_CHIP_ID = 0, |
| 72 | EFUSE_LDO_SETTING, |
| 73 | EFUSE_CLK_SETTING, |
| 74 | EFUSE_SDIO_SETTING, |
| 75 | EFUSE_CCCR, |
| 76 | EFUSE_SDIO_MODE, |
| 77 | EFUSE_OCR, |
| 78 | EFUSE_F0CIS, |
| 79 | EFUSE_F1CIS, |
| 80 | EFUSE_MAC_ADDR, |
| 81 | EFUSE_EEPROM_VER, |
| 82 | EFUSE_CHAN_PLAN, |
| 83 | EFUSE_TXPW_TAB |
| 84 | }; |
| 85 | |
| 86 | enum { |
| 87 | VOLTAGE_V25 = 0x03, |
| 88 | LDOE25_SHIFT = 28, |
| 89 | }; |
| 90 | |
| 91 | struct efuse_priv { |
| 92 | u8 id[2]; |
| 93 | u8 ldo_setting[2]; |
| 94 | u8 clk_setting[2]; |
| 95 | u8 cccr; |
| 96 | u8 sdio_mode; |
| 97 | u8 ocr[3]; |
| 98 | u8 cis0[17]; |
| 99 | u8 cis1[48]; |
| 100 | u8 mac_addr[6]; |
| 101 | u8 eeprom_verno; |
| 102 | u8 channel_plan; |
| 103 | u8 tx_power_b[14]; |
| 104 | u8 tx_power_g[14]; |
| 105 | }; |
| 106 | |
Chaoming_Li | e25f51d | 2011-04-25 12:52:44 -0500 | [diff] [blame] | 107 | extern void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf); |
Larry Finger | 0c81733 | 2010-12-08 11:12:31 -0600 | [diff] [blame] | 108 | extern void efuse_initialize(struct ieee80211_hw *hw); |
| 109 | extern u8 efuse_read_1byte(struct ieee80211_hw *hw, u16 address); |
| 110 | extern void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value); |
| 111 | extern void read_efuse(struct ieee80211_hw *hw, u16 _offset, |
| 112 | u16 _size_byte, u8 *pbuf); |
| 113 | extern void efuse_shadow_read(struct ieee80211_hw *hw, u8 type, |
| 114 | u16 offset, u32 *value); |
| 115 | extern void efuse_shadow_write(struct ieee80211_hw *hw, u8 type, |
| 116 | u16 offset, u32 value); |
| 117 | extern bool efuse_shadow_update(struct ieee80211_hw *hw); |
| 118 | extern bool efuse_shadow_update_chk(struct ieee80211_hw *hw); |
| 119 | extern void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw); |
| 120 | extern void efuse_force_write_vendor_Id(struct ieee80211_hw *hw); |
| 121 | extern void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx); |
Larry Finger | 0c81733 | 2010-12-08 11:12:31 -0600 | [diff] [blame] | 122 | |
| 123 | #endif |