Add board specific code, autodetect the kernel, fixes #1707, thanks Gabor Juhos
[openwrt-10.03/.git] / target / linux / ixp4xx-2.6 / patches / 153-nslu2_mtd_load_mac.patch
1 ---
2  arch/arm/mach-ixp4xx/nslu2-setup.c |   27 +++++++++++++++++++++++++++
3  1 file changed, 27 insertions(+)
4
5 Index: linux-2.6.19/arch/arm/mach-ixp4xx/nslu2-setup.c
6 ===================================================================
7 --- linux-2.6.19.orig/arch/arm/mach-ixp4xx/nslu2-setup.c
8 +++ linux-2.6.19/arch/arm/mach-ixp4xx/nslu2-setup.c
9 @@ -18,6 +18,7 @@
10  #include <linux/serial.h>
11  #include <linux/serial_8250.h>
12  #include <linux/leds.h>
13 +#include <linux/mtd/mtd.h>
14  
15  #include <asm/mach-types.h>
16  #include <asm/mach/arch.h>
17 @@ -180,6 +181,30 @@ static struct platform_device *nslu2_dev
18         &nslu2_npe_ucode,
19  };
20  
21 +static void nslu2_flash_add(struct mtd_info *mtd)
22 +{
23 +       if (strcmp(mtd->name, "RedBoot") == 0) {
24 +               size_t retlen;
25 +               u_char mac[6];
26 +
27 +               if (mtd->read(mtd, 0x3FFB0, 6, &retlen, mac) == 0 && retlen == 6) {
28 +                       printk(KERN_INFO "nslu2 mac: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
29 +                               mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
30 +                       memcpy(plat_mac0.hwaddr, mac, 6);
31 +               } else {
32 +                       printk(KERN_ERR "nslu2 mac: read failed\n");
33 +               }
34 +       }
35 +}
36 +
37 +static void nslu2_flash_remove(struct mtd_info *mtd) {
38 +}
39 +
40 +static struct mtd_notifier nslu2_flash_notifier = {
41 +       .add = nslu2_flash_add,
42 +       .remove = nslu2_flash_remove,
43 +};
44 +
45  static void nslu2_power_off(void)
46  {
47         /* This causes the box to drop the power and go dead. */
48 @@ -210,6 +235,8 @@ static void __init nslu2_init(void)
49         (void)platform_device_register(&nslu2_uart);
50  
51         platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
52 +
53 +       register_mtd_user(&nslu2_flash_notifier);
54  }
55  
56  MACHINE_START(NSLU2, "Linksys NSLU2")