1 /* 2 * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> 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 __MT76x2U_H 18 #define __MT76x2U_H 19 20 #include <linux/device.h> 21 22 #include "mt76x2.h" 23 #include "mt76x2_dma.h" 24 #include "mt76x2_mcu.h" 25 26 #define MT7612U_EEPROM_SIZE 512 27 28 #define MT_USB_AGGR_SIZE_LIMIT 21 /* 1024B unit */ 29 #define MT_USB_AGGR_TIMEOUT 0x80 /* 33ns unit */ 30 31 extern const struct ieee80211_ops mt76x2u_ops; 32 33 struct mt76x2_dev *mt76x2u_alloc_device(struct device *pdev); 34 int mt76x2u_register_device(struct mt76x2_dev *dev); 35 int mt76x2u_init_hardware(struct mt76x2_dev *dev); 36 void mt76x2u_cleanup(struct mt76x2_dev *dev); 37 void mt76x2u_stop_hw(struct mt76x2_dev *dev); 38 39 void mt76x2u_mac_setaddr(struct mt76x2_dev *dev, u8 *addr); 40 int mt76x2u_mac_reset(struct mt76x2_dev *dev); 41 void mt76x2u_mac_resume(struct mt76x2_dev *dev); 42 int mt76x2u_mac_start(struct mt76x2_dev *dev); 43 int mt76x2u_mac_stop(struct mt76x2_dev *dev); 44 45 int mt76x2u_phy_set_channel(struct mt76x2_dev *dev, 46 struct cfg80211_chan_def *chandef); 47 void mt76x2u_phy_calibrate(struct work_struct *work); 48 void mt76x2u_phy_channel_calibrate(struct mt76x2_dev *dev); 49 void mt76x2u_phy_set_txdac(struct mt76x2_dev *dev); 50 void mt76x2u_phy_set_rxpath(struct mt76x2_dev *dev); 51 52 void mt76x2u_mcu_complete_urb(struct urb *urb); 53 int mt76x2u_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw, 54 u8 bw_index, bool scan); 55 int mt76x2u_mcu_calibrate(struct mt76x2_dev *dev, enum mcu_calibration type, 56 u32 val); 57 int mt76x2u_mcu_tssi_comp(struct mt76x2_dev *dev, 58 struct mt76x2_tssi_comp *tssi_data); 59 int mt76x2u_mcu_init_gain(struct mt76x2_dev *dev, u8 channel, u32 gain, 60 bool force); 61 int mt76x2u_mcu_set_dynamic_vga(struct mt76x2_dev *dev, u8 channel, bool ap, 62 bool ext, int rssi, u32 false_cca); 63 int mt76x2u_mcu_set_radio_state(struct mt76x2_dev *dev, bool val); 64 int mt76x2u_mcu_load_cr(struct mt76x2_dev *dev, u8 type, 65 u8 temp_level, u8 channel); 66 int mt76x2u_mcu_init(struct mt76x2_dev *dev); 67 int mt76x2u_mcu_fw_init(struct mt76x2_dev *dev); 68 void mt76x2u_mcu_deinit(struct mt76x2_dev *dev); 69 70 int mt76x2u_alloc_queues(struct mt76x2_dev *dev); 71 void mt76x2u_queues_deinit(struct mt76x2_dev *dev); 72 void mt76x2u_stop_queues(struct mt76x2_dev *dev); 73 bool mt76x2u_tx_status_data(struct mt76_dev *mdev, u8 *update); 74 int mt76x2u_tx_prepare_skb(struct mt76_dev *mdev, void *data, 75 struct sk_buff *skb, struct mt76_queue *q, 76 struct mt76_wcid *wcid, struct ieee80211_sta *sta, 77 u32 *tx_info); 78 void mt76x2u_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q, 79 struct mt76_queue_entry *e, bool flush); 80 int mt76x2u_skb_dma_info(struct sk_buff *skb, enum dma_msg_port port, 81 u32 flags); 82 83 #endif /* __MT76x2U_H */ 84