rename patch
[openwrt.git] / target / linux / ixp4xx / patches / 212-gateway_7001_mtd_microcode.patch
1 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/gateway7001-setup.c
2 ===================================================================
3 --- linux-2.6.21.7.orig/arch/arm/mach-ixp4xx/gateway7001-setup.c
4 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/gateway7001-setup.c
5 @@ -16,6 +16,7 @@
6  #include <linux/device.h>
7  #include <linux/serial.h>
8  #include <linux/tty.h>
9 +#include <linux/mtd/mtd.h>
10  #include <linux/serial_8250.h>
11  #include <linux/slab.h>
12  
13 @@ -122,11 +123,48 @@ static struct platform_device mac1 = {
14         .resource       = &res_mac1,
15  };
16  
17 +struct npe_ucode_platform_data gateway7001_npe_ucode_data = {
18 +       .mtd_partition  = "microcode",
19 +};
20 +
21 +static struct platform_device gateway7001_npe_ucode = {
22 +       .name                   = "ixp4xx_npe_ucode",
23 +       .id                     = 0,
24 +       .dev.platform_data      = &gateway7001_npe_ucode_data,
25 +};
26 +
27  static struct platform_device *gateway7001_devices[] __initdata = {
28         &gateway7001_flash,
29         &gateway7001_uart,
30         &mac0,
31         &mac1,
32 +       &gateway7001_npe_ucode,
33 +};
34 +
35 +static void gateway7001_flash_add(struct mtd_info *mtd) 
36 +{
37 +       if (strcmp(mtd->name, "RedBoot config") == 0) {
38 +               size_t retlen;
39 +               u_char mac0[6], mac1[6];
40 +                       if (mtd->read(mtd, 0x0422, 6, &retlen, mac0) == 0 && retlen == 6) {
41 +                               printk(KERN_INFO "gateway 7001 mac0: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
42 +                                       mac0[0], mac0[1], mac0[2], mac0[3], mac0[4], mac0[5]);
43 +                               memcpy(plat_mac0.hwaddr, mac0, 6);
44 +                       }
45 +                       if (mtd->read(mtd, 0x043B, 6, &retlen, mac1) == 0 && retlen == 6) {
46 +                               printk(KERN_INFO "gateway 7001 mac1: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
47 +                                       mac1[0], mac1[1], mac1[2], mac1[3], mac1[4], mac1[5]);
48 +                               memcpy(plat_mac1.hwaddr, mac1, 6);
49 +               }
50 +       }
51 +}
52 +
53 +static void gateway7001_flash_remove(struct mtd_info *mtd) {
54 +}
55 +
56 +static struct mtd_notifier gateway7001_flash_notifier = {
57 +       .add = gateway7001_flash_add,
58 +       .remove = gateway7001_flash_remove,
59  };
60  
61  static void __init gateway7001_init(void)
62 @@ -140,6 +178,7 @@ static void __init gateway7001_init(void
63         *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
64  
65         platform_add_devices(gateway7001_devices, ARRAY_SIZE(gateway7001_devices));
66 +       register_mtd_user(&gateway7001_flash_notifier);
67  }
68  
69  #ifdef CONFIG_MACH_GATEWAY7001