Commit b2d871c0 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76x0: merge mt76x0_dev in mt76x02_dev



Merge mt76x0_dev data structure in mt76x02_dev one and remove
duplicated code. Remove unused definition in mt76x0.h.
Moreover merge mt76x0_caldata and mt76x02_rx_freq_cal data structures.
This is a preliminary patch for rxwi unification.

Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent e40803f2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
static int
mt76x0_ampdu_stat_read(struct seq_file *file, void *data)
{
	struct mt76x0_dev *dev = file->private;
	struct mt76x02_dev *dev = file->private;
	int i, j;

#define stat_printf(grp, off, name)					\
@@ -75,7 +75,7 @@ static const struct file_operations fops_ampdu_stat = {
	.release = single_release,
};

void mt76x0_init_debugfs(struct mt76x0_dev *dev)
void mt76x0_init_debugfs(struct mt76x02_dev *dev)
{
	struct dentry *dir;

+14 −14
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@

#define MT_MAP_READS	DIV_ROUND_UP(MT_EFUSE_USAGE_MAP_SIZE, 16)
static int
mt76x0_efuse_physical_size_check(struct mt76x0_dev *dev)
mt76x0_efuse_physical_size_check(struct mt76x02_dev *dev)
{
	u8 data[MT_MAP_READS * 16];
	int ret, i;
@@ -53,7 +53,7 @@ mt76x0_efuse_physical_size_check(struct mt76x0_dev *dev)
	return 0;
}

static void mt76x0_set_chip_cap(struct mt76x0_dev *dev)
static void mt76x0_set_chip_cap(struct mt76x02_dev *dev)
{
	u16 nic_conf0 = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_0);
	u16 nic_conf1 = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_1);
@@ -82,20 +82,20 @@ static void mt76x0_set_chip_cap(struct mt76x0_dev *dev)
		dev_err(dev->mt76.dev, "invalid tx-rx stream\n");
}

static void mt76x0_set_temp_offset(struct mt76x0_dev *dev)
static void mt76x0_set_temp_offset(struct mt76x02_dev *dev)
{
	u8 val;

	val = mt76x02_eeprom_get(&dev->mt76, MT_EE_2G_TARGET_POWER) >> 8;
	if (mt76x02_field_valid(val))
		dev->caldata.temp_offset = mt76x02_sign_extend(val, 8);
		dev->cal.rx.temp_offset = mt76x02_sign_extend(val, 8);
	else
		dev->caldata.temp_offset = -10;
		dev->cal.rx.temp_offset = -10;
}

static void mt76x0_set_freq_offset(struct mt76x0_dev *dev)
static void mt76x0_set_freq_offset(struct mt76x02_dev *dev)
{
	struct mt76x0_caldata *caldata = &dev->caldata;
	struct mt76x02_rx_freq_cal *caldata = &dev->cal.rx;
	u8 val;

	val = mt76x02_eeprom_get(&dev->mt76, MT_EE_FREQ_OFFSET);
@@ -110,10 +110,10 @@ static void mt76x0_set_freq_offset(struct mt76x0_dev *dev)
	caldata->freq_offset -= mt76x02_sign_extend(val, 8);
}

void mt76x0_read_rx_gain(struct mt76x0_dev *dev)
void mt76x0_read_rx_gain(struct mt76x02_dev *dev)
{
	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
	struct mt76x0_caldata *caldata = &dev->caldata;
	struct mt76x02_rx_freq_cal *caldata = &dev->cal.rx;
	s8 val, lna_5g[3], lna_2g;
	u16 rssi_offset;
	int i;
@@ -157,7 +157,7 @@ static s8 mt76x0_get_delta(struct mt76_dev *dev)
	return mt76x02_rate_power_val(val);
}

void mt76x0_get_tx_power_per_rate(struct mt76x0_dev *dev)
void mt76x0_get_tx_power_per_rate(struct mt76x02_dev *dev)
{
	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
	bool is_2ghz = chan->band == NL80211_BAND_2GHZ;
@@ -216,7 +216,7 @@ void mt76x0_get_tx_power_per_rate(struct mt76x0_dev *dev)
	mt76x02_add_rate_power_offset(t, delta);
}

void mt76x0_get_power_info(struct mt76x0_dev *dev, u8 *info)
void mt76x0_get_power_info(struct mt76x02_dev *dev, u8 *info)
{
	struct mt76x0_chan_map {
		u8 chan;
@@ -277,7 +277,7 @@ void mt76x0_get_power_info(struct mt76x0_dev *dev, u8 *info)
		info[1] = 5;
}

static int mt76x0_check_eeprom(struct mt76x0_dev *dev)
static int mt76x0_check_eeprom(struct mt76x02_dev *dev)
{
	u16 val;

@@ -297,7 +297,7 @@ static int mt76x0_check_eeprom(struct mt76x0_dev *dev)
	}
}

static int mt76x0_load_eeprom(struct mt76x0_dev *dev)
static int mt76x0_load_eeprom(struct mt76x02_dev *dev)
{
	int found;

@@ -316,7 +316,7 @@ static int mt76x0_load_eeprom(struct mt76x0_dev *dev)
				      MT76X0_EEPROM_SIZE, MT_EE_READ);
}

int mt76x0_eeprom_init(struct mt76x0_dev *dev)
int mt76x0_eeprom_init(struct mt76x02_dev *dev)
{
	u8 version, fae;
	u16 data;
+5 −13
Original line number Diff line number Diff line
@@ -18,23 +18,15 @@

#include "../mt76x02_eeprom.h"

struct mt76x0_dev;
struct mt76x02_dev;

#define MT76X0U_EE_MAX_VER		0x0c
#define MT76X0_EEPROM_SIZE		512

struct mt76x0_caldata {
	s8 rssi_offset[2];
	s8 lna_gain;

	s16 temp_offset;
	u8 freq_offset;
};

int mt76x0_eeprom_init(struct mt76x0_dev *dev);
void mt76x0_read_rx_gain(struct mt76x0_dev *dev);
void mt76x0_get_tx_power_per_rate(struct mt76x0_dev *dev);
void mt76x0_get_power_info(struct mt76x0_dev *dev, u8 *info);
int mt76x0_eeprom_init(struct mt76x02_dev *dev);
void mt76x0_read_rx_gain(struct mt76x02_dev *dev);
void mt76x0_get_tx_power_per_rate(struct mt76x02_dev *dev);
void mt76x0_get_power_info(struct mt76x02_dev *dev, u8 *info);

static inline s8 s6_to_s8(u32 val)
{
+17 −17
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ static void mt76x0_vht_cap_mask(struct ieee80211_supported_band *sband)
}

static void
mt76x0_set_wlan_state(struct mt76x0_dev *dev, u32 val, bool enable)
mt76x0_set_wlan_state(struct mt76x02_dev *dev, u32 val, bool enable)
{
	u32 mask = MT_CMB_CTRL_XTAL_RDY | MT_CMB_CTRL_PLL_LD;

@@ -69,7 +69,7 @@ mt76x0_set_wlan_state(struct mt76x0_dev *dev, u32 val, bool enable)
		dev_err(dev->mt76.dev, "PLL and XTAL check failed\n");
}

void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset)
void mt76x0_chip_onoff(struct mt76x02_dev *dev, bool enable, bool reset)
{
	u32 val;

@@ -97,7 +97,7 @@ void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset)
}
EXPORT_SYMBOL_GPL(mt76x0_chip_onoff);

static void mt76x0_reset_csr_bbp(struct mt76x0_dev *dev)
static void mt76x0_reset_csr_bbp(struct mt76x02_dev *dev)
{
	mt76_wr(dev, MT_MAC_SYS_CTRL,
		MT_MAC_SYS_CTRL_RESET_CSR |
@@ -112,7 +112,7 @@ static void mt76x0_reset_csr_bbp(struct mt76x0_dev *dev)
	mt76_wr_rp(dev, MT_MCU_MEMMAP_WLAN,	\
		   tab, ARRAY_SIZE(tab))

static int mt76x0_init_bbp(struct mt76x0_dev *dev)
static int mt76x0_init_bbp(struct mt76x02_dev *dev)
{
	int ret, i;

@@ -135,7 +135,7 @@ static int mt76x0_init_bbp(struct mt76x0_dev *dev)
	return 0;
}

static void mt76x0_init_mac_registers(struct mt76x0_dev *dev)
static void mt76x0_init_mac_registers(struct mt76x02_dev *dev)
{
	u32 reg;

@@ -170,7 +170,7 @@ static void mt76x0_init_mac_registers(struct mt76x0_dev *dev)
	mt76_wr(dev, MT_WMM_CTRL, reg);
}

static int mt76x0_init_wcid_mem(struct mt76x0_dev *dev)
static int mt76x0_init_wcid_mem(struct mt76x02_dev *dev)
{
	u32 *vals;
	int i;
@@ -189,14 +189,14 @@ static int mt76x0_init_wcid_mem(struct mt76x0_dev *dev)
	return 0;
}

static void mt76x0_init_key_mem(struct mt76x0_dev *dev)
static void mt76x0_init_key_mem(struct mt76x02_dev *dev)
{
	u32 vals[4] = {};

	mt76_wr_copy(dev, MT_SKEY_MODE_BASE_0, vals, ARRAY_SIZE(vals));
}

static int mt76x0_init_wcid_attr_mem(struct mt76x0_dev *dev)
static int mt76x0_init_wcid_attr_mem(struct mt76x02_dev *dev)
{
	u32 *vals;
	int i;
@@ -213,7 +213,7 @@ static int mt76x0_init_wcid_attr_mem(struct mt76x0_dev *dev)
	return 0;
}

static void mt76x0_reset_counters(struct mt76x0_dev *dev)
static void mt76x0_reset_counters(struct mt76x02_dev *dev)
{
	mt76_rr(dev, MT_RX_STAT_0);
	mt76_rr(dev, MT_RX_STAT_1);
@@ -223,7 +223,7 @@ static void mt76x0_reset_counters(struct mt76x0_dev *dev)
	mt76_rr(dev, MT_TX_STA_2);
}

int mt76x0_mac_start(struct mt76x0_dev *dev)
int mt76x0_mac_start(struct mt76x02_dev *dev)
{
	mt76_wr(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_ENABLE_TX);

@@ -238,7 +238,7 @@ int mt76x0_mac_start(struct mt76x0_dev *dev)
}
EXPORT_SYMBOL_GPL(mt76x0_mac_start);

void mt76x0_mac_stop(struct mt76x0_dev *dev)
void mt76x0_mac_stop(struct mt76x02_dev *dev)
{
	int i = 200, ok = 0;

@@ -271,7 +271,7 @@ void mt76x0_mac_stop(struct mt76x0_dev *dev)
}
EXPORT_SYMBOL_GPL(mt76x0_mac_stop);

int mt76x0_init_hardware(struct mt76x0_dev *dev)
int mt76x0_init_hardware(struct mt76x02_dev *dev)
{
	int ret;

@@ -325,12 +325,12 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
}
EXPORT_SYMBOL_GPL(mt76x0_init_hardware);

struct mt76x0_dev *
struct mt76x02_dev *
mt76x0_alloc_device(struct device *pdev,
		    const struct mt76_driver_ops *drv_ops,
		    const struct ieee80211_ops *ops)
{
	struct mt76x0_dev *dev;
	struct mt76x02_dev *dev;
	struct mt76_dev *mdev;

	mdev = mt76_alloc_device(sizeof(*dev), ops);
@@ -340,15 +340,15 @@ mt76x0_alloc_device(struct device *pdev,
	mdev->dev = pdev;
	mdev->drv = drv_ops;

	dev = container_of(mdev, struct mt76x0_dev, mt76);
	mutex_init(&dev->reg_atomic_mutex);
	dev = container_of(mdev, struct mt76x02_dev, mt76);
	mutex_init(&dev->phy_mutex);
	atomic_set(&dev->avg_ampdu_len, 1);

	return dev;
}
EXPORT_SYMBOL_GPL(mt76x0_alloc_device);

int mt76x0_register_device(struct mt76x0_dev *dev)
int mt76x0_register_device(struct mt76x02_dev *dev)
{
	struct mt76_dev *mdev = &dev->mt76;
	struct ieee80211_hw *hw = mdev->hw;
+8 −8
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
#include "../mt76x02_util.h"
#include <linux/etherdevice.h>

void mt76x0_mac_set_protection(struct mt76x0_dev *dev, bool legacy_prot,
void mt76x0_mac_set_protection(struct mt76x02_dev *dev, bool legacy_prot,
			       int ht_mode)
{
	int mode = ht_mode & IEEE80211_HT_OP_MODE_PROTECTION;
@@ -77,7 +77,7 @@ void mt76x0_mac_set_protection(struct mt76x0_dev *dev, bool legacy_prot,
		mt76_wr(dev, MT_CCK_PROT_CFG + i * 4, prot[i]);
}

void mt76x0_mac_set_short_preamble(struct mt76x0_dev *dev, bool short_preamb)
void mt76x0_mac_set_short_preamble(struct mt76x02_dev *dev, bool short_preamb)
{
	if (short_preamb)
		mt76_set(dev, MT_AUTO_RSP_CFG, MT_AUTO_RSP_PREAMB_SHORT);
@@ -85,7 +85,7 @@ void mt76x0_mac_set_short_preamble(struct mt76x0_dev *dev, bool short_preamb)
		mt76_clear(dev, MT_AUTO_RSP_CFG, MT_AUTO_RSP_PREAMB_SHORT);
}

void mt76x0_mac_config_tsf(struct mt76x0_dev *dev, bool enable, int interval)
void mt76x0_mac_config_tsf(struct mt76x02_dev *dev, bool enable, int interval)
{
	u32 val = mt76_rr(dev, MT_BEACON_TIME_CFG);

@@ -105,7 +105,7 @@ void mt76x0_mac_config_tsf(struct mt76x0_dev *dev, bool enable, int interval)
		MT_BEACON_TIME_CFG_TBTT_EN;
}

static void mt76x0_check_mac_err(struct mt76x0_dev *dev)
static void mt76x0_check_mac_err(struct mt76x02_dev *dev)
{
	u32 val = mt76_rr(dev, 0x10f4);

@@ -120,7 +120,7 @@ static void mt76x0_check_mac_err(struct mt76x0_dev *dev)
}
void mt76x0_mac_work(struct work_struct *work)
{
	struct mt76x0_dev *dev = container_of(work, struct mt76x0_dev,
	struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
					       mac_work.work);
	struct {
		u32 addr_base;
@@ -171,7 +171,7 @@ void mt76x0_mac_work(struct work_struct *work)
	ieee80211_queue_delayed_work(dev->mt76.hw, &dev->mac_work, 10 * HZ);
}

void mt76x0_mac_set_ampdu_factor(struct mt76x0_dev *dev)
void mt76x0_mac_set_ampdu_factor(struct mt76x02_dev *dev)
{
	struct ieee80211_sta *sta;
	struct mt76_wcid *wcid;
@@ -196,7 +196,7 @@ void mt76x0_mac_set_ampdu_factor(struct mt76x0_dev *dev)
		   FIELD_PREP(MT_MAX_LEN_CFG_AMPDU, min_factor));
}

u32 mt76x0_mac_process_rx(struct mt76x0_dev *dev, struct sk_buff *skb,
u32 mt76x0_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
			  void *rxi)
{
	struct mt76_rx_status *status = (struct mt76_rx_status *) skb->cb;
Loading