1 /* SPDX-License-Identifier: ISC */
2 /*
3 * Copyright (C) 2022 MediaTek Inc.
4 */
5
6 #ifndef __MT7996_EEPROM_H
7 #define __MT7996_EEPROM_H
8
9 #include "mt7996.h"
10
11 enum mt7996_eeprom_field {
12 MT_EE_CHIP_ID = 0x000,
13 MT_EE_VERSION = 0x002,
14 MT_EE_MAC_ADDR = 0x004,
15 MT_EE_MAC_ADDR2 = 0x00a,
16 MT_EE_WIFI_CONF = 0x190,
17 MT_EE_MAC_ADDR3 = 0x2c0,
18 MT_EE_RATE_DELTA_2G = 0x1400,
19 MT_EE_RATE_DELTA_5G = 0x147d,
20 MT_EE_RATE_DELTA_6G = 0x154a,
21 MT_EE_TX0_POWER_2G = 0x1300,
22 MT_EE_TX0_POWER_5G = 0x1301,
23 MT_EE_TX0_POWER_6G = 0x1310,
24
25 __MT_EE_MAX = 0x1dff,
26 };
27
28 #define MT_EE_WIFI_CONF0_TX_PATH GENMASK(2, 0)
29 #define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(2, 0)
30 #define MT_EE_WIFI_CONF1_BAND_SEL GENMASK(5, 3)
31 #define MT_EE_WIFI_CONF2_BAND_SEL GENMASK(2, 0)
32
33 #define MT_EE_WIFI_CONF1_TX_PATH_BAND0 GENMASK(5, 3)
34 #define MT_EE_WIFI_CONF2_TX_PATH_BAND1 GENMASK(5, 3)
35 #define MT_EE_WIFI_CONF2_TX_PATH_BAND2 GENMASK(2, 0)
36 #define MT_EE_WIFI_CONF4_STREAM_NUM_BAND0 GENMASK(5, 3)
37 #define MT_EE_WIFI_CONF5_STREAM_NUM_BAND1 GENMASK(5, 3)
38 #define MT_EE_WIFI_CONF5_STREAM_NUM_BAND2 GENMASK(2, 0)
39
40 #define MT_EE_RATE_DELTA_MASK GENMASK(5, 0)
41 #define MT_EE_RATE_DELTA_SIGN BIT(6)
42 #define MT_EE_RATE_DELTA_EN BIT(7)
43
44 enum mt7996_eeprom_band {
45 MT_EE_BAND_SEL_DEFAULT,
46 MT_EE_BAND_SEL_2GHZ,
47 MT_EE_BAND_SEL_5GHZ,
48 MT_EE_BAND_SEL_6GHZ,
49 MT_EE_BAND_SEL_5GHZ_6GHZ,
50 };
51
52 static inline int
mt7996_get_channel_group_5g(int channel)53 mt7996_get_channel_group_5g(int channel)
54 {
55 if (channel <= 64)
56 return 0;
57 if (channel <= 96)
58 return 1;
59 if (channel <= 128)
60 return 2;
61 if (channel <= 144)
62 return 3;
63 return 4;
64 }
65
66 static inline int
mt7996_get_channel_group_6g(int channel)67 mt7996_get_channel_group_6g(int channel)
68 {
69 if (channel <= 29)
70 return 0;
71
72 return DIV_ROUND_UP(channel - 29, 32);
73 }
74
75 #endif
76