[U-Boot] [PATCH 1/6] net: gem: Add support for reading MAC from I2C EEPROM

Bin Meng bmeng.cn at gmail.com
Sun Feb 14 03:25:56 CET 2016


Hi Michal,

On Sat, Feb 13, 2016 at 6:39 PM, Michal Simek <monstr at monstr.eu> wrote:
> Add support for reading MAC address from I2C EEPROM.
>

Is this a feature provided by the GEM MAC IP?

> Signed-off-by: Michal Simek <monstr at monstr.eu>
> ---
>
>  drivers/net/zynq_gem.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
> index b3821c31a91d..ace60c901cb5 100644
> --- a/drivers/net/zynq_gem.c
> +++ b/drivers/net/zynq_gem.c
> @@ -627,6 +627,21 @@ static int zynq_gem_remove(struct udevice *dev)
>         return 0;
>  }
>
> +static int zynq_gem_read_rom_hwaddr(struct udevice *dev)
> +{
> +#if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \
> +    defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET)
> +       struct eth_pdata *pdata = dev_get_platdata(dev);
> +
> +       if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR,
> +                       CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET,
> +                       pdata->enetaddr, ARRAY_SIZE(pdata->enetaddr)))

This call to eeprom_read() looks to me a board-specific feature, that
an on-board eeprom is used to store the MAC address for the GEM?

> +               printf("EEPROM MAC address read failed\n");
> +#endif
> +       return 0;
> +}
> +
> +
>  static const struct eth_ops zynq_gem_ops = {
>         .start                  = zynq_gem_init,
>         .send                   = zynq_gem_send,
> @@ -634,6 +649,7 @@ static const struct eth_ops zynq_gem_ops = {
>         .free_pkt               = zynq_gem_free_pkt,
>         .stop                   = zynq_gem_halt,
>         .write_hwaddr           = zynq_gem_setup_mac,
> +       .read_rom_hwaddr        = zynq_gem_read_rom_hwaddr,
>  };
>
>  static int zynq_gem_ofdata_to_platdata(struct udevice *dev)
> --

Regards,
Bin


More information about the U-Boot mailing list