Split up brcm63xx into files/
[openwrt.git] / target / linux / brcm63xx-2.6 / patches / 040-bcm963xx_flashmap.patch
index d8acdfa..82a2c94 100644 (file)
-diff -urN linux-2.6.16.7/drivers/mtd/maps/bcm963xx.c linux-2.6.16.7-brcm63xx/drivers/mtd/maps/bcm963xx.c
---- linux-2.6.16.7/drivers/mtd/maps/bcm963xx.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.16.7-brcm63xx/drivers/mtd/maps/bcm963xx.c        2006-07-07 22:00:36.000000000 +0200
-@@ -0,0 +1,106 @@
-+/*
-+ * A simple flash mapping code for BCM963xx board flash memory
-+ * It is simple because it only treats all the flash memory as ROM
-+ * It is used with chips/map_rom.c
-+ *
-+ *  Song Wang (songw@broadcom.com)
-+ */
-+
-+#include <linux/module.h>
-+#include <linux/types.h>
-+#include <linux/kernel.h>
-+#include <linux/init.h>
-+#include <asm/io.h>
-+#include <linux/mtd/mtd.h>
-+#include <linux/mtd/map.h>
-+#include <linux/config.h>
-+
-+#include <board.h>
-+#include <bcmTag.h>
-+#define  VERSION      "1.0"
-+
-+extern PFILE_TAG kerSysImageTagGet(void);
-+
-+static struct mtd_info *mymtd;
-+
-+static map_word brcm_physmap_read16(struct map_info *map, unsigned long ofs)
-+{
-+      map_word val;
-+      
-+      val.x[0] = __raw_readw(map->map_priv_1 + ofs);
-+      
-+      return val;
-+}
-+
-+static void brcm_physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
-+{
-+      memcpy_fromio(to, map->map_priv_1 + from, len);
-+}
-+
-+static struct map_info brcm_physmap_map = {
-+      .name           = "Physically mapped flash",
-+      .bankwidth      = 2,
-+      .read           = brcm_physmap_read16,
-+      .copy_from      = brcm_physmap_copy_from
-+};
-+
-+static int __init init_brcm_physmap(void)
-+{
-+        PFILE_TAG pTag = NULL;
-+        u_int32_t rootfs_addr, kernel_addr;
-+        FLASH_ADDR_INFO info;
-+
-+      printk("bcm963xx_mtd driver v%s\n", VERSION);
-+        kerSysFlashAddrInfoGet( &info );
-+
-+        /* Read the flash memory map from flash memory. */
-+        if (!(pTag = kerSysImageTagGet())) {
-+                printk("Failed to read image tag from flash\n");
-+                return -EIO;
-+        }
-+
-+        rootfs_addr = (u_int32_t) simple_strtoul(pTag->rootfsAddress, NULL, 10);
-+        kernel_addr = (u_int32_t) simple_strtoul(pTag->kernelAddress, NULL, 10);
-+      
-+      brcm_physmap_map.size = kernel_addr - rootfs_addr;
-+      brcm_physmap_map.map_priv_1 = (unsigned long)rootfs_addr;
-+
-+      if (!brcm_physmap_map.map_priv_1) {
-+              printk("Wrong rootfs starting address\n");
-+              return -EIO;
-+      }
-+      
-+      if (brcm_physmap_map.size <= 0) {
-+              printk("Wrong rootfs size\n");
-+              return -EIO;
-+      }       
-+      
-+      mymtd = do_map_probe("map_rom", &brcm_physmap_map);
-+      if (mymtd) {
-+              mymtd->owner = THIS_MODULE;
-+              add_mtd_device(mymtd);
-+
-+              return 0;
-+      }
-+
-+      return -ENXIO;
-+}
-+
-+static void __exit cleanup_brcm_physmap(void)
-+{
-+      if (mymtd) {
-+              del_mtd_device(mymtd);
-+              map_destroy(mymtd);
-+      }
-+      if (brcm_physmap_map.map_priv_1) {
-+              brcm_physmap_map.map_priv_1 = 0;
-+      }
-+}
-+
-+module_init(init_brcm_physmap);
-+module_exit(cleanup_brcm_physmap);
-+
-+
-+MODULE_LICENSE("GPL");
-+MODULE_AUTHOR("Song Wang songw@broadcom.com");
-+MODULE_DESCRIPTION("Configurable MTD map driver for read-only root file system");
-diff -urN linux-2.6.16.7/drivers/mtd/maps/Kconfig linux-2.6.16.7-brcm63xx/drivers/mtd/maps/Kconfig
---- linux-2.6.16.7/drivers/mtd/maps/Kconfig    2006-04-17 23:53:25.000000000 +0200
-+++ linux-2.6.16.7-brcm63xx/drivers/mtd/maps/Kconfig   2006-07-07 22:02:13.000000000 +0200
+diff -urN linux-2.6.19/drivers/mtd/maps/Kconfig linux-2.6.19.new/drivers/mtd/maps/Kconfig
+--- linux-2.6.19/drivers/mtd/maps/Kconfig      2006-11-29 22:57:37.000000000 +0100
++++ linux-2.6.19.new/drivers/mtd/maps/Kconfig  2006-12-18 17:21:07.000000000 +0100
 @@ -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
-+      tristate "BCM963xx Flash device"
-+      depends on MIPS && MIPS_BRCM
-+      help
-+        This driver seems to detect and provide a valid flash map to the system
-+        of course, it needs checking and testing.
++        tristate "BCM963xx Flash device"
++        depends on MIPS && BCM963XX
++        help
++        Flash memory access on BCM963xx boards. Currently only works with
++        RedBoot and CFE.
 +
  config MTD_DILNETPC
        tristate "CFI Flash device mapped on DIL/Net PC"
        depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
-diff -urN linux-2.6.16.7/drivers/mtd/maps/Makefile linux-2.6.16.7-brcm63xx/drivers/mtd/maps/Makefile
---- linux-2.6.16.7/drivers/mtd/maps/Makefile   2006-04-17 23:53:25.000000000 +0200
-+++ linux-2.6.16.7-brcm63xx/drivers/mtd/maps/Makefile  2006-07-07 22:01:29.000000000 +0200
-@@ -71,3 +71,4 @@
+diff -urN linux-2.6.19/drivers/mtd/maps/Makefile linux-2.6.19.new/drivers/mtd/maps/Makefile
+--- linux-2.6.19/drivers/mtd/maps/Makefile     2006-11-29 22:57:37.000000000 +0100
++++ linux-2.6.19.new/drivers/mtd/maps/Makefile 2006-12-18 17:21:07.000000000 +0100
+@@ -70,3 +70,4 @@
  obj-$(CONFIG_MTD_OMAP_NOR)    += omap_nor.o
  obj-$(CONFIG_MTD_MTX1)                += mtx-1_flash.o
  obj-$(CONFIG_MTD_TQM834x)     += tqm834x.o
-+obj-$(CONFIG_MTD_BCM963XX)      += bcm963xx.o
++obj-$(CONFIG_MTD_BCM963XX)      += bcm963xx-flash.o
+diff -urN linux-2.6.19/drivers/mtd/redboot.c linux-2.6.19.new/drivers/mtd/redboot.c
+--- linux-2.6.19/drivers/mtd/redboot.c 2006-12-18 17:09:14.000000000 +0100
++++ linux-2.6.19.new/drivers/mtd/redboot.c     2006-12-18 17:14:26.000000000 +0100
+@@ -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)
+ {
+@@ -132,6 +132,14 @@
+               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;
+@@ -154,9 +162,8 @@
+               new_fl->img = &buf[i];
+                 if (fis_origin) {
+                         buf[i].flash_base -= fis_origin;
+-                } else {
+-                        buf[i].flash_base &= master->size-1;
+                 }
++              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_
This page took 0.033045 seconds and 4 git commands to generate.