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

Olliver Schinagl oliver at schinagl.nl
Fri Nov 25 16:30:30 CET 2016


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.

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);
-- 
2.10.2



More information about the U-Boot mailing list