refresh kernel patches
[librecmc/librecmc.git] / target / linux / brcm63xx / patches-2.6.25 / 040-bcm963xx_flashmap.patch
1 From e734ace5baa04e0e8af1d4483475fbd6bd2b32a1 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
7 Signed-off-by: Axel Gembe <ago@bastart.eu.org>
8 ---
9  drivers/mtd/maps/Kconfig  |    7 +++++++
10  drivers/mtd/maps/Makefile |    1 +
11  drivers/mtd/redboot.c     |   13 ++++++++++---
12  3 files changed, 18 insertions(+), 3 deletions(-)
13
14 Index: linux-2.6.25.4/drivers/mtd/maps/Kconfig
15 ===================================================================
16 --- linux-2.6.25.4.orig/drivers/mtd/maps/Kconfig
17 +++ linux-2.6.25.4/drivers/mtd/maps/Kconfig
18 @@ -262,6 +262,13 @@ config MTD_MTX1
19           Flash memory access on 4G Systems MTX-1 Board. If you have one of
20           these boards and would like to use the flash chips on it, say 'Y'.
21  
22 +config MTD_BCM963XX
23 +        tristate "BCM963xx Flash device"
24 +        depends on MIPS && BCM963XX
25 +        help
26 +         Flash memory access on BCM963xx boards. Currently only works with
27 +         RedBoot and CFE.
28 +
29  config MTD_DILNETPC
30         tristate "CFI Flash device mapped on DIL/Net PC"
31         depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
32 Index: linux-2.6.25.4/drivers/mtd/maps/Makefile
33 ===================================================================
34 --- linux-2.6.25.4.orig/drivers/mtd/maps/Makefile
35 +++ linux-2.6.25.4/drivers/mtd/maps/Makefile
36 @@ -68,3 +68,4 @@ obj-$(CONFIG_MTD_PLATRAM)     += plat-ram.o
37  obj-$(CONFIG_MTD_OMAP_NOR)     += omap_nor.o
38  obj-$(CONFIG_MTD_MTX1)         += mtx-1_flash.o
39  obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o
40 +obj-$(CONFIG_MTD_BCM963XX)     += bcm963xx-flash.o
41 Index: linux-2.6.25.4/drivers/mtd/redboot.c
42 ===================================================================
43 --- linux-2.6.25.4.orig/drivers/mtd/redboot.c
44 +++ linux-2.6.25.4/drivers/mtd/redboot.c
45 @@ -39,7 +39,7 @@ static inline int redboot_checksum(struc
46         return 1;
47  }
48  
49 -static int parse_redboot_partitions(struct mtd_info *master,
50 +int parse_redboot_partitions(struct mtd_info *master,
51                               struct mtd_partition **pparts,
52                               unsigned long fis_origin)
53  {
54 @@ -161,6 +161,14 @@ static int parse_redboot_partitions(stru
55                 goto out;
56         }
57  
58 +       if (!fis_origin) {
59 +               for (i = 0; i < numslots; i++) {
60 +                       if (!strncmp(buf[i].name, "RedBoot", 8)) {
61 +                               fis_origin = (buf[i].flash_base & (master->size << 1) - 1);
62 +                       }
63 +               }
64 +       }
65 +
66         for (i = 0; i < numslots; i++) {
67                 struct fis_list *new_fl, **prev;
68  
69 @@ -183,9 +191,8 @@ static int parse_redboot_partitions(stru
70                 new_fl->img = &buf[i];
71                  if (fis_origin) {
72                          buf[i].flash_base -= fis_origin;
73 -                } else {
74 -                        buf[i].flash_base &= master->size-1;
75                  }
76 +               buf[i].flash_base &= (master->size << 1) - 1;
77  
78                 /* I'm sure the JFFS2 code has done me permanent damage.
79                  * I now think the following is _normal_