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_H 18 #define __MT76x2_H 19 20 #include <linux/device.h> 21 #include <linux/dma-mapping.h> 22 #include <linux/spinlock.h> 23 #include <linux/skbuff.h> 24 #include <linux/netdevice.h> 25 #include <linux/irq.h> 26 #include <linux/interrupt.h> 27 #include <linux/mutex.h> 28 #include <linux/bitops.h> 29 30 #define MT7662_FIRMWARE "mt7662.bin" 31 #define MT7662_ROM_PATCH "mt7662_rom_patch.bin" 32 #define MT7662_EEPROM_SIZE 512 33 34 #define MT7662U_FIRMWARE "mediatek/mt7662u.bin" 35 #define MT7662U_ROM_PATCH "mediatek/mt7662u_rom_patch.bin" 36 37 #define MT_CALIBRATE_INTERVAL HZ 38 39 #include "../mt76x02.h" 40 #include "mac.h" 41 #include "dfs.h" 42 43 static inline bool is_mt7612(struct mt76x02_dev *dev) 44 { 45 return mt76_chip(&dev->mt76) == 0x7612; 46 } 47 48 static inline bool mt76x2_channel_silent(struct mt76x02_dev *dev) 49 { 50 struct ieee80211_channel *chan = dev->mt76.chandef.chan; 51 52 return ((chan->flags & IEEE80211_CHAN_RADAR) && 53 chan->dfs_state != NL80211_DFS_AVAILABLE); 54 } 55 56 extern const struct ieee80211_ops mt76x2_ops; 57 58 struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev); 59 int mt76x2_register_device(struct mt76x02_dev *dev); 60 void mt76x2_init_debugfs(struct mt76x02_dev *dev); 61 void mt76x2_init_device(struct mt76x02_dev *dev); 62 63 void mt76x2_phy_power_on(struct mt76x02_dev *dev); 64 int mt76x2_init_hardware(struct mt76x02_dev *dev); 65 void mt76x2_stop_hardware(struct mt76x02_dev *dev); 66 int mt76x2_eeprom_init(struct mt76x02_dev *dev); 67 int mt76x2_apply_calibration_data(struct mt76x02_dev *dev, int channel); 68 void mt76x2_set_tx_ackto(struct mt76x02_dev *dev); 69 70 void mt76x2_phy_set_antenna(struct mt76x02_dev *dev); 71 int mt76x2_phy_start(struct mt76x02_dev *dev); 72 int mt76x2_phy_set_channel(struct mt76x02_dev *dev, 73 struct cfg80211_chan_def *chandef); 74 void mt76x2_phy_calibrate(struct work_struct *work); 75 void mt76x2_phy_set_txpower(struct mt76x02_dev *dev); 76 77 int mt76x2_mcu_init(struct mt76x02_dev *dev); 78 int mt76x2_mcu_set_channel(struct mt76x02_dev *dev, u8 channel, u8 bw, 79 u8 bw_index, bool scan); 80 int mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level, 81 u8 channel); 82 83 void mt76x2_cleanup(struct mt76x02_dev *dev); 84 85 void mt76x2_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val); 86 87 void mt76x2_pre_tbtt_tasklet(unsigned long arg); 88 89 void mt76x2_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps); 90 91 void mt76x2_update_channel(struct mt76_dev *mdev); 92 93 void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable); 94 void mt76x2_init_txpower(struct mt76x02_dev *dev, 95 struct ieee80211_supported_band *sband); 96 void mt76_write_mac_initvals(struct mt76x02_dev *dev); 97 98 void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait); 99 void mt76x2_phy_set_txpower_regs(struct mt76x02_dev *dev, 100 enum nl80211_band band); 101 void mt76x2_configure_tx_delay(struct mt76x02_dev *dev, 102 enum nl80211_band band, u8 bw); 103 void mt76x2_apply_gain_adj(struct mt76x02_dev *dev); 104 105 #endif 106