[PATCH 2/2] MTD: Add initial support for DAVE PPChameleon board.

2005-11-01 Thread Matt Porter
On Wed, Oct 12, 2005 at 05:44:31PM +0200, Wolfgang Denk wrote:
 Hello,
 
 the following  patch  (against  current  kernel.org  tree)  adds  MTD
 support  for  the NOR and NAND flashes on the PPChameleon modules /
 eval boards manufactured by DAVE s.r.l.

This should be submitted to the MTD maintainer(s).

-Matt



[PATCH 2/2] MTD: Add initial support for DAVE PPChameleon board.

2005-10-12 Thread Wolfgang Denk
Hello,

the following  patch  (against  current  kernel.org  tree)  adds  MTD
support  for  the NOR and NAND flashes on the PPChameleon modules /
eval boards manufactured by DAVE s.r.l.



[PATCH] MTD: Add support for DAVE PPChameleon board.

Included support for the NOR and NAND flashes on the module, and for
the NAND flash on the eval board.

Note: on my system, all sectors of the NAND flash on the eval board
get flagged as bad, while there are actually only 5 bad sectors on
this device. This needs more investigation,

Signed-off-by: Wolfgang Denk wd at denx.de

---
commit 1fe4ae42778972c8065e5aaa1e807571798c57e8
tree 80ae5bb762dd29bb82d39f7bdd69ed7951aee629
parent c9759e3e50c6e0f7c935a0f84f6c811e0bc3bc84
author Wolfgang Denk wd at pollux.denx.de Wed, 12 Oct 2005 17:42:18 +0200
committer Wolfgang Denk wd at pollux.denx.de Wed, 12 Oct 2005 17:42:18 +0200

 drivers/mtd/maps/Kconfig  |8 +++
 drivers/mtd/maps/Makefile |1 
 drivers/mtd/maps/ppchameleon.c|  109 +
 drivers/mtd/nand/Kconfig  |6 +-
 drivers/mtd/nand/ppchameleonevb.c |   55 +--
 5 files changed, 147 insertions(+), 32 deletions(-)

diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -356,6 +356,14 @@ config MTD_REDWOOD
  Redwood board. If you have one of these boards and would like to
  use the flash chips on it, say 'Y'.
 
+config MTD_PPCHAMELEON
+   tristate Flash device mapped on DAVE PPChamelonEVB Boards
+   depends on MTD_CFI  PPC32  40x  PPChameleonEVB
+   help
+  This enables access routines for the flash chips on the
+  DAVE PPChamelonEVB board. If you have one of these boardsr
+ and would like to use the flash chips on it, say 'Y'.
+
 config MTD_UBOOT_PARTITIONS
bool Use U-Boot partition setup
depends on MTD_WALNUT || MTD_EBONY || MTD_OCOTEA || MTD_BAMBOO
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -72,3 +72,4 @@ obj-$(CONFIG_MTD_DMV182)  += dmv182.o
 obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o
 obj-$(CONFIG_MTD_PLATRAM)  += plat-ram.o
 obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
+obj-$(CONFIG_MTD_PPCHAMELEON)  += ppchameleon.o
diff --git a/drivers/mtd/maps/ppchameleon.c b/drivers/mtd/maps/ppchameleon.c
new file mode 100644
--- /dev/null
+++ b/drivers/mtd/maps/ppchameleon.c
@@ -0,0 +1,109 @@
+/*
+ * drivers/mtd/maps/ppchameleon.c
+ *
+ * Mapping for DAVE PPChamelonEVB flash
+ *
+ * Maintained by Wolfgang Denk, wd at denx.de
+ *
+ * Copyright (c) 2005 DENX Software Engineering
+ * Wolfgang Denk wd at denx.de
+ *
+ * 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.
+ */
+
+#include linux/module.h
+#include linux/types.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/mtd/mtd.h
+#include linux/mtd/map.h
+#include linux/mtd/partitions.h
+#include linux/config.h
+#include linux/version.h
+#include asm/io.h
+#include asm/ibm4xx.h
+#include asm/ppcboot.h
+
+extern bd_t __res;
+
+static struct mtd_info *flash;
+
+static struct map_info ppchameleon_map = {
+   .name = PPChameleon,
+   .bankwidth =2,
+};
+
+static struct mtd_partition ppchameleon_partitions[] = {
+{
+   name:   linux,/* Linux kernel image */
+   offset: 0x,
+   size:   0x0018,
+/* mask_flags: MTD_WRITEABLE,  / * force read-only */
+},
+{
+   name:   user, /* unassigned */
+   offset: 0x0018,
+   size:   0x0024,
+},
+{
+   name:   u-boot,   /* U-Boot Firmware */
+   offset: 0x003C,
+   size:   0x0004, /* 256 KB */
+/* mask_flags: MTD_WRITEABLE,  / * force read-only */
+},
+};
+
+int __init init_ppchameleon(void)
+{
+   unsigned long flash_base, flash_size;
+
+   flash_base = __res.bi_flashstart;
+   flash_size = __res.bi_flashsize;
+
+   ppchameleon_map.size = flash_size;
+   ppchameleon_map.phys = flash_base;
+   ppchameleon_map.virt =
+   (void __iomem *)ioremap(flash_base, ppchameleon_map.size);
+
+   if (!ppchameleon_map.virt) {
+   printk(Failed to ioremap flash.\n);
+   return -EIO;
+   }
+
+   simple_map_init(ppchameleon_map);
+
+   flash = do_map_probe(cfi_probe, ppchameleon_map);
+   if (flash) {
+   flash-owner = THIS_MODULE;
+   add_mtd_partitions(flash, ppchameleon_partitions,
+   ARRAY_SIZE(ppchameleon_partitions));
+   } else {
+