Skip to contentSkip to conversation

Add fdt_fixup_ethernet helper to set mac addresses

PATCH New Kumar Gala 2 participants 2 messages Nov 21, 2007

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 Add fdt_fixup_ethernet helper to set mac addresses

Added a fixup helper that uses aliases to set mac addresses in the device tree based on the bd_t

---
 common/fdt_support.c  |   38 ++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |    1 +
 2 files changed, 39 insertions(+), 0 deletions(-)
common/fdt_support.c +38 -0
index d5743b4..0e61f6d 100644
@@ -386,4 +386,42 @@ void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop,
 	do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create);
 }
 
+void fdt_fixup_ethernet(void *fdt, bd_t *bd)
+{
+	int node;
+	const char *path;
+
+        node = fdt_path_offset(fdt, "/aliases");
+        if (node >= 0) {
+#if defined(CONFIG_HAS_ETH0)
+                path = fdt_getprop(fdt, node, "ethernet0", NULL);
+		if (path) {
+			do_fixup_by_path(fdt, path, "mac-address", bd->bi_enetaddr, 6, 0);
+			do_fixup_by_path(fdt, path, "local-mac-address", bd->bi_enetaddr, 6, 1);
+		}
+#endif
+#if defined(CONFIG_HAS_ETH1)
+                path = fdt_getprop(fdt, node, "ethernet1", NULL);
+		if (path) {
+			do_fixup_by_path(fdt, path, "mac-address", bd->bi_enet1addr, 6, 0);
+			do_fixup_by_path(fdt, path, "local-mac-address", bd->bi_enet1addr, 6, 1);
+		}
+#endif
+#if defined(CONFIG_HAS_ETH2)
+                path = fdt_getprop(fdt, node, "ethernet2", NULL);
+		if (path) {
+			do_fixup_by_path(fdt, path, "mac-address", bd->bi_enet2addr, 6, 0);
+			do_fixup_by_path(fdt, path, "local-mac-address", bd->bi_enet2addr, 6, 1);
+		}
+#endif
+#if defined(CONFIG_HAS_ETH3)
+                path = fdt_getprop(fdt, node, "ethernet3", NULL);
+		if (path) {
+			do_fixup_by_path(fdt, path, "mac-address", bd->bi_enet3addr, 6, 0);
+			do_fixup_by_path(fdt, path, "local-mac-address", bd->bi_enet3addr, 6, 1);
+		}
+#endif
+        }
+}
+
 #endif /* CONFIG_OF_LIBFDT */
include/fdt_support.h +1 -0
index 0314dfd..150dd2b 100644
@@ -33,6 +33,7 @@ void do_fixup_by_path(void *fdt, const char *path, const char *prop,
 		      const void *val, int len, int create);
 void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop,
 			  u32 val, int create);
+void fdt_fixup_ethernet(void *fdt, bd_t *bd);
 
 #ifdef CONFIG_OF_HAS_UBOOT_ENV
 int fdt_env(void *fdt);
Signature · 1 line
1.5.3.4
#1 lore raw

PATCH 1/1 Add fdt_fixup_ethernet helper to set mac addresses

Quoted 18 lines · Kumar Gala

Added a fixup helper that uses aliases to set mac addresses in the device tree based on the bd_t

---
 common/fdt_support.c  |   38 ++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |    1 +
 2 files changed, 39 insertions(+), 0 deletions(-)
common/fdt_support.c +0 -0
index d5743b4..0e61f6d 100644
@@ -386,4 +386,42 @@ void do_fixup_by_path_u32(void *fdt, const char *path,
 const char *prop, do_fixup_by_path(fdt, path, prop, &val, sizeof(val),
 create);
 }
 

common/fdt_support.c void do_fixup_by_path_u32(void *fdt, const char *path, · line 399

Quoted 10 lines
common/fdt_support.c +10 -0
+void fdt_fixup_ethernet(void *fdt, bd_t *bd)
+{
+	int node;
+	const char *path;
+
+        node = fdt_path_offset(fdt, "/aliases");
+        if (node >= 0) {
+#if defined(CONFIG_HAS_ETH0)
+                path = fdt_getprop(fdt, node, "ethernet0", NULL);
+		if (path) {

Seems you have some whitespace problems here.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================