mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-19 08:21:27 +01:00
net: phy: aquantia: use generic firmware loader
Aquantia PHYs are being used w/o SPI flash in some routers recently. Current firmware loader only attempts to load from FS on top of MMC, limiting the use on many devices. Removed the old firmware loader, migrate to generic script based firmware loader to allow a wider range and runtime override of firmware source. (e.g., MMC, USB, UBIFS). Tested on Buffalo WXR18000BE10P with UBIFS. Signed-off-by: Beiyan Yun <root@infi.wang>
This commit is contained in:
parent
322b056116
commit
14ece61178
@ -91,23 +91,22 @@ menuconfig PHY_AQUANTIA
|
|||||||
config PHY_AQUANTIA_UPLOAD_FW
|
config PHY_AQUANTIA_UPLOAD_FW
|
||||||
bool "Aquantia firmware loading support"
|
bool "Aquantia firmware loading support"
|
||||||
depends on PHY_AQUANTIA
|
depends on PHY_AQUANTIA
|
||||||
|
select FW_LOADER
|
||||||
help
|
help
|
||||||
Aquantia PHYs use firmware which can be either loaded automatically
|
Aquantia PHYs use firmware which can be either loaded automatically
|
||||||
from storage directly attached to the phy or loaded by the boot loader
|
from storage directly attached to the phy or loaded by the boot loader
|
||||||
via MDIO commands. The firmware is loaded from a file, specified by
|
via MDIO commands.
|
||||||
the PHY_AQUANTIA_FW_PART and PHY_AQUANTIA_FW_NAME options.
|
|
||||||
|
|
||||||
config PHY_AQUANTIA_FW_PART
|
This option enables loading the firmware using the generic
|
||||||
string "Aquantia firmware partition"
|
firmware loader framework.
|
||||||
depends on PHY_AQUANTIA_UPLOAD_FW
|
|
||||||
help
|
|
||||||
Partition containing the firmware file.
|
|
||||||
|
|
||||||
config PHY_AQUANTIA_FW_NAME
|
config PHY_AQUANTIA_FW_MAX_SIZE
|
||||||
string "Aquantia firmware filename"
|
hex "Max firmware size"
|
||||||
depends on PHY_AQUANTIA_UPLOAD_FW
|
depends on PHY_AQUANTIA_UPLOAD_FW
|
||||||
|
default 0x80000
|
||||||
help
|
help
|
||||||
Firmware filename.
|
The maximum size of the Aquantia PHY firmware. This is used to
|
||||||
|
allocate a buffer to load the firmware into.
|
||||||
|
|
||||||
config PHY_ATHEROS
|
config PHY_ATHEROS
|
||||||
bool "Atheros Ethernet PHYs support"
|
bool "Atheros Ethernet PHYs support"
|
||||||
|
|||||||
@ -16,7 +16,9 @@
|
|||||||
#include <u-boot/crc.h>
|
#include <u-boot/crc.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <asm/byteorder.h>
|
#include <asm/byteorder.h>
|
||||||
#include <fs.h>
|
#if (IS_ENABLED(CONFIG_PHY_AQUANTIA_UPLOAD_FW))
|
||||||
|
#include <fw_loader.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define AQUNTIA_10G_CTL 0x20
|
#define AQUNTIA_10G_CTL 0x20
|
||||||
#define AQUNTIA_VENDOR_P1 0xc400
|
#define AQUNTIA_VENDOR_P1 0xc400
|
||||||
@ -127,52 +129,29 @@ struct fw_header {
|
|||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
#if defined(CONFIG_PHY_AQUANTIA_UPLOAD_FW)
|
#if (IS_ENABLED(CONFIG_PHY_AQUANTIA_UPLOAD_FW))
|
||||||
static int aquantia_read_fw(u8 **fw_addr, size_t *fw_length)
|
int __weak aquantia_read_fw(struct phy_device *phydev,
|
||||||
|
u8 **fw_addr, size_t *fw_length)
|
||||||
{
|
{
|
||||||
loff_t length, read;
|
|
||||||
int ret;
|
int ret;
|
||||||
void *addr = NULL;
|
u8 *microcode;
|
||||||
|
|
||||||
*fw_addr = NULL;
|
microcode = malloc(CONFIG_PHY_AQUANTIA_FW_MAX_SIZE);
|
||||||
*fw_length = 0;
|
if (!microcode) {
|
||||||
debug("Loading Aquantia microcode from %s %s\n",
|
printf("Failed to allocate memory for firmware\n");
|
||||||
CONFIG_PHY_AQUANTIA_FW_PART, CONFIG_PHY_AQUANTIA_FW_NAME);
|
return -ENOMEM;
|
||||||
ret = fs_set_blk_dev("mmc", CONFIG_PHY_AQUANTIA_FW_PART, FS_TYPE_ANY);
|
|
||||||
if (ret < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = fs_size(CONFIG_PHY_AQUANTIA_FW_NAME, &length);
|
|
||||||
if (ret < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
addr = malloc(length);
|
|
||||||
if (!addr) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fs_set_blk_dev("mmc", CONFIG_PHY_AQUANTIA_FW_PART, FS_TYPE_ANY);
|
ret = request_firmware_into_buf_via_script(
|
||||||
if (ret < 0)
|
microcode, CONFIG_PHY_AQUANTIA_FW_MAX_SIZE,
|
||||||
goto cleanup;
|
"aqr_phy_load_firmware", fw_length);
|
||||||
|
if (ret) {
|
||||||
ret = fs_read(CONFIG_PHY_AQUANTIA_FW_NAME, (ulong)addr, 0, length,
|
free(microcode);
|
||||||
&read);
|
return ret;
|
||||||
if (ret < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
*fw_addr = addr;
|
|
||||||
*fw_length = length;
|
|
||||||
debug("Found Aquantia microcode.\n");
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (ret < 0) {
|
|
||||||
printf("loading firmware file %s %s failed with error %d\n",
|
|
||||||
CONFIG_PHY_AQUANTIA_FW_PART,
|
|
||||||
CONFIG_PHY_AQUANTIA_FW_NAME, ret);
|
|
||||||
free(addr);
|
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
*fw_addr = microcode;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load data into the phy's memory */
|
/* load data into the phy's memory */
|
||||||
@ -293,16 +272,17 @@ static int aquantia_do_upload_firmware(struct phy_device *phydev,
|
|||||||
|
|
||||||
static int aquantia_upload_firmware(struct phy_device *phydev)
|
static int aquantia_upload_firmware(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret, fwrc;
|
||||||
u8 *addr = NULL;
|
u8 *addr = NULL;
|
||||||
size_t fw_length = 0;
|
size_t fw_length;
|
||||||
|
|
||||||
ret = aquantia_read_fw(&addr, &fw_length);
|
fwrc = aquantia_read_fw(phydev, &addr, &fw_length);
|
||||||
if (ret != 0)
|
if (fwrc < 0)
|
||||||
return ret;
|
return fwrc;
|
||||||
|
|
||||||
ret = aquantia_do_upload_firmware(phydev, addr, fw_length);
|
ret = aquantia_do_upload_firmware(phydev, addr, fw_length);
|
||||||
free(addr);
|
if (fwrc > 0)
|
||||||
|
free(addr);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user