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