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