bcm63xx: add support for linux 3.8
[openwrt.git] / target / linux / brcm63xx / patches-3.8 / 404-bcm963xx_flashmap.patch
1 From a4d005c91d403d9f3d0272db6cc46202c06ec774 Mon Sep 17 00:00:00 2001
2 From: Axel Gembe <ago@bastart.eu.org>
3 Date: Mon, 12 May 2008 18:54:09 +0200
4 Subject: [PATCH] bcm963xx: flashmap support
5
6 Signed-off-by: Axel Gembe <ago@bastart.eu.org>
7 ---
8  arch/mips/bcm63xx/boards/board_bcm963xx.c |   19 +----------------
9  drivers/mtd/maps/bcm963xx-flash.c         |   32 ++++++++++++++++++++++++----
10  drivers/mtd/redboot.c                     |   13 +++++++++--
11  3 files changed, 38 insertions(+), 26 deletions(-)
12
13 --- a/arch/mips/bcm63xx/dev-flash.c
14 +++ b/arch/mips/bcm63xx/dev-flash.c
15 @@ -30,7 +30,7 @@ static struct mtd_partition mtd_partitio
16         }
17  };
18  
19 -static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
20 +static const char *bcm63xx_part_types[] = { "bcm63xxpart", "RedBoot", NULL };
21  
22  static struct physmap_flash_data flash_data = {
23         .width                  = 2,
24 --- a/drivers/mtd/redboot.c
25 +++ b/drivers/mtd/redboot.c
26 @@ -72,6 +72,7 @@ static int parse_redboot_partitions(stru
27         int nulllen = 0;
28         int numslots;
29         unsigned long offset;
30 +       unsigned long fis_origin = 0;
31  #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
32         static char nullstring[] = "unallocated";
33  #endif
34 @@ -176,6 +177,16 @@ static int parse_redboot_partitions(stru
35                 goto out;
36         }
37  
38 +       if (data && data->origin) {
39 +               fis_origin = data->origin;
40 +       } else {
41 +               for (i = 0; i < numslots; i++) {
42 +                       if (!strncmp(buf[i].name, "RedBoot", 8)) {
43 +                               fis_origin = (buf[i].flash_base & (master->size << 1) - 1);
44 +                       }
45 +               }
46 +       }
47 +
48         for (i = 0; i < numslots; i++) {
49                 struct fis_list *new_fl, **prev;
50  
51 @@ -196,10 +207,10 @@ static int parse_redboot_partitions(stru
52                         goto out;
53                 }
54                 new_fl->img = &buf[i];
55 -               if (data && data->origin)
56 -                       buf[i].flash_base -= data->origin;
57 -               else
58 -                       buf[i].flash_base &= master->size-1;
59 +               if (fis_origin)
60 +                       buf[i].flash_base -= fis_origin;
61 +
62 +               buf[i].flash_base &= (master->size << 1) - 1;
63  
64                 /* I'm sure the JFFS2 code has done me permanent damage.
65                  * I now think the following is _normal_