treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt76 / mt7615 / eeprom.h
blobc3bc69ac210ec89d86a1e8d723ed47171699769e
1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2019 MediaTek Inc. */
4 #ifndef __MT7615_EEPROM_H
5 #define __MT7615_EEPROM_H
7 #include "mt7615.h"
9 enum mt7615_eeprom_field {
10 MT_EE_CHIP_ID = 0x000,
11 MT_EE_VERSION = 0x002,
12 MT_EE_MAC_ADDR = 0x004,
13 MT_EE_NIC_CONF_0 = 0x034,
14 MT_EE_NIC_CONF_1 = 0x036,
15 MT_EE_WIFI_CONF = 0x03e,
16 MT_EE_TX0_2G_TARGET_POWER = 0x058,
17 MT_EE_TX0_5G_G0_TARGET_POWER = 0x070,
18 MT_EE_TX1_5G_G0_TARGET_POWER = 0x098,
19 MT_EE_EXT_PA_2G_TARGET_POWER = 0x0f2,
20 MT_EE_EXT_PA_5G_TARGET_POWER = 0x0f3,
21 MT_EE_TX2_5G_G0_TARGET_POWER = 0x142,
22 MT_EE_TX3_5G_G0_TARGET_POWER = 0x16a,
24 __MT_EE_MAX = 0x3bf
27 #define MT_EE_NIC_CONF_TX_MASK GENMASK(7, 4)
28 #define MT_EE_NIC_CONF_RX_MASK GENMASK(3, 0)
30 #define MT_EE_NIC_CONF_TSSI_2G BIT(5)
31 #define MT_EE_NIC_CONF_TSSI_5G BIT(6)
33 #define MT_EE_NIC_WIFI_CONF_BAND_SEL GENMASK(5, 4)
34 enum mt7615_eeprom_band {
35 MT_EE_DUAL_BAND,
36 MT_EE_5GHZ,
37 MT_EE_2GHZ,
38 MT_EE_DBDC,
41 enum mt7615_channel_group {
42 MT_CH_5G_JAPAN,
43 MT_CH_5G_UNII_1,
44 MT_CH_5G_UNII_2A,
45 MT_CH_5G_UNII_2B,
46 MT_CH_5G_UNII_2E_1,
47 MT_CH_5G_UNII_2E_2,
48 MT_CH_5G_UNII_2E_3,
49 MT_CH_5G_UNII_3,
50 __MT_CH_MAX
53 static inline enum mt7615_channel_group
54 mt7615_get_channel_group(int channel)
56 if (channel >= 184 && channel <= 196)
57 return MT_CH_5G_JAPAN;
58 if (channel <= 48)
59 return MT_CH_5G_UNII_1;
60 if (channel <= 64)
61 return MT_CH_5G_UNII_2A;
62 if (channel <= 114)
63 return MT_CH_5G_UNII_2E_1;
64 if (channel <= 144)
65 return MT_CH_5G_UNII_2E_2;
66 if (channel <= 161)
67 return MT_CH_5G_UNII_2E_3;
68 return MT_CH_5G_UNII_3;
71 static inline bool
72 mt7615_ext_pa_enabled(struct mt7615_dev *dev, enum nl80211_band band)
74 u8 *eep = dev->mt76.eeprom.data;
76 if (band == NL80211_BAND_5GHZ)
77 return !(eep[MT_EE_NIC_CONF_1 + 1] & MT_EE_NIC_CONF_TSSI_5G);
78 else
79 return !(eep[MT_EE_NIC_CONF_1 + 1] & MT_EE_NIC_CONF_TSSI_2G);
82 #endif