1d27a76faSLarry Finger /* SPDX-License-Identifier: GPL-2.0 */ 2d27a76faSLarry Finger /* Copyright(c) 2009-2012 Realtek Corporation.*/ 3f1d2b4d3SLarry Finger 4f1d2b4d3SLarry Finger #ifndef __RTL_EFUSE_H_ 5f1d2b4d3SLarry Finger #define __RTL_EFUSE_H_ 6f1d2b4d3SLarry Finger 7f1d2b4d3SLarry Finger #define EFUSE_IC_ID_OFFSET 506 8f1d2b4d3SLarry Finger 9f1d2b4d3SLarry Finger #define EFUSE_MAX_WORD_UNIT 4 10f1d2b4d3SLarry Finger 11f1d2b4d3SLarry Finger #define EFUSE_INIT_MAP 0 12f1d2b4d3SLarry Finger #define EFUSE_MODIFY_MAP 1 13f1d2b4d3SLarry Finger 14f1d2b4d3SLarry Finger #define PG_STATE_HEADER 0x01 15f1d2b4d3SLarry Finger #define PG_STATE_WORD_0 0x02 16f1d2b4d3SLarry Finger #define PG_STATE_WORD_1 0x04 17f1d2b4d3SLarry Finger #define PG_STATE_WORD_2 0x08 18f1d2b4d3SLarry Finger #define PG_STATE_WORD_3 0x10 19f1d2b4d3SLarry Finger #define PG_STATE_DATA 0x20 20f1d2b4d3SLarry Finger 21f1d2b4d3SLarry Finger #define EFUSE_REPEAT_THRESHOLD_ 3 22f1d2b4d3SLarry Finger #define EFUSE_ERROE_HANDLE 1 23f1d2b4d3SLarry Finger 24f1d2b4d3SLarry Finger struct efuse_map { 25f1d2b4d3SLarry Finger u8 offset; 26f1d2b4d3SLarry Finger u8 word_start; 27f1d2b4d3SLarry Finger u8 byte_start; 28f1d2b4d3SLarry Finger u8 byte_cnts; 29f1d2b4d3SLarry Finger }; 30f1d2b4d3SLarry Finger 31f1d2b4d3SLarry Finger struct pgpkt_struct { 32f1d2b4d3SLarry Finger u8 offset; 33f1d2b4d3SLarry Finger u8 word_en; 34f1d2b4d3SLarry Finger u8 data[8]; 35f1d2b4d3SLarry Finger }; 36f1d2b4d3SLarry Finger 37f1d2b4d3SLarry Finger enum efuse_data_item { 38f1d2b4d3SLarry Finger EFUSE_CHIP_ID = 0, 39f1d2b4d3SLarry Finger EFUSE_LDO_SETTING, 40f1d2b4d3SLarry Finger EFUSE_CLK_SETTING, 41f1d2b4d3SLarry Finger EFUSE_SDIO_SETTING, 42f1d2b4d3SLarry Finger EFUSE_CCCR, 43f1d2b4d3SLarry Finger EFUSE_SDIO_MODE, 44f1d2b4d3SLarry Finger EFUSE_OCR, 45f1d2b4d3SLarry Finger EFUSE_F0CIS, 46f1d2b4d3SLarry Finger EFUSE_F1CIS, 47f1d2b4d3SLarry Finger EFUSE_MAC_ADDR, 48f1d2b4d3SLarry Finger EFUSE_EEPROM_VER, 49f1d2b4d3SLarry Finger EFUSE_CHAN_PLAN, 50f1d2b4d3SLarry Finger EFUSE_TXPW_TAB 51f1d2b4d3SLarry Finger }; 52f1d2b4d3SLarry Finger 53f1d2b4d3SLarry Finger enum { 54f1d2b4d3SLarry Finger VOLTAGE_V25 = 0x03, 55f1d2b4d3SLarry Finger LDOE25_SHIFT = 28, 56f1d2b4d3SLarry Finger }; 57f1d2b4d3SLarry Finger 58f1d2b4d3SLarry Finger struct efuse_priv { 59f1d2b4d3SLarry Finger u8 id[2]; 60f1d2b4d3SLarry Finger u8 ldo_setting[2]; 61f1d2b4d3SLarry Finger u8 clk_setting[2]; 62f1d2b4d3SLarry Finger u8 cccr; 63f1d2b4d3SLarry Finger u8 sdio_mode; 64f1d2b4d3SLarry Finger u8 ocr[3]; 65f1d2b4d3SLarry Finger u8 cis0[17]; 66f1d2b4d3SLarry Finger u8 cis1[48]; 67f1d2b4d3SLarry Finger u8 mac_addr[6]; 68f1d2b4d3SLarry Finger u8 eeprom_verno; 69f1d2b4d3SLarry Finger u8 channel_plan; 70f1d2b4d3SLarry Finger u8 tx_power_b[14]; 71f1d2b4d3SLarry Finger u8 tx_power_g[14]; 72f1d2b4d3SLarry Finger }; 73f1d2b4d3SLarry Finger 74f1d2b4d3SLarry Finger void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf); 75f1d2b4d3SLarry Finger void efuse_initialize(struct ieee80211_hw *hw); 76f1d2b4d3SLarry Finger u8 efuse_read_1byte(struct ieee80211_hw *hw, u16 address); 77f1d2b4d3SLarry Finger int efuse_one_byte_read(struct ieee80211_hw *hw, u16 addr, u8 *data); 78f1d2b4d3SLarry Finger void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value); 79f1d2b4d3SLarry Finger void read_efuse(struct ieee80211_hw *hw, u16 _offset, 80f1d2b4d3SLarry Finger u16 _size_byte, u8 *pbuf); 81f1d2b4d3SLarry Finger void efuse_shadow_read(struct ieee80211_hw *hw, u8 type, 82f1d2b4d3SLarry Finger u16 offset, u32 *value); 83f1d2b4d3SLarry Finger void efuse_shadow_write(struct ieee80211_hw *hw, u8 type, 84f1d2b4d3SLarry Finger u16 offset, u32 value); 85f1d2b4d3SLarry Finger bool efuse_shadow_update(struct ieee80211_hw *hw); 86f1d2b4d3SLarry Finger bool efuse_shadow_update_chk(struct ieee80211_hw *hw); 87f1d2b4d3SLarry Finger void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw); 88*e703c5ddSLarry Finger void efuse_force_write_vendor_id(struct ieee80211_hw *hw); 89f1d2b4d3SLarry Finger void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx); 907fe1fe75SPing-Ke Shih void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate); 91edb45b67SLarry Finger int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv, 92edb45b67SLarry Finger int max_size, u8 *hwinfo, int *params); 9389d32c90SLarry Finger void rtl_fill_dummy(u8 *pfwbuf, u32 *pfwlen); 9489d32c90SLarry Finger void rtl_fw_page_write(struct ieee80211_hw *hw, u32 page, const u8 *buffer, 9589d32c90SLarry Finger u32 size); 9689d32c90SLarry Finger void rtl_fw_block_write(struct ieee80211_hw *hw, const u8 *buffer, u32 size); 972cdd634eSPing-Ke Shih void rtl_efuse_ops_init(struct ieee80211_hw *hw); 98f1d2b4d3SLarry Finger #endif 99