[U-Boot] [PATCH 12/14] fdt: eth_fixup: Add hook for board to override MAC

Marcel Ziswiler marcel.ziswiler at toradex.com
Wed Nov 30 10:00:51 CET 2016


Hi Olliver

On Fri, 2016-11-25 at 16:30 +0100, Olliver Schinagl wrote:
> This patch adds a method for the board to set the MAC address if the
> environment is not yet set. The environment based MAC addresses are
> not
> touched, but if the fdt has an alias set, it is parsed and put into
> the
> environment.
> 
> E.g. The environment contains ethaddr and eth1addr, and the fdt
> contains
> an ethernet1 nothing happens. If the fdt contains ethernet2 however,
> it
> is parsed and inserted into the environment as eth2addr.

My humble understanding of device tree fixup is that it works the other
way around (e.g. it is the device tree that usually gets fixed up). So
the least I would advice for this patch is to change its naming but
most possibly such code also does not belong into the common
fdt_support implementation.

> Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
> ---
>  common/fdt_support.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index c34a13c..f127392 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -465,6 +465,11 @@ int fdt_fixup_memory(void *blob, u64 start, u64
> size)
>  	return fdt_fixup_memory_banks(blob, &start, &size, 1);
>  }
>  
> +__weak int board_get_enetaddr(const int i, unsigned char *mac_addr)
> +{
> +	return -ENOSYS;
> +}
> +
>  void fdt_fixup_ethernet(void *fdt)
>  {
>  	int i, prop;
> @@ -507,7 +512,8 @@ void fdt_fixup_ethernet(void *fdt)
>  			if (fdt_eth_addr)
>  				eth_parse_enetaddr(fdt_eth_addr,
> mac_addr);
>  			else
> -				continue;
> +				if (board_get_enetaddr(i, mac_addr)
> < 0)
> +					continue;
>  
>  			do_fixup_by_path(fdt, path, "mac-address",
>  					 &mac_addr, 6, 0);

Cheers

Marcel


More information about the U-Boot mailing list