Skip to contentSkip to conversation

net: phy: aquantia: Switch to generic firmware loader

PATCH In review Beiyan Yun 3 participants 9 messages Nov 1, 2025 – Nov 29, 2025

Subsystems (2)
lore
Share & tools
lore

Beiyan Yun

author
#0 lore raw

v5 cover net: phy: aquantia: Switch to generic firmware loader

Hi,

This patch series refactors the Aquantia PHY firmware loader to use the generic fwloader framework.

The existing loader is limited to loading firmware from an MMC device, which restricts its use on many devices (e.g., routers) that may use other storage like USB or have a UBIFS root filesystem. Migrating to the generic firmware loader allows firmware to be sourced from any backend supported by the fwloader scripting framework.

The series is structured as follows:
- The first patch prepares current loading code for fwloader.
- The second and main patch replaces the custom loader with generic one.

This change has been tested on a Buffalo WXR18000BE10P router, loading firmware from a UBIFS volume for Marvell CUX3410.

Changes in v5:
- Remove fsloader codepath
- Drop binding changes
- Make script name static
- Minor refactor

Changes in v4:
- Split firmware upload helpers change
- Reorder aquantia_read_fw
- Make aquantia_read_fw weak to allow overide
- Rename exit label in aquantia_read_fw
- Kconfig polish

Changes in v3:
- Select FW_LOADER with PHY_AQUANTIA_UPLOAD_FW

Changes in v2:
- Add support for script based loader

Beiyan Yun (2):
net: phy: aquantia: refactor firmware upload helpers
net: phy: aquantia: use generic firmware loader

 drivers/net/phy/Kconfig    |  23 ++++-----
 drivers/net/phy/aquantia.c | 103 +++++++++++++++++--------------------
 2 files changed, 59 insertions(+), 67 deletions(-)
Signature · 4 lines
2.47.3

base-commit: 62b45e82bdbf703571450e97f605893fe0d50530
branch: aquantia-fsloader-v5
author
#1 lore raw

PATCH v5 1/2 net: phy: aquantia: refactor firmware upload helpers

Split aquantia_upload_firmware into aquantia_upload_firmware and aquantia_do_upload_firmware to prepare for fwloader change.

---

Changes in v5:
- Minor refactor

Changes in v4:
- New

 drivers/net/phy/aquantia.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)
drivers/net/phy/aquantia.c +25 -12
index 903fcd667f6..fc2476fb038 100644
@@ -218,27 +218,26 @@ static u32 unpack_u24(const u8 *data)
 	return (data[2] << 16) + (data[1] << 8) + data[0];
 }
 
-static int aquantia_upload_firmware(struct phy_device *phydev)
+static int aquantia_do_upload_firmware(struct phy_device *phydev,
+					const u8 *addr, size_t fw_length)
 {
 	int ret;
-	u8 *addr = NULL;
-	size_t fw_length = 0;
 	u16 calculated_crc, read_crc;
 	char version[VERSION_STRING_SIZE];
 	u32 primary_offset, iram_offset, iram_size, dram_offset, dram_size;
 	const struct fw_header *header;
 
-	ret = aquantia_read_fw(&addr, &fw_length);
-	if (ret != 0)
-		return ret;
+	if (!addr || !fw_length) {
+		printf("%s: Invalid firmware data\n", phydev->dev->name);
+		return -EINVAL;
+	}
 
-	read_crc = (addr[fw_length - 2] << 8)  | addr[fw_length - 1];
+	read_crc = (addr[fw_length - 2] << 8) | addr[fw_length - 1];
 	calculated_crc = crc16_ccitt(0, addr, fw_length - 2);
 	if (read_crc != calculated_crc) {
 		printf("%s bad firmware crc: file 0x%04x calculated 0x%04x\n",
 		       phydev->dev->name, read_crc, calculated_crc);
-		ret = -EINVAL;
-		goto done;
+		return -EINVAL;
 	}
 
 	/* Find the DRAM and IRAM sections within the firmware file. */
@@ -268,14 +267,14 @@ static int aquantia_upload_firmware(struct phy_device *phydev)
 	ret = aquantia_load_memory(phydev, DRAM_BASE_ADDR, &addr[dram_offset],
 				   dram_size);
 	if (ret != 0)
-		goto done;
+		return ret;
 
 	debug("loading iram 0x%08x from offset=%d size=%d\n",
 	      IRAM_BASE_ADDR, iram_offset, iram_size);
 	ret = aquantia_load_memory(phydev, IRAM_BASE_ADDR, &addr[iram_offset],
 				   iram_size);
 	if (ret != 0)
-		goto done;
+		return ret;
 
 	/* make sure soft reset and low power mode are clear */
 	phy_write(phydev, MDIO_MMD_VEND1, GLOBAL_STANDARD_CONTROL, 0);
@@ -289,8 +288,22 @@ static int aquantia_upload_firmware(struct phy_device *phydev)
 	phy_write(phydev, MDIO_MMD_VEND1, UP_CONTROL, UP_RUN_STALL_OVERRIDE);
 
 	printf("%s firmware loading done.\n", phydev->dev->name);
-done:
+	return 0;
+}
+
+static int aquantia_upload_firmware(struct phy_device *phydev)
+{
+	int ret;
+	u8 *addr = NULL;
+	size_t fw_length = 0;
+
+	ret = aquantia_read_fw(&addr, &fw_length);
+	if (ret != 0)
+		return ret;
+
+	ret = aquantia_do_upload_firmware(phydev, addr, fw_length);
 	free(addr);
+
 	return ret;
 }
 #else
Signature · 1 line
2.47.3
author
#2 lore raw

PATCH v5 2/2 net: phy: aquantia: use generic firmware loader

In reply to Beiyan Yun

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.

---

Changes in v5:
- Remove fsloader codepath
- Drop binding changes
- Make script name static

Changes in v4:
- Split firmware upload helpers change
- Reorder aquantia_read_fw
- Make aquantia_read_fw weak to allow overide
- Rename exit label in aquantia_read_fw
- Kconfig polish

Changes in v3:
- Select FW_LOADER with PHY_AQUANTIA_UPLOAD_FW

Changes in v2:
- Add support for script based loader

 drivers/net/phy/Kconfig    | 23 ++++++------
 drivers/net/phy/aquantia.c | 76 ++++++++++++++------------------------
 2 files changed, 39 insertions(+), 60 deletions(-)
drivers/net/phy/Kconfig +11 -12
index 018be98705a..d8845469dd5 100644
@@ -91,23 +91,22 @@ menuconfig PHY_AQUANTIA
 config PHY_AQUANTIA_UPLOAD_FW
 	bool "Aquantia firmware loading support"
 	depends on PHY_AQUANTIA
+	select FW_LOADER
 	help
-		Aquantia PHYs use firmware which can be either loaded automatically
-		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
-		the PHY_AQUANTIA_FW_PART and PHY_AQUANTIA_FW_NAME options.
+	  Aquantia PHYs use firmware which can be either loaded automatically
+	  from storage directly attached to the phy or loaded by the boot loader
+	  via MDIO commands.
 
-config PHY_AQUANTIA_FW_PART
-	string "Aquantia firmware partition"
-	depends on PHY_AQUANTIA_UPLOAD_FW
-	help
-		Partition containing the firmware file.
+	  This option enables loading the firmware using the generic
+	  firmware loader framework.
 
-config PHY_AQUANTIA_FW_NAME
-	string "Aquantia firmware filename"
+config PHY_AQUANTIA_FW_MAX_SIZE
+	hex "Max firmware size"
 	depends on PHY_AQUANTIA_UPLOAD_FW
+	default 0x80000
 	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
 	bool "Atheros Ethernet PHYs support"
drivers/net/phy/aquantia.c +28 -48

103 lines not on this page · raw message

Signature · 1 line
2.47.3
author
#3 lore raw
In reply to Beiyan Yun

Hi all,

Gentle ping. Any comments on this patch?

Thanks,
Yun

Quoted 53 lines

Beiyan Yun <[email protected]>於2025年11月1日 下午8:34寫道:


Hi,

This patch series refactors the Aquantia PHY firmware loader to use the generic fwloader framework.

The existing loader is limited to loading firmware from an MMC device, which restricts its use on many devices (e.g., routers) that may use other storage like USB or have a UBIFS root filesystem. Migrating to the generic firmware loader allows firmware to be sourced from any backend supported by the fwloader scripting framework.

The series is structured as follows:
- The first patch prepares current loading code for fwloader.
- The second and main patch replaces the custom loader with generic one.

This change has been tested on a Buffalo WXR18000BE10P router, loading firmware from a UBIFS volume for Marvell CUX3410.

Changes in v5:
- Remove fsloader codepath
- Drop binding changes
- Make script name static
- Minor refactor

Changes in v4:
- Split firmware upload helpers change
- Reorder aquantia_read_fw
- Make aquantia_read_fw weak to allow overide
- Rename exit label in aquantia_read_fw
- Kconfig polish

Changes in v3:
- Select FW_LOADER with PHY_AQUANTIA_UPLOAD_FW

Changes in v2:
- Add support for script based loader

Beiyan Yun (2):
net: phy: aquantia: refactor firmware upload helpers
net: phy: aquantia: use generic firmware loader

drivers/net/phy/Kconfig | 23 ++++-----
drivers/net/phy/aquantia.c | 103 +++++++++++++++++--------------------

2 files changed, 59 insertions(+), 67 deletions(-)

--
2.47.3

base-commit: 62b45e82bdbf703571450e97f605893fe0d50530
branch: aquantia-fsloader-v5

#4 lore raw

Hi Yun,

Quoted 3 lines · Beiyan Yun

Hi all,

Gentle ping. Any comments on this patch?

Since there is no comment I will pick it up and move it to my net-next queue. Thanks!

Signature · 1 line
Jerome
Quoted 57 lines

Thanks,
Yun

Quoted 53 lines

Beiyan Yun <[email protected]>於2025年11月1日 下午8:34寫道:


Hi,

This patch series refactors the Aquantia PHY firmware loader to use the generic fwloader framework.

The existing loader is limited to loading firmware from an MMC device, which restricts its use on many devices (e.g., routers) that may use other storage like USB or have a UBIFS root filesystem. Migrating to the generic firmware loader allows firmware to be sourced from any backend supported by the fwloader scripting framework.

The series is structured as follows:
- The first patch prepares current loading code for fwloader.
- The second and main patch replaces the custom loader with generic one.

This change has been tested on a Buffalo WXR18000BE10P router, loading firmware from a UBIFS volume for Marvell CUX3410.

Changes in v5:
- Remove fsloader codepath
- Drop binding changes
- Make script name static
- Minor refactor

Changes in v4:
- Split firmware upload helpers change
- Reorder aquantia_read_fw
- Make aquantia_read_fw weak to allow overide
- Rename exit label in aquantia_read_fw
- Kconfig polish

Changes in v3:
- Select FW_LOADER with PHY_AQUANTIA_UPLOAD_FW

Changes in v2:
- Add support for script based loader

Beiyan Yun (2):
net: phy: aquantia: refactor firmware upload helpers
net: phy: aquantia: use generic firmware loader

drivers/net/phy/Kconfig | 23 ++++-----
drivers/net/phy/aquantia.c | 103 +++++++++++++++++--------------------

2 files changed, 59 insertions(+), 67 deletions(-)

--
2.47.3

base-commit: 62b45e82bdbf703571450e97f605893fe0d50530
branch: aquantia-fsloader-v5

#5 lore raw
Quoted 8 lines · Jerome Forissier

Hi Yun,

Quoted 3 lines · Beiyan Yun

Hi all,

Gentle ping. Any comments on this patch?

Since there is no comment I will pick it up and move it to my net-next queue.

Ideally the driver should use one firmware loader, not both.

#6 lore raw
Quoted 11 lines · Marek Vasut
Quoted 8 lines · Jerome Forissier

Hi Yun,

Quoted 3 lines · Beiyan Yun

Hi all,

Gentle ping. Any comments on this patch?

Since there is no comment I will pick it up and move it to my net-next queue.

Ideally the driver should use one firmware loader, not both.

Is this a NACK or can things be improved later on?

Signature · 1 line
Jerome
author
#7 lore raw
In reply to Marek Vasut

Hi Marek,

Quoted 11 lines · Marek Vasut
Quoted 6 lines · Jerome Forissier

Hi Yun,

Quoted 3 lines · Beiyan Yun

Hi all,

Gentle ping. Any comments on this patch?

Since there is no comment I will pick it up and move it to my net-next queue.

Ideally the driver should use one firmware loader, not both.

v5 removed fsloader, only the fwloader codepath is used.

#8 lore raw

On 11/29/25 4:10 AM, Beiyan Yun wrote:

Hello Yun,

Quoted 5 lines
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Jerome Forissier

Hi Yun,
On 11/15/25 08:48, Beiyan Yun wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Hi all,

Gentle ping. Any comments on this patch?

Since there is no comment I will pick it up and move it to my net-next queue.

Ideally the driver should use one firmware loader, not both.

v5 removed fsloader, only the fwloader codepath is used.

Oh, that's nice, thank you.