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
6 Signed-off-by: Axel Gembe <ago@bastart.eu.org>
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(-)
13 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
14 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
15 @@ -822,20 +822,6 @@ void __init board_setup(void)
16 panic("unexpected CPU for bcm963xx board");
19 -static struct mtd_partition mtd_partitions[] = {
27 -static struct physmap_flash_data flash_data = {
29 - .nr_parts = ARRAY_SIZE(mtd_partitions),
30 - .parts = mtd_partitions,
33 static struct resource mtd_resources[] = {
35 .start = 0, /* filled at runtime */
36 @@ -845,12 +831,9 @@ static struct resource mtd_resources[] =
39 static struct platform_device mtd_dev = {
40 - .name = "physmap-flash",
41 + .name = "bcm963xx-flash",
42 .resource = mtd_resources,
43 .num_resources = ARRAY_SIZE(mtd_resources),
45 - .platform_data = &flash_data,
49 static struct gpio_led_platform_data bcm63xx_led_data;
50 --- a/drivers/mtd/maps/bcm963xx-flash.c
51 +++ b/drivers/mtd/maps/bcm963xx-flash.c
53 #include <linux/vmalloc.h>
54 #include <linux/platform_device.h>
56 +#include <linux/magic.h>
57 +#include <linux/jffs2.h>
59 #include <asm/mach-bcm63xx/bcm963xx_tag.h>
63 #define PFX KBUILD_MODNAME ": "
65 +struct squashfs_super_block {
71 +extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long fis_origin);
73 static struct mtd_partition *parsed_parts;
75 static struct mtd_info *bcm963xx_mtd_info;
76 @@ -220,9 +230,21 @@ probe_ok:
80 - dev_info(&pdev->dev, "unsupported bootloader\n");
83 + printk(KERN_INFO PFX "assuming RedBoot bootloader\n");
84 + if (bcm963xx_mtd_info->size > 0x00400000) {
85 + printk(KERN_INFO PFX "Support for extended flash memory size : 0x%lx ; ONLY 64MBIT SUPPORT\n", bcm963xx_mtd_info->size);
86 + bcm963xx_map.virt = (u32)(BCM63XX_EXTENDED_SIZE);
89 +#ifdef CONFIG_MTD_REDBOOT_PARTS
90 + if (parsed_nr_parts == 0) {
91 + int ret = parse_redboot_partitions(bcm963xx_mtd_info, &parsed_parts, 0);
93 + part_type = "RedBoot";
94 + parsed_nr_parts = ret;
100 return mtd_device_register(bcm963xx_mtd_info, parsed_parts,
101 --- a/drivers/mtd/redboot.c
102 +++ b/drivers/mtd/redboot.c
103 @@ -58,7 +58,7 @@ static inline int redboot_checksum(struc
107 -static int parse_redboot_partitions(struct mtd_info *master,
108 +int parse_redboot_partitions(struct mtd_info *master,
109 struct mtd_partition **pparts,
110 struct mtd_part_parser_data *data)
112 @@ -75,6 +75,7 @@ static int parse_redboot_partitions(stru
115 unsigned long offset;
116 + unsigned long fis_origin = 0;
117 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
118 static char nullstring[] = "unallocated";
120 @@ -181,6 +182,16 @@ static int parse_redboot_partitions(stru
124 + if (data && data->origin) {
125 + fis_origin = data->origin;
127 + for (i = 0; i < numslots; i++) {
128 + if (!strncmp(buf[i].name, "RedBoot", 8)) {
129 + fis_origin = (buf[i].flash_base & (master->size << 1) - 1);
134 for (i = 0; i < numslots; i++) {
135 struct fis_list *new_fl, **prev;
137 @@ -201,10 +212,10 @@ static int parse_redboot_partitions(stru
140 new_fl->img = &buf[i];
141 - if (data && data->origin)
142 - buf[i].flash_base -= data->origin;
144 - buf[i].flash_base &= master->size-1;
146 + buf[i].flash_base -= fis_origin;
148 + buf[i].flash_base &= (master->size << 1) - 1;
150 /* I'm sure the JFFS2 code has done me permanent damage.
151 * I now think the following is _normal_