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(2, 0)
35 #define MT_EE_WIFI_CONF2_TX_PATH_BAND2		GENMASK(5, 3)
36 #define MT_EE_WIFI_CONF4_STREAM_NUM_BAND0	GENMASK(5, 3)
37 #define MT_EE_WIFI_CONF5_STREAM_NUM_BAND1	GENMASK(2, 0)
38 #define MT_EE_WIFI_CONF5_STREAM_NUM_BAND2	GENMASK(5, 3)
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 };
50 
51 static inline int
mt7996_get_channel_group_5g(int channel)52 mt7996_get_channel_group_5g(int channel)
53 {
54 	if (channel <= 64)
55 		return 0;
56 	if (channel <= 96)
57 		return 1;
58 	if (channel <= 128)
59 		return 2;
60 	if (channel <= 144)
61 		return 3;
62 	return 4;
63 }
64 
65 static inline int
mt7996_get_channel_group_6g(int channel)66 mt7996_get_channel_group_6g(int channel)
67 {
68 	if (channel <= 29)
69 		return 0;
70 
71 	return DIV_ROUND_UP(channel - 29, 32);
72 }
73 
74 #endif
75