1 diff -urN linux-2.6.17/drivers/mtd/maps/bcm963xx-flash.c linux-2.6.17-brcm63xx/drivers/mtd/maps/bcm963xx-flash.c
2 --- linux-2.6.17/drivers/mtd/maps/bcm963xx-flash.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.17-brcm63xx/drivers/mtd/maps/bcm963xx-flash.c 2006-08-30 13:03:16.000000000 +0200
7 + * Copyright (C) 2006 Florian Fainelli
8 + * Copyright (C) $Date$ $Author$
10 + * This program is free software; you can redistribute it and/or modify
11 + * it under the terms of the GNU General Public License as published by
12 + * the Free Software Foundation; either version 2 of the License, or
13 + * (at your option) any later version.
15 + * This program is distributed in the hope that it will be useful,
16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 + * GNU General Public License for more details.
20 + * You should have received a copy of the GNU General Public License
21 + * along with this program; if not, write to the Free Software
22 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 +/* This is the BCM963xx flash map driver, in its actual state it only supports BCM96348 devices
26 + * this driver is able to manage both bootloader we found on these boards : CFE and RedBoot
29 + * - this bootloader allows us to parse partitions and therefore deduce the MTD partition table
32 + * - we have to use a "physically mapped flash" defined bellow
37 +#include <linux/init.h>
38 +#include <linux/mtd/map.h>
39 +#include <linux/mtd/mtd.h>
40 +#include <linux/mtd/partitions.h>
43 +#define WINDOW_ADDR 0x1e400000 /* Real address of the flash */
44 +#define WINDOW_SIZE 0x800000 /* Size of flash */
45 +#define BUSWIDTH 2 /* Buswidth */
46 +#define EXTENDED_SIZE 0xBE400000 /* Extended flash addresse */
48 +extern int boot_loader_type; /* For RedBoot / CFE detection */
49 +extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long fis_origin);
50 +static struct mtd_partition *parsed_parts;
52 +static void __exit bcm963xx_mtd_cleanup(void);
54 +static struct mtd_info *bcm963xx_mtd_info;
56 +static struct map_info bcm963xx_map = {
58 + .size = WINDOW_SIZE,
59 + .bankwidth = BUSWIDTH,
60 + .phys = WINDOW_ADDR,
63 +static struct mtd_partition bcm963xx_parts[] = {
64 + { name: "bootloader", size: 0, offset: 0, mask_flags: MTD_WRITEABLE },
65 + { name: "rootfs", size: 0, offset: 0},
66 + { name: "jffs2", size: 5 * 0x10000, offset: 57*0x10000}
69 +static int bcm963xx_parts_size = sizeof(bcm963xx_parts) / sizeof(bcm963xx_parts[0]);
71 +static int __init bcm963xx_mtd_init(void)
73 + printk("bcm963xx: 0x%08x at 0x%08x\n", WINDOW_SIZE, WINDOW_ADDR);
74 + bcm963xx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
76 + if (!bcm963xx_map.virt) {
77 + printk("bcm963xx: Failed to ioremap\n");
81 + simple_map_init(&bcm963xx_map);
83 + bcm963xx_mtd_info = do_map_probe("cfi_probe", &bcm963xx_map);
85 + if (bcm963xx_mtd_info) {
86 + bcm963xx_mtd_info->owner = THIS_MODULE;
88 + if (boot_loader_type == BOOT_CFE)
90 + add_mtd_device(bcm963xx_mtd_info);
91 + add_mtd_partitions(bcm963xx_mtd_info, bcm963xx_parts, bcm963xx_parts_size);
96 + int parsed_nr_parts = 0;
99 + if (bcm963xx_mtd_info->size > 0x00400000) {
100 + printk("Support for extended flash memory size : 0x%08X ; ONLY 64MBIT SUPPORT\n", bcm963xx_mtd_info->size);
101 + bcm963xx_map.virt = (unsigned long)(EXTENDED_SIZE);
104 +#ifdef CONFIG_MTD_REDBOOT_PARTS
105 + if (parsed_nr_parts == 0) {
106 + int ret = parse_redboot_partitions(bcm963xx_mtd_info, &parsed_parts, 0);
108 + part_type = "RedBoot";
109 + parsed_nr_parts = ret;
113 + add_mtd_partitions(bcm963xx_mtd_info, parsed_parts, parsed_nr_parts);
118 + iounmap(bcm963xx_map.virt);
122 +static void __exit bcm963xx_mtd_cleanup(void)
124 + if (bcm963xx_mtd_info) {
125 + del_mtd_partitions(bcm963xx_mtd_info);
126 + map_destroy(bcm963xx_mtd_info);
129 + if (bcm963xx_map.virt) {
130 + iounmap(bcm963xx_map.virt);
131 + bcm963xx_map.virt = 0;
135 +module_init(bcm963xx_mtd_init);
136 +module_exit(bcm963xx_mtd_cleanup);
138 +MODULE_LICENSE("GPL");
139 +MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
140 diff -urN linux-2.6.17/drivers/mtd/maps/Kconfig linux-2.6.17-brcm63xx/drivers/mtd/maps/Kconfig
141 --- linux-2.6.17/drivers/mtd/maps/Kconfig 2006-06-18 03:49:35.000000000 +0200
142 +++ linux-2.6.17-brcm63xx/drivers/mtd/maps/Kconfig 2006-08-30 13:03:06.000000000 +0200
144 Flash memory access on 4G Systems MTX-1 Board. If you have one of
145 these boards and would like to use the flash chips on it, say 'Y'.
148 + tristate "BCM963xx Flash device"
149 + depends on MIPS && MIPS_BRCM
151 + Flash memory access on BCM963xx boards. Currently only works with
152 + RedBoot, CFE support coming soon.
155 tristate "CFI Flash device mapped on DIL/Net PC"
156 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
157 diff -urN linux-2.6.17/drivers/mtd/maps/Makefile linux-2.6.17-brcm63xx/drivers/mtd/maps/Makefile
158 --- linux-2.6.17/drivers/mtd/maps/Makefile 2006-06-18 03:49:35.000000000 +0200
159 +++ linux-2.6.17-brcm63xx/drivers/mtd/maps/Makefile 2006-08-30 13:03:06.000000000 +0200
161 obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
162 obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
163 obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
164 +obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o
165 diff -urN linux-2.6.17/drivers/mtd/redboot.c linux-2.6.17-brcm63xx/drivers/mtd/redboot.c
166 --- linux-2.6.17/drivers/mtd/redboot.c 2006-06-18 03:49:35.000000000 +0200
167 +++ linux-2.6.17-brcm63xx/drivers/mtd/redboot.c 2006-08-30 13:03:06.000000000 +0200
172 -static int parse_redboot_partitions(struct mtd_info *master,
173 +int parse_redboot_partitions(struct mtd_info *master,
174 struct mtd_partition **pparts,
175 unsigned long fis_origin)
177 @@ -120,11 +120,19 @@
182 + for (i = 0; i < numslots; i++) {
183 + if (!strncmp(buf[i].name, "RedBoot", 8)) {
184 + fis_origin = (buf[i].flash_base & (master->size << 1) - 1);
189 for (i = 0; i < numslots; i++) {
190 struct fis_list *new_fl, **prev;
192 if (buf[i].name[0] == 0xff)
195 if (!redboot_checksum(&buf[i]))
198 @@ -135,11 +143,10 @@
201 new_fl->img = &buf[i];
203 - buf[i].flash_base -= fis_origin;
205 - buf[i].flash_base &= master->size-1;
208 + buf[i].flash_base -= fis_origin;
210 + buf[i].flash_base &= (master->size << 1) - 1;
212 /* I'm sure the JFFS2 code has done me permanent damage.
213 * I now think the following is _normal_