]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
fc70711ea9e4b676e003ca9bc312f03b349c72e3
[linux.git] / drivers / net / wireless / mediatek / mt76 / mt76x2 / mt76x2.h
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 irqreturn_t mt76x2_irq_handler(int irq, void *dev_instance);
64 void mt76x2_phy_power_on(struct mt76x02_dev *dev);
65 int mt76x2_init_hardware(struct mt76x02_dev *dev);
66 void mt76x2_stop_hardware(struct mt76x02_dev *dev);
67 int mt76x2_eeprom_init(struct mt76x02_dev *dev);
68 int mt76x2_apply_calibration_data(struct mt76x02_dev *dev, int channel);
69 void mt76x2_set_tx_ackto(struct mt76x02_dev *dev);
70
71 void mt76x2_phy_set_antenna(struct mt76x02_dev *dev);
72 int mt76x2_phy_start(struct mt76x02_dev *dev);
73 int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
74                            struct cfg80211_chan_def *chandef);
75 void mt76x2_phy_calibrate(struct work_struct *work);
76 void mt76x2_phy_set_txpower(struct mt76x02_dev *dev);
77
78 int mt76x2_mcu_init(struct mt76x02_dev *dev);
79 int mt76x2_mcu_set_channel(struct mt76x02_dev *dev, u8 channel, u8 bw,
80                            u8 bw_index, bool scan);
81 int mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level,
82                        u8 channel);
83
84 void mt76x2_cleanup(struct mt76x02_dev *dev);
85
86 void mt76x2_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val);
87
88 void mt76x2_pre_tbtt_tasklet(unsigned long arg);
89
90 void mt76x2_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q);
91
92 void mt76x2_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps);
93
94 void mt76x2_update_channel(struct mt76_dev *mdev);
95
96 void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable);
97 void mt76x2_init_txpower(struct mt76x02_dev *dev,
98                          struct ieee80211_supported_band *sband);
99 void mt76_write_mac_initvals(struct mt76x02_dev *dev);
100
101 void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait);
102 void mt76x2_phy_set_txpower_regs(struct mt76x02_dev *dev,
103                                  enum nl80211_band band);
104 void mt76x2_configure_tx_delay(struct mt76x02_dev *dev,
105                                enum nl80211_band band, u8 bw);
106 void mt76x2_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl);
107 void mt76x2_phy_set_band(struct mt76x02_dev *dev, int band, bool primary_upper);
108 void mt76x2_apply_gain_adj(struct mt76x02_dev *dev);
109
110 #endif