linux/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h

/* SPDX-License-Identifier: ISC */
/* Copyright (C) 2019 MediaTek Inc. */

#ifndef __MT7615_H
#define __MT7615_H

#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/ktime.h>
#include <linux/regmap.h>
#include "../mt76_connac_mcu.h"
#include "regs.h"

#define MT7615_MAX_INTERFACES
#define MT7615_MAX_WMM_SETS
#define MT7663_WTBL_SIZE
#define MT7615_WTBL_SIZE
#define MT7615_WTBL_RESERVED
#define MT7615_WTBL_STA

#define MT7615_PM_TIMEOUT
#define MT7615_HW_SCAN_TIMEOUT
#define MT7615_RESET_TIMEOUT
#define MT7615_RATE_RETRY

#define MT7615_TX_RING_SIZE
#define MT7615_TX_MGMT_RING_SIZE
#define MT7615_TX_MCU_RING_SIZE
#define MT7615_TX_FWDL_RING_SIZE

#define MT7615_RX_RING_SIZE
#define MT7615_RX_MCU_RING_SIZE

#define MT7615_DRV_OWN_RETRY_COUNT

#define MT7615_FIRMWARE_CR4
#define MT7615_FIRMWARE_N9
#define MT7615_ROM_PATCH

#define MT7622_FIRMWARE_N9
#define MT7622_ROM_PATCH

#define MT7615_FIRMWARE_V1
#define MT7615_FIRMWARE_V2
#define MT7615_FIRMWARE_V3

#define MT7663_OFFLOAD_ROM_PATCH
#define MT7663_OFFLOAD_FIRMWARE_N9
#define MT7663_ROM_PATCH
#define MT7663_FIRMWARE_N9

#define MT7615_EEPROM_SIZE
#define MT7663_EEPROM_SIZE
#define MT7615_TOKEN_SIZE

#define MT_FRAC_SCALE
#define MT_FRAC(val, div)

#define MT_CHFREQ_VALID
#define MT_CHFREQ_DBDC_IDX
#define MT_CHFREQ_SEQ

#define MT7615_BAR_RATE_DEFAULT
#define MT7615_CFEND_RATE_DEFAULT
#define MT7615_CFEND_RATE_11B

struct mt7615_vif;
struct mt7615_sta;
struct mt7615_dfs_pulse;
struct mt7615_dfs_pattern;
enum mt7615_cipher_type;

enum mt7615_hw_txq_id {};

enum mt7622_hw_txq_id {};

struct mt7615_rate_set {};

struct mt7615_rate_desc {};

struct mt7615_wtbl_rate_desc {};

struct mt7663s_intr {} __packed;

struct mt7615_sta {};

struct mt7615_vif {};

struct mib_stats {};

struct mt7615_phy {};

#define mt7615_mcu_add_tx_ba(dev, ...)
#define mt7615_mcu_add_rx_ba(dev, ...)
#define mt7615_mcu_sta_add(phy, ...)
#define mt7615_mcu_add_dev_info(phy, ...)
#define mt7615_mcu_add_bss_info(phy, ...)
#define mt7615_mcu_add_beacon(dev, ...)
#define mt7615_mcu_set_pm(dev, ...)
#define mt7615_mcu_set_drv_ctrl(dev)
#define mt7615_mcu_set_fw_ctrl(dev)
#define mt7615_mcu_set_sta_decap_offload(dev, ...)
struct mt7615_mcu_ops {};

struct mt7615_dev {};

enum tx_pkt_queue_idx {};

enum {};

enum mt7615_rdd_cmd {};

static inline struct mt7615_phy *
mt7615_hw_phy(struct ieee80211_hw *hw)
{}

static inline struct mt7615_dev *
mt7615_hw_dev(struct ieee80211_hw *hw)
{}

static inline struct mt7615_phy *
mt7615_ext_phy(struct mt7615_dev *dev)
{}

extern struct ieee80211_rate mt7615_rates[12];
extern const struct ieee80211_ops mt7615_ops;
extern const u32 mt7615e_reg_map[__MT_BASE_MAX];
extern const u32 mt7663e_reg_map[__MT_BASE_MAX];
extern const u32 mt7663_usb_sdio_reg_map[__MT_BASE_MAX];
extern struct pci_driver mt7615_pci_driver;
extern struct platform_driver mt7622_wmac_driver;
extern const struct mt76_testmode_ops mt7615_testmode_ops;

#ifdef CONFIG_MT7622_WMAC
int mt7622_wmac_init(struct mt7615_dev *dev);
#else
static inline int mt7622_wmac_init(struct mt7615_dev *dev)
{
	return 0;
}
#endif

int mt7615_thermal_init(struct mt7615_dev *dev);
int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
		      int irq, const u32 *map);
u32 mt7615_reg_map(struct mt7615_dev *dev, u32 addr);

u32 mt7615_reg_map(struct mt7615_dev *dev, u32 addr);
int mt7615_led_set_blink(struct led_classdev *led_cdev,
			 unsigned long *delay_on,
			 unsigned long *delay_off);
void mt7615_led_set_brightness(struct led_classdev *led_cdev,
			       enum led_brightness brightness);
void mt7615_init_device(struct mt7615_dev *dev);
int mt7615_register_device(struct mt7615_dev *dev);
void mt7615_unregister_device(struct mt7615_dev *dev);
int mt7615_register_ext_phy(struct mt7615_dev *dev);
void mt7615_unregister_ext_phy(struct mt7615_dev *dev);
int mt7615_eeprom_init(struct mt7615_dev *dev, u32 addr);
int mt7615_eeprom_get_target_power_index(struct mt7615_dev *dev,
					 struct ieee80211_channel *chan,
					 u8 chain_idx);
int mt7615_eeprom_get_power_delta_index(struct mt7615_dev *dev,
					enum nl80211_band band);
int mt7615_wait_pdma_busy(struct mt7615_dev *dev);
int mt7615_dma_init(struct mt7615_dev *dev);
void mt7615_dma_start(struct mt7615_dev *dev);
void mt7615_dma_cleanup(struct mt7615_dev *dev);
int mt7615_mcu_init(struct mt7615_dev *dev);
bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev);
void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
			  struct ieee80211_tx_rate *probe_rate,
			  struct ieee80211_tx_rate *rates);
void mt7615_pm_wake_work(struct work_struct *work);
void mt7615_pm_power_save_work(struct work_struct *work);
int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev);
int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd);
int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
		       const struct ieee80211_tx_queue_params *params);
void mt7615_mcu_rx_event(struct mt7615_dev *dev, struct sk_buff *skb);
int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev);
int mt7615_mcu_fw_log_2_host(struct mt7615_dev *dev, u8 ctrl);

static inline bool mt7615_firmware_offload(struct mt7615_dev *dev)
{}

static inline u16 mt7615_wtbl_size(struct mt7615_dev *dev)
{}

#define mt7615_mutex_acquire(dev)
#define mt7615_mutex_release(dev)

static inline u8 mt7615_lmac_mapping(struct mt7615_dev *dev, u8 ac)
{}

static inline u32 mt7615_tx_mcu_int_mask(struct mt7615_dev *dev)
{}

static inline unsigned long
mt7615_get_macwork_timeout(struct mt7615_dev *dev)
{}

void mt7615_dma_reset(struct mt7615_dev *dev);
void mt7615_scan_work(struct work_struct *work);
void mt7615_roc_work(struct work_struct *work);
void mt7615_roc_timer(struct timer_list *timer);
void mt7615_init_txpower(struct mt7615_dev *dev,
			 struct ieee80211_supported_band *sband);
int mt7615_set_channel(struct mt7615_phy *phy);
void mt7615_init_work(struct mt7615_dev *dev);

int mt7615_mcu_restart(struct mt76_dev *dev);
void mt7615_update_channel(struct mt76_phy *mphy);
bool mt7615_mac_wtbl_update(struct mt7615_dev *dev, int idx, u32 mask);
void mt7615_mac_reset_counters(struct mt7615_phy *phy);
void mt7615_mac_cca_stats_reset(struct mt7615_phy *phy);
void mt7615_mac_set_scs(struct mt7615_phy *phy, bool enable);
void mt7615_mac_enable_nf(struct mt7615_dev *dev, bool ext_phy);
void mt7615_mac_enable_rtscts(struct mt7615_dev *dev,
			      struct ieee80211_vif *vif, bool enable);
void mt7615_mac_sta_poll(struct mt7615_dev *dev);
int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
			  struct sk_buff *skb, struct mt76_wcid *wcid,
			  struct ieee80211_sta *sta, int pid,
			  struct ieee80211_key_conf *key,
			  enum mt76_txq_id qid, bool beacon);
void mt7615_mac_set_timing(struct mt7615_phy *phy);
int __mt7615_mac_wtbl_set_key(struct mt7615_dev *dev,
			      struct mt76_wcid *wcid,
			      struct ieee80211_key_conf *key);
int mt7615_mac_wtbl_set_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
			    struct ieee80211_key_conf *key);
void mt7615_mac_reset_work(struct work_struct *work);
u32 mt7615_mac_get_sta_tid_sn(struct mt7615_dev *dev, int wcid, u8 tid);

int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
			      struct sk_buff *skb, int seq);
u32 mt7615_rf_rr(struct mt7615_dev *dev, u32 wf, u32 reg);
int mt7615_rf_wr(struct mt7615_dev *dev, u32 wf, u32 reg, u32 val);
int mt7615_mcu_set_dbdc(struct mt7615_dev *dev);
int mt7615_mcu_set_eeprom(struct mt7615_dev *dev);
int mt7615_mcu_get_temperature(struct mt7615_dev *dev);
int mt7615_mcu_set_tx_power(struct mt7615_phy *phy);
void mt7615_mcu_exit(struct mt7615_dev *dev);
void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
			 int cmd, int *wait_seq);

int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
			  enum mt76_txq_id qid, struct mt76_wcid *wcid,
			  struct ieee80211_sta *sta,
			  struct mt76_tx_info *tx_info);

void mt7615_tx_worker(struct mt76_worker *w);
void mt7615_tx_token_put(struct mt7615_dev *dev);
bool mt7615_rx_check(struct mt76_dev *mdev, void *data, int len);
void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
			 struct sk_buff *skb, u32 *info);
int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
		       struct ieee80211_sta *sta);
void mt7615_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
			   struct ieee80211_sta *sta);
void mt7615_mac_work(struct work_struct *work);
int mt7615_mcu_set_rx_hdr_trans_blacklist(struct mt7615_dev *dev);
int mt7615_mcu_set_fcc5_lpn(struct mt7615_dev *dev, int val);
int mt7615_mcu_set_pulse_th(struct mt7615_dev *dev,
			    const struct mt7615_dfs_pulse *pulse);
int mt7615_mcu_set_radar_th(struct mt7615_dev *dev, int index,
			    const struct mt7615_dfs_pattern *pattern);
int mt7615_mcu_set_test_param(struct mt7615_dev *dev, u8 param, bool test_mode,
			      u32 val);
int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable);
int mt7615_mcu_apply_rx_dcoc(struct mt7615_phy *phy);
int mt7615_mcu_apply_tx_dpd(struct mt7615_phy *phy);
int mt7615_dfs_init_radar_detector(struct mt7615_phy *phy);

int mt7615_mcu_set_roc(struct mt7615_phy *phy, struct ieee80211_vif *vif,
		       struct ieee80211_channel *chan, int duration);

int mt7615_init_debugfs(struct mt7615_dev *dev);
int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);

int mt7615_mac_set_beacon_filter(struct mt7615_phy *phy,
				 struct ieee80211_vif *vif,
				 bool enable);
int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
			  bool enable);
int __mt7663_load_firmware(struct mt7615_dev *dev);
void mt7615_coredump_work(struct work_struct *work);

void mt7622_trigger_hif_int(struct mt7615_dev *dev, bool en);

/* usb */
int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
				   enum mt76_txq_id qid, struct mt76_wcid *wcid,
				   struct ieee80211_sta *sta,
				   struct mt76_tx_info *tx_info);
bool mt7663_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update);
void mt7663_usb_sdio_tx_complete_skb(struct mt76_dev *mdev,
				     struct mt76_queue_entry *e);
int mt7663_usb_sdio_register_device(struct mt7615_dev *dev);
int mt7663u_mcu_init(struct mt7615_dev *dev);
int mt7663u_mcu_power_on(struct mt7615_dev *dev);

/* sdio */
int mt7663s_mcu_init(struct mt7615_dev *dev);

#endif