summaryrefslogtreecommitdiff
path: root/packages/linux/ixp4xx-kernel/2.6.15/93-loft-maclist.patch
blob: ffda1136eff8a5899e0f7d6b58fe1984d931a634 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
add loft support for setting the maclist from EEPROM

Signed-off-by: John Bowler <jbowler@acm.org>

--- linux-2.6.15/arch/arm/mach-ixp4xx/ixdp425-setup.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.15/arch/arm/mach-ixp4xx/ixdp425-setup.c	1970-01-01 00:00:00.000000000 +0000
@@ -14,6 +14,7 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
+#include <linux/eeprom.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -24,6 +25,8 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
 
+#include <net/maclist.h>
+
 static struct flash_platform_data ixdp425_flash_data = {
 	.map_name	= "cfi_probe",
 	.width		= 2,
@@ -188,9 +191,62 @@ MACHINE_END
 /*
  * Loft is functionally equivalent to Avila except that it has a
  * different number for the maximum PCI devices.  The MACHINE
- * structure below is identical to Avila except for the comment.
+ * structure below is identical to Avila except for the and
+ * the use of a loft specific init.
+ *
+ * The loft init registers a notifier on the on-board EEPROM to
+ * detect the MAC addresses.
+ * NOTE: this probably works for all Gateworks Avila boards and
+ * maybe the ixdp425 too.
  */
 #ifdef CONFIG_MACH_LOFT
+/*
+ * When the EEPROM is added the MAC address are read from it.
+ */
+static void loft_eeprom_add(int address, int kind, struct kobject *kobj,
+				struct bin_attribute *eeprom_attr) {
+	/* The MACs are the first 12 bytes in the eeprom at address 0x51 */
+	if (address == 0x51) {
+		ssize_t retlen;
+		char data[12];
+
+		/* Two Macs, one at 0, the other at 6, maclist_add will
+		 * complain if the ID is not a valid MAC.
+		 */
+		retlen = eeprom_attr->read(kobj, data, 0, sizeof data);
+		if (retlen >= 6) {
+			u8 mac[6];
+			memcpy(mac, data+0, sizeof mac);
+			printk(KERN_INFO "LOFT MAC[0]: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
+				mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+			maclist_add(mac);
+		}
+		if (retlen >= 12) {
+			u8 mac[6];
+			memcpy(mac, data+6, sizeof mac);
+			printk(KERN_INFO "LOFT MAC[1]: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
+				mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+			maclist_add(mac);
+		}
+	}
+}
+
+static struct eeprom_notifier loft_eeprom_notifier = {
+	.add = loft_eeprom_add
+};
+
+static void __init loft_init(void)
+{
+	/* The EEPROM has two ethernet MACs embedded in it which we need,
+	 * that is all this notifier does.
+	 */
+	register_eeprom_user(&loft_eeprom_notifier);
+
+	ixp4xx_sys_init();
+
+	platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
+}
+
 MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
 	/* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */
 	.phys_ram	= PHYS_OFFSET,
@@ -200,7 +256,7 @@ MACHINE_START(LOFT, "Giant Shoulder Inc 
 	.init_irq	= ixp4xx_init_irq,
 	.timer		= &ixp4xx_timer,
 	.boot_params	= 0x0100,
-	.init_machine	= ixdp425_init,
+	.init_machine	= loft_init,
 MACHINE_END
 #endif