18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: ISC */ 28c2ecf20Sopenharmony_ci/* Copyright (C) 2019 MediaTek Inc. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef __MT7615_EEPROM_H 58c2ecf20Sopenharmony_ci#define __MT7615_EEPROM_H 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include "mt7615.h" 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define MT7615_EEPROM_DCOC_OFFSET MT7615_EEPROM_SIZE 118c2ecf20Sopenharmony_ci#define MT7615_EEPROM_DCOC_SIZE 256 128c2ecf20Sopenharmony_ci#define MT7615_EEPROM_DCOC_COUNT 34 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define MT7615_EEPROM_TXDPD_OFFSET (MT7615_EEPROM_SIZE + \ 158c2ecf20Sopenharmony_ci MT7615_EEPROM_DCOC_COUNT * \ 168c2ecf20Sopenharmony_ci MT7615_EEPROM_DCOC_SIZE) 178c2ecf20Sopenharmony_ci#define MT7615_EEPROM_TXDPD_SIZE 216 188c2ecf20Sopenharmony_ci#define MT7615_EEPROM_TXDPD_COUNT (44 + 3) 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define MT7615_EEPROM_FULL_SIZE (MT7615_EEPROM_TXDPD_OFFSET + \ 218c2ecf20Sopenharmony_ci MT7615_EEPROM_TXDPD_COUNT * \ 228c2ecf20Sopenharmony_ci MT7615_EEPROM_TXDPD_SIZE) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cienum mt7615_eeprom_field { 258c2ecf20Sopenharmony_ci MT_EE_CHIP_ID = 0x000, 268c2ecf20Sopenharmony_ci MT_EE_VERSION = 0x002, 278c2ecf20Sopenharmony_ci MT_EE_MAC_ADDR = 0x004, 288c2ecf20Sopenharmony_ci MT_EE_NIC_CONF_0 = 0x034, 298c2ecf20Sopenharmony_ci MT_EE_NIC_CONF_1 = 0x036, 308c2ecf20Sopenharmony_ci MT_EE_WIFI_CONF = 0x03e, 318c2ecf20Sopenharmony_ci MT_EE_CALDATA_FLASH = 0x052, 328c2ecf20Sopenharmony_ci MT_EE_TX0_2G_TARGET_POWER = 0x058, 338c2ecf20Sopenharmony_ci MT_EE_TX0_5G_G0_TARGET_POWER = 0x070, 348c2ecf20Sopenharmony_ci MT7663_EE_5G_RATE_POWER = 0x089, 358c2ecf20Sopenharmony_ci MT_EE_TX1_5G_G0_TARGET_POWER = 0x098, 368c2ecf20Sopenharmony_ci MT_EE_2G_RATE_POWER = 0x0be, 378c2ecf20Sopenharmony_ci MT_EE_5G_RATE_POWER = 0x0d5, 388c2ecf20Sopenharmony_ci MT7663_EE_TX0_2G_TARGET_POWER = 0x0e3, 398c2ecf20Sopenharmony_ci MT_EE_EXT_PA_2G_TARGET_POWER = 0x0f2, 408c2ecf20Sopenharmony_ci MT_EE_EXT_PA_5G_TARGET_POWER = 0x0f3, 418c2ecf20Sopenharmony_ci MT_EE_TX2_5G_G0_TARGET_POWER = 0x142, 428c2ecf20Sopenharmony_ci MT_EE_TX3_5G_G0_TARGET_POWER = 0x16a, 438c2ecf20Sopenharmony_ci MT7663_EE_HW_CONF1 = 0x1b0, 448c2ecf20Sopenharmony_ci MT7663_EE_TX0_5G_G0_TARGET_POWER = 0x245, 458c2ecf20Sopenharmony_ci MT7663_EE_TX1_5G_G0_TARGET_POWER = 0x2b5, 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci MT7615_EE_MAX = 0x3bf, 488c2ecf20Sopenharmony_ci MT7622_EE_MAX = 0x3db, 498c2ecf20Sopenharmony_ci MT7663_EE_MAX = 0x400, 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define MT_EE_RATE_POWER_MASK GENMASK(5, 0) 538c2ecf20Sopenharmony_ci#define MT_EE_RATE_POWER_SIGN BIT(6) 548c2ecf20Sopenharmony_ci#define MT_EE_RATE_POWER_EN BIT(7) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define MT_EE_CALDATA_FLASH_TX_DPD BIT(0) 578c2ecf20Sopenharmony_ci#define MT_EE_CALDATA_FLASH_RX_CAL BIT(1) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define MT_EE_NIC_CONF_TX_MASK GENMASK(7, 4) 608c2ecf20Sopenharmony_ci#define MT_EE_NIC_CONF_RX_MASK GENMASK(3, 0) 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define MT_EE_HW_CONF1_TX_MASK GENMASK(2, 0) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define MT_EE_NIC_CONF_TSSI_2G BIT(5) 658c2ecf20Sopenharmony_ci#define MT_EE_NIC_CONF_TSSI_5G BIT(6) 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define MT_EE_NIC_WIFI_CONF_BAND_SEL GENMASK(5, 4) 688c2ecf20Sopenharmony_cienum mt7615_eeprom_band { 698c2ecf20Sopenharmony_ci MT_EE_DUAL_BAND, 708c2ecf20Sopenharmony_ci MT_EE_5GHZ, 718c2ecf20Sopenharmony_ci MT_EE_2GHZ, 728c2ecf20Sopenharmony_ci MT_EE_DBDC, 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cienum mt7615_channel_group { 768c2ecf20Sopenharmony_ci MT_CH_5G_JAPAN, 778c2ecf20Sopenharmony_ci MT_CH_5G_UNII_1, 788c2ecf20Sopenharmony_ci MT_CH_5G_UNII_2A, 798c2ecf20Sopenharmony_ci MT_CH_5G_UNII_2B, 808c2ecf20Sopenharmony_ci MT_CH_5G_UNII_2E_1, 818c2ecf20Sopenharmony_ci MT_CH_5G_UNII_2E_2, 828c2ecf20Sopenharmony_ci MT_CH_5G_UNII_2E_3, 838c2ecf20Sopenharmony_ci MT_CH_5G_UNII_3, 848c2ecf20Sopenharmony_ci __MT_CH_MAX 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistatic inline enum mt7615_channel_group 888c2ecf20Sopenharmony_cimt7615_get_channel_group(int channel) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci if (channel >= 184 && channel <= 196) 918c2ecf20Sopenharmony_ci return MT_CH_5G_JAPAN; 928c2ecf20Sopenharmony_ci if (channel <= 48) 938c2ecf20Sopenharmony_ci return MT_CH_5G_UNII_1; 948c2ecf20Sopenharmony_ci if (channel <= 64) 958c2ecf20Sopenharmony_ci return MT_CH_5G_UNII_2A; 968c2ecf20Sopenharmony_ci if (channel <= 114) 978c2ecf20Sopenharmony_ci return MT_CH_5G_UNII_2E_1; 988c2ecf20Sopenharmony_ci if (channel <= 144) 998c2ecf20Sopenharmony_ci return MT_CH_5G_UNII_2E_2; 1008c2ecf20Sopenharmony_ci if (channel <= 161) 1018c2ecf20Sopenharmony_ci return MT_CH_5G_UNII_2E_3; 1028c2ecf20Sopenharmony_ci return MT_CH_5G_UNII_3; 1038c2ecf20Sopenharmony_ci} 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic inline bool 1068c2ecf20Sopenharmony_cimt7615_ext_pa_enabled(struct mt7615_dev *dev, enum nl80211_band band) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci u8 *eep = dev->mt76.eeprom.data; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci if (band == NL80211_BAND_5GHZ) 1118c2ecf20Sopenharmony_ci return !(eep[MT_EE_NIC_CONF_1 + 1] & MT_EE_NIC_CONF_TSSI_5G); 1128c2ecf20Sopenharmony_ci else 1138c2ecf20Sopenharmony_ci return !(eep[MT_EE_NIC_CONF_1 + 1] & MT_EE_NIC_CONF_TSSI_2G); 1148c2ecf20Sopenharmony_ci} 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#endif 117