Commit 1c88e7e0 authored by Felix Fietkau's avatar Felix Fietkau

mt76: mt7615: split up firmware loading functions

Preparation for adding MT7622 support
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 57ec55e9
...@@ -345,7 +345,7 @@ static int mt7615_driver_own(struct mt7615_dev *dev) ...@@ -345,7 +345,7 @@ static int mt7615_driver_own(struct mt7615_dev *dev)
return 0; return 0;
} }
static int mt7615_load_patch(struct mt7615_dev *dev) static int mt7615_load_patch(struct mt7615_dev *dev, const char *name)
{ {
const struct mt7615_patch_hdr *hdr; const struct mt7615_patch_hdr *hdr;
const struct firmware *fw = NULL; const struct firmware *fw = NULL;
...@@ -362,7 +362,7 @@ static int mt7615_load_patch(struct mt7615_dev *dev) ...@@ -362,7 +362,7 @@ static int mt7615_load_patch(struct mt7615_dev *dev)
return -EAGAIN; return -EAGAIN;
} }
ret = request_firmware(&fw, MT7615_ROM_PATCH, dev->mt76.dev); ret = request_firmware(&fw, name, dev->mt76.dev);
if (ret) if (ret)
goto out; goto out;
...@@ -458,13 +458,13 @@ mt7615_mcu_send_ram_firmware(struct mt7615_dev *dev, ...@@ -458,13 +458,13 @@ mt7615_mcu_send_ram_firmware(struct mt7615_dev *dev,
return 0; return 0;
} }
static int mt7615_load_ram(struct mt7615_dev *dev) static int mt7615_load_n9(struct mt7615_dev *dev, const char *name)
{ {
const struct mt7615_fw_trailer *hdr; const struct mt7615_fw_trailer *hdr;
const struct firmware *fw; const struct firmware *fw;
int ret; int ret;
ret = request_firmware(&fw, MT7615_FIRMWARE_N9, dev->mt76.dev); ret = request_firmware(&fw, name, dev->mt76.dev);
if (ret) if (ret)
return ret; return ret;
...@@ -491,9 +491,18 @@ static int mt7615_load_ram(struct mt7615_dev *dev) ...@@ -491,9 +491,18 @@ static int mt7615_load_ram(struct mt7615_dev *dev)
goto out; goto out;
} }
out:
release_firmware(fw); release_firmware(fw);
return ret;
}
static int mt7615_load_cr4(struct mt7615_dev *dev, const char *name)
{
const struct mt7615_fw_trailer *hdr;
const struct firmware *fw;
int ret;
ret = request_firmware(&fw, MT7615_FIRMWARE_CR4, dev->mt76.dev); ret = request_firmware(&fw, name, dev->mt76.dev);
if (ret) if (ret)
return ret; return ret;
...@@ -529,6 +538,17 @@ static int mt7615_load_ram(struct mt7615_dev *dev) ...@@ -529,6 +538,17 @@ static int mt7615_load_ram(struct mt7615_dev *dev)
return ret; return ret;
} }
static int mt7615_load_ram(struct mt7615_dev *dev)
{
int ret;
ret = mt7615_load_n9(dev, MT7615_FIRMWARE_N9);
if (ret)
return ret;
return mt7615_load_cr4(dev, MT7615_FIRMWARE_CR4);
}
static int mt7615_load_firmware(struct mt7615_dev *dev) static int mt7615_load_firmware(struct mt7615_dev *dev)
{ {
int ret; int ret;
...@@ -541,7 +561,7 @@ static int mt7615_load_firmware(struct mt7615_dev *dev) ...@@ -541,7 +561,7 @@ static int mt7615_load_firmware(struct mt7615_dev *dev)
return -EIO; return -EIO;
} }
ret = mt7615_load_patch(dev); ret = mt7615_load_patch(dev, MT7615_ROM_PATCH);
if (ret) if (ret)
return ret; return ret;
......
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