1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2020 MediaTek Inc. */
3
4 #ifndef __MT7915_EEPROM_H
5 #define __MT7915_EEPROM_H
6
7 #include "mt7915.h"
8
9 struct cal_data {
10 u8 count;
11 u16 offset[60];
12 };
13
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_DDIE_FT_VERSION = 0x050,
19 MT_EE_WIFI_CONF = 0x190,
20 MT_EE_TX0_POWER_2G = 0x2fc,
21 MT_EE_TX0_POWER_5G = 0x34b,
22 MT_EE_ADIE_FT_VERSION = 0x9a0,
23
24 __MT_EE_MAX = 0xe00
25 };
26
27 #define MT_EE_WIFI_CONF_TX_MASK GENMASK(2, 0)
28 #define MT_EE_WIFI_CONF_BAND_SEL GENMASK(7, 6)
29 #define MT_EE_WIFI_CONF_TSSI0_2G BIT(0)
30 #define MT_EE_WIFI_CONF_TSSI0_5G BIT(2)
31 #define MT_EE_WIFI_CONF_TSSI1_5G BIT(4)
32
33 enum mt7915_eeprom_band {
34 MT_EE_DUAL_BAND,
35 MT_EE_5GHZ,
36 MT_EE_2GHZ,
37 MT_EE_DBDC,
38 };
39
40 #define SKU_DELTA_VAL GENMASK(5, 0)
41 #define SKU_DELTA_ADD BIT(6)
42 #define SKU_DELTA_EN BIT(7)
43
44 enum mt7915_sku_delta_group {
45 SKU_CCK_GROUP0,
46 SKU_CCK_GROUP1,
47
48 SKU_OFDM_GROUP0 = 0,
49 SKU_OFDM_GROUP1,
50 SKU_OFDM_GROUP2,
51 SKU_OFDM_GROUP3,
52 SKU_OFDM_GROUP4,
53
54 SKU_MCS_GROUP0 = 0,
55 SKU_MCS_GROUP1,
56 SKU_MCS_GROUP2,
57 SKU_MCS_GROUP3,
58 SKU_MCS_GROUP4,
59 SKU_MCS_GROUP5,
60 SKU_MCS_GROUP6,
61 SKU_MCS_GROUP7,
62 SKU_MCS_GROUP8,
63 SKU_MCS_GROUP9,
64 };
65
66 enum mt7915_sku_rate_group {
67 SKU_CCK,
68 SKU_OFDM,
69 SKU_HT_BW20,
70 SKU_HT_BW40,
71 SKU_VHT_BW20,
72 SKU_VHT_BW40,
73 SKU_VHT_BW80,
74 SKU_VHT_BW160,
75 SKU_HE_RU26,
76 SKU_HE_RU52,
77 SKU_HE_RU106,
78 SKU_HE_RU242,
79 SKU_HE_RU484,
80 SKU_HE_RU996,
81 SKU_HE_RU2x996,
82 MAX_SKU_RATE_GROUP_NUM,
83 };
84
85 struct sku_group {
86 u8 len;
87 u16 offset[2];
88 const u8 *delta_map;
89 };
90
91 static inline int
mt7915_get_channel_group(int channel)92 mt7915_get_channel_group(int channel)
93 {
94 if (channel >= 184 && channel <= 196)
95 return 0;
96 if (channel <= 48)
97 return 1;
98 if (channel <= 64)
99 return 2;
100 if (channel <= 96)
101 return 3;
102 if (channel <= 112)
103 return 4;
104 if (channel <= 128)
105 return 5;
106 if (channel <= 144)
107 return 6;
108 return 7;
109 }
110
111 static inline bool
mt7915_tssi_enabled(struct mt7915_dev * dev,enum nl80211_band band)112 mt7915_tssi_enabled(struct mt7915_dev *dev, enum nl80211_band band)
113 {
114 u8 *eep = dev->mt76.eeprom.data;
115
116 /* TODO: DBDC */
117 if (band == NL80211_BAND_5GHZ)
118 return eep[MT_EE_WIFI_CONF + 7] & MT_EE_WIFI_CONF_TSSI0_5G;
119 else
120 return eep[MT_EE_WIFI_CONF + 7] & MT_EE_WIFI_CONF_TSSI0_2G;
121 }
122
123 extern const struct sku_group mt7915_sku_groups[];
124
125 #endif
126