diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2007-11-21 11:11:03 -0600 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-11-21 15:08:56 -0600 |
commit | ab544633abdd14f4dd5d92e500b73eb59ef57e67 (patch) | |
tree | 1d336ca2515d240b95a4d00a01243147a08cfedc /common/fdt_support.c | |
parent | dbaf07ce620aab249e3502b20a986234a6af1d3a (diff) | |
download | u-boot-ab544633abdd14f4dd5d92e500b73eb59ef57e67.tar.gz u-boot-ab544633abdd14f4dd5d92e500b73eb59ef57e67.tar.bz2 u-boot-ab544633abdd14f4dd5d92e500b73eb59ef57e67.zip |
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
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'common/fdt_support.c')
-rw-r--r-- | common/fdt_support.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c index d5743b445d..e848386fbe 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -386,4 +386,50 @@ 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 */ |