mt76: mt7921: rely on mcu_get_nic_capability
Rely on mcu_get_nic_capability to obtain Tx quota information for the SDIO device, get PHY capability, MAC address and then we can totally drop mt7921/eeprom.c and any unnecessary code. Noting that mt76_connac_mcu_get_nic_capability should be run before set flag MT76_STATE_MCU_RUNNING being set to setup the proper parameters like Tx quota control before the device is started to running. Tested-by: Deren Wu <deren.wu@mediatek.com> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
8c94f0e63b
commit
16d98b5483
|
@ -27,6 +27,7 @@ static int mt7663s_mcu_init_sched(struct mt7615_dev *dev)
|
||||||
MT_HIF1_MIN_QUOTA);
|
MT_HIF1_MIN_QUOTA);
|
||||||
sdio->sched.ple_data_quota = mt76_get_field(dev, MT_PLE_PG_HIF0_GROUP,
|
sdio->sched.ple_data_quota = mt76_get_field(dev, MT_PLE_PG_HIF0_GROUP,
|
||||||
MT_HIF0_MIN_QUOTA);
|
MT_HIF0_MIN_QUOTA);
|
||||||
|
sdio->sched.pse_page_size = MT_PSE_PAGE_SZ;
|
||||||
txdwcnt = mt76_get_field(dev, MT_PP_TXDWCNT,
|
txdwcnt = mt76_get_field(dev, MT_PP_TXDWCNT,
|
||||||
MT_PP_TXDWCNT_TX1_ADD_DW_CNT);
|
MT_PP_TXDWCNT_TX1_ADD_DW_CNT);
|
||||||
sdio->sched.deficit = txdwcnt << 2;
|
sdio->sched.deficit = txdwcnt << 2;
|
||||||
|
|
|
@ -5,6 +5,6 @@ obj-$(CONFIG_MT7921E) += mt7921e.o
|
||||||
|
|
||||||
CFLAGS_trace.o := -I$(src)
|
CFLAGS_trace.o := -I$(src)
|
||||||
|
|
||||||
mt7921-common-y := mac.o mcu.o eeprom.o main.o init.o debugfs.o trace.o
|
mt7921-common-y := mac.o mcu.o main.o init.o debugfs.o trace.o
|
||||||
mt7921-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
|
mt7921-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
|
||||||
mt7921e-y := pci.o pci_mac.o pci_mcu.o dma.o
|
mt7921e-y := pci.o pci_mac.o pci_mcu.o dma.o
|
||||||
|
|
|
@ -1,101 +0,0 @@
|
||||||
// SPDX-License-Identifier: ISC
|
|
||||||
/* Copyright (C) 2020 MediaTek Inc. */
|
|
||||||
|
|
||||||
#include "mt7921.h"
|
|
||||||
#include "eeprom.h"
|
|
||||||
|
|
||||||
static u32 mt7921_eeprom_read(struct mt7921_dev *dev, u32 offset)
|
|
||||||
{
|
|
||||||
u8 *data = dev->mt76.eeprom.data;
|
|
||||||
|
|
||||||
if (data[offset] == 0xff)
|
|
||||||
mt7921_mcu_get_eeprom(dev, offset);
|
|
||||||
|
|
||||||
return data[offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mt7921_eeprom_load(struct mt7921_dev *dev)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = mt76_eeprom_init(&dev->mt76, MT7921_EEPROM_SIZE);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
memset(dev->mt76.eeprom.data, -1, MT7921_EEPROM_SIZE);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mt7921_check_eeprom(struct mt7921_dev *dev)
|
|
||||||
{
|
|
||||||
u8 *eeprom = dev->mt76.eeprom.data;
|
|
||||||
u16 val;
|
|
||||||
|
|
||||||
mt7921_eeprom_read(dev, MT_EE_CHIP_ID);
|
|
||||||
val = get_unaligned_le16(eeprom);
|
|
||||||
|
|
||||||
switch (val) {
|
|
||||||
case 0x7922:
|
|
||||||
case 0x7961:
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mt7921_eeprom_parse_band_config(struct mt7921_phy *phy)
|
|
||||||
{
|
|
||||||
struct mt7921_dev *dev = phy->dev;
|
|
||||||
u32 val;
|
|
||||||
|
|
||||||
val = mt7921_eeprom_read(dev, MT_EE_WIFI_CONF);
|
|
||||||
val = FIELD_GET(MT_EE_WIFI_CONF_BAND_SEL, val);
|
|
||||||
|
|
||||||
switch (val) {
|
|
||||||
case MT_EE_5GHZ:
|
|
||||||
phy->mt76->cap.has_5ghz = true;
|
|
||||||
break;
|
|
||||||
case MT_EE_2GHZ:
|
|
||||||
phy->mt76->cap.has_2ghz = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
phy->mt76->cap.has_2ghz = true;
|
|
||||||
phy->mt76->cap.has_5ghz = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mt7921_eeprom_parse_hw_cap(struct mt7921_dev *dev)
|
|
||||||
{
|
|
||||||
u8 tx_mask;
|
|
||||||
|
|
||||||
mt7921_eeprom_parse_band_config(&dev->phy);
|
|
||||||
|
|
||||||
/* TODO: read NSS with MCU_CMD_NIC_CAPV2 */
|
|
||||||
tx_mask = 2;
|
|
||||||
dev->chainmask = BIT(tx_mask) - 1;
|
|
||||||
dev->mphy.antenna_mask = dev->chainmask;
|
|
||||||
dev->mphy.chainmask = dev->mphy.antenna_mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mt7921_eeprom_init(struct mt7921_dev *dev)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = mt7921_eeprom_load(dev);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = mt7921_check_eeprom(dev);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
mt7921_eeprom_parse_hw_cap(dev);
|
|
||||||
memcpy(dev->mphy.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
|
|
||||||
ETH_ALEN);
|
|
||||||
|
|
||||||
mt76_eeprom_override(&dev->mphy);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -149,7 +149,6 @@ EXPORT_SYMBOL_GPL(mt7921_mac_init);
|
||||||
|
|
||||||
static int __mt7921_init_hardware(struct mt7921_dev *dev)
|
static int __mt7921_init_hardware(struct mt7921_dev *dev)
|
||||||
{
|
{
|
||||||
struct mt76_dev *mdev = &dev->mt76;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* force firmware operation mode into normal state,
|
/* force firmware operation mode into normal state,
|
||||||
|
@ -160,9 +159,7 @@ static int __mt7921_init_hardware(struct mt7921_dev *dev)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = mt7921_eeprom_init(dev);
|
mt76_eeprom_override(&dev->mphy);
|
||||||
if (ret)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
ret = mt7921_mcu_set_eeprom(dev);
|
ret = mt7921_mcu_set_eeprom(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -170,11 +167,6 @@ static int __mt7921_init_hardware(struct mt7921_dev *dev)
|
||||||
|
|
||||||
ret = mt7921_mac_init(dev);
|
ret = mt7921_mac_init(dev);
|
||||||
out:
|
out:
|
||||||
if (ret && mdev->eeprom.data) {
|
|
||||||
devm_kfree(mdev->dev, mdev->eeprom.data);
|
|
||||||
mdev->eeprom.data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -906,10 +906,12 @@ int mt7921_run_firmware(struct mt7921_dev *dev)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
|
err = mt76_connac_mcu_get_nic_capability(&dev->mphy);
|
||||||
mt7921_mcu_fw_log_2_host(dev, 1);
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
return mt76_connac_mcu_get_nic_capability(&dev->mphy);
|
set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
|
||||||
|
return mt7921_mcu_fw_log_2_host(dev, 1);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mt7921_run_firmware);
|
EXPORT_SYMBOL_GPL(mt7921_run_firmware);
|
||||||
|
|
||||||
|
|
|
@ -156,8 +156,6 @@ struct mt7921_dev {
|
||||||
struct mt7921_phy phy;
|
struct mt7921_phy phy;
|
||||||
struct tasklet_struct irq_tasklet;
|
struct tasklet_struct irq_tasklet;
|
||||||
|
|
||||||
u16 chainmask;
|
|
||||||
|
|
||||||
struct work_struct reset_work;
|
struct work_struct reset_work;
|
||||||
bool hw_full_reset:1;
|
bool hw_full_reset:1;
|
||||||
bool hw_init_done:1;
|
bool hw_init_done:1;
|
||||||
|
@ -247,12 +245,6 @@ u32 mt7921_reg_map(struct mt7921_dev *dev, u32 addr);
|
||||||
int __mt7921_start(struct mt7921_phy *phy);
|
int __mt7921_start(struct mt7921_phy *phy);
|
||||||
int mt7921_register_device(struct mt7921_dev *dev);
|
int mt7921_register_device(struct mt7921_dev *dev);
|
||||||
void mt7921_unregister_device(struct mt7921_dev *dev);
|
void mt7921_unregister_device(struct mt7921_dev *dev);
|
||||||
int mt7921_eeprom_init(struct mt7921_dev *dev);
|
|
||||||
void mt7921_eeprom_parse_band_config(struct mt7921_phy *phy);
|
|
||||||
int mt7921_eeprom_get_target_power(struct mt7921_dev *dev,
|
|
||||||
struct ieee80211_channel *chan,
|
|
||||||
u8 chain_idx);
|
|
||||||
void mt7921_eeprom_init_sku(struct mt7921_dev *dev);
|
|
||||||
int mt7921_dma_init(struct mt7921_dev *dev);
|
int mt7921_dma_init(struct mt7921_dev *dev);
|
||||||
int mt7921_wpdma_reset(struct mt7921_dev *dev, bool force);
|
int mt7921_wpdma_reset(struct mt7921_dev *dev, bool force);
|
||||||
int mt7921_wpdma_reinit_cond(struct mt7921_dev *dev);
|
int mt7921_wpdma_reinit_cond(struct mt7921_dev *dev);
|
||||||
|
|
|
@ -173,7 +173,8 @@ mt76s_tx_pick_quota(struct mt76_sdio *sdio, bool mcu, int buf_sz,
|
||||||
{
|
{
|
||||||
int pse_sz;
|
int pse_sz;
|
||||||
|
|
||||||
pse_sz = DIV_ROUND_UP(buf_sz + sdio->sched.deficit, MT_PSE_PAGE_SZ);
|
pse_sz = DIV_ROUND_UP(buf_sz + sdio->sched.deficit,
|
||||||
|
sdio->sched.pse_page_size);
|
||||||
|
|
||||||
if (mcu && sdio->hw_ver == MT76_CONNAC2_SDIO)
|
if (mcu && sdio->hw_ver == MT76_CONNAC2_SDIO)
|
||||||
pse_sz = 1;
|
pse_sz = 1;
|
||||||
|
|
Loading…
Reference in New Issue