Commit 583204ae authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

wifi: mt76: mt792x: move mt7921_load_firmware in mt792x-lib module

mt7921_load_firmware routine is shared between mt7921 and mt7925 chipset
so move it in mt792x-lib module.
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarDeren Wu <deren.wu@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent d28e1a48
...@@ -364,30 +364,6 @@ int mt7921_mcu_uni_rx_ba(struct mt792x_dev *dev, ...@@ -364,30 +364,6 @@ int mt7921_mcu_uni_rx_ba(struct mt792x_dev *dev,
enable, false); enable, false);
} }
static char *mt7921_patch_name(struct mt792x_dev *dev)
{
char *ret;
if (is_mt7922(&dev->mt76))
ret = MT7922_ROM_PATCH;
else
ret = MT7921_ROM_PATCH;
return ret;
}
static char *mt7921_ram_name(struct mt792x_dev *dev)
{
char *ret;
if (is_mt7922(&dev->mt76))
ret = MT7922_FIRMWARE_WM;
else
ret = MT7921_FIRMWARE_WM;
return ret;
}
static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name) static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name)
{ {
const struct mt76_connac2_fw_trailer *hdr; const struct mt76_connac2_fw_trailer *hdr;
...@@ -472,41 +448,6 @@ static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name) ...@@ -472,41 +448,6 @@ static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name)
return ret; return ret;
} }
static int mt7921_load_firmware(struct mt792x_dev *dev)
{
int ret;
ret = mt76_connac2_load_patch(&dev->mt76, mt7921_patch_name(dev));
if (ret)
return ret;
if (mt76_is_sdio(&dev->mt76)) {
/* activate again */
ret = __mt792x_mcu_fw_pmctrl(dev);
if (!ret)
ret = __mt792x_mcu_drv_pmctrl(dev);
}
ret = mt76_connac2_load_ram(&dev->mt76, mt7921_ram_name(dev), NULL);
if (ret)
return ret;
if (!mt76_poll_msec(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_N9_RDY,
MT_TOP_MISC2_FW_N9_RDY, 1500)) {
dev_err(dev->mt76.dev, "Timeout for initializing firmware\n");
return -EIO;
}
#ifdef CONFIG_PM
dev->mt76.hw->wiphy->wowlan = &mt76_connac_wowlan_support;
#endif /* CONFIG_PM */
dev_dbg(dev->mt76.dev, "Firmware init done\n");
return 0;
}
int mt7921_mcu_fw_log_2_host(struct mt792x_dev *dev, u8 ctrl) int mt7921_mcu_fw_log_2_host(struct mt792x_dev *dev, u8 ctrl)
{ {
struct { struct {
...@@ -524,7 +465,7 @@ int mt7921_run_firmware(struct mt792x_dev *dev) ...@@ -524,7 +465,7 @@ int mt7921_run_firmware(struct mt792x_dev *dev)
{ {
int err; int err;
err = mt7921_load_firmware(dev); err = mt792x_load_firmware(dev);
if (err) if (err)
return err; return err;
...@@ -533,7 +474,7 @@ int mt7921_run_firmware(struct mt792x_dev *dev) ...@@ -533,7 +474,7 @@ int mt7921_run_firmware(struct mt792x_dev *dev)
return err; return err;
set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
err = mt7921_load_clc(dev, mt7921_ram_name(dev)); err = mt7921_load_clc(dev, mt792x_ram_name(dev));
if (err) if (err)
return err; return err;
......
...@@ -17,12 +17,6 @@ ...@@ -17,12 +17,6 @@
#define MT7921_RX_RING_SIZE 1536 #define MT7921_RX_RING_SIZE 1536
#define MT7921_RX_MCU_RING_SIZE 512 #define MT7921_RX_MCU_RING_SIZE 512
#define MT7921_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7961_1.bin"
#define MT7921_ROM_PATCH "mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin"
#define MT7922_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7922_1.bin"
#define MT7922_ROM_PATCH "mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin"
#define MT7921_EEPROM_SIZE 3584 #define MT7921_EEPROM_SIZE 3584
#define MT7921_TOKEN_SIZE 8192 #define MT7921_TOKEN_SIZE 8192
......
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
#define MT792x_MCU_INIT_RETRY_COUNT 10 #define MT792x_MCU_INIT_RETRY_COUNT 10
#define MT792x_WFSYS_INIT_RETRY_COUNT 2 #define MT792x_WFSYS_INIT_RETRY_COUNT 2
#define MT7921_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7961_1.bin"
#define MT7922_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7922_1.bin"
#define MT7921_ROM_PATCH "mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin"
#define MT7922_ROM_PATCH "mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin"
struct mt792x_vif; struct mt792x_vif;
struct mt792x_sta; struct mt792x_sta;
...@@ -294,6 +300,28 @@ int mt792x_init_wcid(struct mt792x_dev *dev); ...@@ -294,6 +300,28 @@ int mt792x_init_wcid(struct mt792x_dev *dev);
int mt792x_mcu_drv_pmctrl(struct mt792x_dev *dev); int mt792x_mcu_drv_pmctrl(struct mt792x_dev *dev);
int mt792x_mcu_fw_pmctrl(struct mt792x_dev *dev); int mt792x_mcu_fw_pmctrl(struct mt792x_dev *dev);
static inline char *mt792x_ram_name(struct mt792x_dev *dev)
{
switch (mt76_chip(&dev->mt76)) {
case 0x7922:
return MT7922_FIRMWARE_WM;
default:
return MT7921_FIRMWARE_WM;
}
}
static inline char *mt792x_patch_name(struct mt792x_dev *dev)
{
switch (mt76_chip(&dev->mt76)) {
case 0x7922:
return MT7922_ROM_PATCH;
default:
return MT7921_ROM_PATCH;
}
}
int mt792x_load_firmware(struct mt792x_dev *dev);
/* usb */ /* usb */
#define MT_USB_TYPE_VENDOR (USB_TYPE_VENDOR | 0x1f) #define MT_USB_TYPE_VENDOR (USB_TYPE_VENDOR | 0x1f)
#define MT_USB_TYPE_UHW_VENDOR (USB_TYPE_VENDOR | 0x1e) #define MT_USB_TYPE_UHW_VENDOR (USB_TYPE_VENDOR | 0x1e)
......
...@@ -804,5 +804,41 @@ int mt792xe_mcu_fw_pmctrl(struct mt792x_dev *dev) ...@@ -804,5 +804,41 @@ int mt792xe_mcu_fw_pmctrl(struct mt792x_dev *dev)
} }
EXPORT_SYMBOL_GPL(mt792xe_mcu_fw_pmctrl); EXPORT_SYMBOL_GPL(mt792xe_mcu_fw_pmctrl);
int mt792x_load_firmware(struct mt792x_dev *dev)
{
int ret;
ret = mt76_connac2_load_patch(&dev->mt76, mt792x_patch_name(dev));
if (ret)
return ret;
if (mt76_is_sdio(&dev->mt76)) {
/* activate again */
ret = __mt792x_mcu_fw_pmctrl(dev);
if (!ret)
ret = __mt792x_mcu_drv_pmctrl(dev);
}
ret = mt76_connac2_load_ram(&dev->mt76, mt792x_ram_name(dev), NULL);
if (ret)
return ret;
if (!mt76_poll_msec(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_N9_RDY,
MT_TOP_MISC2_FW_N9_RDY, 1500)) {
dev_err(dev->mt76.dev, "Timeout for initializing firmware\n");
return -EIO;
}
#ifdef CONFIG_PM
dev->mt76.hw->wiphy->wowlan = &mt76_connac_wowlan_support;
#endif /* CONFIG_PM */
dev_dbg(dev->mt76.dev, "Firmware init done\n");
return 0;
}
EXPORT_SYMBOL_GPL(mt792x_load_firmware);
MODULE_LICENSE("Dual BSD/GPL"); MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>"); MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment