WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt76 / mt7915 / eeprom.h
blob6712032b40dfc0ea94af0f5a19e817a6c519239e
1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2020 MediaTek Inc. */
4 #ifndef __MT7915_EEPROM_H
5 #define __MT7915_EEPROM_H
7 #include "mt7915.h"
9 struct cal_data {
10 u8 count;
11 u16 offset[60];
14 enum mt7915_eeprom_field {
15 MT_EE_CHIP_ID = 0x000,
16 MT_EE_VERSION = 0x002,
17 MT_EE_MAC_ADDR = 0x004,
18 MT_EE_MAC_ADDR2 = 0x00a,
19 MT_EE_DDIE_FT_VERSION = 0x050,
20 MT_EE_WIFI_CONF = 0x190,
21 MT_EE_TX0_POWER_2G = 0x2fc,
22 MT_EE_TX0_POWER_5G = 0x34b,
23 MT_EE_ADIE_FT_VERSION = 0x9a0,
25 __MT_EE_MAX = 0xe00
28 #define MT_EE_WIFI_CONF_TX_MASK GENMASK(2, 0)
29 #define MT_EE_WIFI_CONF_BAND_SEL GENMASK(7, 6)
30 #define MT_EE_WIFI_CONF_TSSI0_2G BIT(0)
31 #define MT_EE_WIFI_CONF_TSSI0_5G BIT(2)
32 #define MT_EE_WIFI_CONF_TSSI1_5G BIT(4)
34 enum mt7915_eeprom_band {
35 MT_EE_DUAL_BAND,
36 MT_EE_5GHZ,
37 MT_EE_2GHZ,
38 MT_EE_DBDC,
41 #define SKU_DELTA_VAL GENMASK(5, 0)
42 #define SKU_DELTA_ADD BIT(6)
43 #define SKU_DELTA_EN BIT(7)
45 enum mt7915_sku_delta_group {
46 SKU_CCK_GROUP0,
47 SKU_CCK_GROUP1,
49 SKU_OFDM_GROUP0 = 0,
50 SKU_OFDM_GROUP1,
51 SKU_OFDM_GROUP2,
52 SKU_OFDM_GROUP3,
53 SKU_OFDM_GROUP4,
55 SKU_MCS_GROUP0 = 0,
56 SKU_MCS_GROUP1,
57 SKU_MCS_GROUP2,
58 SKU_MCS_GROUP3,
59 SKU_MCS_GROUP4,
60 SKU_MCS_GROUP5,
61 SKU_MCS_GROUP6,
62 SKU_MCS_GROUP7,
63 SKU_MCS_GROUP8,
64 SKU_MCS_GROUP9,
67 enum mt7915_sku_rate_group {
68 SKU_CCK,
69 SKU_OFDM,
70 SKU_HT_BW20,
71 SKU_HT_BW40,
72 SKU_VHT_BW20,
73 SKU_VHT_BW40,
74 SKU_VHT_BW80,
75 SKU_VHT_BW160,
76 SKU_HE_RU26,
77 SKU_HE_RU52,
78 SKU_HE_RU106,
79 SKU_HE_RU242,
80 SKU_HE_RU484,
81 SKU_HE_RU996,
82 SKU_HE_RU2x996,
83 MAX_SKU_RATE_GROUP_NUM,
86 struct sku_group {
87 u8 len;
88 u16 offset[2];
89 const u8 *delta_map;
92 static inline int
93 mt7915_get_channel_group(int channel)
95 if (channel >= 184 && channel <= 196)
96 return 0;
97 if (channel <= 48)
98 return 1;
99 if (channel <= 64)
100 return 2;
101 if (channel <= 96)
102 return 3;
103 if (channel <= 112)
104 return 4;
105 if (channel <= 128)
106 return 5;
107 if (channel <= 144)
108 return 6;
109 return 7;
112 static inline bool
113 mt7915_tssi_enabled(struct mt7915_dev *dev, enum nl80211_band band)
115 u8 *eep = dev->mt76.eeprom.data;
117 /* TODO: DBDC */
118 if (band == NL80211_BAND_5GHZ)
119 return eep[MT_EE_WIFI_CONF + 7] & MT_EE_WIFI_CONF_TSSI0_5G;
120 else
121 return eep[MT_EE_WIFI_CONF + 7] & MT_EE_WIFI_CONF_TSSI0_2G;
124 extern const struct sku_group mt7915_sku_groups[];
126 #endif