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-03 16:29:52.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>
42 +#define WINDOW_ADDR 0x1e400000 /* Real address of the flash */
43 +#define WINDOW_SIZE 0x800000 /* Size of flash */
44 +#define BUSWIDTH 2 /* Buswidth */
46 +extern int boot_loader_type; /* For RedBoot / CFE detection */
47 +extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long fis_origin);
48 +static struct mtd_partition *parsed_parts;
50 +static void __exit bcm963xx_mtd_cleanup(void);
52 +static struct mtd_info *bcm963xx_mtd_info;
54 +static struct map_info bcm963xx_map = {
56 + .size = WINDOW_SIZE,
57 + .bankwidth = BUSWIDTH,
58 + .phys = WINDOW_ADDR,
61 +static struct mtd_partition bcm963xx_parts[] = {
62 + { name: "bootloader", size: 0, offset: 0, mask_flags: MTD_WRITEABLE },
63 + { name: "rootfs", size: 0, offset: 0},
64 + { name: "jffs2", size: 5 * 0x10000, offset: 57*0x10000}
67 +static int __init bcm963xx_mtd_init(void)
69 + printk("bcm963xx: 0x%08x at 0x%08x\n", WINDOW_SIZE, WINDOW_ADDR);
70 + bcm963xx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
72 + if (!bcm963xx_map.virt) {
73 + printk("bcm963xx: Failed to ioremap\n");
77 + simple_map_init(&bcm963xx_map);
79 + bcm963xx_mtd_info = do_map_probe("cfi_probe", &bcm963xx_map);
81 + if (bcm963xx_mtd_info) {
82 + bcm963xx_mtd_info->owner = THIS_MODULE;
83 + int parsed_nr_parts = 0;
86 +#ifdef CONFIG_MTD_REDBOOT_PARTS
87 + if (parsed_nr_parts == 0) {
88 + int ret = parse_redboot_partitions(bcm963xx_mtd_info, &parsed_parts, 0);
90 + part_type = "RedBoot";
91 + parsed_nr_parts = ret;
95 + add_mtd_partitions(bcm963xx_mtd_info, parsed_parts, parsed_nr_parts);
99 + iounmap(bcm963xx_map.virt);
103 +static void __exit bcm963xx_mtd_cleanup(void)
105 + if (bcm963xx_mtd_info) {
106 + del_mtd_partitions(bcm963xx_mtd_info);
107 + map_destroy(bcm963xx_mtd_info);
110 + if (bcm963xx_map.virt) {
111 + iounmap(bcm963xx_map.virt);
112 + bcm963xx_map.virt = 0;
116 +module_init(bcm963xx_mtd_init);
117 +module_exit(bcm963xx_mtd_cleanup);
119 +MODULE_LICENSE("GPL");
120 +MODULE_AUTHOR("Florian Fainelli");
121 diff -urN linux-2.6.17/drivers/mtd/maps/Kconfig linux-2.6.17-brcm63xx/drivers/mtd/maps/Kconfig
122 --- linux-2.6.17/drivers/mtd/maps/Kconfig 2006-06-18 03:49:35.000000000 +0200
123 +++ linux-2.6.17-brcm63xx/drivers/mtd/maps/Kconfig 2006-08-03 16:32:05.000000000 +0200
125 Flash memory access on 4G Systems MTX-1 Board. If you have one of
126 these boards and would like to use the flash chips on it, say 'Y'.
129 + tristate "BCM963xx Flash device"
130 + depends on MIPS && MIPS_BRCM
132 + Flash memory access on BCM963xx boards. Currently only works with
133 + RedBoot, CFE support coming soon.
136 tristate "CFI Flash device mapped on DIL/Net PC"
137 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
138 diff -urN linux-2.6.17/drivers/mtd/maps/Makefile linux-2.6.17-brcm63xx/drivers/mtd/maps/Makefile
139 --- linux-2.6.17/drivers/mtd/maps/Makefile 2006-06-18 03:49:35.000000000 +0200
140 +++ linux-2.6.17-brcm63xx/drivers/mtd/maps/Makefile 2006-08-03 16:32:27.000000000 +0200
142 obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
143 obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
144 obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
145 +obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o
146 diff -urN linux-2.6.17/drivers/mtd/redboot.c linux-2.6.17-brcm63xx/drivers/mtd/redboot.c
147 --- linux-2.6.17/drivers/mtd/redboot.c 2006-06-18 03:49:35.000000000 +0200
148 +++ linux-2.6.17-brcm63xx/drivers/mtd/redboot.c 2006-08-03 16:32:39.000000000 +0200
153 -static int parse_redboot_partitions(struct mtd_info *master,
154 +int parse_redboot_partitions(struct mtd_info *master,
155 struct mtd_partition **pparts,
156 unsigned long fis_origin)
158 @@ -120,11 +120,19 @@
163 + for (i = 0; i < numslots; i++) {
164 + if (!strncmp(buf[i].name, "RedBoot", 8)) {
165 + fis_origin = (buf[i].flash_base & (master->size << 1) - 1);
170 for (i = 0; i < numslots; i++) {
171 struct fis_list *new_fl, **prev;
173 if (buf[i].name[0] == 0xff)
176 if (!redboot_checksum(&buf[i]))
179 @@ -135,11 +143,10 @@
182 new_fl->img = &buf[i];
184 - buf[i].flash_base -= fis_origin;
186 - buf[i].flash_base &= master->size-1;
189 + buf[i].flash_base -= fis_origin;
191 + buf[i].flash_base &= (master->size << 1) - 1;
193 /* I'm sure the JFFS2 code has done me permanent damage.
194 * I now think the following is _normal_