treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt76 / mt76x2 / eeprom.h
blob4dcf6518cb0de5b102702eab38f7fae2365eb1f7
1 /* SPDX-License-Identifier: ISC */
2 /*
3 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
4 */
6 #ifndef __MT76x2_EEPROM_H
7 #define __MT76x2_EEPROM_H
9 #include "../mt76x02_eeprom.h"
11 enum mt76x2_cal_channel_group {
12 MT_CH_5G_JAPAN,
13 MT_CH_5G_UNII_1,
14 MT_CH_5G_UNII_2,
15 MT_CH_5G_UNII_2E_1,
16 MT_CH_5G_UNII_2E_2,
17 MT_CH_5G_UNII_3,
18 __MT_CH_MAX
21 struct mt76x2_tx_power_info {
22 u8 target_power;
24 s8 delta_bw40;
25 s8 delta_bw80;
27 struct {
28 s8 tssi_slope;
29 s8 tssi_offset;
30 s8 target_power;
31 s8 delta;
32 } chain[MT_MAX_CHAINS];
35 struct mt76x2_temp_comp {
36 u8 temp_25_ref;
37 int lower_bound; /* J */
38 int upper_bound; /* J */
39 unsigned int high_slope; /* J / dB */
40 unsigned int low_slope; /* J / dB */
43 void mt76x2_get_rate_power(struct mt76x02_dev *dev, struct mt76_rate_power *t,
44 struct ieee80211_channel *chan);
45 void mt76x2_get_power_info(struct mt76x02_dev *dev,
46 struct mt76x2_tx_power_info *t,
47 struct ieee80211_channel *chan);
48 int mt76x2_get_temp_comp(struct mt76x02_dev *dev, struct mt76x2_temp_comp *t);
49 void mt76x2_read_rx_gain(struct mt76x02_dev *dev);
51 static inline bool
52 mt76x2_has_ext_lna(struct mt76x02_dev *dev)
54 u32 val = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1);
56 if (dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ)
57 return val & MT_EE_NIC_CONF_1_LNA_EXT_2G;
58 else
59 return val & MT_EE_NIC_CONF_1_LNA_EXT_5G;
62 static inline bool
63 mt76x2_temp_tx_alc_enabled(struct mt76x02_dev *dev)
65 u16 val;
67 val = mt76x02_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G);
68 if (!(val & BIT(15)))
69 return false;
71 return mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
72 MT_EE_NIC_CONF_1_TEMP_TX_ALC;
75 static inline bool
76 mt76x2_tssi_enabled(struct mt76x02_dev *dev)
78 return !mt76x2_temp_tx_alc_enabled(dev) &&
79 (mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_1) &
80 MT_EE_NIC_CONF_1_TX_ALC_EN);
83 #endif