mt76x2.h 3.1 KB
Newer Older
F
Felix Fietkau 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef __MT76x2_H
#define __MT76x2_H

#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/spinlock.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/bitops.h>

#define MT7662_FIRMWARE		"mt7662.bin"
#define MT7662_ROM_PATCH	"mt7662_rom_patch.bin"
#define MT7662_EEPROM_SIZE	512

34
#include "../mt76x02.h"
35
#include "mac.h"
F
Felix Fietkau 已提交
36

37
static inline bool is_mt7612(struct mt76x02_dev *dev)
F
Felix Fietkau 已提交
38
{
L
Lorenzo Bianconi 已提交
39
	return mt76_chip(&dev->mt76) == 0x7612;
F
Felix Fietkau 已提交
40 41
}

42
static inline bool mt76x2_channel_silent(struct mt76x02_dev *dev)
43 44 45 46 47 48 49
{
	struct ieee80211_channel *chan = dev->mt76.chandef.chan;

	return ((chan->flags & IEEE80211_CHAN_RADAR) &&
		chan->dfs_state != NL80211_DFS_AVAILABLE);
}

F
Felix Fietkau 已提交
50 51
extern const struct ieee80211_ops mt76x2_ops;

52 53
struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev);
int mt76x2_register_device(struct mt76x02_dev *dev);
F
Felix Fietkau 已提交
54

55 56 57 58 59 60 61 62 63 64
void mt76x2_phy_power_on(struct mt76x02_dev *dev);
int mt76x2_init_hardware(struct mt76x02_dev *dev);
void mt76x2_stop_hardware(struct mt76x02_dev *dev);
int mt76x2_eeprom_init(struct mt76x02_dev *dev);
int mt76x2_apply_calibration_data(struct mt76x02_dev *dev, int channel);

void mt76x2_phy_set_antenna(struct mt76x02_dev *dev);
int mt76x2_phy_start(struct mt76x02_dev *dev);
int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
			   struct cfg80211_chan_def *chandef);
F
Felix Fietkau 已提交
65
void mt76x2_phy_calibrate(struct work_struct *work);
66
void mt76x2_phy_set_txpower(struct mt76x02_dev *dev);
F
Felix Fietkau 已提交
67

68 69
int mt76x2_mcu_init(struct mt76x02_dev *dev);
int mt76x2_mcu_set_channel(struct mt76x02_dev *dev, u8 channel, u8 bw,
F
Felix Fietkau 已提交
70
			   u8 bw_index, bool scan);
71
int mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level,
F
Felix Fietkau 已提交
72 73
		       u8 channel);

74
void mt76x2_cleanup(struct mt76x02_dev *dev);
F
Felix Fietkau 已提交
75

76 77
void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable);
void mt76x2_init_txpower(struct mt76x02_dev *dev,
78
			 struct ieee80211_supported_band *sband);
79
void mt76_write_mac_initvals(struct mt76x02_dev *dev);
80

81 82
void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait);
void mt76x2_phy_set_txpower_regs(struct mt76x02_dev *dev,
83
				 enum nl80211_band band);
84
void mt76x2_configure_tx_delay(struct mt76x02_dev *dev,
85
			       enum nl80211_band band, u8 bw);
86
void mt76x2_apply_gain_adj(struct mt76x02_dev *dev);
87
void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev);
88

F
Felix Fietkau 已提交
89
#endif