summaryrefslogtreecommitdiff
path: root/target/linux/ixp4xx/patches/740-avila_loft_mac_platform.patch
blob: 87d0892ec8db88ae2ba2c51c7691d8bb82dbbaa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/avila-setup.c
===================================================================
--- linux-2.6.21.7.orig/arch/arm/mach-ixp4xx/avila-setup.c
+++ linux-2.6.21.7/arch/arm/mach-ixp4xx/avila-setup.c
@@ -18,6 +18,10 @@
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
 #include <linux/slab.h>
+#ifdef CONFIG_SENSORS_EEPROM
+#include <linux/i2c.h>
+#include <linux/eeprom.h>
+#endif
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -188,9 +192,34 @@ static struct platform_device *avila_dev
 
 };
 
+#ifdef CONFIG_SENSORS_EEPROM
+static int loft_eeprom_do(struct notifier_block *self, unsigned long event, void *t)
+{
+       struct eeprom_data *data = t;
+
+       char macs[12];
+
+       /* The MACs are the first 12 bytes in the eeprom at address 0x51 */
+       if (event == EEPROM_REGISTER && data->client.addr == 0x51) {
+               data->attr->read(&data->client.dev.kobj, macs, 0, 12);
+               memcpy(&plat_mac0.hwaddr, macs, 6);
+               memcpy(&plat_mac1.hwaddr, macs + 6, 6);
+       }
+
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block loft_eeprom_notifier = {
+       .notifier_call = loft_eeprom_do
+};
+#endif
+
 static void __init avila_init(void)
 {
 	ixp4xx_sys_init();
+#ifdef CONFIG_SENSORS_EEPROM
+       register_eeprom_notifier(&loft_eeprom_notifier);
+#endif
 
 	avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
 	avila_flash_resource.end =