2 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef __MT76x2_EEPROM_H
18 #define __MT76x2_EEPROM_H
20 #include "../mt76x02_eeprom.h"
22 enum mt76x2_cal_channel_group {
32 struct mt76x2_tx_power_info {
43 } chain[MT_MAX_CHAINS];
46 struct mt76x2_temp_comp {
48 int lower_bound; /* J */
49 int upper_bound; /* J */
50 unsigned int high_slope; /* J / dB */
51 unsigned int low_slope; /* J / dB */
54 void mt76x2_get_rate_power(struct mt76x02_dev *dev, struct mt76_rate_power *t,
55 struct ieee80211_channel *chan);
56 void mt76x2_get_power_info(struct mt76x02_dev *dev,
57 struct mt76x2_tx_power_info *t,
58 struct ieee80211_channel *chan);
59 int mt76x2_get_temp_comp(struct mt76x02_dev *dev, struct mt76x2_temp_comp *t);
60 void mt76x2_read_rx_gain(struct mt76x02_dev *dev);
63 mt76x2_has_ext_lna(struct mt76x02_dev *dev)
65 u32 val = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1);
67 if (dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ)
68 return val & MT_EE_NIC_CONF_1_LNA_EXT_2G;
70 return val & MT_EE_NIC_CONF_1_LNA_EXT_5G;
74 mt76x2_temp_tx_alc_enabled(struct mt76x02_dev *dev)
78 val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G);
82 return mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
83 MT_EE_NIC_CONF_1_TEMP_TX_ALC;
87 mt76x2_tssi_enabled(struct mt76x02_dev *dev)
89 return !mt76x2_temp_tx_alc_enabled(dev) &&
90 (mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
91 MT_EE_NIC_CONF_1_TX_ALC_EN);