1f1d2b4d3SLarry Finger /****************************************************************************** 2f1d2b4d3SLarry Finger * 3f1d2b4d3SLarry Finger * Copyright(c) 2009-2012 Realtek Corporation. 4f1d2b4d3SLarry Finger * 5f1d2b4d3SLarry Finger * This program is free software; you can redistribute it and/or modify it 6f1d2b4d3SLarry Finger * under the terms of version 2 of the GNU General Public License as 7f1d2b4d3SLarry Finger * published by the Free Software Foundation. 8f1d2b4d3SLarry Finger * 9f1d2b4d3SLarry Finger * This program is distributed in the hope that it will be useful, but WITHOUT 10f1d2b4d3SLarry Finger * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11f1d2b4d3SLarry Finger * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12f1d2b4d3SLarry Finger * more details. 13f1d2b4d3SLarry Finger * 14f1d2b4d3SLarry Finger * The full GNU General Public License is included in this distribution in the 15f1d2b4d3SLarry Finger * file called LICENSE. 16f1d2b4d3SLarry Finger * 17f1d2b4d3SLarry Finger * Contact Information: 18f1d2b4d3SLarry Finger * wlanfae <wlanfae@realtek.com> 19f1d2b4d3SLarry Finger * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, 20f1d2b4d3SLarry Finger * Hsinchu 300, Taiwan. 21f1d2b4d3SLarry Finger * 22f1d2b4d3SLarry Finger * Larry Finger <Larry.Finger@lwfinger.net> 23f1d2b4d3SLarry Finger * 24f1d2b4d3SLarry Finger *****************************************************************************/ 25f1d2b4d3SLarry Finger 26f1d2b4d3SLarry Finger #ifndef __RTL_EFUSE_H_ 27f1d2b4d3SLarry Finger #define __RTL_EFUSE_H_ 28f1d2b4d3SLarry Finger 29f1d2b4d3SLarry Finger #define EFUSE_IC_ID_OFFSET 506 30f1d2b4d3SLarry Finger 31f1d2b4d3SLarry Finger #define EFUSE_MAX_WORD_UNIT 4 32f1d2b4d3SLarry Finger 33f1d2b4d3SLarry Finger #define EFUSE_INIT_MAP 0 34f1d2b4d3SLarry Finger #define EFUSE_MODIFY_MAP 1 35f1d2b4d3SLarry Finger 36f1d2b4d3SLarry Finger #define PG_STATE_HEADER 0x01 37f1d2b4d3SLarry Finger #define PG_STATE_WORD_0 0x02 38f1d2b4d3SLarry Finger #define PG_STATE_WORD_1 0x04 39f1d2b4d3SLarry Finger #define PG_STATE_WORD_2 0x08 40f1d2b4d3SLarry Finger #define PG_STATE_WORD_3 0x10 41f1d2b4d3SLarry Finger #define PG_STATE_DATA 0x20 42f1d2b4d3SLarry Finger 43f1d2b4d3SLarry Finger #define EFUSE_REPEAT_THRESHOLD_ 3 44f1d2b4d3SLarry Finger #define EFUSE_ERROE_HANDLE 1 45f1d2b4d3SLarry Finger 46f1d2b4d3SLarry Finger struct efuse_map { 47f1d2b4d3SLarry Finger u8 offset; 48f1d2b4d3SLarry Finger u8 word_start; 49f1d2b4d3SLarry Finger u8 byte_start; 50f1d2b4d3SLarry Finger u8 byte_cnts; 51f1d2b4d3SLarry Finger }; 52f1d2b4d3SLarry Finger 53f1d2b4d3SLarry Finger struct pgpkt_struct { 54f1d2b4d3SLarry Finger u8 offset; 55f1d2b4d3SLarry Finger u8 word_en; 56f1d2b4d3SLarry Finger u8 data[8]; 57f1d2b4d3SLarry Finger }; 58f1d2b4d3SLarry Finger 59f1d2b4d3SLarry Finger enum efuse_data_item { 60f1d2b4d3SLarry Finger EFUSE_CHIP_ID = 0, 61f1d2b4d3SLarry Finger EFUSE_LDO_SETTING, 62f1d2b4d3SLarry Finger EFUSE_CLK_SETTING, 63f1d2b4d3SLarry Finger EFUSE_SDIO_SETTING, 64f1d2b4d3SLarry Finger EFUSE_CCCR, 65f1d2b4d3SLarry Finger EFUSE_SDIO_MODE, 66f1d2b4d3SLarry Finger EFUSE_OCR, 67f1d2b4d3SLarry Finger EFUSE_F0CIS, 68f1d2b4d3SLarry Finger EFUSE_F1CIS, 69f1d2b4d3SLarry Finger EFUSE_MAC_ADDR, 70f1d2b4d3SLarry Finger EFUSE_EEPROM_VER, 71f1d2b4d3SLarry Finger EFUSE_CHAN_PLAN, 72f1d2b4d3SLarry Finger EFUSE_TXPW_TAB 73f1d2b4d3SLarry Finger }; 74f1d2b4d3SLarry Finger 75f1d2b4d3SLarry Finger enum { 76f1d2b4d3SLarry Finger VOLTAGE_V25 = 0x03, 77f1d2b4d3SLarry Finger LDOE25_SHIFT = 28, 78f1d2b4d3SLarry Finger }; 79f1d2b4d3SLarry Finger 80f1d2b4d3SLarry Finger struct efuse_priv { 81f1d2b4d3SLarry Finger u8 id[2]; 82f1d2b4d3SLarry Finger u8 ldo_setting[2]; 83f1d2b4d3SLarry Finger u8 clk_setting[2]; 84f1d2b4d3SLarry Finger u8 cccr; 85f1d2b4d3SLarry Finger u8 sdio_mode; 86f1d2b4d3SLarry Finger u8 ocr[3]; 87f1d2b4d3SLarry Finger u8 cis0[17]; 88f1d2b4d3SLarry Finger u8 cis1[48]; 89f1d2b4d3SLarry Finger u8 mac_addr[6]; 90f1d2b4d3SLarry Finger u8 eeprom_verno; 91f1d2b4d3SLarry Finger u8 channel_plan; 92f1d2b4d3SLarry Finger u8 tx_power_b[14]; 93f1d2b4d3SLarry Finger u8 tx_power_g[14]; 94f1d2b4d3SLarry Finger }; 95f1d2b4d3SLarry Finger 96f1d2b4d3SLarry Finger void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf); 97f1d2b4d3SLarry Finger void efuse_initialize(struct ieee80211_hw *hw); 98f1d2b4d3SLarry Finger u8 efuse_read_1byte(struct ieee80211_hw *hw, u16 address); 99f1d2b4d3SLarry Finger int efuse_one_byte_read(struct ieee80211_hw *hw, u16 addr, u8 *data); 100f1d2b4d3SLarry Finger void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value); 101f1d2b4d3SLarry Finger void read_efuse(struct ieee80211_hw *hw, u16 _offset, 102f1d2b4d3SLarry Finger u16 _size_byte, u8 *pbuf); 103f1d2b4d3SLarry Finger void efuse_shadow_read(struct ieee80211_hw *hw, u8 type, 104f1d2b4d3SLarry Finger u16 offset, u32 *value); 105f1d2b4d3SLarry Finger void efuse_shadow_write(struct ieee80211_hw *hw, u8 type, 106f1d2b4d3SLarry Finger u16 offset, u32 value); 107f1d2b4d3SLarry Finger bool efuse_shadow_update(struct ieee80211_hw *hw); 108f1d2b4d3SLarry Finger bool efuse_shadow_update_chk(struct ieee80211_hw *hw); 109f1d2b4d3SLarry Finger void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw); 110f1d2b4d3SLarry Finger void efuse_force_write_vendor_Id(struct ieee80211_hw *hw); 111f1d2b4d3SLarry Finger void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx); 1127fe1fe75SPing-Ke Shih void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate); 113edb45b67SLarry Finger int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv, 114edb45b67SLarry Finger int max_size, u8 *hwinfo, int *params); 11589d32c90SLarry Finger void rtl_fill_dummy(u8 *pfwbuf, u32 *pfwlen); 11689d32c90SLarry Finger void rtl_fw_page_write(struct ieee80211_hw *hw, u32 page, const u8 *buffer, 11789d32c90SLarry Finger u32 size); 11889d32c90SLarry Finger void rtl_fw_block_write(struct ieee80211_hw *hw, const u8 *buffer, u32 size); 119*2cdd634eSPing-Ke Shih void rtl_efuse_ops_init(struct ieee80211_hw *hw); 120f1d2b4d3SLarry Finger #endif 121