104b8e659SRyder Lee /* SPDX-License-Identifier: ISC */ 204b8e659SRyder Lee /* Copyright (C) 2019 MediaTek Inc. */ 304b8e659SRyder Lee 404b8e659SRyder Lee #ifndef __MT7615_EEPROM_H 504b8e659SRyder Lee #define __MT7615_EEPROM_H 604b8e659SRyder Lee 704b8e659SRyder Lee #include "mt7615.h" 804b8e659SRyder Lee 904b8e659SRyder Lee enum mt7615_eeprom_field { 1004b8e659SRyder Lee MT_EE_CHIP_ID = 0x000, 1104b8e659SRyder Lee MT_EE_VERSION = 0x002, 1204b8e659SRyder Lee MT_EE_MAC_ADDR = 0x004, 1304b8e659SRyder Lee MT_EE_NIC_CONF_0 = 0x034, 1416a2f8e2SLorenzo Bianconi MT_EE_NIC_CONF_1 = 0x036, 15c988a77fSLorenzo Bianconi MT_EE_WIFI_CONF = 0x03e, 1661d36824SLorenzo Bianconi MT_EE_TX0_2G_TARGET_POWER = 0x058, 1761d36824SLorenzo Bianconi MT_EE_TX0_5G_G0_TARGET_POWER = 0x070, 1861d36824SLorenzo Bianconi MT_EE_TX1_5G_G0_TARGET_POWER = 0x098, 1916a2f8e2SLorenzo Bianconi MT_EE_EXT_PA_2G_TARGET_POWER = 0x0f2, 2016a2f8e2SLorenzo Bianconi MT_EE_EXT_PA_5G_TARGET_POWER = 0x0f3, 2161d36824SLorenzo Bianconi MT_EE_TX2_5G_G0_TARGET_POWER = 0x142, 2261d36824SLorenzo Bianconi MT_EE_TX3_5G_G0_TARGET_POWER = 0x16a, 2304b8e659SRyder Lee 24*5dff21eeSFelix Fietkau MT7615_EE_MAX = 0x3bf, 25*5dff21eeSFelix Fietkau MT7622_EE_MAX = 0x3db, 2604b8e659SRyder Lee }; 2704b8e659SRyder Lee 28acf5457fSLorenzo Bianconi #define MT_EE_NIC_CONF_TX_MASK GENMASK(7, 4) 29acf5457fSLorenzo Bianconi #define MT_EE_NIC_CONF_RX_MASK GENMASK(3, 0) 30acf5457fSLorenzo Bianconi 3116a2f8e2SLorenzo Bianconi #define MT_EE_NIC_CONF_TSSI_2G BIT(5) 3216a2f8e2SLorenzo Bianconi #define MT_EE_NIC_CONF_TSSI_5G BIT(6) 3316a2f8e2SLorenzo Bianconi 34c988a77fSLorenzo Bianconi #define MT_EE_NIC_WIFI_CONF_BAND_SEL GENMASK(5, 4) 35c988a77fSLorenzo Bianconi enum mt7615_eeprom_band { 36c988a77fSLorenzo Bianconi MT_EE_DUAL_BAND, 37c988a77fSLorenzo Bianconi MT_EE_5GHZ, 38c988a77fSLorenzo Bianconi MT_EE_2GHZ, 39c988a77fSLorenzo Bianconi MT_EE_DBDC, 40c988a77fSLorenzo Bianconi }; 41c988a77fSLorenzo Bianconi 4261d36824SLorenzo Bianconi enum mt7615_channel_group { 4361d36824SLorenzo Bianconi MT_CH_5G_JAPAN, 4461d36824SLorenzo Bianconi MT_CH_5G_UNII_1, 4561d36824SLorenzo Bianconi MT_CH_5G_UNII_2A, 4661d36824SLorenzo Bianconi MT_CH_5G_UNII_2B, 4761d36824SLorenzo Bianconi MT_CH_5G_UNII_2E_1, 4861d36824SLorenzo Bianconi MT_CH_5G_UNII_2E_2, 4961d36824SLorenzo Bianconi MT_CH_5G_UNII_2E_3, 5061d36824SLorenzo Bianconi MT_CH_5G_UNII_3, 5161d36824SLorenzo Bianconi __MT_CH_MAX 5261d36824SLorenzo Bianconi }; 5361d36824SLorenzo Bianconi 5461d36824SLorenzo Bianconi static inline enum mt7615_channel_group 5561d36824SLorenzo Bianconi mt7615_get_channel_group(int channel) 5661d36824SLorenzo Bianconi { 5761d36824SLorenzo Bianconi if (channel >= 184 && channel <= 196) 5861d36824SLorenzo Bianconi return MT_CH_5G_JAPAN; 5961d36824SLorenzo Bianconi if (channel <= 48) 6061d36824SLorenzo Bianconi return MT_CH_5G_UNII_1; 6161d36824SLorenzo Bianconi if (channel <= 64) 6261d36824SLorenzo Bianconi return MT_CH_5G_UNII_2A; 6361d36824SLorenzo Bianconi if (channel <= 114) 6461d36824SLorenzo Bianconi return MT_CH_5G_UNII_2E_1; 6561d36824SLorenzo Bianconi if (channel <= 144) 6661d36824SLorenzo Bianconi return MT_CH_5G_UNII_2E_2; 6761d36824SLorenzo Bianconi if (channel <= 161) 6861d36824SLorenzo Bianconi return MT_CH_5G_UNII_2E_3; 6961d36824SLorenzo Bianconi return MT_CH_5G_UNII_3; 7061d36824SLorenzo Bianconi } 7161d36824SLorenzo Bianconi 7216a2f8e2SLorenzo Bianconi static inline bool 7316a2f8e2SLorenzo Bianconi mt7615_ext_pa_enabled(struct mt7615_dev *dev, enum nl80211_band band) 7416a2f8e2SLorenzo Bianconi { 7516a2f8e2SLorenzo Bianconi u8 *eep = dev->mt76.eeprom.data; 7616a2f8e2SLorenzo Bianconi 7716a2f8e2SLorenzo Bianconi if (band == NL80211_BAND_5GHZ) 7816a2f8e2SLorenzo Bianconi return !(eep[MT_EE_NIC_CONF_1 + 1] & MT_EE_NIC_CONF_TSSI_5G); 7916a2f8e2SLorenzo Bianconi else 8016a2f8e2SLorenzo Bianconi return !(eep[MT_EE_NIC_CONF_1 + 1] & MT_EE_NIC_CONF_TSSI_2G); 8116a2f8e2SLorenzo Bianconi } 8216a2f8e2SLorenzo Bianconi 8304b8e659SRyder Lee #endif 84