0001
0002
0003
0004
0005
0006 #ifndef __MT76x2_EEPROM_H
0007 #define __MT76x2_EEPROM_H
0008
0009 #include "../mt76x02_eeprom.h"
0010
0011 enum mt76x2_cal_channel_group {
0012 MT_CH_5G_JAPAN,
0013 MT_CH_5G_UNII_1,
0014 MT_CH_5G_UNII_2,
0015 MT_CH_5G_UNII_2E_1,
0016 MT_CH_5G_UNII_2E_2,
0017 MT_CH_5G_UNII_3,
0018 __MT_CH_MAX
0019 };
0020
0021 struct mt76x2_tx_power_info {
0022 u8 target_power;
0023
0024 s8 delta_bw40;
0025 s8 delta_bw80;
0026
0027 struct {
0028 s8 tssi_slope;
0029 s8 tssi_offset;
0030 s8 target_power;
0031 s8 delta;
0032 } chain[MT_MAX_CHAINS];
0033 };
0034
0035 struct mt76x2_temp_comp {
0036 u8 temp_25_ref;
0037 int lower_bound;
0038 int upper_bound;
0039 unsigned int high_slope;
0040 unsigned int low_slope;
0041 };
0042
0043 void mt76x2_get_rate_power(struct mt76x02_dev *dev, struct mt76_rate_power *t,
0044 struct ieee80211_channel *chan);
0045 void mt76x2_get_power_info(struct mt76x02_dev *dev,
0046 struct mt76x2_tx_power_info *t,
0047 struct ieee80211_channel *chan);
0048 int mt76x2_get_temp_comp(struct mt76x02_dev *dev, struct mt76x2_temp_comp *t);
0049 void mt76x2_read_rx_gain(struct mt76x02_dev *dev);
0050
0051 static inline bool
0052 mt76x2_has_ext_lna(struct mt76x02_dev *dev)
0053 {
0054 u32 val = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1);
0055
0056 if (dev->mphy.chandef.chan->band == NL80211_BAND_2GHZ)
0057 return val & MT_EE_NIC_CONF_1_LNA_EXT_2G;
0058 else
0059 return val & MT_EE_NIC_CONF_1_LNA_EXT_5G;
0060 }
0061
0062 static inline bool
0063 mt76x2_temp_tx_alc_enabled(struct mt76x02_dev *dev)
0064 {
0065 u16 val;
0066
0067 val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G);
0068 if (!(val & BIT(15)))
0069 return false;
0070
0071 return mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
0072 MT_EE_NIC_CONF_1_TEMP_TX_ALC;
0073 }
0074
0075 static inline bool
0076 mt76x2_tssi_enabled(struct mt76x02_dev *dev)
0077 {
0078 return !mt76x2_temp_tx_alc_enabled(dev) &&
0079 (mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
0080 MT_EE_NIC_CONF_1_TX_ALC_EN);
0081 }
0082
0083 #endif