aboutsummaryrefslogtreecommitdiffstats
path: root/arch/xtensa
diff options
context:
space:
mode:
authorChris Zankel <chris@zankel.net>2012-11-28 19:52:09 -0500
committerChris Zankel <chris@zankel.net>2012-12-19 00:10:26 -0500
commit33c760fbb7a8fa46314437746dd7f5540da5498e (patch)
treebcb246804343781b605893cc865911c04612b708 /arch/xtensa
parentc4c4594b005d89b56964071bbbdeb07daac5bc76 (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.c36
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 @@
32#include <asm/platform.h> 32#include <asm/platform.h>
33#include <asm/bootparam.h> 33#include <asm/bootparam.h>
34#include <platform/lcd.h> 34#include <platform/lcd.h>
35#include <platform/hardware.h>
35 36
36void platform_halt(void) 37void platform_halt(void)
37{ 38{
@@ -84,8 +85,7 @@ static void __init update_clock_frequency(struct device_node *node)
84 struct property *newfreq; 85 struct property *newfreq;
85 u32 freq; 86 u32 freq;
86 87
87 if (!of_property_read_u32(node, "clock-frequency", &freq) && 88 if (!of_property_read_u32(node, "clock-frequency", &freq) && freq != 0)
88 freq != 0)
89 return; 89 return;
90 90
91 newfreq = kzalloc(sizeof(*newfreq) + sizeof(u32), GFP_KERNEL); 91 newfreq = kzalloc(sizeof(*newfreq) + sizeof(u32), GFP_KERNEL);
@@ -103,12 +103,44 @@ static void __init update_clock_frequency(struct device_node *node)
103 prom_update_property(node, newfreq); 103 prom_update_property(node, newfreq);
104} 104}
105 105
106#define MAC_LEN 6
107static void __init update_local_mac(struct device_node *node)
108{
109 struct property *newmac;
110 const u8* macaddr;
111 int prop_len;
112
113 macaddr = of_get_property(node, "local-mac-address", &prop_len);
114 if (macaddr == NULL || prop_len != MAC_LEN)
115 return;
116
117 newmac = kzalloc(sizeof(*newmac) + MAC_LEN, GFP_KERNEL);
118 if (newmac == NULL)
119 return;
120
121 newmac->value = newmac + 1;
122 newmac->length = MAC_LEN;
123 newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
124 if (newmac->name == NULL) {
125 kfree(newmac);
126 return;
127 }
128
129 memcpy(newmac->value, macaddr, MAC_LEN);
130 ((u8*)newmac->value)[5] = (*(u32*)DIP_SWITCHES_VADDR) & 0x3f;
131 prom_update_property(node, newmac);
132}
133
106static int __init machine_setup(void) 134static int __init machine_setup(void)
107{ 135{
108 struct device_node *serial; 136 struct device_node *serial;
137 struct device_node *eth = NULL;
109 138
110 for_each_compatible_node(serial, NULL, "ns16550a") 139 for_each_compatible_node(serial, NULL, "ns16550a")
111 update_clock_frequency(serial); 140 update_clock_frequency(serial);
141
142 if ((eth = of_find_compatible_node(eth, NULL, "opencores,ethoc")))
143 update_local_mac(eth);
112 return 0; 144 return 0;
113} 145}
114arch_initcall(machine_setup); 146arch_initcall(machine_setup);