diff options
author | Chris Zankel <chris@zankel.net> | 2012-11-28 16:52:09 -0800 |
---|---|---|
committer | Chris Zankel <chris@zankel.net> | 2012-12-18 21:10:26 -0800 |
commit | 33c760fbb7a8fa46314437746dd7f5540da5498e (patch) | |
tree | bcb246804343781b605893cc865911c04612b708 /arch/xtensa | |
parent | c4c4594b005d89b56964071bbbdeb07daac5bc76 (diff) |
xtensa: set the correct ethernet address for xtfpga
The last byte of the mac address is determined by a DIP switch, so
update the OF property with that address.
Signed-off-by: Chris Zankel <chris@zankel.net>
Diffstat (limited to 'arch/xtensa')
-rw-r--r-- | arch/xtensa/platforms/xtfpga/setup.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c index 237c36dc18b8..4b9951a4569d 100644 --- a/arch/xtensa/platforms/xtfpga/setup.c +++ b/arch/xtensa/platforms/xtfpga/setup.c @@ -32,6 +32,7 @@ #include <asm/platform.h> #include <asm/bootparam.h> #include <platform/lcd.h> +#include <platform/hardware.h> void platform_halt(void) { @@ -84,8 +85,7 @@ static void __init update_clock_frequency(struct device_node *node) struct property *newfreq; u32 freq; - if (!of_property_read_u32(node, "clock-frequency", &freq) && - freq != 0) + if (!of_property_read_u32(node, "clock-frequency", &freq) && freq != 0) return; newfreq = kzalloc(sizeof(*newfreq) + sizeof(u32), GFP_KERNEL); @@ -103,12 +103,44 @@ static void __init update_clock_frequency(struct device_node *node) prom_update_property(node, newfreq); } +#define MAC_LEN 6 +static void __init update_local_mac(struct device_node *node) +{ + struct property *newmac; + const u8* macaddr; + int prop_len; + + macaddr = of_get_property(node, "local-mac-address", &prop_len); + if (macaddr == NULL || prop_len != MAC_LEN) + return; + + newmac = kzalloc(sizeof(*newmac) + MAC_LEN, GFP_KERNEL); + if (newmac == NULL) + return; + + newmac->value = newmac + 1; + newmac->length = MAC_LEN; + newmac->name = kstrdup("local-mac-address", GFP_KERNEL); + if (newmac->name == NULL) { + kfree(newmac); + return; + } + + memcpy(newmac->value, macaddr, MAC_LEN); + ((u8*)newmac->value)[5] = (*(u32*)DIP_SWITCHES_VADDR) & 0x3f; + prom_update_property(node, newmac); +} + static int __init machine_setup(void) { struct device_node *serial; + struct device_node *eth = NULL; for_each_compatible_node(serial, NULL, "ns16550a") update_clock_frequency(serial); + + if ((eth = of_find_compatible_node(eth, NULL, "opencores,ethoc"))) + update_local_mac(eth); return 0; } arch_initcall(machine_setup); |