xref: /linux/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h (revision 9410645520e9b820069761f3450ef6661418e279)
1 /* SPDX-License-Identifier: ISC */
2 /*
3  * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
4  */
5 
6 #ifndef __MT76x2_H
7 #define __MT76x2_H
8 
9 #include <linux/device.h>
10 #include <linux/dma-mapping.h>
11 #include <linux/spinlock.h>
12 #include <linux/skbuff.h>
13 #include <linux/netdevice.h>
14 #include <linux/irq.h>
15 #include <linux/interrupt.h>
16 #include <linux/mutex.h>
17 #include <linux/bitops.h>
18 
19 #define MT7662_FIRMWARE		"mt7662.bin"
20 #define MT7662_ROM_PATCH	"mt7662_rom_patch.bin"
21 #define MT7662_EEPROM_SIZE	512
22 
23 #include "../mt76x02.h"
24 #include "mac.h"
25 
is_mt7612(struct mt76x02_dev * dev)26 static inline bool is_mt7612(struct mt76x02_dev *dev)
27 {
28 	return mt76_chip(&dev->mt76) == 0x7612;
29 }
30 
mt76x2_channel_silent(struct mt76x02_dev * dev)31 static inline bool mt76x2_channel_silent(struct mt76x02_dev *dev)
32 {
33 	struct ieee80211_channel *chan = dev->mphy.chandef.chan;
34 
35 	return ((chan->flags & IEEE80211_CHAN_RADAR) &&
36 		chan->dfs_state != NL80211_DFS_AVAILABLE);
37 }
38 
39 extern const struct ieee80211_ops mt76x2_ops;
40 
41 int mt76x2_register_device(struct mt76x02_dev *dev);
42 int mt76x2_resume_device(struct mt76x02_dev *dev);
43 
44 int mt76x2_set_sar_specs(struct ieee80211_hw *hw,
45 			 const struct cfg80211_sar_specs *sar);
46 void mt76x2_phy_power_on(struct mt76x02_dev *dev);
47 void mt76x2_stop_hardware(struct mt76x02_dev *dev);
48 int mt76x2_eeprom_init(struct mt76x02_dev *dev);
49 int mt76x2_apply_calibration_data(struct mt76x02_dev *dev, int channel);
50 int mt76x2e_set_channel(struct mt76_phy *phy);
51 int mt76x2u_set_channel(struct mt76_phy *phy);
52 
53 void mt76x2_phy_set_antenna(struct mt76x02_dev *dev);
54 int mt76x2_phy_start(struct mt76x02_dev *dev);
55 int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
56 			   struct cfg80211_chan_def *chandef);
57 void mt76x2_phy_calibrate(struct work_struct *work);
58 void mt76x2_phy_set_txpower(struct mt76x02_dev *dev);
59 
60 int mt76x2_mcu_init(struct mt76x02_dev *dev);
61 int mt76x2_mcu_set_channel(struct mt76x02_dev *dev, u8 channel, u8 bw,
62 			   u8 bw_index, bool scan);
63 int mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level,
64 		       u8 channel);
65 
66 void mt76x2_cleanup(struct mt76x02_dev *dev);
67 
68 int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard);
69 void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable);
70 void mt76x2_init_txpower(struct mt76x02_dev *dev,
71 			 struct ieee80211_supported_band *sband);
72 void mt76_write_mac_initvals(struct mt76x02_dev *dev);
73 
74 void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev);
75 void mt76x2_phy_set_txpower_regs(struct mt76x02_dev *dev,
76 				 enum nl80211_band band);
77 void mt76x2_configure_tx_delay(struct mt76x02_dev *dev,
78 			       enum nl80211_band band, u8 bw);
79 void mt76x2_apply_gain_adj(struct mt76x02_dev *dev);
80 void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev);
81 
82 #endif
83