359fc0b2dec7d4b04a4ee1ae498b49a0d0a4f687
[openwrt/openwrt.git] / target / linux / ixp4xx / patches-2.6.23 / 064-fsg3_setup_mac.patch
1 diff --git a/arch/arm/mach-ixp4xx/fsg-setup.c b/arch/arm/mach-ixp4xx/fsg-setup.c
2 index ec3d517..7cc7201 100644
3 --- a/arch/arm/mach-ixp4xx/fsg-setup.c
4 +++ b/arch/arm/mach-ixp4xx/fsg-setup.c
5 @@ -16,6 +16,7 @@
6 #include <linux/serial_8250.h>
7 #include <linux/leds.h>
8 #include <linux/i2c-gpio.h>
9 +#include <linux/mtd/mtd.h>
10
11 #include <asm/mach-types.h>
12 #include <asm/mach/arch.h>
13 @@ -177,6 +178,34 @@ static struct platform_device *fsg_devices[] __initdata = {
14 &fsg_eth[1],
15 };
16
17 +static void fsg_flash_add(struct mtd_info *mtd)
18 +{
19 + if (strcmp(mtd->name, "RedBoot config") == 0) {
20 + size_t retlen;
21 + u_char mac[6];
22 +
23 + if (mtd->read(mtd, 0x0422, 6, &retlen, mac) == 0 && retlen == 6) {
24 + printk(KERN_INFO "eth0 mac: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
25 + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
26 + memcpy(fsg_plat_eth[0].hwaddr, mac, 6);
27 + mac[5]++;
28 + printk(KERN_INFO "eth1 mac: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
29 + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
30 + memcpy(fsg_plat_eth[1].hwaddr, mac, 6);
31 + } else {
32 + printk(KERN_ERR "fsg mac: read failed\n");
33 + }
34 + }
35 +}
36 +
37 +static void fsg_flash_remove(struct mtd_info *mtd) {
38 +}
39 +
40 +static struct mtd_notifier fsg_flash_notifier = {
41 + .add = fsg_flash_add,
42 + .remove = fsg_flash_remove,
43 +};
44 +
45 static void __init fsg_init(void)
46 {
47 ixp4xx_sys_init();
48 @@ -198,6 +227,8 @@ static void __init fsg_init(void)
49 (void)platform_device_register(&fsg_uart);
50
51 platform_add_devices(fsg_devices, ARRAY_SIZE(fsg_devices));
52 +
53 + register_mtd_user(&fsg_flash_notifier);
54 }
55
56 MACHINE_START(FSG, "Freecom FSG-3")