1 /* SPDX-License-Identifier: ISC */ 2 /* Copyright (C) 2019 MediaTek Inc. */ 3 4 #ifndef __MT7615_EEPROM_H 5 #define __MT7615_EEPROM_H 6 7 #include "mt7615.h" 8 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 MT7663_EE_TX0_2G_TARGET_POWER = 0x123, 22 MT_EE_TX2_5G_G0_TARGET_POWER = 0x142, 23 MT_EE_TX3_5G_G0_TARGET_POWER = 0x16a, 24 25 MT7615_EE_MAX = 0x3bf, 26 MT7622_EE_MAX = 0x3db, 27 MT7663_EE_MAX = 0x400, 28 }; 29 30 #define MT_EE_NIC_CONF_TX_MASK GENMASK(7, 4) 31 #define MT_EE_NIC_CONF_RX_MASK GENMASK(3, 0) 32 33 #define MT_EE_NIC_CONF_TSSI_2G BIT(5) 34 #define MT_EE_NIC_CONF_TSSI_5G BIT(6) 35 36 #define MT_EE_NIC_WIFI_CONF_BAND_SEL GENMASK(5, 4) 37 enum mt7615_eeprom_band { 38 MT_EE_DUAL_BAND, 39 MT_EE_5GHZ, 40 MT_EE_2GHZ, 41 MT_EE_DBDC, 42 }; 43 44 enum mt7615_channel_group { 45 MT_CH_5G_JAPAN, 46 MT_CH_5G_UNII_1, 47 MT_CH_5G_UNII_2A, 48 MT_CH_5G_UNII_2B, 49 MT_CH_5G_UNII_2E_1, 50 MT_CH_5G_UNII_2E_2, 51 MT_CH_5G_UNII_2E_3, 52 MT_CH_5G_UNII_3, 53 __MT_CH_MAX 54 }; 55 56 static inline enum mt7615_channel_group 57 mt7615_get_channel_group(int channel) 58 { 59 if (channel >= 184 && channel <= 196) 60 return MT_CH_5G_JAPAN; 61 if (channel <= 48) 62 return MT_CH_5G_UNII_1; 63 if (channel <= 64) 64 return MT_CH_5G_UNII_2A; 65 if (channel <= 114) 66 return MT_CH_5G_UNII_2E_1; 67 if (channel <= 144) 68 return MT_CH_5G_UNII_2E_2; 69 if (channel <= 161) 70 return MT_CH_5G_UNII_2E_3; 71 return MT_CH_5G_UNII_3; 72 } 73 74 static inline bool 75 mt7615_ext_pa_enabled(struct mt7615_dev *dev, enum nl80211_band band) 76 { 77 u8 *eep = dev->mt76.eeprom.data; 78 79 if (band == NL80211_BAND_5GHZ) 80 return !(eep[MT_EE_NIC_CONF_1 + 1] & MT_EE_NIC_CONF_TSSI_5G); 81 else 82 return !(eep[MT_EE_NIC_CONF_1 + 1] & MT_EE_NIC_CONF_TSSI_2G); 83 } 84 85 #endif 86