Skip to contentSkip to conversation

net: phy: Add the Airoha EN8811H PHY driver

PATCH Superseded Lucien.Jheng 2 participants 7 messages Sep 14, 2025 – Sep 22, 2025

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 net: phy: Add the Airoha EN8811H PHY driver

Add the driver for the Airoha EN8811H 2.5 Gigabit PHY. The PHY supports 100/1000/2500 Mbps with auto negotiation only.

The driver uses two firmware files, for which updated versions are added to linux-firmware already.

Locating the AIROHA FW within the filesystem at the designated partition and path will trigger its automatic loading and writing to the PHY via MDIO. If need board specific loading override,
please override the en8811h_read_fw function on board or architecture level.

Linux upstream AIROHA EN8811H driver commit:
71e79430117d56c409c5ea485a263bc0d8083390

Based on the Linux upstream AIROHA EN8811H driver code(air_en8811h.c), I have modified the relevant process to align with the U-Boot boot sequence. and have validated this on Banana Pi BPI-R3 Mini.

---
Change in PATCH v4:
air_en8811.c:
* Create the airoha folder to store all future airoha phy drivers.
* Use request_firmware_into_buf_via_script for firmware loading.

Change in PATCH v3:
air_en8811.c:
* Add U-Boot environment variable(en8811h_fw_part, en8811h_fw_dm_dir, en8811h_fw_dsp_dir) support for firmware loading.

Regarding the firmware loading mechanism,
Please refer to the following script example for guidance:
1. `env set en8811h_load_firmware 'env set fw_addr 0x46000000 && env set fw_size 0x24000 && mw.b ${fw_addr} 0 ${fw_size} && load mmc 0:3 0x46000000 /boot/EthMD32.dm.bin && if test ${filesize} -eq 4000; then load mmc 0:3 0x46004000 /boot/EthMD32.DSP.bin; else echo "loading MD32 FW failed"; env set fw_size 0; exit 1;fi'`

````Test Log````
Net:   16384 bytes read in 1 ms (15.6 MiB/s)
131072 bytes read in 9 ms (13.9 MiB/s)
addr: 0x46000000, size: 0x24000
Found Airoha Firmware.
MD32 firmware version: 24112802
````End of Test Log````

2. env set en8811h_load_firmware 'env set fw_addr 0x46000000 && env set fw_size 0x24000 && mmc partconf 0 1 2 2 && mmc read $fw_addr 0x0 0x120 && mmc partconf 0 1 1 0'

````Test Log````
Net:   MMC read: dev # 0, block # 0, count 288 ... 288 blocks read: OK
addr: 0x46000000, size: 0x24000
Found Airoha Firmware.
MD32 firmware version: 24112802
````End of Test Log````
 drivers/net/phy/Kconfig             |   2 +
 drivers/net/phy/Makefile            |   1 +
 drivers/net/phy/airoha/Kconfig      |  11 +
 drivers/net/phy/airoha/Makefile     |   3 +
 drivers/net/phy/airoha/air_en8811.c | 833 ++++++++++++++++++++++++++++
 5 files changed, 850 insertions(+)
 create mode 100644 drivers/net/phy/airoha/Kconfig
 create mode 100644 drivers/net/phy/airoha/Makefile
 create mode 100644 drivers/net/phy/airoha/air_en8811.c
drivers/net/phy/Kconfig +2 -0
index 21bf983056a..538819d92cd 100644
@@ -184,6 +184,8 @@ config PHY_MARVELL_10G
 	help
 	  Support for the Marvell Alaska MV88X3310 and compatible PHYs.
 
+source "drivers/net/phy/airoha/Kconfig"
+
 config PHY_MESON_GXL
 	bool "Amlogic Meson GXL Internal PHY support"
 
drivers/net/phy/Makefile +1 -0
index a119eb5e177..62446e4ef44 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_PHY_ET1011C) += et1011c.o
 obj-$(CONFIG_PHY_LXT) += lxt.o
 obj-$(CONFIG_PHY_MARVELL) += marvell.o
 obj-$(CONFIG_PHY_MARVELL_10G) += marvell10g.o
+obj-y += airoha/
 obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
 obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
 obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
drivers/net/phy/airoha/Kconfig new file +11 -0
new file mode 100644
index 00000000000..84f12ebb1a2
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+menuconfig PHY_AIROHA
+	bool "Airoha Ethernet PHYs support"
+
+config PHY_AIROHA_EN8811
+	bool "Airoha Ethernet EN8811H support"
+	depends on PHY_AIROHA
+        select FS_LOADER
+	help
+	  AIROHA EN8811H supported.
+
drivers/net/phy/airoha/Makefile new file +3 -0
new file mode 100644
index 00000000000..84d23b19ab0
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_PHY_AIROHA_EN8811) += air_en8811.o
drivers/net/phy/airoha/air_en8811.c new file +833 -0

833 lines not on this page · raw message

--
2.34.1

#1 lore raw
Quoted 18 lines · Lucien.Jheng

Add the driver for the Airoha EN8811H 2.5 Gigabit PHY. The PHY supports 100/1000/2500 Mbps with auto negotiation only.

The driver uses two firmware files, for which updated versions are added to linux-firmware already.

Locating the AIROHA FW within the filesystem at the designated partition and path will trigger its automatic loading and writing to the PHY via MDIO. If need board specific loading override,
please override the en8811h_read_fw function on board or architecture level.

Linux upstream AIROHA EN8811H driver commit:
71e79430117d56c409c5ea485a263bc0d8083390

Based on the Linux upstream AIROHA EN8811H driver code(air_en8811h.c), I have modified the relevant process to align with the U-Boot boot sequence. and have validated this on Banana Pi BPI-R3 Mini.

Quoted 5 lines

---
Change in PATCH v4:
air_en8811.c:
* Create the airoha folder

directory

Quoted 2 lines

to store all future airoha phy drivers.
* Use request_firmware_into_buf_via_script for firmware loading.

[...]

drivers/net/phy/airoha/Kconfig line 8

Quoted 10 lines

+++ b/drivers/net/phy/airoha/Kconfig

drivers/net/phy/airoha/Kconfig new file +8 -0
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+menuconfig PHY_AIROHA
+	bool "Airoha Ethernet PHYs support"
+
+config PHY_AIROHA_EN8811
+	bool "Airoha Ethernet EN8811H support"
+	depends on PHY_AIROHA
+        select FS_LOADER

It seems tabs/spaces are mixed here, please fix.

Quoted 2 lines
drivers/net/phy/airoha/Kconfig new file +2 -0
+	help
+	  AIROHA EN8811H supported.

[...]

drivers/net/phy/airoha/air_en8811.c line 39

Quoted 8 lines
drivers/net/phy/airoha/air_en8811.c new file +8 -0
+#define EN8811H_MD32_DM_SIZE	0x4000
+#define EN8811H_MD32_DSP_SIZE	0x20000
+
+ #define EN8811H_FW_CTRL_1		0x0f0018
+ #define EN8811H_FW_CTRL_1_START	0x0
+ #define EN8811H_FW_CTRL_1_FINISH	0x1
+ #define EN8811H_FW_CTRL_2		0x800000
+ #define EN8811H_FW_CTRL_2_LOADING	BIT(11)

Same here, avoid leading space.

[...]

Quoted 1 line

+__weak int en8811h_read_fw(void **addr)

Does this still have to be a __weak function, now that it uses generic fw loader ?

Quoted 4 lines
drivers/net/phy/airoha/air_en8811.c new file +4 -0
+{
+	void *buffer;
+	int ret;
+

drivers/net/phy/airoha/air_en8811.c line 479

Quoted 10 lines
drivers/net/phy/airoha/air_en8811.c new file +10 -0
+	if (!IS_ENABLED(CONFIG_FS_LOADER))
+		return -EOPNOTSUPP;
+
+	buffer = malloc(EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE);
+	if (!buffer) {
+		printf("Failed to allocate memory for firmware\n");
+		return -ENOMEM;
+	}
+
+	ret = request_firmware_into_buf_via_script(&buffer,

I think 'buffer' without the & should be used here.

Quoted 2 lines
drivers/net/phy/airoha/air_en8811.c new file +2 -0
+						   EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE,
+						   "en8811h_load_firmware");

[...]

#2 lore raw

Hi Marek

Thank you for reviewing my patch.

Marek Vasut 於 2025/9/15 上午 01:49 寫道:

Quoted 68 lines · Lucien.Jheng
Quoted 18 lines

Add the driver for the Airoha EN8811H 2.5 Gigabit PHY. The PHY supports 100/1000/2500 Mbps with auto negotiation only.

The driver uses two firmware files, for which updated versions are added to linux-firmware already.

Locating the AIROHA FW within the filesystem at the designated partition and path will trigger its automatic loading and writing to the PHY via MDIO. If need board specific loading override,
please override the en8811h_read_fw function on board or architecture level.

Linux upstream AIROHA EN8811H driver commit:
71e79430117d56c409c5ea485a263bc0d8083390

Based on the Linux upstream AIROHA EN8811H driver code(air_en8811h.c), I have modified the relevant process to align with the U-Boot boot sequence. and have validated this on Banana Pi BPI-R3 Mini.

Quoted 5 lines

---
Change in PATCH v4:
air_en8811.c:
  * Create the airoha folder

directory

Quoted 2 lines

to store all future airoha phy drivers.
  * Use request_firmware_into_buf_via_script for firmware loading.

[...]

drivers/net/phy/airoha/Kconfig line 8

Quoted 10 lines

+++ b/drivers/net/phy/airoha/Kconfig

drivers/net/phy/airoha/Kconfig new file +8 -0
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+menuconfig PHY_AIROHA
+    bool "Airoha Ethernet PHYs support"
+
+config PHY_AIROHA_EN8811
+    bool "Airoha Ethernet EN8811H support"
+    depends on PHY_AIROHA
+        select FS_LOADER

It seems tabs/spaces are mixed here, please fix.

Quoted 2 lines
drivers/net/phy/airoha/Kconfig new file +2 -0
+    help
+      AIROHA EN8811H supported.

[...]

drivers/net/phy/airoha/air_en8811.c line 39

Quoted 8 lines
drivers/net/phy/airoha/air_en8811.c new file +8 -0
+#define EN8811H_MD32_DM_SIZE    0x4000
+#define EN8811H_MD32_DSP_SIZE    0x20000
+
+ #define EN8811H_FW_CTRL_1        0x0f0018
+ #define EN8811H_FW_CTRL_1_START    0x0
+ #define EN8811H_FW_CTRL_1_FINISH    0x1
+ #define EN8811H_FW_CTRL_2        0x800000
+ #define EN8811H_FW_CTRL_2_LOADING    BIT(11)

Same here, avoid leading space.

[...]

Quoted 1 line

+__weak int en8811h_read_fw(void **addr)

Does this still have to be a __weak function, now that it uses generic fw loader ?

Quoted 16 lines
Quoted 4 lines
drivers/net/phy/airoha/air_en8811.c new file +4 -0
+{
+    void *buffer;
+    int ret;
+

drivers/net/phy/airoha/air_en8811.c line 479

Quoted 10 lines
drivers/net/phy/airoha/air_en8811.c new file +10 -0
+    if (!IS_ENABLED(CONFIG_FS_LOADER))
+        return -EOPNOTSUPP;
+
+    buffer = malloc(EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE);
+    if (!buffer) {
+        printf("Failed to allocate memory for firmware\n");
+        return -ENOMEM;
+    }
+
+    ret = request_firmware_into_buf_via_script(&buffer,

I think 'buffer' without the & should be used here.

Regarding buffer,

I've reviewed the function definition for request_firmware_into_buf_via_script. The first parameter is void **buf, which is a pointer to a pointer.

I think passing &buffer is the correct way to call this function.

If we were to pass just buffer (a void *), the function would receive a copy of the pointer's value, and any memory allocation inside the function would not be reflected in our original buffer variable.

Please let me know if my understanding is incorrect, as I want to ensure I'm using the function as intended.

Quoted 4 lines
Quoted 3 lines

+ EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE, +                           "en8811h_load_firmware");

[...]

#3 lore raw

On 9/15/25 4:35 PM, Lucien.Jheng wrote:

Hi,

sorry for the late reply.

Quoted 23 lines
Quoted 4 lines
Quoted 1 line

+__weak int en8811h_read_fw(void **addr)

Does this still have to be a __weak function, now that it uses generic fw loader ?

Quoted 16 lines
Quoted 4 lines
drivers/net/phy/airoha/air_en8811.c new file +4 -0
+{
+    void *buffer;
+    int ret;
+

drivers/net/phy/airoha/air_en8811.c line 479

Quoted 10 lines
drivers/net/phy/airoha/air_en8811.c new file +10 -0
+    if (!IS_ENABLED(CONFIG_FS_LOADER))
+        return -EOPNOTSUPP;
+
+    buffer = malloc(EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE);
+    if (!buffer) {
+        printf("Failed to allocate memory for firmware\n");
+        return -ENOMEM;
+    }
+
+    ret = request_firmware_into_buf_via_script(&buffer,

I think 'buffer' without the & should be used here.

Regarding buffer,

Quoted 8 lines

I've reviewed the function definition for request_firmware_into_buf_via_script. The first parameter is void **buf, which is a pointer to a pointer.

I think passing &buffer is the correct way to call this function.

If we were to pass just buffer (a void *), the function would receive a copy of the pointer's value, and any memory allocation inside the function would not be reflected in our original buffer variable.

Please let me know if my understanding is incorrect, as I want to ensure I'm using the function as intended.

I was confused by the current request_firmware_into_buf_via_script() interface.

In the current design, passing pointer to pointer into request_firmware_into_buf_via_script() is not necessary, because the request_firmware_into_buf_via_script() function internally does memcpy() into the 'buf' buffer, and for that to work, pointer to pointer is not necessary, plain pointer to buffer would do just fine.

I think this current interface which does memcpy() is actually better than the one I originally suggested which would use memdup(), so let's keep it.

I now sent an update patch to remove the pointer to pointer:

[PATCH] misc: fs_loader: Use buffer pointer in request_firmware_into_buf_via_script()

That should be all I hope.

#4 lore raw

Hi Marek

Marek Vasut 於 2025/9/22 上午 06:40 寫道:

Quoted 41 lines · Lucien.Jheng

Hi,

sorry for the late reply.

Quoted 23 lines
Quoted 4 lines
Quoted 1 line

+__weak int en8811h_read_fw(void **addr)

Does this still have to be a __weak function, now that it uses generic fw loader ?

Quoted 16 lines
Quoted 4 lines
drivers/net/phy/airoha/air_en8811.c new file +4 -0
+{
+    void *buffer;
+    int ret;
+

drivers/net/phy/airoha/air_en8811.c line 479

Quoted 10 lines
drivers/net/phy/airoha/air_en8811.c new file +10 -0
+    if (!IS_ENABLED(CONFIG_FS_LOADER))
+        return -EOPNOTSUPP;
+
+    buffer = malloc(EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE);
+    if (!buffer) {
+        printf("Failed to allocate memory for firmware\n");
+        return -ENOMEM;
+    }
+
+    ret = request_firmware_into_buf_via_script(&buffer,

I think 'buffer' without the & should be used here.

Regarding buffer,

Quoted 8 lines

I've reviewed the function definition for request_firmware_into_buf_via_script. The first parameter is void **buf, which is a pointer to a pointer.

I think passing &buffer is the correct way to call this function.

If we were to pass just buffer (a void *), the function would receive a copy of the pointer's value, and any memory allocation inside the function would not be reflected in our original buffer variable.

Please let me know if my understanding is incorrect, as I want to ensure I'm using the function as intended.

I was confused by the current request_firmware_into_buf_via_script() interface.

In the current design, passing pointer to pointer into request_firmware_into_buf_via_script() is not necessary, because the request_firmware_into_buf_via_script() function internally does memcpy() into the 'buf' buffer, and for that to work, pointer to pointer is not necessary, plain pointer to buffer would do just fine.

Quoted 7 lines

I think this current interface which does memcpy() is actually better than the one I originally suggested which would use memdup(), so let's keep it.

I now sent an update patch to remove the pointer to pointer:

[PATCH] misc: fs_loader: Use buffer pointer in request_firmware_into_buf_via_script()

That should be all I hope.

Thank you for sharing.

After your patch commit, I will update the driver again.

#5 lore raw
Quoted 48 lines · Lucien.Jheng

Hi Marek

Marek Vasut 於 2025/9/22 上午 06:40 寫道:

Quoted 45 lines · Lucien.Jheng

Hi,

sorry for the late reply.

Quoted 23 lines
Quoted 4 lines
Quoted 1 line

+__weak int en8811h_read_fw(void **addr)

Does this still have to be a __weak function, now that it uses generic fw loader ?

Quoted 16 lines
Quoted 4 lines
drivers/net/phy/airoha/air_en8811.c new file +4 -0
+{
+    void *buffer;
+    int ret;
+

drivers/net/phy/airoha/air_en8811.c line 479

Quoted 10 lines
drivers/net/phy/airoha/air_en8811.c new file +10 -0
+    if (!IS_ENABLED(CONFIG_FS_LOADER))
+        return -EOPNOTSUPP;
+
+    buffer = malloc(EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE);
+    if (!buffer) {
+        printf("Failed to allocate memory for firmware\n");
+        return -ENOMEM;
+    }
+
+    ret = request_firmware_into_buf_via_script(&buffer,

I think 'buffer' without the & should be used here.

Regarding buffer,

Quoted 8 lines

I've reviewed the function definition for request_firmware_into_buf_via_script. The first parameter is void **buf, which is a pointer to a pointer.

I think passing &buffer is the correct way to call this function.

If we were to pass just buffer (a void *), the function would receive a copy of the pointer's value, and any memory allocation inside the function would not be reflected in our original buffer variable.

Please let me know if my understanding is incorrect, as I want to ensure I'm using the function as intended.

I was confused by the current request_firmware_into_buf_via_script() interface.

In the current design, passing pointer to pointer into request_firmware_into_buf_via_script() is not necessary, because the request_firmware_into_buf_via_script() function internally does memcpy() into the 'buf' buffer, and for that to work, pointer to pointer is not necessary, plain pointer to buffer would do just fine.

I think this current interface which does memcpy() is actually better than the one I originally suggested which would use memdup(), so let's keep it.

I now sent an update patch to remove the pointer to pointer:

Quoted 7 lines
Quoted 3 lines

[PATCH] misc: fs_loader: Use buffer pointer in request_firmware_into_buf_via_script()

That should be all I hope.

Thank you for sharing.

After your patch commit, I will update the driver again.

Thank you for that. I sent a few trivial nitpicks for V4 too, but nothing significant.

#6 lore raw
In reply to Lucien.Jheng

drivers/net/phy/airoha/air_en8811.c line 25

Quoted 12 lines · Lucien.Jheng
drivers/net/phy/airoha/air_en8811.c new file +12 -0
+#include <phy.h>
+#include <errno.h>
+#include <log.h>
+#include <env.h>
+#include <malloc.h>
+#include <fs_loader.h>
+#include <asm/unaligned.h>
+#include <linux/iopoll.h>
+#include <linux/bitops.h>
+#include <linux/compat.h>
+#include <dm/device_compat.h>
+#include <u-boot/crc.h>

Keep the list sorted.

drivers/net/phy/airoha/air_en8811.c line 119

Quoted 2 lines
drivers/net/phy/airoha/air_en8811.c new file +2 -0
+#define air_upper_16_bits(n) ((u16)((n) >> 16))
+#define air_lower_16_bits(n) ((u16)((n) & 0xffff))

As a separate/follow up patch, you could port Linux wordpart.h to U-Boot . [...]

drivers/net/phy/airoha/air_en8811.c line 199

Quoted 5 lines
drivers/net/phy/airoha/air_en8811.c new file +5 -0
+struct en8811h_priv {
+	int firmware_version;
+	bool		mcu_needs_restart;
+	struct led	led[EN8811H_LED_COUNT];
+};

Use tabs consistently , there is a space before firmware_version , replace with tab.

[...]

Quoted 40 lines
drivers/net/phy/airoha/air_en8811.c new file +40 -0
+static int en8811h_load_firmware(struct phy_device *phydev)
+{
+	struct en8811h_priv *priv = phydev->priv;
+	void *buffer;
+	int ret;
+
+	if (!IS_ENABLED(CONFIG_FS_LOADER))
+		return -EOPNOTSUPP;
+
+	ret = en8811h_read_fw(&buffer);
+	if (ret < 0)
+		goto en8811h_load_firmware_out;
+
+	ret = air_buckpbus_reg_write(phydev, EN8811H_FW_CTRL_1,
+				     EN8811H_FW_CTRL_1_START);
+	if (ret < 0)
+		goto en8811h_load_firmware_out;
+
+	ret = air_buckpbus_reg_modify(phydev, EN8811H_FW_CTRL_2,
+				      EN8811H_FW_CTRL_2_LOADING,
+				      EN8811H_FW_CTRL_2_LOADING);
+	if (ret < 0)
+		goto en8811h_load_firmware_out;
+
+	ret = air_write_buf(phydev, AIR_FW_ADDR_DM, EN8811H_MD32_DM_SIZE,
+			    (unsigned char *)buffer);
+	if (ret < 0)
+		goto en8811h_load_firmware_out;
+
+	ret = air_write_buf(phydev, AIR_FW_ADDR_DSP, EN8811H_MD32_DSP_SIZE,
+			    (unsigned char *)buffer + EN8811H_MD32_DM_SIZE);
+	if (ret < 0)
+		goto en8811h_load_firmware_out;
+
+	ret = air_buckpbus_reg_modify(phydev, EN8811H_FW_CTRL_2,
+				      EN8811H_FW_CTRL_2_LOADING, 0);
+	if (ret < 0)
+		goto en8811h_load_firmware_out;
+
+	ret = air_buckpbus_reg_write(phydev, EN8811H_FW_CTRL_1,

drivers/net/phy/airoha/air_en8811.c line 543

Quoted 10 lines
drivers/net/phy/airoha/air_en8811.c new file +10 -0
+				     EN8811H_FW_CTRL_1_FINISH);
+	if (ret < 0)
+		goto en8811h_load_firmware_out;
+
+	ret = en8811h_wait_mcu_ready(phydev);
+
+	air_buckpbus_reg_read(phydev, EN8811H_FW_VERSION,
+			      &priv->firmware_version);
+	printf("MD32 firmware version: %08x\n",
+	       priv->firmware_version);

Can this be log_debug() or debug() , or is this print really needed ?

Quoted 7 lines
drivers/net/phy/airoha/air_en8811.c new file +7 -0
+en8811h_load_firmware_out:
+	free(buffer);
+	if (ret < 0)
+		printf("Firmware loading failed: %d\n", ret);
+
+	return ret;
+}

[...]

drivers/net/phy/airoha/air_en8811.c line 808

Quoted 5 lines
drivers/net/phy/airoha/air_en8811.c new file +5 -0
+static int en8811h_probe(struct phy_device *phydev)
+{
+	struct en8811h_priv *priv;
+
+	priv = malloc(sizeof(*priv));

Use "priv = calloc(1, sizeof(*priv));" and you can remove the memset() below, calloc zeroes out the allocated data.

Quoted 3 lines
drivers/net/phy/airoha/air_en8811.c new file +3 -0
+	if (!priv)
+		return -ENOMEM;
+	memset(priv, 0, sizeof(*priv));

[...]