1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2020 MediaTek Inc. */
3 
4 #ifndef __MT7915_H
5 #define __MT7915_H
6 
7 #include <linux/interrupt.h>
8 #include <linux/ktime.h>
9 #include "../mt76_connac.h"
10 #include "regs.h"
11 
12 #define MT7915_MAX_INTERFACES		19
13 #define MT7915_WTBL_SIZE		288
14 #define MT7916_WTBL_SIZE		544
15 #define MT7915_WTBL_RESERVED		(mt7915_wtbl_size(dev) - 1)
16 #define MT7915_WTBL_STA			(MT7915_WTBL_RESERVED - \
17 					 MT7915_MAX_INTERFACES)
18 
19 #define MT7915_WATCHDOG_TIME		(HZ / 10)
20 #define MT7915_RESET_TIMEOUT		(30 * HZ)
21 
22 #define MT7915_TX_RING_SIZE		2048
23 #define MT7915_TX_MCU_RING_SIZE		256
24 #define MT7915_TX_FWDL_RING_SIZE	128
25 
26 #define MT7915_RX_RING_SIZE		1536
27 #define MT7915_RX_MCU_RING_SIZE		512
28 
29 #define MT7915_FIRMWARE_WA		"mediatek/mt7915_wa.bin"
30 #define MT7915_FIRMWARE_WM		"mediatek/mt7915_wm.bin"
31 #define MT7915_ROM_PATCH		"mediatek/mt7915_rom_patch.bin"
32 
33 #define MT7916_FIRMWARE_WA		"mediatek/mt7916_wa.bin"
34 #define MT7916_FIRMWARE_WM		"mediatek/mt7916_wm.bin"
35 #define MT7916_ROM_PATCH		"mediatek/mt7916_rom_patch.bin"
36 
37 #define MT7986_FIRMWARE_WA		"mediatek/mt7986_wa.bin"
38 #define MT7986_FIRMWARE_WM		"mediatek/mt7986_wm.bin"
39 #define MT7986_FIRMWARE_WM_MT7975	"mediatek/mt7986_wm_mt7975.bin"
40 #define MT7986_ROM_PATCH		"mediatek/mt7986_rom_patch.bin"
41 #define MT7986_ROM_PATCH_MT7975		"mediatek/mt7986_rom_patch_mt7975.bin"
42 
43 #define MT7915_EEPROM_DEFAULT		"mediatek/mt7915_eeprom.bin"
44 #define MT7915_EEPROM_DEFAULT_DBDC	"mediatek/mt7915_eeprom_dbdc.bin"
45 #define MT7916_EEPROM_DEFAULT		"mediatek/mt7916_eeprom.bin"
46 #define MT7986_EEPROM_MT7975_DEFAULT		"mediatek/mt7986_eeprom_mt7975.bin"
47 #define MT7986_EEPROM_MT7975_DUAL_DEFAULT	"mediatek/mt7986_eeprom_mt7975_dual.bin"
48 #define MT7986_EEPROM_MT7976_DEFAULT		"mediatek/mt7986_eeprom_mt7976.bin"
49 #define MT7986_EEPROM_MT7976_DEFAULT_DBDC	"mediatek/mt7986_eeprom_mt7976_dbdc.bin"
50 #define MT7986_EEPROM_MT7976_DUAL_DEFAULT	"mediatek/mt7986_eeprom_mt7976_dual.bin"
51 
52 #define MT7915_EEPROM_SIZE		3584
53 #define MT7916_EEPROM_SIZE		4096
54 
55 #define MT7915_EEPROM_BLOCK_SIZE	16
56 #define MT7915_HW_TOKEN_SIZE		4096
57 #define MT7915_TOKEN_SIZE		8192
58 
59 #define MT7915_CFEND_RATE_DEFAULT	0x49	/* OFDM 24M */
60 #define MT7915_CFEND_RATE_11B		0x03	/* 11B LP, 11M */
61 
62 #define MT7915_THERMAL_THROTTLE_MAX	100
63 #define MT7915_CDEV_THROTTLE_MAX	99
64 
65 #define MT7915_SKU_RATE_NUM		161
66 
67 #define MT7915_MAX_TWT_AGRT		16
68 #define MT7915_MAX_STA_TWT_AGRT		8
69 #define MT7915_MIN_TWT_DUR 64
70 #define MT7915_MAX_QUEUE		(MT_RXQ_BAND2 + __MT_MCUQ_MAX + 2)
71 
72 #define MT7915_WED_RX_TOKEN_SIZE	12288
73 
74 #define MT7915_CRIT_TEMP_IDX		0
75 #define MT7915_MAX_TEMP_IDX		1
76 #define MT7915_CRIT_TEMP		110
77 #define MT7915_MAX_TEMP			120
78 
79 struct mt7915_vif;
80 struct mt7915_sta;
81 struct mt7915_dfs_pulse;
82 struct mt7915_dfs_pattern;
83 
84 enum mt7915_txq_id {
85 	MT7915_TXQ_FWDL = 16,
86 	MT7915_TXQ_MCU_WM,
87 	MT7915_TXQ_BAND0,
88 	MT7915_TXQ_BAND1,
89 	MT7915_TXQ_MCU_WA,
90 };
91 
92 enum mt7915_rxq_id {
93 	MT7915_RXQ_BAND0 = 0,
94 	MT7915_RXQ_BAND1,
95 	MT7915_RXQ_MCU_WM = 0,
96 	MT7915_RXQ_MCU_WA,
97 	MT7915_RXQ_MCU_WA_EXT,
98 };
99 
100 enum mt7916_rxq_id {
101 	MT7916_RXQ_MCU_WM = 0,
102 	MT7916_RXQ_MCU_WA,
103 	MT7916_RXQ_MCU_WA_MAIN,
104 	MT7916_RXQ_MCU_WA_EXT,
105 	MT7916_RXQ_BAND0,
106 	MT7916_RXQ_BAND1,
107 };
108 
109 struct mt7915_twt_flow {
110 	struct list_head list;
111 	u64 start_tsf;
112 	u64 tsf;
113 	u32 duration;
114 	u16 wcid;
115 	__le16 mantissa;
116 	u8 exp;
117 	u8 table_id;
118 	u8 id;
119 	u8 protection:1;
120 	u8 flowtype:1;
121 	u8 trigger:1;
122 	u8 sched:1;
123 };
124 
125 DECLARE_EWMA(avg_signal, 10, 8)
126 
127 struct mt7915_sta {
128 	struct mt76_wcid wcid; /* must be first */
129 
130 	struct mt7915_vif *vif;
131 
132 	struct list_head poll_list;
133 	struct list_head rc_list;
134 	u32 airtime_ac[8];
135 
136 	int ack_signal;
137 	struct ewma_avg_signal avg_ack_signal;
138 
139 	unsigned long changed;
140 	unsigned long jiffies;
141 	unsigned long ampdu_state;
142 	struct mt76_connac_sta_key_conf bip;
143 
144 	struct {
145 		u8 flowid_mask;
146 		struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT];
147 	} twt;
148 };
149 
150 struct mt7915_vif {
151 	struct mt76_vif mt76; /* must be first */
152 
153 	struct mt7915_sta sta;
154 	struct mt7915_phy *phy;
155 
156 	struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
157 	struct cfg80211_bitrate_mask bitrate_mask;
158 };
159 
160 /* per-phy stats.  */
161 struct mib_stats {
162 	u32 ack_fail_cnt;
163 	u32 fcs_err_cnt;
164 	u32 rts_cnt;
165 	u32 rts_retries_cnt;
166 	u32 ba_miss_cnt;
167 	u32 tx_bf_cnt;
168 	u32 tx_mu_mpdu_cnt;
169 	u32 tx_mu_acked_mpdu_cnt;
170 	u32 tx_su_acked_mpdu_cnt;
171 	u32 tx_bf_ibf_ppdu_cnt;
172 	u32 tx_bf_ebf_ppdu_cnt;
173 
174 	u32 tx_bf_rx_fb_all_cnt;
175 	u32 tx_bf_rx_fb_he_cnt;
176 	u32 tx_bf_rx_fb_vht_cnt;
177 	u32 tx_bf_rx_fb_ht_cnt;
178 
179 	u32 tx_bf_rx_fb_bw; /* value of last sample, not cumulative */
180 	u32 tx_bf_rx_fb_nc_cnt;
181 	u32 tx_bf_rx_fb_nr_cnt;
182 	u32 tx_bf_fb_cpl_cnt;
183 	u32 tx_bf_fb_trig_cnt;
184 
185 	u32 tx_ampdu_cnt;
186 	u32 tx_stop_q_empty_cnt;
187 	u32 tx_mpdu_attempts_cnt;
188 	u32 tx_mpdu_success_cnt;
189 	u32 tx_pkt_ebf_cnt;
190 	u32 tx_pkt_ibf_cnt;
191 
192 	u32 tx_rwp_fail_cnt;
193 	u32 tx_rwp_need_cnt;
194 
195 	/* rx stats */
196 	u32 rx_fifo_full_cnt;
197 	u32 channel_idle_cnt;
198 	u32 primary_cca_busy_time;
199 	u32 secondary_cca_busy_time;
200 	u32 primary_energy_detect_time;
201 	u32 cck_mdrdy_time;
202 	u32 ofdm_mdrdy_time;
203 	u32 green_mdrdy_time;
204 	u32 rx_vector_mismatch_cnt;
205 	u32 rx_delimiter_fail_cnt;
206 	u32 rx_mrdy_cnt;
207 	u32 rx_len_mismatch_cnt;
208 	u32 rx_mpdu_cnt;
209 	u32 rx_ampdu_cnt;
210 	u32 rx_ampdu_bytes_cnt;
211 	u32 rx_ampdu_valid_subframe_cnt;
212 	u32 rx_ampdu_valid_subframe_bytes_cnt;
213 	u32 rx_pfdrop_cnt;
214 	u32 rx_vec_queue_overflow_drop_cnt;
215 	u32 rx_ba_cnt;
216 
217 	u32 tx_amsdu[8];
218 	u32 tx_amsdu_cnt;
219 };
220 
221 /* crash-dump */
222 struct mt7915_crash_data {
223 	guid_t guid;
224 	struct timespec64 timestamp;
225 
226 	u8 *memdump_buf;
227 	size_t memdump_buf_len;
228 };
229 
230 struct mt7915_hif {
231 	struct list_head list;
232 
233 	struct device *dev;
234 	void __iomem *regs;
235 	int irq;
236 };
237 
238 struct mt7915_phy {
239 	struct mt76_phy *mt76;
240 	struct mt7915_dev *dev;
241 
242 	struct ieee80211_sband_iftype_data iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES];
243 
244 	struct ieee80211_vif *monitor_vif;
245 
246 	struct thermal_cooling_device *cdev;
247 	u8 cdev_state;
248 	u8 throttle_state;
249 	u32 throttle_temp[2]; /* 0: critical high, 1: maximum */
250 
251 	u32 rxfilter;
252 	u64 omac_mask;
253 
254 	u16 noise;
255 
256 	s16 coverage_class;
257 	u8 slottime;
258 
259 	u8 rdd_state;
260 
261 	u32 trb_ts;
262 
263 	u32 rx_ampdu_ts;
264 	u32 ampdu_ref;
265 
266 	struct mib_stats mib;
267 	struct mt76_channel_state state_ts;
268 
269 #ifdef CONFIG_NL80211_TESTMODE
270 	struct {
271 		u32 *reg_backup;
272 
273 		s32 last_freq_offset;
274 		u8 last_rcpi[4];
275 		s8 last_ib_rssi[4];
276 		s8 last_wb_rssi[4];
277 		u8 last_snr;
278 
279 		u8 spe_idx;
280 	} test;
281 #endif
282 };
283 
284 struct mt7915_dev {
285 	union { /* must be first */
286 		struct mt76_dev mt76;
287 		struct mt76_phy mphy;
288 	};
289 
290 	struct mt7915_hif *hif2;
291 	struct mt7915_reg_desc reg;
292 	u8 q_id[MT7915_MAX_QUEUE];
293 	u32 q_int_mask[MT7915_MAX_QUEUE];
294 	u32 wfdma_mask;
295 
296 	const struct mt76_bus_ops *bus_ops;
297 	struct mt7915_phy phy;
298 
299 	/* monitor rx chain configured channel */
300 	struct cfg80211_chan_def rdd2_chandef;
301 	struct mt7915_phy *rdd2_phy;
302 
303 	u16 chainmask;
304 	u16 chainshift;
305 	u32 hif_idx;
306 
307 	struct work_struct init_work;
308 	struct work_struct rc_work;
309 	struct work_struct dump_work;
310 	struct work_struct reset_work;
311 	wait_queue_head_t reset_wait;
312 
313 	struct {
314 		u32 state;
315 		u32 wa_reset_count;
316 		u32 wm_reset_count;
317 		bool hw_full_reset:1;
318 		bool hw_init_done:1;
319 		bool restart:1;
320 	} recovery;
321 
322 	/* protects coredump data */
323 	struct mutex dump_mutex;
324 #ifdef CONFIG_DEV_COREDUMP
325 	struct {
326 		struct mt7915_crash_data *crash_data;
327 	} coredump;
328 #endif
329 
330 	struct list_head sta_rc_list;
331 	struct list_head sta_poll_list;
332 	struct list_head twt_list;
333 	spinlock_t sta_poll_lock;
334 
335 	u32 hw_pattern;
336 
337 	bool dbdc_support;
338 	bool flash_mode;
339 	bool muru_debug;
340 	bool ibf;
341 
342 	struct dentry *debugfs_dir;
343 	struct rchan *relay_fwlog;
344 
345 	void *cal;
346 
347 	struct {
348 		u8 debug_wm;
349 		u8 debug_wa;
350 		u8 debug_bin;
351 	} fw;
352 
353 	struct {
354 		u16 table_mask;
355 		u8 n_agrt;
356 	} twt;
357 
358 	struct reset_control *rstc;
359 	void __iomem *dcm;
360 	void __iomem *sku;
361 };
362 
363 enum {
364 	WFDMA0 = 0x0,
365 	WFDMA1,
366 	WFDMA_EXT,
367 	__MT_WFDMA_MAX,
368 };
369 
370 enum {
371 	MT_RX_SEL0,
372 	MT_RX_SEL1,
373 	MT_RX_SEL2, /* monitor chain */
374 };
375 
376 enum mt7915_rdd_cmd {
377 	RDD_STOP,
378 	RDD_START,
379 	RDD_DET_MODE,
380 	RDD_RADAR_EMULATE,
381 	RDD_START_TXQ = 20,
382 	RDD_SET_WF_ANT = 30,
383 	RDD_CAC_START = 50,
384 	RDD_CAC_END,
385 	RDD_NORMAL_START,
386 	RDD_DISABLE_DFS_CAL,
387 	RDD_PULSE_DBG,
388 	RDD_READ_PULSE,
389 	RDD_RESUME_BF,
390 	RDD_IRQ_OFF,
391 };
392 
393 static inline struct mt7915_phy *
394 mt7915_hw_phy(struct ieee80211_hw *hw)
395 {
396 	struct mt76_phy *phy = hw->priv;
397 
398 	return phy->priv;
399 }
400 
401 static inline struct mt7915_dev *
402 mt7915_hw_dev(struct ieee80211_hw *hw)
403 {
404 	struct mt76_phy *phy = hw->priv;
405 
406 	return container_of(phy->dev, struct mt7915_dev, mt76);
407 }
408 
409 static inline struct mt7915_phy *
410 mt7915_ext_phy(struct mt7915_dev *dev)
411 {
412 	struct mt76_phy *phy = dev->mt76.phys[MT_BAND1];
413 
414 	if (!phy)
415 		return NULL;
416 
417 	return phy->priv;
418 }
419 
420 static inline u32 mt7915_check_adie(struct mt7915_dev *dev, bool sku)
421 {
422 	u32 mask = sku ? MT_CONNINFRA_SKU_MASK : MT_ADIE_TYPE_MASK;
423 
424 	if (!is_mt7986(&dev->mt76))
425 		return 0;
426 
427 	return mt76_rr(dev, MT_CONNINFRA_SKU_DEC_ADDR) & mask;
428 }
429 
430 extern const struct ieee80211_ops mt7915_ops;
431 extern const struct mt76_testmode_ops mt7915_testmode_ops;
432 extern struct pci_driver mt7915_pci_driver;
433 extern struct pci_driver mt7915_hif_driver;
434 extern struct platform_driver mt7986_wmac_driver;
435 
436 #ifdef CONFIG_MT7986_WMAC
437 int mt7986_wmac_enable(struct mt7915_dev *dev);
438 void mt7986_wmac_disable(struct mt7915_dev *dev);
439 #else
440 static inline int mt7986_wmac_enable(struct mt7915_dev *dev)
441 {
442 	return 0;
443 }
444 
445 static inline void mt7986_wmac_disable(struct mt7915_dev *dev)
446 {
447 }
448 #endif
449 struct mt7915_dev *mt7915_mmio_probe(struct device *pdev,
450 				     void __iomem *mem_base, u32 device_id);
451 void mt7915_wfsys_reset(struct mt7915_dev *dev);
452 irqreturn_t mt7915_irq_handler(int irq, void *dev_instance);
453 u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif);
454 u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id);
455 
456 int mt7915_register_device(struct mt7915_dev *dev);
457 void mt7915_unregister_device(struct mt7915_dev *dev);
458 int mt7915_eeprom_init(struct mt7915_dev *dev);
459 void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
460 				struct mt7915_phy *phy);
461 int mt7915_eeprom_get_target_power(struct mt7915_dev *dev,
462 				   struct ieee80211_channel *chan,
463 				   u8 chain_idx);
464 s8 mt7915_eeprom_get_power_delta(struct mt7915_dev *dev, int band);
465 int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2);
466 void mt7915_dma_prefetch(struct mt7915_dev *dev);
467 void mt7915_dma_cleanup(struct mt7915_dev *dev);
468 int mt7915_dma_reset(struct mt7915_dev *dev, bool force);
469 int mt7915_txbf_init(struct mt7915_dev *dev);
470 void mt7915_init_txpower(struct mt7915_dev *dev,
471 			 struct ieee80211_supported_band *sband);
472 void mt7915_reset(struct mt7915_dev *dev);
473 int mt7915_run(struct ieee80211_hw *hw);
474 int mt7915_mcu_init(struct mt7915_dev *dev);
475 int mt7915_mcu_init_firmware(struct mt7915_dev *dev);
476 int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
477 			       struct mt7915_vif *mvif,
478 			       struct mt7915_twt_flow *flow,
479 			       int cmd);
480 int mt7915_mcu_add_dev_info(struct mt7915_phy *phy,
481 			    struct ieee80211_vif *vif, bool enable);
482 int mt7915_mcu_add_bss_info(struct mt7915_phy *phy,
483 			    struct ieee80211_vif *vif, int enable);
484 int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
485 		       struct ieee80211_sta *sta, bool enable);
486 int mt7915_mcu_add_tx_ba(struct mt7915_dev *dev,
487 			 struct ieee80211_ampdu_params *params,
488 			 bool add);
489 int mt7915_mcu_add_rx_ba(struct mt7915_dev *dev,
490 			 struct ieee80211_ampdu_params *params,
491 			 bool add);
492 int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vif,
493 				struct cfg80211_he_bss_color *he_bss_color);
494 int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
495 			  int enable, u32 changed);
496 int mt7915_mcu_add_obss_spr(struct mt7915_phy *phy, struct ieee80211_vif *vif,
497 			    struct ieee80211_he_obss_pd *he_obss_pd);
498 int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif,
499 			     struct ieee80211_sta *sta, bool changed);
500 int mt7915_mcu_add_smps(struct mt7915_dev *dev, struct ieee80211_vif *vif,
501 			struct ieee80211_sta *sta);
502 int mt7915_set_channel(struct mt7915_phy *phy);
503 int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd);
504 int mt7915_mcu_set_tx(struct mt7915_dev *dev, struct ieee80211_vif *vif);
505 int mt7915_mcu_update_edca(struct mt7915_dev *dev, void *req);
506 int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
507 				   struct ieee80211_vif *vif,
508 				   struct ieee80211_sta *sta,
509 				   void *data, u32 field);
510 int mt7915_mcu_set_eeprom(struct mt7915_dev *dev);
511 int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset);
512 int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num);
513 int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
514 		       bool hdr_trans);
515 int mt7915_mcu_set_test_param(struct mt7915_dev *dev, u8 param, bool test_mode,
516 			      u8 en);
517 int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band);
518 int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable);
519 int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy);
520 int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len);
521 int mt7915_mcu_set_txpower_frame_min(struct mt7915_phy *phy, s8 txpower);
522 int mt7915_mcu_set_txpower_frame(struct mt7915_phy *phy,
523 				 struct ieee80211_vif *vif,
524 				 struct ieee80211_sta *sta, s8 txpower);
525 int mt7915_mcu_set_txbf(struct mt7915_dev *dev, u8 action);
526 int mt7915_mcu_set_fcc5_lpn(struct mt7915_dev *dev, int val);
527 int mt7915_mcu_set_pulse_th(struct mt7915_dev *dev,
528 			    const struct mt7915_dfs_pulse *pulse);
529 int mt7915_mcu_set_radar_th(struct mt7915_dev *dev, int index,
530 			    const struct mt7915_dfs_pattern *pattern);
531 int mt7915_mcu_set_muru_ctrl(struct mt7915_dev *dev, u32 cmd, u32 val);
532 int mt7915_mcu_apply_group_cal(struct mt7915_dev *dev);
533 int mt7915_mcu_apply_tx_dpd(struct mt7915_phy *phy);
534 int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch);
535 int mt7915_mcu_get_temperature(struct mt7915_phy *phy);
536 int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state);
537 int mt7915_mcu_set_thermal_protect(struct mt7915_phy *phy);
538 int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif,
539 			   struct ieee80211_sta *sta, struct rate_info *rate);
540 int mt7915_mcu_rdd_background_enable(struct mt7915_phy *phy,
541 				     struct cfg80211_chan_def *chandef);
542 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set);
543 int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3);
544 int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl);
545 int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level);
546 void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb);
547 void mt7915_mcu_exit(struct mt7915_dev *dev);
548 
549 static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev)
550 {
551 	return is_mt7915(&dev->mt76) ? MT7915_WTBL_SIZE : MT7916_WTBL_SIZE;
552 }
553 
554 static inline u16 mt7915_eeprom_size(struct mt7915_dev *dev)
555 {
556 	return is_mt7915(&dev->mt76) ? MT7915_EEPROM_SIZE : MT7916_EEPROM_SIZE;
557 }
558 
559 void mt7915_dual_hif_set_irq_mask(struct mt7915_dev *dev, bool write_reg,
560 				  u32 clear, u32 set);
561 
562 static inline void mt7915_irq_enable(struct mt7915_dev *dev, u32 mask)
563 {
564 	if (dev->hif2)
565 		mt7915_dual_hif_set_irq_mask(dev, false, 0, mask);
566 	else
567 		mt76_set_irq_mask(&dev->mt76, 0, 0, mask);
568 
569 	tasklet_schedule(&dev->mt76.irq_tasklet);
570 }
571 
572 static inline void mt7915_irq_disable(struct mt7915_dev *dev, u32 mask)
573 {
574 	if (dev->hif2)
575 		mt7915_dual_hif_set_irq_mask(dev, true, mask, 0);
576 	else
577 		mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, mask, 0);
578 }
579 
580 void mt7915_memcpy_fromio(struct mt7915_dev *dev, void *buf, u32 offset,
581 			  size_t len);
582 
583 void mt7915_mac_init(struct mt7915_dev *dev);
584 u32 mt7915_mac_wtbl_lmac_addr(struct mt7915_dev *dev, u16 wcid, u8 dw);
585 bool mt7915_mac_wtbl_update(struct mt7915_dev *dev, int idx, u32 mask);
586 void mt7915_mac_reset_counters(struct mt7915_phy *phy);
587 void mt7915_mac_cca_stats_reset(struct mt7915_phy *phy);
588 void mt7915_mac_enable_nf(struct mt7915_dev *dev, bool ext_phy);
589 void mt7915_mac_enable_rtscts(struct mt7915_dev *dev,
590 			      struct ieee80211_vif *vif, bool enable);
591 void mt7915_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
592 			   struct sk_buff *skb, struct mt76_wcid *wcid, int pid,
593 			   struct ieee80211_key_conf *key,
594 			   enum mt76_txq_id qid, u32 changed);
595 void mt7915_mac_set_timing(struct mt7915_phy *phy);
596 int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
597 		       struct ieee80211_sta *sta);
598 void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
599 			   struct ieee80211_sta *sta);
600 void mt7915_mac_work(struct work_struct *work);
601 void mt7915_mac_reset_work(struct work_struct *work);
602 void mt7915_mac_dump_work(struct work_struct *work);
603 void mt7915_mac_sta_rc_work(struct work_struct *work);
604 void mt7915_mac_update_stats(struct mt7915_phy *phy);
605 void mt7915_mac_twt_teardown_flow(struct mt7915_dev *dev,
606 				  struct mt7915_sta *msta,
607 				  u8 flowid);
608 void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
609 			      struct ieee80211_sta *sta,
610 			      struct ieee80211_twt_setup *twt);
611 int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
612 			  enum mt76_txq_id qid, struct mt76_wcid *wcid,
613 			  struct ieee80211_sta *sta,
614 			  struct mt76_tx_info *tx_info);
615 void mt7915_tx_token_put(struct mt7915_dev *dev);
616 void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
617 			 struct sk_buff *skb, u32 *info);
618 bool mt7915_rx_check(struct mt76_dev *mdev, void *data, int len);
619 void mt7915_stats_work(struct work_struct *work);
620 int mt76_dfs_start_rdd(struct mt7915_dev *dev, bool force);
621 int mt7915_dfs_init_radar_detector(struct mt7915_phy *phy);
622 void mt7915_set_stream_he_caps(struct mt7915_phy *phy);
623 void mt7915_set_stream_vht_txbf_caps(struct mt7915_phy *phy);
624 void mt7915_update_channel(struct mt76_phy *mphy);
625 int mt7915_mcu_muru_debug_set(struct mt7915_dev *dev, bool enable);
626 int mt7915_mcu_muru_debug_get(struct mt7915_phy *phy, void *ms);
627 int mt7915_mcu_wed_enable_rx_stats(struct mt7915_dev *dev);
628 int mt7915_init_debugfs(struct mt7915_phy *phy);
629 void mt7915_debugfs_rx_fw_monitor(struct mt7915_dev *dev, const void *data, int len);
630 bool mt7915_debugfs_rx_log(struct mt7915_dev *dev, const void *data, int len);
631 #ifdef CONFIG_MAC80211_DEBUGFS
632 void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
633 			    struct ieee80211_sta *sta, struct dentry *dir);
634 #endif
635 int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
636 			 bool pci, int *irq);
637 
638 #endif
639