18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: ISC */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef __MT76x2_H
78c2ecf20Sopenharmony_ci#define __MT76x2_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/device.h>
108c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h>
118c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
128c2ecf20Sopenharmony_ci#include <linux/skbuff.h>
138c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
148c2ecf20Sopenharmony_ci#include <linux/irq.h>
158c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
168c2ecf20Sopenharmony_ci#include <linux/mutex.h>
178c2ecf20Sopenharmony_ci#include <linux/bitops.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define MT7662_FIRMWARE		"mt7662.bin"
208c2ecf20Sopenharmony_ci#define MT7662_ROM_PATCH	"mt7662_rom_patch.bin"
218c2ecf20Sopenharmony_ci#define MT7662_EEPROM_SIZE	512
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include "../mt76x02.h"
248c2ecf20Sopenharmony_ci#include "mac.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic inline bool is_mt7612(struct mt76x02_dev *dev)
278c2ecf20Sopenharmony_ci{
288c2ecf20Sopenharmony_ci	return mt76_chip(&dev->mt76) == 0x7612;
298c2ecf20Sopenharmony_ci}
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistatic inline bool mt76x2_channel_silent(struct mt76x02_dev *dev)
328c2ecf20Sopenharmony_ci{
338c2ecf20Sopenharmony_ci	struct ieee80211_channel *chan = dev->mphy.chandef.chan;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	return ((chan->flags & IEEE80211_CHAN_RADAR) &&
368c2ecf20Sopenharmony_ci		chan->dfs_state != NL80211_DFS_AVAILABLE);
378c2ecf20Sopenharmony_ci}
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciextern const struct ieee80211_ops mt76x2_ops;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciint mt76x2_register_device(struct mt76x02_dev *dev);
428c2ecf20Sopenharmony_ciint mt76x2_resume_device(struct mt76x02_dev *dev);
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_civoid mt76x2_phy_power_on(struct mt76x02_dev *dev);
458c2ecf20Sopenharmony_civoid mt76x2_stop_hardware(struct mt76x02_dev *dev);
468c2ecf20Sopenharmony_ciint mt76x2_eeprom_init(struct mt76x02_dev *dev);
478c2ecf20Sopenharmony_ciint mt76x2_apply_calibration_data(struct mt76x02_dev *dev, int channel);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_civoid mt76x2_phy_set_antenna(struct mt76x02_dev *dev);
508c2ecf20Sopenharmony_ciint mt76x2_phy_start(struct mt76x02_dev *dev);
518c2ecf20Sopenharmony_ciint mt76x2_phy_set_channel(struct mt76x02_dev *dev,
528c2ecf20Sopenharmony_ci			   struct cfg80211_chan_def *chandef);
538c2ecf20Sopenharmony_civoid mt76x2_phy_calibrate(struct work_struct *work);
548c2ecf20Sopenharmony_civoid mt76x2_phy_set_txpower(struct mt76x02_dev *dev);
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ciint mt76x2_mcu_init(struct mt76x02_dev *dev);
578c2ecf20Sopenharmony_ciint mt76x2_mcu_set_channel(struct mt76x02_dev *dev, u8 channel, u8 bw,
588c2ecf20Sopenharmony_ci			   u8 bw_index, bool scan);
598c2ecf20Sopenharmony_ciint mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level,
608c2ecf20Sopenharmony_ci		       u8 channel);
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_civoid mt76x2_cleanup(struct mt76x02_dev *dev);
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ciint mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard);
658c2ecf20Sopenharmony_civoid mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable);
668c2ecf20Sopenharmony_civoid mt76x2_init_txpower(struct mt76x02_dev *dev,
678c2ecf20Sopenharmony_ci			 struct ieee80211_supported_band *sband);
688c2ecf20Sopenharmony_civoid mt76_write_mac_initvals(struct mt76x02_dev *dev);
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_civoid mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev);
718c2ecf20Sopenharmony_civoid mt76x2_phy_set_txpower_regs(struct mt76x02_dev *dev,
728c2ecf20Sopenharmony_ci				 enum nl80211_band band);
738c2ecf20Sopenharmony_civoid mt76x2_configure_tx_delay(struct mt76x02_dev *dev,
748c2ecf20Sopenharmony_ci			       enum nl80211_band band, u8 bw);
758c2ecf20Sopenharmony_civoid mt76x2_apply_gain_adj(struct mt76x02_dev *dev);
768c2ecf20Sopenharmony_civoid mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev);
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#endif
79