1 /*
2  * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
3  * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
4  * Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2
8  * as published by the Free Software Foundation
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15 
16 #ifndef MT76X0U_H
17 #define MT76X0U_H
18 
19 #include <linux/bitfield.h>
20 #include <linux/kernel.h>
21 #include <linux/device.h>
22 #include <linux/mutex.h>
23 #include <linux/usb.h>
24 #include <linux/completion.h>
25 #include <net/mac80211.h>
26 #include <linux/debugfs.h>
27 
28 #include "../mt76.h"
29 #include "../mt76x02_regs.h"
30 #include "../mt76x02_mac.h"
31 #include "../mt76x02_util.h"
32 #include "eeprom.h"
33 
34 #define MT_CALIBRATE_INTERVAL		(4 * HZ)
35 
36 #define MT_USB_AGGR_SIZE_LIMIT		21 /* * 1024B */
37 #define MT_USB_AGGR_TIMEOUT		0x80 /* * 33ns */
38 
39 static inline bool is_mt7610e(struct mt76x02_dev *dev)
40 {
41 	/* TODO */
42 	return false;
43 }
44 
45 void mt76x0_init_debugfs(struct mt76x02_dev *dev);
46 
47 /* Init */
48 struct mt76x02_dev *
49 mt76x0_alloc_device(struct device *pdev,
50 		    const struct mt76_driver_ops *drv_ops,
51 		    const struct ieee80211_ops *ops);
52 int mt76x0_init_hardware(struct mt76x02_dev *dev);
53 int mt76x0_register_device(struct mt76x02_dev *dev);
54 void mt76x0_chip_onoff(struct mt76x02_dev *dev, bool enable, bool reset);
55 
56 int mt76x0_mac_start(struct mt76x02_dev *dev);
57 void mt76x0_mac_stop(struct mt76x02_dev *dev);
58 
59 int mt76x0_config(struct ieee80211_hw *hw, u32 changed);
60 void mt76x0_bss_info_changed(struct ieee80211_hw *hw,
61 			     struct ieee80211_vif *vif,
62 			     struct ieee80211_bss_conf *info, u32 changed);
63 void mt76x0_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
64 		    const u8 *mac_addr);
65 void mt76x0_sw_scan_complete(struct ieee80211_hw *hw,
66 			     struct ieee80211_vif *vif);
67 int mt76x0_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
68 
69 /* PHY */
70 void mt76x0_phy_init(struct mt76x02_dev *dev);
71 int mt76x0_wait_bbp_ready(struct mt76x02_dev *dev);
72 void mt76x0_agc_save(struct mt76x02_dev *dev);
73 void mt76x0_agc_restore(struct mt76x02_dev *dev);
74 int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
75 			    struct cfg80211_chan_def *chandef);
76 void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev);
77 void mt76x0_phy_set_txpower(struct mt76x02_dev *dev);
78 
79 /* MAC */
80 void mt76x0_mac_work(struct work_struct *work);
81 void mt76x0_mac_set_protection(struct mt76x02_dev *dev, bool legacy_prot,
82 				int ht_mode);
83 void mt76x0_mac_set_short_preamble(struct mt76x02_dev *dev, bool short_preamb);
84 void mt76x0_mac_config_tsf(struct mt76x02_dev *dev, bool enable, int interval);
85 void mt76x0_mac_set_ampdu_factor(struct mt76x02_dev *dev);
86 
87 /* TX */
88 void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
89 		struct sk_buff *skb);
90 
91 #endif
92