1 /*
2  * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef __MT76x2_MCU_H
18 #define __MT76x2_MCU_H
19 
20 #include "../mt76x02_mcu.h"
21 
22 /* Register definitions */
23 #define MT_MCU_CPU_CTL			0x0704
24 #define MT_MCU_CLOCK_CTL		0x0708
25 #define MT_MCU_PCIE_REMAP_BASE1		0x0740
26 #define MT_MCU_PCIE_REMAP_BASE2		0x0744
27 #define MT_MCU_PCIE_REMAP_BASE3		0x0748
28 
29 #define MT_MCU_ROM_PATCH_OFFSET		0x80000
30 #define MT_MCU_ROM_PATCH_ADDR		0x90000
31 
32 #define MT_MCU_ILM_OFFSET		0x80000
33 
34 #define MT_MCU_DLM_OFFSET		0x100000
35 #define MT_MCU_DLM_ADDR			0x90000
36 #define MT_MCU_DLM_ADDR_E3		0x90800
37 
38 enum mcu_calibration {
39 	MCU_CAL_R = 1,
40 	MCU_CAL_TEMP_SENSOR,
41 	MCU_CAL_RXDCOC,
42 	MCU_CAL_RC,
43 	MCU_CAL_SX_LOGEN,
44 	MCU_CAL_LC,
45 	MCU_CAL_TX_LOFT,
46 	MCU_CAL_TXIQ,
47 	MCU_CAL_TSSI,
48 	MCU_CAL_TSSI_COMP,
49 	MCU_CAL_DPD,
50 	MCU_CAL_RXIQC_FI,
51 	MCU_CAL_RXIQC_FD,
52 	MCU_CAL_PWRON,
53 	MCU_CAL_TX_SHAPING,
54 };
55 
56 enum mt76x2_mcu_cr_mode {
57 	MT_RF_CR,
58 	MT_BBP_CR,
59 	MT_RF_BBP_CR,
60 	MT_HL_TEMP_CR_UPDATE,
61 };
62 
63 struct mt76x2_tssi_comp {
64 	u8 pa_mode;
65 	u8 cal_mode;
66 	u16 pad;
67 
68 	u8 slope0;
69 	u8 slope1;
70 	u8 offset0;
71 	u8 offset1;
72 } __packed __aligned(4);
73 
74 int mt76x2_mcu_tssi_comp(struct mt76x02_dev *dev, struct mt76x2_tssi_comp *tssi_data);
75 int mt76x2_mcu_init_gain(struct mt76x02_dev *dev, u8 channel, u32 gain,
76 			 bool force);
77 
78 #endif
79