[PATCH 1/1] [U-Boot, v4, 1/1]net: phy: Add the Airoha EN8811H PHY driver
Marek Vasut
marek.vasut at mailbox.org
Mon Sep 22 01:14:21 CEST 2025
On 9/14/25 6:41 AM, Lucien.Jheng wrote:
> +#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.
> +#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 .
[...]
> +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.
[...]
> +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,
> + 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 ?
> +en8811h_load_firmware_out:
> + free(buffer);
> + if (ret < 0)
> + printf("Firmware loading failed: %d\n", ret);
> +
> + return ret;
> +}
[...]
> +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.
> + if (!priv)
> + return -ENOMEM;
> + memset(priv, 0, sizeof(*priv));
[...]
More information about the U-Boot
mailing list