2006-08-03 22:43:03 +08:00
|
|
|
diff -urN linux-2.6.17/drivers/mtd/maps/bcm963xx-flash.c linux-2.6.17-brcm63xx/drivers/mtd/maps/bcm963xx-flash.c
|
|
|
|
--- linux-2.6.17/drivers/mtd/maps/bcm963xx-flash.c 1970-01-01 01:00:00.000000000 +0100
|
2006-08-30 19:16:06 +08:00
|
|
|
+++ linux-2.6.17-brcm63xx/drivers/mtd/maps/bcm963xx-flash.c 2006-08-30 13:03:16.000000000 +0200
|
|
|
|
@@ -0,0 +1,135 @@
|
2006-07-08 05:04:02 +08:00
|
|
|
+/*
|
2006-08-03 22:43:03 +08:00
|
|
|
+ * $Id$
|
|
|
|
+ * Copyright (C) 2006 Florian Fainelli
|
|
|
|
+ * Copyright (C) $Date$ $Author$
|
|
|
|
+ *
|
|
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
|
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+ * (at your option) any later version.
|
|
|
|
+ *
|
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+ * GNU General Public License for more details.
|
|
|
|
+ *
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program; if not, write to the Free Software
|
|
|
|
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+/* This is the BCM963xx flash map driver, in its actual state it only supports BCM96348 devices
|
|
|
|
+ * this driver is able to manage both bootloader we found on these boards : CFE and RedBoot
|
|
|
|
+ *
|
|
|
|
+ * RedBoot :
|
|
|
|
+ * - this bootloader allows us to parse partitions and therefore deduce the MTD partition table
|
|
|
|
+ *
|
|
|
|
+ * CFE :
|
|
|
|
+ * - we have to use a "physically mapped flash" defined bellow
|
2006-07-08 05:04:02 +08:00
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <asm/io.h>
|
2006-08-03 22:43:03 +08:00
|
|
|
+#include <linux/init.h>
|
2006-07-08 05:04:02 +08:00
|
|
|
+#include <linux/mtd/map.h>
|
2006-08-03 22:43:03 +08:00
|
|
|
+#include <linux/mtd/mtd.h>
|
|
|
|
+#include <linux/mtd/partitions.h>
|
2006-08-30 19:16:06 +08:00
|
|
|
+#include <board.h>
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+#define WINDOW_ADDR 0x1e400000 /* Real address of the flash */
|
|
|
|
+#define WINDOW_SIZE 0x800000 /* Size of flash */
|
|
|
|
+#define BUSWIDTH 2 /* Buswidth */
|
2006-08-30 19:16:06 +08:00
|
|
|
+#define EXTENDED_SIZE 0xBE400000 /* Extended flash addresse */
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+extern int boot_loader_type; /* For RedBoot / CFE detection */
|
|
|
|
+extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long fis_origin);
|
|
|
|
+static struct mtd_partition *parsed_parts;
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+static void __exit bcm963xx_mtd_cleanup(void);
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+static struct mtd_info *bcm963xx_mtd_info;
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+static struct map_info bcm963xx_map = {
|
|
|
|
+ .name = "bcm963xx",
|
|
|
|
+ .size = WINDOW_SIZE,
|
|
|
|
+ .bankwidth = BUSWIDTH,
|
|
|
|
+ .phys = WINDOW_ADDR,
|
|
|
|
+};
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+static struct mtd_partition bcm963xx_parts[] = {
|
|
|
|
+ { name: "bootloader", size: 0, offset: 0, mask_flags: MTD_WRITEABLE },
|
|
|
|
+ { name: "rootfs", size: 0, offset: 0},
|
|
|
|
+ { name: "jffs2", size: 5 * 0x10000, offset: 57*0x10000}
|
2006-07-08 05:04:02 +08:00
|
|
|
+};
|
|
|
|
+
|
2006-08-30 19:16:06 +08:00
|
|
|
+static int bcm963xx_parts_size = sizeof(bcm963xx_parts) / sizeof(bcm963xx_parts[0]);
|
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+static int __init bcm963xx_mtd_init(void)
|
2006-07-08 05:04:02 +08:00
|
|
|
+{
|
2006-08-03 22:43:03 +08:00
|
|
|
+ printk("bcm963xx: 0x%08x at 0x%08x\n", WINDOW_SIZE, WINDOW_ADDR);
|
|
|
|
+ bcm963xx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+ if (!bcm963xx_map.virt) {
|
|
|
|
+ printk("bcm963xx: Failed to ioremap\n");
|
|
|
|
+ return -EIO;
|
|
|
|
+ }
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+ simple_map_init(&bcm963xx_map);
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+ bcm963xx_mtd_info = do_map_probe("cfi_probe", &bcm963xx_map);
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+ if (bcm963xx_mtd_info) {
|
|
|
|
+ bcm963xx_mtd_info->owner = THIS_MODULE;
|
2006-08-30 19:16:06 +08:00
|
|
|
+
|
|
|
|
+ if (boot_loader_type == BOOT_CFE)
|
|
|
|
+ {
|
|
|
|
+ add_mtd_device(bcm963xx_mtd_info);
|
|
|
|
+ add_mtd_partitions(bcm963xx_mtd_info, bcm963xx_parts, bcm963xx_parts_size);
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ int parsed_nr_parts = 0;
|
|
|
|
+ char * part_type;
|
|
|
|
+
|
|
|
|
+ if (bcm963xx_mtd_info->size > 0x00400000) {
|
|
|
|
+ printk("Support for extended flash memory size : 0x%08X ; ONLY 64MBIT SUPPORT\n", bcm963xx_mtd_info->size);
|
|
|
|
+ bcm963xx_map.virt = (unsigned long)(EXTENDED_SIZE);
|
|
|
|
+ }
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+#ifdef CONFIG_MTD_REDBOOT_PARTS
|
2006-08-30 19:16:06 +08:00
|
|
|
+ if (parsed_nr_parts == 0) {
|
|
|
|
+ int ret = parse_redboot_partitions(bcm963xx_mtd_info, &parsed_parts, 0);
|
|
|
|
+ if (ret > 0) {
|
|
|
|
+ part_type = "RedBoot";
|
|
|
|
+ parsed_nr_parts = ret;
|
|
|
|
+ }
|
2006-08-03 22:43:03 +08:00
|
|
|
+ }
|
|
|
|
+#endif
|
2006-08-30 19:16:06 +08:00
|
|
|
+ add_mtd_partitions(bcm963xx_mtd_info, parsed_parts, parsed_nr_parts);
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
2006-08-30 19:16:06 +08:00
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
2006-08-03 22:43:03 +08:00
|
|
|
+ iounmap(bcm963xx_map.virt);
|
2006-07-08 05:04:02 +08:00
|
|
|
+ return -ENXIO;
|
|
|
|
+}
|
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+static void __exit bcm963xx_mtd_cleanup(void)
|
2006-07-08 05:04:02 +08:00
|
|
|
+{
|
2006-08-03 22:43:03 +08:00
|
|
|
+ if (bcm963xx_mtd_info) {
|
|
|
|
+ del_mtd_partitions(bcm963xx_mtd_info);
|
|
|
|
+ map_destroy(bcm963xx_mtd_info);
|
2006-07-08 05:04:02 +08:00
|
|
|
+ }
|
2006-08-03 22:43:03 +08:00
|
|
|
+
|
|
|
|
+ if (bcm963xx_map.virt) {
|
|
|
|
+ iounmap(bcm963xx_map.virt);
|
|
|
|
+ bcm963xx_map.virt = 0;
|
2006-07-08 05:04:02 +08:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
2006-08-03 22:43:03 +08:00
|
|
|
+module_init(bcm963xx_mtd_init);
|
|
|
|
+module_exit(bcm963xx_mtd_cleanup);
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
|
|
|
+MODULE_LICENSE("GPL");
|
2006-08-30 19:16:06 +08:00
|
|
|
+MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
|
2006-08-03 22:43:03 +08:00
|
|
|
diff -urN linux-2.6.17/drivers/mtd/maps/Kconfig linux-2.6.17-brcm63xx/drivers/mtd/maps/Kconfig
|
|
|
|
--- linux-2.6.17/drivers/mtd/maps/Kconfig 2006-06-18 03:49:35.000000000 +0200
|
2006-08-30 19:16:06 +08:00
|
|
|
+++ linux-2.6.17-brcm63xx/drivers/mtd/maps/Kconfig 2006-08-30 13:03:06.000000000 +0200
|
2006-07-08 05:04:02 +08:00
|
|
|
@@ -224,6 +224,13 @@
|
|
|
|
Flash memory access on 4G Systems MTX-1 Board. If you have one of
|
|
|
|
these boards and would like to use the flash chips on it, say 'Y'.
|
|
|
|
|
|
|
|
+config MTD_BCM963XX
|
2006-08-03 22:43:03 +08:00
|
|
|
+ tristate "BCM963xx Flash device"
|
|
|
|
+ depends on MIPS && MIPS_BRCM
|
|
|
|
+ help
|
|
|
|
+ Flash memory access on BCM963xx boards. Currently only works with
|
|
|
|
+ RedBoot, CFE support coming soon.
|
2006-07-08 05:04:02 +08:00
|
|
|
+
|
|
|
|
config MTD_DILNETPC
|
|
|
|
tristate "CFI Flash device mapped on DIL/Net PC"
|
|
|
|
depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
|
2006-08-03 22:43:03 +08:00
|
|
|
diff -urN linux-2.6.17/drivers/mtd/maps/Makefile linux-2.6.17-brcm63xx/drivers/mtd/maps/Makefile
|
|
|
|
--- linux-2.6.17/drivers/mtd/maps/Makefile 2006-06-18 03:49:35.000000000 +0200
|
2006-08-30 19:16:06 +08:00
|
|
|
+++ linux-2.6.17-brcm63xx/drivers/mtd/maps/Makefile 2006-08-30 13:03:06.000000000 +0200
|
2006-07-08 05:04:02 +08:00
|
|
|
@@ -71,3 +71,4 @@
|
|
|
|
obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
|
|
|
|
obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
|
|
|
|
obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
|
2006-08-03 22:43:03 +08:00
|
|
|
+obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o
|
|
|
|
diff -urN linux-2.6.17/drivers/mtd/redboot.c linux-2.6.17-brcm63xx/drivers/mtd/redboot.c
|
|
|
|
--- linux-2.6.17/drivers/mtd/redboot.c 2006-06-18 03:49:35.000000000 +0200
|
2006-08-30 19:16:06 +08:00
|
|
|
+++ linux-2.6.17-brcm63xx/drivers/mtd/redboot.c 2006-08-30 13:03:06.000000000 +0200
|
2006-08-03 22:43:03 +08:00
|
|
|
@@ -39,7 +39,7 @@
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static int parse_redboot_partitions(struct mtd_info *master,
|
|
|
|
+int parse_redboot_partitions(struct mtd_info *master,
|
|
|
|
struct mtd_partition **pparts,
|
|
|
|
unsigned long fis_origin)
|
|
|
|
{
|
|
|
|
@@ -120,11 +120,19 @@
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (!fis_origin) {
|
|
|
|
+ for (i = 0; i < numslots; i++) {
|
|
|
|
+ if (!strncmp(buf[i].name, "RedBoot", 8)) {
|
|
|
|
+ fis_origin = (buf[i].flash_base & (master->size << 1) - 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
for (i = 0; i < numslots; i++) {
|
|
|
|
struct fis_list *new_fl, **prev;
|
|
|
|
|
|
|
|
if (buf[i].name[0] == 0xff)
|
|
|
|
- continue;
|
|
|
|
+ break;
|
|
|
|
if (!redboot_checksum(&buf[i]))
|
|
|
|
break;
|
|
|
|
|
|
|
|
@@ -135,11 +143,10 @@
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
new_fl->img = &buf[i];
|
|
|
|
- if (fis_origin) {
|
|
|
|
- buf[i].flash_base -= fis_origin;
|
|
|
|
- } else {
|
|
|
|
- buf[i].flash_base &= master->size-1;
|
|
|
|
- }
|
|
|
|
+ if (fis_origin) {
|
|
|
|
+ buf[i].flash_base -= fis_origin;
|
|
|
|
+ }
|
|
|
|
+ buf[i].flash_base &= (master->size << 1) - 1;
|
|
|
|
|
|
|
|
/* I'm sure the JFFS2 code has done me permanent damage.
|
|
|
|
* I now think the following is _normal_
|