104b8e659SRyder Lee /* SPDX-License-Identifier: ISC */
204b8e659SRyder Lee /* Copyright (C) 2019 MediaTek Inc. */
304b8e659SRyder Lee 
404b8e659SRyder Lee #ifndef __MT7615_H
504b8e659SRyder Lee #define __MT7615_H
604b8e659SRyder Lee 
708523a2aSLorenzo Bianconi #include <linux/completion.h>
804b8e659SRyder Lee #include <linux/interrupt.h>
904b8e659SRyder Lee #include <linux/ktime.h>
1035da599fSFelix Fietkau #include <linux/regmap.h>
1104b8e659SRyder Lee #include "../mt76.h"
1204b8e659SRyder Lee #include "regs.h"
1304b8e659SRyder Lee 
1404b8e659SRyder Lee #define MT7615_MAX_INTERFACES		4
1549f1132cSRyder Lee #define MT7615_MAX_WMM_SETS		4
168f997dddSLorenzo Bianconi #define MT7663_WTBL_SIZE		32
1704b8e659SRyder Lee #define MT7615_WTBL_SIZE		128
188f997dddSLorenzo Bianconi #define MT7615_WTBL_RESERVED		(mt7615_wtbl_size(dev) - 1)
1904b8e659SRyder Lee #define MT7615_WTBL_STA			(MT7615_WTBL_RESERVED - \
2004b8e659SRyder Lee 					 MT7615_MAX_INTERFACES)
2104b8e659SRyder Lee 
22de5ff3c9SLorenzo Bianconi #define MT7615_PM_TIMEOUT		(HZ / 12)
23457d19c7SLorenzo Bianconi #define MT7615_WATCHDOG_TIME		(HZ / 10)
24fcdfc29eSLorenzo Bianconi #define MT7615_HW_SCAN_TIMEOUT		(HZ / 10)
2561c4fa72SFelix Fietkau #define MT7615_RESET_TIMEOUT		(30 * HZ)
2604b8e659SRyder Lee #define MT7615_RATE_RETRY		2
2704b8e659SRyder Lee 
2804b8e659SRyder Lee #define MT7615_TX_RING_SIZE		1024
29cdad4874SFelix Fietkau #define MT7615_TX_MGMT_RING_SIZE	128
3004b8e659SRyder Lee #define MT7615_TX_MCU_RING_SIZE		128
3104b8e659SRyder Lee #define MT7615_TX_FWDL_RING_SIZE	128
3204b8e659SRyder Lee 
3304b8e659SRyder Lee #define MT7615_RX_RING_SIZE		1024
3404b8e659SRyder Lee #define MT7615_RX_MCU_RING_SIZE		512
3504b8e659SRyder Lee 
36894b7767SLorenzo Bianconi #define MT7615_DRV_OWN_RETRY_COUNT	10
37894b7767SLorenzo Bianconi 
389d4d0d06SLorenzo Bianconi #define MT7615_FIRMWARE_CR4		"mediatek/mt7615_cr4.bin"
399d4d0d06SLorenzo Bianconi #define MT7615_FIRMWARE_N9		"mediatek/mt7615_n9.bin"
409d4d0d06SLorenzo Bianconi #define MT7615_ROM_PATCH		"mediatek/mt7615_rom_patch.bin"
4104b8e659SRyder Lee 
4235da599fSFelix Fietkau #define MT7622_FIRMWARE_N9		"mediatek/mt7622_n9.bin"
4335da599fSFelix Fietkau #define MT7622_ROM_PATCH		"mediatek/mt7622_rom_patch.bin"
4435da599fSFelix Fietkau 
456849e29eSRyder Lee #define MT7615_FIRMWARE_V1		1
466849e29eSRyder Lee #define MT7615_FIRMWARE_V2		2
47f40ac0f3SLorenzo Bianconi #define MT7615_FIRMWARE_V3		3
48f40ac0f3SLorenzo Bianconi 
49f2dc8ea1SLorenzo Bianconi #define MT7663_OFFLOAD_ROM_PATCH	"mediatek/mt7663pr2h.bin"
50f2dc8ea1SLorenzo Bianconi #define MT7663_OFFLOAD_FIRMWARE_N9	"mediatek/mt7663_n9_v3.bin"
51f2dc8ea1SLorenzo Bianconi #define MT7663_ROM_PATCH		"mediatek/mt7663pr2h_rebb.bin"
52f2dc8ea1SLorenzo Bianconi #define MT7663_FIRMWARE_N9		"mediatek/mt7663_n9_rebb.bin"
536849e29eSRyder Lee 
5404b8e659SRyder Lee #define MT7615_EEPROM_SIZE		1024
5504b8e659SRyder Lee #define MT7615_TOKEN_SIZE		4096
5604b8e659SRyder Lee 
5749de79adSLorenzo Bianconi #define MT_FRAC_SCALE		12
5849de79adSLorenzo Bianconi #define MT_FRAC(val, div)	(((val) << MT_FRAC_SCALE) / (div))
5949de79adSLorenzo Bianconi 
6027ae7219SFelix Fietkau #define MT_CHFREQ_VALID		BIT(7)
6127ae7219SFelix Fietkau #define MT_CHFREQ_DBDC_IDX	BIT(6)
6227ae7219SFelix Fietkau #define MT_CHFREQ_SEQ		GENMASK(5, 0)
6327ae7219SFelix Fietkau 
64a25c888fSRyder Lee #define MT7615_BAR_RATE_DEFAULT		0x4b /* OFDM 6M */
65a25c888fSRyder Lee #define MT7615_CFEND_RATE_DEFAULT	0x49 /* OFDM 24M */
66183d1fcfSLorenzo Bianconi #define MT7615_CFEND_RATE_11B		0x03 /* 11B LP, 11M */
67183d1fcfSLorenzo Bianconi 
68fcdfc29eSLorenzo Bianconi #define MT7615_SCAN_IE_LEN		600
6920305f98SLorenzo Bianconi #define MT7615_MAX_SCHED_SCAN_INTERVAL	10
7020305f98SLorenzo Bianconi #define MT7615_MAX_SCHED_SCAN_SSID	10
7120305f98SLorenzo Bianconi #define MT7615_MAX_SCAN_MATCH		16
72fcdfc29eSLorenzo Bianconi 
7304b8e659SRyder Lee struct mt7615_vif;
7404b8e659SRyder Lee struct mt7615_sta;
752ce73efeSLorenzo Bianconi struct mt7615_dfs_pulse;
762ce73efeSLorenzo Bianconi struct mt7615_dfs_pattern;
77294f17aeSLorenzo Bianconi enum mt7615_cipher_type;
7804b8e659SRyder Lee 
7904b8e659SRyder Lee enum mt7615_hw_txq_id {
8004b8e659SRyder Lee 	MT7615_TXQ_MAIN,
8104b8e659SRyder Lee 	MT7615_TXQ_EXT,
8204b8e659SRyder Lee 	MT7615_TXQ_MCU,
8304b8e659SRyder Lee 	MT7615_TXQ_FWDL,
8404b8e659SRyder Lee };
8504b8e659SRyder Lee 
86cdad4874SFelix Fietkau enum mt7622_hw_txq_id {
87cdad4874SFelix Fietkau 	MT7622_TXQ_AC0,
88cdad4874SFelix Fietkau 	MT7622_TXQ_AC1,
89cdad4874SFelix Fietkau 	MT7622_TXQ_AC2,
90cdad4874SFelix Fietkau 	MT7622_TXQ_FWDL = MT7615_TXQ_FWDL,
91cdad4874SFelix Fietkau 	MT7622_TXQ_AC3,
92cdad4874SFelix Fietkau 	MT7622_TXQ_MGMT,
93cdad4874SFelix Fietkau 	MT7622_TXQ_MCU = 15,
94cdad4874SFelix Fietkau };
95cdad4874SFelix Fietkau 
964af81f02SFelix Fietkau struct mt7615_rate_set {
974af81f02SFelix Fietkau 	struct ieee80211_tx_rate probe_rate;
984af81f02SFelix Fietkau 	struct ieee80211_tx_rate rates[4];
994af81f02SFelix Fietkau };
1004af81f02SFelix Fietkau 
1018f93af9cSLorenzo Bianconi struct mt7615_rate_desc {
1028f93af9cSLorenzo Bianconi 	bool rateset;
1038f93af9cSLorenzo Bianconi 	u16 probe_val;
1048f93af9cSLorenzo Bianconi 	u16 val[4];
1058f93af9cSLorenzo Bianconi 	u8 bw_idx;
1068f93af9cSLorenzo Bianconi 	u8 bw;
1078f93af9cSLorenzo Bianconi };
1088f93af9cSLorenzo Bianconi 
1097d9f1d10SLorenzo Bianconi enum mt7615_wtbl_desc_type {
1107d9f1d10SLorenzo Bianconi 	MT7615_WTBL_RATE_DESC,
1117d9f1d10SLorenzo Bianconi 	MT7615_WTBL_KEY_DESC
1127d9f1d10SLorenzo Bianconi };
1137d9f1d10SLorenzo Bianconi 
1147d9f1d10SLorenzo Bianconi struct mt7615_key_desc {
1157d9f1d10SLorenzo Bianconi 	enum set_key_cmd cmd;
1167d9f1d10SLorenzo Bianconi 	u32 cipher;
1177d9f1d10SLorenzo Bianconi 	s8 keyidx;
1187d9f1d10SLorenzo Bianconi 	u8 keylen;
1197d9f1d10SLorenzo Bianconi 	u8 *key;
1207d9f1d10SLorenzo Bianconi };
1217d9f1d10SLorenzo Bianconi 
1227d9f1d10SLorenzo Bianconi struct mt7615_wtbl_desc {
1237d9f1d10SLorenzo Bianconi 	struct list_head node;
1247d9f1d10SLorenzo Bianconi 
1257d9f1d10SLorenzo Bianconi 	enum mt7615_wtbl_desc_type type;
1267d9f1d10SLorenzo Bianconi 	struct mt7615_sta *sta;
1277d9f1d10SLorenzo Bianconi 
1287d9f1d10SLorenzo Bianconi 	union {
1297d9f1d10SLorenzo Bianconi 		struct mt7615_rate_desc rate;
1307d9f1d10SLorenzo Bianconi 		struct mt7615_key_desc key;
1317d9f1d10SLorenzo Bianconi 	};
1327d9f1d10SLorenzo Bianconi };
1337d9f1d10SLorenzo Bianconi 
13404b8e659SRyder Lee struct mt7615_sta {
13504b8e659SRyder Lee 	struct mt76_wcid wcid; /* must be first */
13604b8e659SRyder Lee 
13704b8e659SRyder Lee 	struct mt7615_vif *vif;
13804b8e659SRyder Lee 
139b2c2f029SLorenzo Bianconi 	struct list_head poll_list;
140b2c2f029SLorenzo Bianconi 	u32 airtime_ac[8];
141b2c2f029SLorenzo Bianconi 
1424af81f02SFelix Fietkau 	struct ieee80211_tx_rate rates[4];
1434af81f02SFelix Fietkau 
1444af81f02SFelix Fietkau 	struct mt7615_rate_set rateset[2];
1454af81f02SFelix Fietkau 	u32 rate_set_tsf;
1464af81f02SFelix Fietkau 
14704b8e659SRyder Lee 	u8 rate_count;
14804b8e659SRyder Lee 	u8 n_rates;
14904b8e659SRyder Lee 
15004b8e659SRyder Lee 	u8 rate_probe;
15104b8e659SRyder Lee };
15204b8e659SRyder Lee 
15304b8e659SRyder Lee struct mt7615_vif {
15404b8e659SRyder Lee 	u8 idx;
15504b8e659SRyder Lee 	u8 omac_idx;
15604b8e659SRyder Lee 	u8 band_idx;
15704b8e659SRyder Lee 	u8 wmm_idx;
158fcdfc29eSLorenzo Bianconi 	u8 scan_seq_num;
15904b8e659SRyder Lee 
16004b8e659SRyder Lee 	struct mt7615_sta sta;
16104b8e659SRyder Lee };
16204b8e659SRyder Lee 
163679b23feSRyder Lee struct mib_stats {
164b7825ca0SRyder Lee 	u16 ack_fail_cnt;
165b7825ca0SRyder Lee 	u16 fcs_err_cnt;
166b7825ca0SRyder Lee 	u16 rts_cnt;
167b7825ca0SRyder Lee 	u16 rts_retries_cnt;
168aef16345SRyder Lee 	u16 ba_miss_cnt;
169aef16345SRyder Lee 	unsigned long aggr_per;
170679b23feSRyder Lee };
171679b23feSRyder Lee 
172fdd2e570SFelix Fietkau struct mt7615_phy {
173fdd2e570SFelix Fietkau 	struct mt76_phy *mt76;
174fdd2e570SFelix Fietkau 	struct mt7615_dev *dev;
175fdd2e570SFelix Fietkau 
1764f0bce1cSFelix Fietkau 	struct ieee80211_vif *monitor_vif;
1774f0bce1cSFelix Fietkau 
178fdd2e570SFelix Fietkau 	u32 rxfilter;
179ac3ef85cSFelix Fietkau 	u32 omac_mask;
180d446a20fSFelix Fietkau 
181e5051965SFelix Fietkau 	u16 noise;
182e5051965SFelix Fietkau 
183594034b7SLorenzo Bianconi 	bool scs_en;
184594034b7SLorenzo Bianconi 
185d446a20fSFelix Fietkau 	unsigned long last_cca_adj;
186d446a20fSFelix Fietkau 	int false_cca_ofdm, false_cca_cck;
187d446a20fSFelix Fietkau 	s8 ofdm_sensitivity;
188d446a20fSFelix Fietkau 	s8 cck_sensitivity;
1895dabdf71SFelix Fietkau 
1902bed2a3eSFelix Fietkau 	u16 chainmask;
1912bed2a3eSFelix Fietkau 
192183d1fcfSLorenzo Bianconi 	s16 coverage_class;
193183d1fcfSLorenzo Bianconi 	u8 slottime;
194183d1fcfSLorenzo Bianconi 
1950e544cb5SFelix Fietkau 	u8 chfreq;
1965dabdf71SFelix Fietkau 	u8 rdd_state;
1975dabdf71SFelix Fietkau 	int dfs_state;
19827ae7219SFelix Fietkau 
19927ae7219SFelix Fietkau 	__le32 rx_ampdu_ts;
20027ae7219SFelix Fietkau 	u32 ampdu_ref;
201679b23feSRyder Lee 
202679b23feSRyder Lee 	struct mib_stats mib;
203fcdfc29eSLorenzo Bianconi 
2044fcf6e77SLorenzo Bianconi 	struct delayed_work mac_work;
2054fcf6e77SLorenzo Bianconi 	u8 mac_work_count;
2064fcf6e77SLorenzo Bianconi 
20720305f98SLorenzo Bianconi 	struct sk_buff_head scan_event_list;
208fcdfc29eSLorenzo Bianconi 	struct delayed_work scan_work;
2097f8ebafeSLorenzo Bianconi 
2107307f296SLorenzo Bianconi 	struct work_struct roc_work;
2117307f296SLorenzo Bianconi 	struct timer_list roc_timer;
2127307f296SLorenzo Bianconi 	wait_queue_head_t roc_wait;
2137307f296SLorenzo Bianconi 	bool roc_grant;
214fdd2e570SFelix Fietkau };
215fdd2e570SFelix Fietkau 
2166f4d7cc8SLorenzo Bianconi #define mt7615_mcu_add_tx_ba(dev, ...)	(dev)->mcu_ops->add_tx_ba((dev), __VA_ARGS__)
2176f4d7cc8SLorenzo Bianconi #define mt7615_mcu_add_rx_ba(dev, ...)	(dev)->mcu_ops->add_rx_ba((dev), __VA_ARGS__)
21899c457d9SLorenzo Bianconi #define mt7615_mcu_sta_add(dev, ...)	(dev)->mcu_ops->sta_add((dev),  __VA_ARGS__)
219062c3699SLorenzo Bianconi #define mt7615_mcu_add_dev_info(dev, ...) (dev)->mcu_ops->add_dev_info((dev),  __VA_ARGS__)
2205d3a4a4bSLorenzo Bianconi #define mt7615_mcu_add_bss_info(phy, ...) (phy->dev)->mcu_ops->add_bss_info((phy),  __VA_ARGS__)
221062c3699SLorenzo Bianconi #define mt7615_mcu_add_beacon(dev, ...)	(dev)->mcu_ops->add_beacon_offload((dev),  __VA_ARGS__)
222062c3699SLorenzo Bianconi #define mt7615_mcu_set_pm(dev, ...)	(dev)->mcu_ops->set_pm_state((dev),  __VA_ARGS__)
223186b659cSLorenzo Bianconi #define mt7615_mcu_set_drv_ctrl(dev)	(dev)->mcu_ops->set_drv_ctrl((dev))
224186b659cSLorenzo Bianconi #define mt7615_mcu_set_fw_ctrl(dev)	(dev)->mcu_ops->set_fw_ctrl((dev))
2256f4d7cc8SLorenzo Bianconi struct mt7615_mcu_ops {
2266f4d7cc8SLorenzo Bianconi 	int (*add_tx_ba)(struct mt7615_dev *dev,
2276f4d7cc8SLorenzo Bianconi 			 struct ieee80211_ampdu_params *params,
2286f4d7cc8SLorenzo Bianconi 			 bool enable);
2296f4d7cc8SLorenzo Bianconi 	int (*add_rx_ba)(struct mt7615_dev *dev,
2306f4d7cc8SLorenzo Bianconi 			 struct ieee80211_ampdu_params *params,
2316f4d7cc8SLorenzo Bianconi 			 bool enable);
23299c457d9SLorenzo Bianconi 	int (*sta_add)(struct mt7615_dev *dev,
23399c457d9SLorenzo Bianconi 		       struct ieee80211_vif *vif,
23499c457d9SLorenzo Bianconi 		       struct ieee80211_sta *sta, bool enable);
235062c3699SLorenzo Bianconi 	int (*add_dev_info)(struct mt7615_dev *dev,
236062c3699SLorenzo Bianconi 			    struct ieee80211_vif *vif, bool enable);
2375d3a4a4bSLorenzo Bianconi 	int (*add_bss_info)(struct mt7615_phy *phy, struct ieee80211_vif *vif,
238f5596850SLorenzo Bianconi 			    struct ieee80211_sta *sta, bool enable);
239062c3699SLorenzo Bianconi 	int (*add_beacon_offload)(struct mt7615_dev *dev,
240062c3699SLorenzo Bianconi 				  struct ieee80211_hw *hw,
241062c3699SLorenzo Bianconi 				  struct ieee80211_vif *vif, bool enable);
242062c3699SLorenzo Bianconi 	int (*set_pm_state)(struct mt7615_dev *dev, int band, int state);
243186b659cSLorenzo Bianconi 	int (*set_drv_ctrl)(struct mt7615_dev *dev);
244186b659cSLorenzo Bianconi 	int (*set_fw_ctrl)(struct mt7615_dev *dev);
2456f4d7cc8SLorenzo Bianconi };
2466f4d7cc8SLorenzo Bianconi 
24704b8e659SRyder Lee struct mt7615_dev {
248ac24dd35SFelix Fietkau 	union { /* must be first */
249ac24dd35SFelix Fietkau 		struct mt76_dev mt76;
250ac24dd35SFelix Fietkau 		struct mt76_phy mphy;
251ac24dd35SFelix Fietkau 	};
252ac24dd35SFelix Fietkau 
253557b5a17SFelix Fietkau 	const struct mt76_bus_ops *bus_ops;
2549b90ab32SFelix Fietkau 	struct tasklet_struct irq_tasklet;
2559b90ab32SFelix Fietkau 
256fdd2e570SFelix Fietkau 	struct mt7615_phy phy;
25704b8e659SRyder Lee 	u32 omac_mask;
25804b8e659SRyder Lee 
2590f2173f0SFelix Fietkau 	u16 chainmask;
2600f2173f0SFelix Fietkau 
261635cb010SFelix Fietkau 	struct ieee80211_ops *ops;
2626f4d7cc8SLorenzo Bianconi 	const struct mt7615_mcu_ops *mcu_ops;
26335da599fSFelix Fietkau 	struct regmap *infracfg;
26494f83b66SLorenzo Bianconi 	const u32 *reg_map;
26535da599fSFelix Fietkau 
266c3c25d09SFelix Fietkau 	struct work_struct mcu_work;
267c3c25d09SFelix Fietkau 
26861c4fa72SFelix Fietkau 	struct work_struct reset_work;
26961c4fa72SFelix Fietkau 	wait_queue_head_t reset_wait;
27061c4fa72SFelix Fietkau 	u32 reset_state;
27161c4fa72SFelix Fietkau 
272b2c2f029SLorenzo Bianconi 	struct list_head sta_poll_list;
273b2c2f029SLorenzo Bianconi 	spinlock_t sta_poll_lock;
274b2c2f029SLorenzo Bianconi 
27570911d96SLorenzo Bianconi 	struct {
27670911d96SLorenzo Bianconi 		u8 n_pulses;
27770911d96SLorenzo Bianconi 		u32 period;
27870911d96SLorenzo Bianconi 		u16 width;
27970911d96SLorenzo Bianconi 		s16 power;
28070911d96SLorenzo Bianconi 	} radar_pattern;
281d67a6646SLorenzo Bianconi 	u32 hw_pattern;
282d67a6646SLorenzo Bianconi 
283f347f81aSFelix Fietkau 	bool fw_debug;
284ad380ad1SFelix Fietkau 	bool flash_eeprom;
2857660a1bdSShayne Chen 	bool dbdc_support;
28649de79adSLorenzo Bianconi 
28704b8e659SRyder Lee 	spinlock_t token_lock;
28804b8e659SRyder Lee 	struct idr token;
2896849e29eSRyder Lee 
2906849e29eSRyder Lee 	u8 fw_ver;
291eb99cc95SLorenzo Bianconi 
292eb99cc95SLorenzo Bianconi 	struct work_struct wtbl_work;
293eb99cc95SLorenzo Bianconi 	struct list_head wd_head;
294dc804058SFelix Fietkau 
295dc804058SFelix Fietkau 	u32 debugfs_rf_wf;
296dc804058SFelix Fietkau 	u32 debugfs_rf_reg;
2974f0bce1cSFelix Fietkau 
2984f0bce1cSFelix Fietkau #ifdef CONFIG_NL80211_TESTMODE
2994f0bce1cSFelix Fietkau 	struct {
3004f0bce1cSFelix Fietkau 		u32 *reg_backup;
3014f0bce1cSFelix Fietkau 
3024f0bce1cSFelix Fietkau 		s16 last_freq_offset;
3034f0bce1cSFelix Fietkau 		u8 last_rcpi[4];
3044f0bce1cSFelix Fietkau 		s8 last_ib_rssi;
3054f0bce1cSFelix Fietkau 		s8 last_wb_rssi;
3064f0bce1cSFelix Fietkau 	} test;
3074f0bce1cSFelix Fietkau #endif
30808523a2aSLorenzo Bianconi 
30908523a2aSLorenzo Bianconi 	struct {
310de5ff3c9SLorenzo Bianconi 		bool enable;
311de5ff3c9SLorenzo Bianconi 
3122b8cdfb2SLorenzo Bianconi 		spinlock_t txq_lock;
3132b8cdfb2SLorenzo Bianconi 		struct {
3142b8cdfb2SLorenzo Bianconi 			struct mt7615_sta *msta;
3152b8cdfb2SLorenzo Bianconi 			struct sk_buff *skb;
3162b8cdfb2SLorenzo Bianconi 		} tx_q[IEEE80211_NUM_ACS];
3172b8cdfb2SLorenzo Bianconi 
31808523a2aSLorenzo Bianconi 		struct work_struct wake_work;
31908523a2aSLorenzo Bianconi 		struct completion wake_cmpl;
320adfd5112SLorenzo Bianconi 
321de5ff3c9SLorenzo Bianconi 		struct delayed_work ps_work;
322adfd5112SLorenzo Bianconi 		unsigned long last_activity;
323ec4b9f38SLorenzo Bianconi 		unsigned long idle_timeout;
32408523a2aSLorenzo Bianconi 	} pm;
32504b8e659SRyder Lee };
32604b8e659SRyder Lee 
3271fec635bSLorenzo Bianconi enum tx_pkt_queue_idx {
3281fec635bSLorenzo Bianconi 	MT_LMAC_AC00,
3291fec635bSLorenzo Bianconi 	MT_LMAC_AC01,
3301fec635bSLorenzo Bianconi 	MT_LMAC_AC02,
3311fec635bSLorenzo Bianconi 	MT_LMAC_AC03,
3321fec635bSLorenzo Bianconi 	MT_LMAC_ALTX0 = 0x10,
3331fec635bSLorenzo Bianconi 	MT_LMAC_BMC0,
3341fec635bSLorenzo Bianconi 	MT_LMAC_BCN0,
3351fec635bSLorenzo Bianconi 	MT_LMAC_PSMP0,
3361fec635bSLorenzo Bianconi 	MT_LMAC_ALTX1,
3371fec635bSLorenzo Bianconi 	MT_LMAC_BMC1,
3381fec635bSLorenzo Bianconi 	MT_LMAC_BCN1,
3391fec635bSLorenzo Bianconi 	MT_LMAC_PSMP1,
3401fec635bSLorenzo Bianconi };
3411fec635bSLorenzo Bianconi 
34204b8e659SRyder Lee enum {
34304b8e659SRyder Lee 	HW_BSSID_0 = 0x0,
34404b8e659SRyder Lee 	HW_BSSID_1,
34504b8e659SRyder Lee 	HW_BSSID_2,
34604b8e659SRyder Lee 	HW_BSSID_3,
34704b8e659SRyder Lee 	HW_BSSID_MAX,
34804b8e659SRyder Lee 	EXT_BSSID_START = 0x10,
34904b8e659SRyder Lee 	EXT_BSSID_1,
35004b8e659SRyder Lee 	EXT_BSSID_2,
35104b8e659SRyder Lee 	EXT_BSSID_3,
35204b8e659SRyder Lee 	EXT_BSSID_4,
35304b8e659SRyder Lee 	EXT_BSSID_5,
35404b8e659SRyder Lee 	EXT_BSSID_6,
35504b8e659SRyder Lee 	EXT_BSSID_7,
35604b8e659SRyder Lee 	EXT_BSSID_8,
35704b8e659SRyder Lee 	EXT_BSSID_9,
35804b8e659SRyder Lee 	EXT_BSSID_10,
35904b8e659SRyder Lee 	EXT_BSSID_11,
36004b8e659SRyder Lee 	EXT_BSSID_12,
36104b8e659SRyder Lee 	EXT_BSSID_13,
36204b8e659SRyder Lee 	EXT_BSSID_14,
36304b8e659SRyder Lee 	EXT_BSSID_15,
36404b8e659SRyder Lee 	EXT_BSSID_END
36504b8e659SRyder Lee };
36604b8e659SRyder Lee 
367d67a6646SLorenzo Bianconi enum {
368d67a6646SLorenzo Bianconi 	MT_RX_SEL0,
369d67a6646SLorenzo Bianconi 	MT_RX_SEL1,
370d67a6646SLorenzo Bianconi };
371d67a6646SLorenzo Bianconi 
372d67a6646SLorenzo Bianconi enum mt7615_rdd_cmd {
373d67a6646SLorenzo Bianconi 	RDD_STOP,
374d67a6646SLorenzo Bianconi 	RDD_START,
375d67a6646SLorenzo Bianconi 	RDD_DET_MODE,
376d67a6646SLorenzo Bianconi 	RDD_DET_STOP,
377d67a6646SLorenzo Bianconi 	RDD_CAC_START,
378d67a6646SLorenzo Bianconi 	RDD_CAC_END,
379d67a6646SLorenzo Bianconi 	RDD_NORMAL_START,
380d67a6646SLorenzo Bianconi 	RDD_DISABLE_DFS_CAL,
381d67a6646SLorenzo Bianconi 	RDD_PULSE_DBG,
382d67a6646SLorenzo Bianconi 	RDD_READ_PULSE,
383d67a6646SLorenzo Bianconi 	RDD_RESUME_BF,
384d67a6646SLorenzo Bianconi };
385d67a6646SLorenzo Bianconi 
386fdd2e570SFelix Fietkau static inline struct mt7615_phy *
387fdd2e570SFelix Fietkau mt7615_hw_phy(struct ieee80211_hw *hw)
388fdd2e570SFelix Fietkau {
389fdd2e570SFelix Fietkau 	struct mt76_phy *phy = hw->priv;
390fdd2e570SFelix Fietkau 
391fdd2e570SFelix Fietkau 	return phy->priv;
392fdd2e570SFelix Fietkau }
393fdd2e570SFelix Fietkau 
394fdd2e570SFelix Fietkau static inline struct mt7615_dev *
395fdd2e570SFelix Fietkau mt7615_hw_dev(struct ieee80211_hw *hw)
396fdd2e570SFelix Fietkau {
397fdd2e570SFelix Fietkau 	struct mt76_phy *phy = hw->priv;
398fdd2e570SFelix Fietkau 
399fdd2e570SFelix Fietkau 	return container_of(phy->dev, struct mt7615_dev, mt76);
400fdd2e570SFelix Fietkau }
401fdd2e570SFelix Fietkau 
402fdd2e570SFelix Fietkau static inline struct mt7615_phy *
403fdd2e570SFelix Fietkau mt7615_ext_phy(struct mt7615_dev *dev)
404fdd2e570SFelix Fietkau {
405fdd2e570SFelix Fietkau 	struct mt76_phy *phy = dev->mt76.phy2;
406fdd2e570SFelix Fietkau 
407fdd2e570SFelix Fietkau 	if (!phy)
408fdd2e570SFelix Fietkau 		return NULL;
409fdd2e570SFelix Fietkau 
410fdd2e570SFelix Fietkau 	return phy->priv;
411fdd2e570SFelix Fietkau }
412fdd2e570SFelix Fietkau 
413e90354e0SLorenzo Bianconi extern struct ieee80211_rate mt7615_rates[12];
41404b8e659SRyder Lee extern const struct ieee80211_ops mt7615_ops;
41594f83b66SLorenzo Bianconi extern const u32 mt7615e_reg_map[__MT_BASE_MAX];
416f40ac0f3SLorenzo Bianconi extern const u32 mt7663e_reg_map[__MT_BASE_MAX];
41790520afbSLorenzo Bianconi extern const u32 mt7663_usb_sdio_reg_map[__MT_BASE_MAX];
41804b8e659SRyder Lee extern struct pci_driver mt7615_pci_driver;
41935da599fSFelix Fietkau extern struct platform_driver mt7622_wmac_driver;
4204f0bce1cSFelix Fietkau extern const struct mt76_testmode_ops mt7615_testmode_ops;
42135da599fSFelix Fietkau 
42235da599fSFelix Fietkau #ifdef CONFIG_MT7622_WMAC
42335da599fSFelix Fietkau int mt7622_wmac_init(struct mt7615_dev *dev);
42435da599fSFelix Fietkau #else
42535da599fSFelix Fietkau static inline int mt7622_wmac_init(struct mt7615_dev *dev)
42635da599fSFelix Fietkau {
42735da599fSFelix Fietkau 	return 0;
42835da599fSFelix Fietkau }
42935da599fSFelix Fietkau #endif
43004b8e659SRyder Lee 
43194f83b66SLorenzo Bianconi int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
43294f83b66SLorenzo Bianconi 		      int irq, const u32 *map);
43304b8e659SRyder Lee u32 mt7615_reg_map(struct mt7615_dev *dev, u32 addr);
43404b8e659SRyder Lee 
43553b42ae2SLorenzo Bianconi void mt7615_check_offload_capability(struct mt7615_dev *dev);
4362ee920c2SLorenzo Bianconi void mt7615_init_device(struct mt7615_dev *dev);
43704b8e659SRyder Lee int mt7615_register_device(struct mt7615_dev *dev);
43804b8e659SRyder Lee void mt7615_unregister_device(struct mt7615_dev *dev);
4390f2173f0SFelix Fietkau int mt7615_register_ext_phy(struct mt7615_dev *dev);
4400f2173f0SFelix Fietkau void mt7615_unregister_ext_phy(struct mt7615_dev *dev);
4416e5d2099SLorenzo Bianconi int mt7615_eeprom_init(struct mt7615_dev *dev, u32 addr);
442e0ec633dSLorenzo Bianconi int mt7615_eeprom_get_target_power_index(struct mt7615_dev *dev,
44316a2f8e2SLorenzo Bianconi 					 struct ieee80211_channel *chan,
44461d36824SLorenzo Bianconi 					 u8 chain_idx);
445c88bf52bSLorenzo Bianconi int mt7615_eeprom_get_power_delta_index(struct mt7615_dev *dev,
446c88bf52bSLorenzo Bianconi 					enum nl80211_band band);
4476dd4072cSLorenzo Bianconi int mt7615_wait_pdma_busy(struct mt7615_dev *dev);
44804b8e659SRyder Lee int mt7615_dma_init(struct mt7615_dev *dev);
44904b8e659SRyder Lee void mt7615_dma_cleanup(struct mt7615_dev *dev);
45004b8e659SRyder Lee int mt7615_mcu_init(struct mt7615_dev *dev);
451c3c25d09SFelix Fietkau bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev);
452fdd2e570SFelix Fietkau void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
45304b8e659SRyder Lee 			  struct ieee80211_tx_rate *probe_rate,
45404b8e659SRyder Lee 			  struct ieee80211_tx_rate *rates);
455b5b4c7ddSLorenzo Bianconi int mt7615_pm_set_enable(struct mt7615_dev *dev, bool enable);
45608523a2aSLorenzo Bianconi void mt7615_pm_wake_work(struct work_struct *work);
45708523a2aSLorenzo Bianconi int mt7615_pm_wake(struct mt7615_dev *dev);
458de5ff3c9SLorenzo Bianconi void mt7615_pm_power_save_sched(struct mt7615_dev *dev);
459de5ff3c9SLorenzo Bianconi void mt7615_pm_power_save_work(struct work_struct *work);
46004b8e659SRyder Lee int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev);
4614fe9218cSRyder Lee int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd);
46204b8e659SRyder Lee int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
46304b8e659SRyder Lee 		       const struct ieee80211_tx_queue_params *params);
464d67a6646SLorenzo Bianconi void mt7615_mcu_rx_event(struct mt7615_dev *dev, struct sk_buff *skb);
465d67a6646SLorenzo Bianconi int mt7615_mcu_rdd_cmd(struct mt7615_dev *dev,
466d67a6646SLorenzo Bianconi 		       enum mt7615_rdd_cmd cmd, u8 index,
467d67a6646SLorenzo Bianconi 		       u8 rx_sel, u8 val);
46870911d96SLorenzo Bianconi int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev);
469f347f81aSFelix Fietkau int mt7615_mcu_fw_log_2_host(struct mt7615_dev *dev, u8 ctrl);
470d67a6646SLorenzo Bianconi 
47149de79adSLorenzo Bianconi static inline bool is_mt7622(struct mt76_dev *dev)
47249de79adSLorenzo Bianconi {
47335da599fSFelix Fietkau 	if (!IS_ENABLED(CONFIG_MT7622_WMAC))
47435da599fSFelix Fietkau 		return false;
47535da599fSFelix Fietkau 
47649de79adSLorenzo Bianconi 	return mt76_chip(dev) == 0x7622;
47749de79adSLorenzo Bianconi }
47849de79adSLorenzo Bianconi 
479cdad4874SFelix Fietkau static inline bool is_mt7615(struct mt76_dev *dev)
480cdad4874SFelix Fietkau {
481e47f2245SDENG Qingfang 	return mt76_chip(dev) == 0x7615 || mt76_chip(dev) == 0x7611;
482cdad4874SFelix Fietkau }
483cdad4874SFelix Fietkau 
484f82282efSLorenzo Bianconi static inline bool is_mt7663(struct mt76_dev *dev)
485f82282efSLorenzo Bianconi {
486f82282efSLorenzo Bianconi 	return mt76_chip(dev) == 0x7663;
487f82282efSLorenzo Bianconi }
488f82282efSLorenzo Bianconi 
489e47f2245SDENG Qingfang static inline bool is_mt7611(struct mt76_dev *dev)
490e47f2245SDENG Qingfang {
491e47f2245SDENG Qingfang 	return mt76_chip(dev) == 0x7611;
492e47f2245SDENG Qingfang }
493e47f2245SDENG Qingfang 
49404b8e659SRyder Lee static inline void mt7615_irq_enable(struct mt7615_dev *dev, u32 mask)
49504b8e659SRyder Lee {
4969b90ab32SFelix Fietkau 	mt76_set_irq_mask(&dev->mt76, 0, 0, mask);
49704b8e659SRyder Lee 
4989b90ab32SFelix Fietkau 	tasklet_schedule(&dev->irq_tasklet);
49904b8e659SRyder Lee }
50004b8e659SRyder Lee 
501bf18fcdcSLorenzo Bianconi static inline bool mt7615_firmware_offload(struct mt7615_dev *dev)
502bf18fcdcSLorenzo Bianconi {
503bf18fcdcSLorenzo Bianconi 	return dev->fw_ver > MT7615_FIRMWARE_V2;
504bf18fcdcSLorenzo Bianconi }
505bf18fcdcSLorenzo Bianconi 
5068f997dddSLorenzo Bianconi static inline u16 mt7615_wtbl_size(struct mt7615_dev *dev)
5078f997dddSLorenzo Bianconi {
5088f997dddSLorenzo Bianconi 	if (is_mt7663(&dev->mt76) && mt7615_firmware_offload(dev))
5098f997dddSLorenzo Bianconi 		return MT7663_WTBL_SIZE;
5108f997dddSLorenzo Bianconi 	else
5118f997dddSLorenzo Bianconi 		return MT7615_WTBL_SIZE;
5128f997dddSLorenzo Bianconi }
5138f997dddSLorenzo Bianconi 
514adfd5112SLorenzo Bianconi static inline void mt7615_mutex_acquire(struct mt7615_dev *dev)
515adfd5112SLorenzo Bianconi 	 __acquires(&dev->mt76.mutex)
516adfd5112SLorenzo Bianconi {
517adfd5112SLorenzo Bianconi 	mutex_lock(&dev->mt76.mutex);
518adfd5112SLorenzo Bianconi 	mt7615_pm_wake(dev);
519adfd5112SLorenzo Bianconi }
520adfd5112SLorenzo Bianconi 
521adfd5112SLorenzo Bianconi static inline void mt7615_mutex_release(struct mt7615_dev *dev)
522adfd5112SLorenzo Bianconi 	__releases(&dev->mt76.mutex)
523adfd5112SLorenzo Bianconi {
524de5ff3c9SLorenzo Bianconi 	mt7615_pm_power_save_sched(dev);
525adfd5112SLorenzo Bianconi 	mutex_unlock(&dev->mt76.mutex);
526adfd5112SLorenzo Bianconi }
527adfd5112SLorenzo Bianconi 
5281fec635bSLorenzo Bianconi static inline u8 mt7615_lmac_mapping(struct mt7615_dev *dev, u8 ac)
5291fec635bSLorenzo Bianconi {
5301fec635bSLorenzo Bianconi 	static const u8 lmac_queue_map[] = {
5311fec635bSLorenzo Bianconi 		[IEEE80211_AC_BK] = MT_LMAC_AC00,
5321fec635bSLorenzo Bianconi 		[IEEE80211_AC_BE] = MT_LMAC_AC01,
5331fec635bSLorenzo Bianconi 		[IEEE80211_AC_VI] = MT_LMAC_AC02,
5341fec635bSLorenzo Bianconi 		[IEEE80211_AC_VO] = MT_LMAC_AC03,
5351fec635bSLorenzo Bianconi 	};
5361fec635bSLorenzo Bianconi 
5371fec635bSLorenzo Bianconi 	if (WARN_ON_ONCE(ac >= ARRAY_SIZE(lmac_queue_map)))
5381fec635bSLorenzo Bianconi 		return MT_LMAC_AC01; /* BE */
5391fec635bSLorenzo Bianconi 
5401fec635bSLorenzo Bianconi 	return lmac_queue_map[ac];
5411fec635bSLorenzo Bianconi }
5421fec635bSLorenzo Bianconi 
543e17d7945SFelix Fietkau static inline u32 mt7615_tx_mcu_int_mask(struct mt7615_dev *dev)
544e17d7945SFelix Fietkau {
545e17d7945SFelix Fietkau 	return MT_INT_TX_DONE(dev->mt76.q_tx[MT_TXQ_MCU].q->hw_idx);
546e17d7945SFelix Fietkau }
547e17d7945SFelix Fietkau 
5486dd4072cSLorenzo Bianconi void mt7615_dma_reset(struct mt7615_dev *dev);
549fcdfc29eSLorenzo Bianconi void mt7615_scan_work(struct work_struct *work);
5507307f296SLorenzo Bianconi void mt7615_roc_work(struct work_struct *work);
5517307f296SLorenzo Bianconi void mt7615_roc_timer(struct timer_list *timer);
552e90354e0SLorenzo Bianconi void mt7615_init_txpower(struct mt7615_dev *dev,
553e90354e0SLorenzo Bianconi 			 struct ieee80211_supported_band *sband);
554e90354e0SLorenzo Bianconi void mt7615_phy_init(struct mt7615_dev *dev);
555e90354e0SLorenzo Bianconi void mt7615_mac_init(struct mt7615_dev *dev);
5564f0bce1cSFelix Fietkau int mt7615_set_channel(struct mt7615_phy *phy);
557e90354e0SLorenzo Bianconi 
558e90354e0SLorenzo Bianconi int mt7615_mcu_restart(struct mt76_dev *dev);
559863c15a1SLorenzo Bianconi void mt7615_update_channel(struct mt76_dev *mdev);
56087d3cdebSLorenzo Bianconi bool mt7615_mac_wtbl_update(struct mt7615_dev *dev, int idx, u32 mask);
56175601194SLorenzo Bianconi void mt7615_mac_reset_counters(struct mt7615_dev *dev);
562d446a20fSFelix Fietkau void mt7615_mac_cca_stats_reset(struct mt7615_phy *phy);
563594034b7SLorenzo Bianconi void mt7615_mac_set_scs(struct mt7615_phy *phy, bool enable);
564e5051965SFelix Fietkau void mt7615_mac_enable_nf(struct mt7615_dev *dev, bool ext_phy);
565b2c2f029SLorenzo Bianconi void mt7615_mac_sta_poll(struct mt7615_dev *dev);
56604b8e659SRyder Lee int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
56704b8e659SRyder Lee 			  struct sk_buff *skb, struct mt76_wcid *wcid,
56804b8e659SRyder Lee 			  struct ieee80211_sta *sta, int pid,
569c984457bSFelix Fietkau 			  struct ieee80211_key_conf *key, bool beacon);
570183d1fcfSLorenzo Bianconi void mt7615_mac_set_timing(struct mt7615_phy *phy);
57127b8a900SLorenzo Bianconi int mt7615_mac_wtbl_set_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
57227b8a900SLorenzo Bianconi 			    struct ieee80211_key_conf *key,
57327b8a900SLorenzo Bianconi 			    enum set_key_cmd cmd);
574294f17aeSLorenzo Bianconi int mt7615_mac_wtbl_update_pk(struct mt7615_dev *dev,
575294f17aeSLorenzo Bianconi 			      struct mt76_wcid *wcid,
576294f17aeSLorenzo Bianconi 			      enum mt7615_cipher_type cipher,
577294f17aeSLorenzo Bianconi 			      int keyidx, enum set_key_cmd cmd);
578294f17aeSLorenzo Bianconi void mt7615_mac_wtbl_update_cipher(struct mt7615_dev *dev,
579294f17aeSLorenzo Bianconi 				   struct mt76_wcid *wcid,
580294f17aeSLorenzo Bianconi 				   enum mt7615_cipher_type cipher,
581294f17aeSLorenzo Bianconi 				   enum set_key_cmd cmd);
582294f17aeSLorenzo Bianconi int mt7615_mac_wtbl_update_key(struct mt7615_dev *dev,
583294f17aeSLorenzo Bianconi 			       struct mt76_wcid *wcid,
584294f17aeSLorenzo Bianconi 			       u8 *key, u8 keylen,
585294f17aeSLorenzo Bianconi 			       enum mt7615_cipher_type cipher,
586294f17aeSLorenzo Bianconi 			       enum set_key_cmd cmd);
58761c4fa72SFelix Fietkau void mt7615_mac_reset_work(struct work_struct *work);
588a28bef56SFelix Fietkau u32 mt7615_mac_get_sta_tid_sn(struct mt7615_dev *dev, int wcid, u8 tid);
58904b8e659SRyder Lee 
590b899150eSLorenzo Bianconi int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
591e90354e0SLorenzo Bianconi int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
592e90354e0SLorenzo Bianconi 			int len, bool wait_resp);
593dc804058SFelix Fietkau u32 mt7615_rf_rr(struct mt7615_dev *dev, u32 wf, u32 reg);
594dc804058SFelix Fietkau int mt7615_rf_wr(struct mt7615_dev *dev, u32 wf, u32 reg, u32 val);
595ac3ef85cSFelix Fietkau int mt7615_mcu_set_dbdc(struct mt7615_dev *dev);
59604b8e659SRyder Lee int mt7615_mcu_set_eeprom(struct mt7615_dev *dev);
597b0b5426eSFelix Fietkau int mt7615_mcu_set_mac_enable(struct mt7615_dev *dev, int band, bool enable);
598fdd2e570SFelix Fietkau int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val);
5990e6a29e4SLorenzo Bianconi int mt7615_mcu_get_temperature(struct mt7615_dev *dev, int index);
6004f0bce1cSFelix Fietkau int mt7615_mcu_set_tx_power(struct mt7615_phy *phy);
60104b8e659SRyder Lee void mt7615_mcu_exit(struct mt7615_dev *dev);
60263f09b6bSLorenzo Bianconi void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
60363f09b6bSLorenzo Bianconi 			 int cmd, int *wait_seq);
604bf18fcdcSLorenzo Bianconi int mt7615_mcu_set_channel_domain(struct mt7615_phy *phy);
605fcdfc29eSLorenzo Bianconi int mt7615_mcu_hw_scan(struct mt7615_phy *phy, struct ieee80211_vif *vif,
606fcdfc29eSLorenzo Bianconi 		       struct ieee80211_scan_request *scan_req);
607fcdfc29eSLorenzo Bianconi int mt7615_mcu_cancel_hw_scan(struct mt7615_phy *phy,
608fcdfc29eSLorenzo Bianconi 			      struct ieee80211_vif *vif);
60920305f98SLorenzo Bianconi int mt7615_mcu_sched_scan_req(struct mt7615_phy *phy,
61020305f98SLorenzo Bianconi 			      struct ieee80211_vif *vif,
61120305f98SLorenzo Bianconi 			      struct cfg80211_sched_scan_request *sreq);
61220305f98SLorenzo Bianconi int mt7615_mcu_sched_scan_enable(struct mt7615_phy *phy,
61320305f98SLorenzo Bianconi 				 struct ieee80211_vif *vif,
61420305f98SLorenzo Bianconi 				 bool enable);
61504b8e659SRyder Lee 
61604b8e659SRyder Lee int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
61704b8e659SRyder Lee 			  enum mt76_txq_id qid, struct mt76_wcid *wcid,
61804b8e659SRyder Lee 			  struct ieee80211_sta *sta,
61904b8e659SRyder Lee 			  struct mt76_tx_info *tx_info);
62004b8e659SRyder Lee 
62104b8e659SRyder Lee void mt7615_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid,
62204b8e659SRyder Lee 			    struct mt76_queue_entry *e);
62304b8e659SRyder Lee 
62404b8e659SRyder Lee void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
62504b8e659SRyder Lee 			 struct sk_buff *skb);
62604b8e659SRyder Lee void mt7615_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps);
6273e384828SFelix Fietkau int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
62804b8e659SRyder Lee 		       struct ieee80211_sta *sta);
6293e384828SFelix Fietkau void mt7615_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
63004b8e659SRyder Lee 			   struct ieee80211_sta *sta);
63104b8e659SRyder Lee void mt7615_mac_work(struct work_struct *work);
63204b8e659SRyder Lee void mt7615_txp_skb_unmap(struct mt76_dev *dev,
63304b8e659SRyder Lee 			  struct mt76_txwi_cache *txwi);
6342ce73efeSLorenzo Bianconi int mt7615_mcu_set_fcc5_lpn(struct mt7615_dev *dev, int val);
6352ce73efeSLorenzo Bianconi int mt7615_mcu_set_pulse_th(struct mt7615_dev *dev,
6362ce73efeSLorenzo Bianconi 			    const struct mt7615_dfs_pulse *pulse);
6372ce73efeSLorenzo Bianconi int mt7615_mcu_set_radar_th(struct mt7615_dev *dev, int index,
6382ce73efeSLorenzo Bianconi 			    const struct mt7615_dfs_pattern *pattern);
6394f0bce1cSFelix Fietkau int mt7615_mcu_set_test_param(struct mt7615_dev *dev, u8 param, bool test_mode,
6404f0bce1cSFelix Fietkau 			      u32 val);
64115d9a5d7SFelix Fietkau int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable);
642ad380ad1SFelix Fietkau int mt7615_mcu_apply_rx_dcoc(struct mt7615_phy *phy);
643371a59d1SFelix Fietkau int mt7615_mcu_apply_tx_dpd(struct mt7615_phy *phy);
644a5e0aa78SLorenzo Bianconi int mt7615_mcu_set_vif_ps(struct mt7615_dev *dev, struct ieee80211_vif *vif);
6455dabdf71SFelix Fietkau int mt7615_dfs_init_radar_detector(struct mt7615_phy *phy);
64604b8e659SRyder Lee 
64750eb0a88SLorenzo Bianconi int mt7615_mcu_set_p2p_oppps(struct ieee80211_hw *hw,
64850eb0a88SLorenzo Bianconi 			     struct ieee80211_vif *vif);
6497307f296SLorenzo Bianconi int mt7615_mcu_set_roc(struct mt7615_phy *phy, struct ieee80211_vif *vif,
6507307f296SLorenzo Bianconi 		       struct ieee80211_channel *chan, int duration);
6516dd4072cSLorenzo Bianconi 
65270911d96SLorenzo Bianconi int mt7615_init_debugfs(struct mt7615_dev *dev);
653eb99cc95SLorenzo Bianconi int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
654eb99cc95SLorenzo Bianconi 
65583b9f42aSLorenzo Bianconi int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
65683b9f42aSLorenzo Bianconi 			  bool enable);
6576f117852SSean Wang int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend);
658c6bf2010SLorenzo Bianconi void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,
659c6bf2010SLorenzo Bianconi 				 struct ieee80211_vif *vif);
660b47e21e7SLorenzo Bianconi int mt7615_mcu_update_gtk_rekey(struct ieee80211_hw *hw,
661b47e21e7SLorenzo Bianconi 				struct ieee80211_vif *vif,
662b47e21e7SLorenzo Bianconi 				struct cfg80211_gtk_rekey_data *key);
66373741b9bSSean Wang int mt7615_mcu_update_arp_filter(struct ieee80211_hw *hw,
66473741b9bSSean Wang 				 struct ieee80211_vif *vif,
66573741b9bSSean Wang 				 struct ieee80211_bss_conf *info);
6668915c3ceSLorenzo Bianconi int __mt7663_load_firmware(struct mt7615_dev *dev);
667a66cbdd6SSean Wang u32 mt7615_mcu_reg_rr(struct mt76_dev *dev, u32 offset);
668a66cbdd6SSean Wang void mt7615_mcu_reg_wr(struct mt76_dev *dev, u32 offset, u32 val);
66970911d96SLorenzo Bianconi 
670eb99cc95SLorenzo Bianconi /* usb */
67190520afbSLorenzo Bianconi int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
67290520afbSLorenzo Bianconi 				   enum mt76_txq_id qid, struct mt76_wcid *wcid,
67390520afbSLorenzo Bianconi 				   struct ieee80211_sta *sta,
67490520afbSLorenzo Bianconi 				   struct mt76_tx_info *tx_info);
67590520afbSLorenzo Bianconi bool mt7663_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update);
67690520afbSLorenzo Bianconi void mt7663_usb_sdio_tx_complete_skb(struct mt76_dev *mdev,
67790520afbSLorenzo Bianconi 				     enum mt76_txq_id qid,
67890520afbSLorenzo Bianconi 				     struct mt76_queue_entry *e);
67990520afbSLorenzo Bianconi void mt7663_usb_sdio_wtbl_work(struct work_struct *work);
68090520afbSLorenzo Bianconi int mt7663_usb_sdio_register_device(struct mt7615_dev *dev);
681eb99cc95SLorenzo Bianconi int mt7663u_mcu_init(struct mt7615_dev *dev);
682eb99cc95SLorenzo Bianconi 
683a66cbdd6SSean Wang /* sdio */
684a66cbdd6SSean Wang u32 mt7663s_read_pcr(struct mt7615_dev *dev);
685a66cbdd6SSean Wang int mt7663s_mcu_init(struct mt7615_dev *dev);
686974327a4SLorenzo Bianconi void mt7663s_tx_work(struct work_struct *work);
6873e5f374dSLorenzo Bianconi void mt7663s_rx_work(struct work_struct *work);
688a66cbdd6SSean Wang void mt7663s_sdio_irq(struct sdio_func *func);
689a66cbdd6SSean Wang 
69004b8e659SRyder Lee #endif
691