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