Re: [U-Boot] [PATCH v3 6/8] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-15 Thread Scott Wood

On 04/13/2013 09:42:34 AM, Marek Vasut wrote:

Dear Scott Wood,

 On 04/12/2013 01:59:18 PM, Mike Dunn wrote:
  This patch adds a driver for the diskonchip G4 nand flash  
device.  It

  is based
  on the driver from the linux kernel.
 
  This also includes a separate SPL driver.  A separate SPL driver  
is

  used because
  the device operates in a different mode (reliable mode) when  
loading

  a boot
  image, and also because the storage format of the boot image is
  different from
  normal data (pages are stored redundantly).  The SPL driver  
basically

  mimics how
  a typical IPL reads data from the device.  The special operating  
mode

  and
  storage format are used to compensate for the fact that the IPL  
does

  not contain
  the BCH ecc decoding algorithm (due to size constraints).   
Although

  the u-boot
  SPL *could* use ecc, it operates like an IPL for the sake of
  simplicity and
  uniformity, since the IPL and SPL share the task of loading the
  u-boot image.
  As a side benefit, the SPL driver is very small.
 
  [port from linux kernel 3.4 commit
  570469f3bde7f71cc1ece07a18d54a05b6a8775d]
 
  Signed-off-by: Mike Dunn miked...@newsguy.com
  ---
 
  Changelog:
v3: replace dbg macro with MTDDEBUG
v2: remove commented-out code
 
   drivers/mtd/nand/Makefile|2 +
   drivers/mtd/nand/docg4.c | 1028
 
  ++
 
   drivers/mtd/nand/docg4_spl.c |  222 +
   include/linux/mtd/docg4.h|  134 ++
   4 files changed, 1386 insertions(+), 0 deletions(-)
   create mode 100644 drivers/mtd/nand/docg4.c
   create mode 100644 drivers/mtd/nand/docg4_spl.c
   create mode 100644 include/linux/mtd/docg4.h

 Acked-by: Scott Wood scottw...@freescale.com

I'll pick them all if that's ok with you, Scott ?


Yes, that's fine.

-Scott
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 6/8] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-13 Thread Marek Vasut
Dear Scott Wood,

 On 04/12/2013 01:59:18 PM, Mike Dunn wrote:
  This patch adds a driver for the diskonchip G4 nand flash device.  It
  is based
  on the driver from the linux kernel.
  
  This also includes a separate SPL driver.  A separate SPL driver is
  used because
  the device operates in a different mode (reliable mode) when loading
  a boot
  image, and also because the storage format of the boot image is
  different from
  normal data (pages are stored redundantly).  The SPL driver basically
  mimics how
  a typical IPL reads data from the device.  The special operating mode
  and
  storage format are used to compensate for the fact that the IPL does
  not contain
  the BCH ecc decoding algorithm (due to size constraints).  Although
  the u-boot
  SPL *could* use ecc, it operates like an IPL for the sake of
  simplicity and
  uniformity, since the IPL and SPL share the task of loading the
  u-boot image.
  As a side benefit, the SPL driver is very small.
  
  [port from linux kernel 3.4 commit
  570469f3bde7f71cc1ece07a18d54a05b6a8775d]
  
  Signed-off-by: Mike Dunn miked...@newsguy.com
  ---
  
  Changelog:
v3: replace dbg macro with MTDDEBUG
v2: remove commented-out code
   
   drivers/mtd/nand/Makefile|2 +
   drivers/mtd/nand/docg4.c | 1028
  
  ++
  
   drivers/mtd/nand/docg4_spl.c |  222 +
   include/linux/mtd/docg4.h|  134 ++
   4 files changed, 1386 insertions(+), 0 deletions(-)
   create mode 100644 drivers/mtd/nand/docg4.c
   create mode 100644 drivers/mtd/nand/docg4_spl.c
   create mode 100644 include/linux/mtd/docg4.h
 
 Acked-by: Scott Wood scottw...@freescale.com

I'll pick them all if that's ok with you, Scott ?

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 6/8] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-12 Thread Mike Dunn
This patch adds a driver for the diskonchip G4 nand flash device.  It is based
on the driver from the linux kernel.

This also includes a separate SPL driver.  A separate SPL driver is used because
the device operates in a different mode (reliable mode) when loading a boot
image, and also because the storage format of the boot image is different from
normal data (pages are stored redundantly).  The SPL driver basically mimics how
a typical IPL reads data from the device.  The special operating mode and
storage format are used to compensate for the fact that the IPL does not contain
the BCH ecc decoding algorithm (due to size constraints).  Although the u-boot
SPL *could* use ecc, it operates like an IPL for the sake of simplicity and
uniformity, since the IPL and SPL share the task of loading the u-boot image.
As a side benefit, the SPL driver is very small.

[port from linux kernel 3.4 commit 570469f3bde7f71cc1ece07a18d54a05b6a8775d]

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v3: replace dbg macro with MTDDEBUG
  v2: remove commented-out code

 drivers/mtd/nand/Makefile|2 +
 drivers/mtd/nand/docg4.c | 1028 ++
 drivers/mtd/nand/docg4_spl.c |  222 +
 include/linux/mtd/docg4.h|  134 ++
 4 files changed, 1386 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/docg4.c
 create mode 100644 drivers/mtd/nand/docg4_spl.c
 create mode 100644 include/linux/mtd/docg4.h

diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index c77c0c4..1bcf43c 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -34,6 +34,7 @@ NORMAL_DRIVERS=y
 endif
 
 COBJS-$(CONFIG_SPL_NAND_AM33XX_BCH) += am335x_spl_bch.o
+COBJS-$(CONFIG_SPL_NAND_DOCG4) += docg4_spl.o
 COBJS-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o
 COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o
 COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
@@ -78,6 +79,7 @@ COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o
 COBJS-$(CONFIG_TEGRA_NAND) += tegra_nand.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
 COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
+COBJS-$(CONFIG_NAND_DOCG4) += docg4.o
 
 else  # minimal SPL drivers
 
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
new file mode 100644
index 000..7dd9953
--- /dev/null
+++ b/drivers/mtd/nand/docg4.c
@@ -0,0 +1,1028 @@
+/*
+ * drivers/mtd/nand/docg4.c
+ *
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ * mtd nand driver for M-Systems DiskOnChip G4
+ *
+ * Tested on the Palm Treo 680.  The G4 is also present on Toshiba Portege, 
Asus
+ * P526, some HTC smartphones (Wizard, Prophet, ...), O2 XDA Zinc, maybe 
others.
+ * Should work on these as well.  Let me know!
+ *
+ * TODO:
+ *
+ *  Mechanism for management of password-protected areas
+ *
+ *  Hamming ecc when reading oob only
+ *
+ *  According to the M-Sys documentation, this device is also available in a
+ *  dual-die configuration having a 256MB capacity, but no mechanism for
+ *  detecting this variant is documented.  Currently this driver assumes 128MB
+ *  capacity.
+ *
+ *  Support for multiple cascaded devices (floors).  Not sure which gadgets
+ *  contain multiple G4s in a cascaded configuration, if any.
+ *
+ */
+
+
+#include common.h
+#include asm/arch/hardware.h
+#include asm/io.h
+#include asm/bitops.h
+#include asm/errno.h
+#include malloc.h
+#include nand.h
+#include linux/bch.h
+#include linux/bitrev.h
+#include linux/mtd/docg4.h
+
+/*
+ * The device has a nop register which M-Sys claims is for the purpose of
+ * inserting precise delays.  But beware; at least some operations fail if the
+ * nop writes are replaced with a generic delay!
+ */
+static inline void write_nop(void __iomem *docptr)
+{
+   writew(0, docptr + DOC_NOP);
+}
+
+
+static int poll_status(void __iomem *docptr)
+{
+   /*
+* Busy-wait for the FLASHREADY bit to be set in the FLASHCONTROL
+* register.  Operations known to take a long time (e.g., block erase)
+* should sleep for a while before calling this.
+*/
+
+   uint8_t flash_status;
+
+   /* hardware quirk requires reading twice initially */
+   flash_status = readb(docptr + DOC_FLASHCONTROL);
+
+   do {
+   flash_status = readb(docptr + DOC_FLASHCONTROL);
+   } while (!(flash_status  DOC_CTRL_FLASHREADY));
+
+   return 0;
+}
+
+static void write_addr(void __iomem *docptr, uint32_t docg4_addr)
+{
+   /* write the four address bytes packed in docg4_addr to the device */
+
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, 

Re: [U-Boot] [PATCH v3 6/8] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-12 Thread Scott Wood

On 04/12/2013 01:59:18 PM, Mike Dunn wrote:
This patch adds a driver for the diskonchip G4 nand flash device.  It  
is based

on the driver from the linux kernel.

This also includes a separate SPL driver.  A separate SPL driver is  
used because
the device operates in a different mode (reliable mode) when loading  
a boot
image, and also because the storage format of the boot image is  
different from
normal data (pages are stored redundantly).  The SPL driver basically  
mimics how
a typical IPL reads data from the device.  The special operating mode  
and
storage format are used to compensate for the fact that the IPL does  
not contain
the BCH ecc decoding algorithm (due to size constraints).  Although  
the u-boot
SPL *could* use ecc, it operates like an IPL for the sake of  
simplicity and
uniformity, since the IPL and SPL share the task of loading the  
u-boot image.

As a side benefit, the SPL driver is very small.

[port from linux kernel 3.4 commit  
570469f3bde7f71cc1ece07a18d54a05b6a8775d]


Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v3: replace dbg macro with MTDDEBUG
  v2: remove commented-out code

 drivers/mtd/nand/Makefile|2 +
 drivers/mtd/nand/docg4.c | 1028  
++

 drivers/mtd/nand/docg4_spl.c |  222 +
 include/linux/mtd/docg4.h|  134 ++
 4 files changed, 1386 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/docg4.c
 create mode 100644 drivers/mtd/nand/docg4_spl.c
 create mode 100644 include/linux/mtd/docg4.h


Acked-by: Scott Wood scottw...@freescale.com

-Scott
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot