Skip to contentSkip to conversation

net: phy: Add the Airoha EN8811H PHY driver

PATCH Superseded Lucien.Jheng 4 participants 6 messages May 11, 2025 – Jun 12, 2025 1 message not in the archive

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/net/phy/Kconfig       |  43 ++
 drivers/net/phy/air_en8811h.c | 852 ++++++++++++++++++++++++++++++++++
 2 files changed, 895 insertions(+)
 create mode 100644 drivers/net/phy/air_en8811h.c
drivers/net/phy/Kconfig +43 -0
index 3132718e4f8..384cef845e1 100644
@@ -79,6 +79,49 @@ config PHY_ADIN
 	help
 		Add support for configuring RGMII on Analog Devices ADIN PHYs.
 
+menuconfig PHY_AIROHA
+	bool "Airoha Ethernet PHYs support"
+
+config PHY_AIROHA_EN8811H
+	bool "Airoha Ethernet EN8811H support"
+	depends on PHY_AIROHA
+	help
+		AIROHA EN8811H supported.
+
+choice
+	prompt "Location of the Airoha PHY firmware"
+	default PHY_AIROHA_FW_IN_MMC
+	depends on PHY_AIROHA_EN8811H
+
+config PHY_AIROHA_FW_IN_MMC
+	bool "Airoha firmware in MMC partition"
+	help
+		Airoha PHYs use firmware which can be loaded automatically
+		from storage directly attached to the PHY, and then loaded
+		via MDIO commands by the boot loader. The firmware is loaded
+		from a file specified by the PHY_AIROHA_FW_PART,
+		PHY_AIROHA_FW_DM_FILEPATH and PHY_AIROHA_FW_DSP_FILEPATH options.
+
+config PHY_AIROHA_FW_PART
+	string "Airoha firmware partition"
+	depends on PHY_AIROHA_FW_IN_MMC
+	help
+		Partition containing the firmware file.
+
+config PHY_AIROHA_FW_DM_FILEPATH
+	string "Airoha firmware DM file path in the filesystem"
+	depends on PHY_AIROHA_FW_IN_MMC
+	help
+		Specify Airoha firmware DM file path in the filesystem.
+
+config PHY_AIROHA_FW_DSP_FILEPATH
+	string "Airoha firmware DSP file path in the filesystem"
+	depends on PHY_AIROHA_FW_IN_MMC
+	help
+		Specify Airoha firmware DSP file path in the filesystem.
+
+endchoice
+
 menuconfig PHY_AQUANTIA
 	bool "Aquantia Ethernet PHYs support"
 	select PHY_GIGE
drivers/net/phy/air_en8811h.c new file +852 -0

852 lines not on this page · raw message

--
2.34.1

#1 lore raw
Quoted 22 lines

Gesendet: Sonntag, 11. Mai 2025 um 07:14
Von: "Lucien.Jheng" <[email protected]>
Betreff: [U-Boot, v1, 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.

Quoted 6 lines
---
 drivers/net/phy/Kconfig       |  43 ++
 drivers/net/phy/air_en8811h.c | 852 ++++++++++++++++++++++++++++++++++
 2 files changed, 895 insertions(+)
 create mode 100644 drivers/net/phy/air_en8811h.c

Hi,

is there any progress? i see no review or apply (+tom in To-header).

regards Frank

#2 lore raw
Quoted 29 lines · On Thu, Jun 12, 2025 at 10:09:48AM +0000, [email protected] wrote:
Quoted 22 lines

Gesendet: Sonntag, 11. Mai 2025 um 07:14
Von: "Lucien.Jheng" <[email protected]>
Betreff: [U-Boot, v1, 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.

Quoted 6 lines
---
 drivers/net/phy/Kconfig       |  43 ++
 drivers/net/phy/air_en8811h.c | 852 ++++++++++++++++++++++++++++++++++
 2 files changed, 895 insertions(+)
 create mode 100644 drivers/net/phy/air_en8811h.c
Quoted 3 lines

Hi,

is there any progress? i see no review or apply (+tom in To-header).

I'm not super thrilled at the concept of having to load firmware from a filesystem. But since we have to do this anyways in other cases, is this something we could be using FS_LOADER for or no?

Signature · 1 line
Tom

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Frank Wunderlich 於 2025/6/12 下午 10:44 寫道:

Quoted 38 lines

Am 12. Juni 2025 16:36:41 MESZ schrieb Tom Rini<[email protected]>:

Quoted 30 lines · On Thu, Jun 12, 2025 at 10:09:48AM +0000,[email protected] wrote:
Quoted 29 lines
Quoted 29 lines

Gesendet: Sonntag, 11. Mai 2025 um 07:14
Von: "Lucien.Jheng"<[email protected]>
Betreff: [U-Boot, v1, 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.

---
  drivers/net/phy/Kconfig       |  43 ++
  drivers/net/phy/air_en8811h.c | 852 ++++++++++++++++++++++++++++++++++
  2 files changed, 895 insertions(+)

create mode 100644 drivers/net/phy/air_en8811h.c

Quoted 7 lines
Quoted 3 lines

Hi,

is there any progress? i see no review or apply (+tom in To-header).

I'm not super thrilled at the concept of having to load firmware from a filesystem. But since we have to do this anyways in other cases, is this something we could be using FS_LOADER for or no?

Quoted 5 lines

The filesystem loading was requested in mailinglist.
Original version loaded firmware from emmc boot1 partition (current openwrt driver version) or c header file generated from the binaries (my version). I do not know FS_LOADER yet,but if this a more generic way to load firmware file it could be a way. Lucien,what do you think?

regards Frank

I'm not very familiar with the FS_LOADER part of U-Boot, so I'll need to look into that.

However, based on previous mailing list discussions, it was suggested that I refer to the Aquatia PHY and its method of loading the PHY firmware from the filesystem on a block device.

Additionally, the recommendation was to implement a __weak default loading from a file on the filesystem by default.

This way, if a specific platform needs to replace its loading method, it can simply be overridden at the board or architecture level.

Thanks
Lucien Jheng

#5 lore raw
Quoted 41 lines · Lucien.Jheng

Frank Wunderlich 於 2025/6/12 下午 10:44 寫道:

Quoted 39 lines

Am 12. Juni 2025 16:36:41 MESZ schrieb Tom Rini<[email protected]>:

Quoted 38 lines · On Thu, Jun 12, 2025 at 10:09:48AM +0000,[email protected] wrote:
Quoted 30 lines
Quoted 23 lines

Gesendet: Sonntag, 11. Mai 2025 um 07:14
Von: "Lucien.Jheng"<[email protected]>
Betreff: [U-Boot, v1, 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.

Quoted 7 lines

---
  drivers/net/phy/Kconfig       |  43 ++ drivers/net/phy/air_en8811h.c | 852 +++++++++++++++++++++++++++++
+++++

  2 files changed, 895 insertions(+)

  create mode 100644 drivers/net/phy/air_en8811h.c

Quoted 3 lines

Hi,

is there any progress? i see no review or apply (+tom in To-header).

I'm not super thrilled at the concept of having to load firmware from a filesystem. But since we have to do this anyways in other cases, is this something we could be using FS_LOADER for or no?

Quoted 7 lines
Quoted 5 lines

The filesystem loading was requested in mailinglist.
Original version loaded firmware from emmc boot1 partition (current openwrt driver version) or c header file generated from the binaries (my version). I do not know FS_LOADER yet,but if this a more generic way to load firmware file it could be a way. Lucien,what do you think?

regards Frank

I'm not very familiar with the FS_LOADER part of U-Boot, so I'll need to look into that.

I also have to look at firmware loading at some point soon, but first I need to sort out my todo, I am entirely overloaded recently. About the FS_LOADER , I feel it never really took off, but maybe it improved since I looked at it last ? We clearly do need some generic firmware loader, one which also covers SPL firmware loading, I am just not sure how the interface should look like just yet.

#6 lore raw
In reply to Lucien.Jheng
Quoted 31 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.

---
  drivers/net/phy/Kconfig       |  43 ++
  drivers/net/phy/air_en8811h.c | 852 ++++++++++++++++++++++++++++++++++
  2 files changed, 895 insertions(+)

create mode 100644 drivers/net/phy/air_en8811h.c

drivers/net/phy/Kconfig +0 -0
index 3132718e4f8..384cef845e1 100644
@@ -79,6 +79,49 @@ config PHY_ADIN
  	help

drivers/net/phy/Kconfig config PHY_ADIN · line 89

Quoted 10 lines
drivers/net/phy/Kconfig +8 -0
  		Add support for configuring RGMII on Analog Devices ADIN PHYs.
 
+menuconfig PHY_AIROHA
+	bool "Airoha Ethernet PHYs support"
+
+config PHY_AIROHA_EN8811H
+	bool "Airoha Ethernet EN8811H support"
+	depends on PHY_AIROHA
+	help
+		AIROHA EN8811H supported.

Indent of help text is two spaces right of indent of 'help' Kconfig keyword.

Quoted 4 lines
drivers/net/phy/Kconfig +4 -0
+
+choice
+	prompt "Location of the Airoha PHY firmware"
+	default PHY_AIROHA_FW_IN_MMC

drivers/net/phy/Kconfig config PHY_ADIN · line 103

Quoted 10 lines
drivers/net/phy/Kconfig +10 -0
+	depends on PHY_AIROHA_EN8811H
+
+config PHY_AIROHA_FW_IN_MMC
+	bool "Airoha firmware in MMC partition"
+	help
+		Airoha PHYs use firmware which can be loaded automatically
+		from storage directly attached to the PHY, and then loaded
+		via MDIO commands by the boot loader. The firmware is loaded
+		from a file specified by the PHY_AIROHA_FW_PART,
+		PHY_AIROHA_FW_DM_FILEPATH and PHY_AIROHA_FW_DSP_FILEPATH options.

Indent, fix globally.

[...]

Quoted 1 line
drivers/net/phy/air_en8811h.c +0 -0

[...]

Quoted 9 lines

+ #define EN8811H_FW_CTRL_2 0x800000
+ #define EN8811H_FW_CTRL_2_LOADING BIT(11)
+
+ /* MII Registers */
+ #define AIR_AUX_CTRL_STATUS 0x1d

+ #define   AIR_AUX_CTRL_STATUS_SPEED_MASK	GENMASK(4, 2)
+ #define   AIR_AUX_CTRL_STATUS_SPEED_100		0x4
+ #define   AIR_AUX_CTRL_STATUS_SPEED_1000	0x8
+ #define   AIR_AUX_CTRL_STATUS_SPEED_2500	0xc

Please fix indent, and be consistent about it:

#define<space>MACRO_NAME<tab><more tabs as needed>0xvalue

Quoted 3 lines
drivers/net/phy/air_en8811h.c +3 -0
+#define AIR_EXT_PAGE_ACCESS		0x1f
+#define   AIR_PHY_PAGE_STANDARD			0x0000
+#define   AIR_PHY_PAGE_EXTENDED_4		0x0004

[...]

drivers/net/phy/air_en8811h.c line 236

Quoted 11 lines
drivers/net/phy/air_en8811h.c +11 -0
+int air_phy_restore_page(struct phy_device *phydev, int oldpage, int ret)
+{
+	int r;
+
+	if (oldpage >= 0) {
+		r = air_phy_write_page(phydev, oldpage);
+
+		if (ret >= 0 && r < 0)
+			ret = r;
+	} else {
+		ret = oldpage;

Invert the conditionals to reduce indent

if (oldpage < 0)
return oldpage;

r = ...

drivers/net/phy/air_en8811h.c line 249

Quoted 13 lines
drivers/net/phy/air_en8811h.c +13 -0
+	}
+
+	return ret;
+}
+
+static int air_buckpbus_reg_write(struct phy_device *phydev,
+				  u32 pbus_address, u32 pbus_data)
+{
+	int ret, saved_page;
+
+	saved_page = air_phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4);
+
+	if (saved_page >= 0) {

Invert the conditional (*):

if (saved_page < 0)
return saved_page; // this is OK, because air_phy_restore_page() will

                     // bail in case saved_page < 0 , see above

...

Quoted 30 lines
drivers/net/phy/air_en8811h.c +30 -0
+		ret = phy_write(phydev, MDIO_DEVAD_NONE, AIR_BPBUS_MODE, AIR_BPBUS_MODE_ADDR_FIXED);
+		if (ret < 0)
+			goto restore_page;
+
+		ret = phy_write(phydev, MDIO_DEVAD_NONE, AIR_BPBUS_WR_ADDR_HIGH,
+				air_upper_16_bits(pbus_address));
+		if (ret < 0)
+			goto restore_page;
+
+		ret = phy_write(phydev, MDIO_DEVAD_NONE, AIR_BPBUS_WR_ADDR_LOW,
+				air_lower_16_bits(pbus_address));
+		if (ret < 0)
+			goto restore_page;
+
+		ret = phy_write(phydev, MDIO_DEVAD_NONE, AIR_BPBUS_WR_DATA_HIGH,
+				air_upper_16_bits(pbus_data));
+		if (ret < 0)
+			goto restore_page;
+
+		ret = phy_write(phydev, MDIO_DEVAD_NONE, AIR_BPBUS_WR_DATA_LOW,
+				air_lower_16_bits(pbus_data));
+		if (ret < 0)
+			goto restore_page;
+	}
+
+restore_page:
+	if (ret < 0)
+		printf("%s 0x%08x failed: %d\n", __func__,
+		       pbus_address, ret);
+

drivers/net/phy/air_en8811h.c line 289

Quoted 10 lines
drivers/net/phy/air_en8811h.c +10 -0
+	return air_phy_restore_page(phydev, saved_page, ret);
+}
+
+static int air_buckpbus_reg_read(struct phy_device *phydev,
+				 u32 pbus_address, u32 *pbus_data)
+{
+	int pbus_data_low, pbus_data_high;
+	int ret = 0, saved_page;
+
+	saved_page = air_phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4);

Same change (*) applies here, see above.

Quoted 1 line
drivers/net/phy/air_en8811h.c +1 -0
+	if (saved_page >= 0) {

[...]

drivers/net/phy/air_en8811h.c line 336

Quoted 8 lines
drivers/net/phy/air_en8811h.c +8 -0
+static int air_buckpbus_reg_modify(struct phy_device *phydev,
+				   u32 pbus_address, u32 mask, u32 set)
+{
+	int pbus_data_low, pbus_data_high;
+	u32 pbus_data_old, pbus_data_new;
+	int ret = 0, saved_page;
+
+	saved_page = air_phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4);

Same change (*) applies here, see above, fix globally.

Quoted 1 line
drivers/net/phy/air_en8811h.c +1 -0
+	if (saved_page >= 0) {

[...]

drivers/net/phy/air_en8811h.c line 462

Quoted 6 lines
drivers/net/phy/air_en8811h.c +6 -0
+static void crc32_check(unsigned char *buf, u32 len)
+{
+	u32 ca_crc32;
+
+	ca_crc32 = crc32(0, buf, len);
+	printf("crc32 is 0x%x\n", ca_crc32);

Shouldn't this produce some return value , in case the check fails ?

drivers/net/phy/air_en8811h.c line 472

Quoted 10 lines
drivers/net/phy/air_en8811h.c +10 -0
+}
+
+__weak int en8811h_read_fw(void **addr)
+{
+	loff_t read;
+	int ret;
+
+	printf("\nLoading Airoha FW from %s %s\n",
+	       CONFIG_PHY_AIROHA_FW_PART,
+	       CONFIG_PHY_AIROHA_FW_DM_FILEPATH);

debug() instead of printf() .

Quoted 31 lines
drivers/net/phy/air_en8811h.c +31 -0
+	ret = fs_set_blk_dev("mmc", CONFIG_PHY_AIROHA_FW_PART, FS_TYPE_ANY);
+	if (ret < 0)
+		return ret;
+
+	ret = fs_read(CONFIG_PHY_AIROHA_FW_DM_FILEPATH,
+		      (ulong)*addr, 0, EN8811H_MD32_DM_SIZE, &read);
+	if (ret < 0)
+		return ret;
+
+	/* Calculate the CRC32 */
+	crc32_check((unsigned char *)*addr, EN8811H_MD32_DM_SIZE);
+
+	printf("Loading Airoha FW from %s %s\n",
+	       CONFIG_PHY_AIROHA_FW_PART,
+	       CONFIG_PHY_AIROHA_FW_DSP_FILEPATH);
+	ret = fs_set_blk_dev("mmc", CONFIG_PHY_AIROHA_FW_PART, FS_TYPE_ANY);
+	if (ret < 0)
+		return ret;
+
+	ret = fs_read(CONFIG_PHY_AIROHA_FW_DSP_FILEPATH,
+		      (ulong)*addr + EN8811H_MD32_DM_SIZE,
+		      0, EN8811H_MD32_DSP_SIZE, &read);
+	if (ret < 0)
+		return ret;
+
+	/* Calculate the CRC32 */
+	crc32_check((unsigned char *)*addr + EN8811H_MD32_DM_SIZE,
+		    EN8811H_MD32_DSP_SIZE);
+
+	printf("Found Airoha Firmware.\n");
+

drivers/net/phy/air_en8811h.c line 513

Quoted 10 lines
drivers/net/phy/air_en8811h.c +10 -0
+	return 0;
+}
+
+static int en8811h_load_firmware(struct phy_device *phydev)
+{
+	struct en8811h_priv *priv = phydev->priv;
+	void *addr = NULL;
+	int ret;
+
+	if (IS_ENABLED(CONFIG_PHY_AIROHA_FW_IN_MMC)) {

This conditional should be in en8811h_read_fw() too , the malloc as well , so user can completely override the loading and only return a buffer with firmware from wherever they loaded it from .

This:

__weak int en8811h_read_fw(void **addr) {
if (!IS_ENABLED(CONFIG_PHY_AIROHA_FW_IN_MMC))

    return -EOPNOTSUPP;

buffer = malloc();
...
load_the_firmware(buffer);
...
*addr = buffer;
...
return 0;
}

And here:

...
void *buffer;
...
ret = en8811h_read_fw(&buffer);
if (ret)
return ret;
...

drivers/net/phy/air_en8811h.c line 525

Quoted 12 lines
drivers/net/phy/air_en8811h.c +12 -0
+		u32 fw_length = EN8811H_MD32_DM_SIZE + EN8811H_MD32_DSP_SIZE;
+
+		addr = malloc(fw_length);
+		if (!addr) {
+			printf("Failed to allocate memory for firmware\n");
+			return -ENOMEM;
+		}
+
+		ret = en8811h_read_fw(&addr);
+		if (ret < 0) {
+			free(addr);
+			return ret;

Remove the free() and goto en8811h_load_firmware_out;

drivers/net/phy/air_en8811h.c line 529

Quoted 4 lines
drivers/net/phy/air_en8811h.c +4 -0
+		}
+	} else {
+		puts("EN8811H firmware loading not implemented");
+		return -EOPNOTSUPP;

Invert the conditional, reduce indent.

Quoted 47 lines
drivers/net/phy/air_en8811h.c +47 -0
+	}
+
+	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 *)addr);
+	if (ret < 0)
+		goto en8811h_load_firmware_out;
+
+	ret = air_write_buf(phydev, AIR_FW_ADDR_DSP, EN8811H_MD32_DSP_SIZE,
+			    (unsigned char *)addr + 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,
+				     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);
+
+en8811h_load_firmware_out:
+	free(addr);
+	if (ret < 0)
+		printf("Firmware loading failed: %d\n", ret);
+
+	return ret;
+}

[...]

drivers/net/phy/air_en8811h.c line 684

Quoted 4 lines
drivers/net/phy/air_en8811h.c +4 -0
+static int air_leds_init(struct phy_device *phydev, int num, int dur, int mode)
+{
+	int ret, i;
+	struct en8811h_priv *priv = phydev->priv;

Use reverse xmas tree sorting for variables, i.e. 'int ret, i;' goes below struct en88... , fix globally.

Quoted 4 lines
drivers/net/phy/air_en8811h.c +4 -0
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_DUR_BLINK,
+			    dur);
+	if (ret < 0)
+		return ret;

[...]

Quoted 16 lines
drivers/net/phy/air_en8811h.c +16 -0
+static int en8811h_config(struct phy_device *phydev)
+{
+	ofnode node = phy_get_ofnode(phydev);
+	struct en8811h_priv *priv = phydev->priv;
+	int ret = 0;
+	u32 pbus_value = 0;
+
+	/* If restart happened in .probe(), no need to restart now */
+	if (priv->mcu_needs_restart) {
+		ret = en8811h_restart_mcu(phydev);
+		if (ret < 0)
+			return ret;
+	} else {
+		ret = en8811h_load_firmware(phydev);
+		if (ret) {
+			printf("Load firmware fail.\n");

drivers/net/phy/air_en8811h.c line 753

Quoted 10 lines
drivers/net/phy/air_en8811h.c +10 -0
+			return ret;
+		}
+		/* Next calls to .config() mcu needs to restart */
+		priv->mcu_needs_restart = true;
+	}
+
+	ret = phy_write_mmd(phydev, 0x1e, 0x800c, 0x0);
+	ret |= phy_write_mmd(phydev, 0x1e, 0x800d, 0x0);
+	ret |= phy_write_mmd(phydev, 0x1e, 0x800e, 0x1101);
+	ret |= phy_write_mmd(phydev, 0x1e, 0x800f, 0x0002);

Bitwise operations do not work on signed integers , do proper error checking on all four return values above.

Quoted 28 lines
drivers/net/phy/air_en8811h.c +28 -0
+	if (ret < 0)
+		return ret;
+
+	/* Serdes polarity */
+	pbus_value = 0;
+	if (ofnode_read_bool(node, "airoha,pnswap-rx"))
+		pbus_value |=  EN8811H_POLARITY_RX_REVERSE;
+	else
+		pbus_value &= ~EN8811H_POLARITY_RX_REVERSE;
+	if (ofnode_read_bool(node, "airoha,pnswap-tx"))
+		pbus_value &= ~EN8811H_POLARITY_TX_NORMAL;
+	else
+		pbus_value |=  EN8811H_POLARITY_TX_NORMAL;
+	ret = air_buckpbus_reg_modify(phydev, EN8811H_POLARITY,
+				      EN8811H_POLARITY_RX_REVERSE |
+				      EN8811H_POLARITY_TX_NORMAL, pbus_value);
+	if (ret < 0)
+		return ret;
+
+	ret = air_leds_init(phydev, EN8811H_LED_COUNT, AIR_PHY_LED_DUR,
+			    AIR_LED_MODE_USER_DEFINE);
+	if (ret < 0) {
+		printf("Failed to disable leds: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}

[...]

Signature · 2 lines
Best regards,
Marek Vasut