[PATCH] omap mmc: extended to pass host capabilities from board file

2010-09-15 Thread Sukumar Ghorai
  wires variable is renamed, extended and this single variable to be used to
  pass the platform capabilities, e.g DDR mode. Also removed the hardcoded
  value was using as bus-width.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c  |3 ++-
 arch/arm/mach-omap2/board-3430sdp.c  |5 +++--
 arch/arm/mach-omap2/board-4430sdp.c  |4 ++--
 arch/arm/mach-omap2/board-cm-t35.c   |5 +++--
 arch/arm/mach-omap2/board-devkit8000.c   |3 ++-
 arch/arm/mach-omap2/board-igep0020.c |5 +++--
 arch/arm/mach-omap2/board-ldp.c  |3 ++-
 arch/arm/mach-omap2/board-n8x0.c |2 +-
 arch/arm/mach-omap2/board-omap3beagle.c  |3 ++-
 arch/arm/mach-omap2/board-omap3evm.c |3 ++-
 arch/arm/mach-omap2/board-omap3pandora.c |7 ---
 arch/arm/mach-omap2/board-omap3stalker.c |3 ++-
 arch/arm/mach-omap2/board-omap3touchbook.c   |3 ++-
 arch/arm/mach-omap2/board-omap4panda.c   |2 +-
 arch/arm/mach-omap2/board-overo.c|5 +++--
 arch/arm/mach-omap2/board-rx51-peripherals.c |5 +++--
 arch/arm/mach-omap2/board-zoom-peripherals.c |5 +++--
 arch/arm/mach-omap2/devices.c|   16 +---
 arch/arm/mach-omap2/hsmmc.c  |   16 ++--
 arch/arm/mach-omap2/hsmmc.h  |3 ++-
 arch/arm/plat-omap/include/plat/mmc.h|7 +++
 drivers/mmc/host/omap.c  |2 +-
 drivers/mmc/host/omap_hsmmc.c|   18 ++
 23 files changed, 67 insertions(+), 61 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index 8538e41..fc178a0 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -19,6 +19,7 @@
 #include linux/mtd/mtd.h
 #include linux/mtd/partitions.h
 #include linux/mtd/physmap.h
+#include linux/mmc/host.h
 #include linux/delay.h
 #include linux/i2c/twl.h
 #include linux/err.h
@@ -190,7 +191,7 @@ static int __init omap2430_i2c_init(void)
 static struct omap2_hsmmc_info mmc[] __initdata = {
{
.mmc= 1,
-   .wires  = 4,
+   .caps   = MMC_CAP_4_BIT_DATA,
.gpio_cd= -EINVAL,
.gpio_wp= -EINVAL,
.ext_clock  = 1,
diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 67b95b5..3eb9839 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -24,6 +24,7 @@
 #include linux/regulator/machine.h
 #include linux/io.h
 #include linux/gpio.h
+#include linux/mmc/host.h
 
 #include mach/hardware.h
 #include asm/mach-types.h
@@ -353,12 +354,12 @@ static struct omap2_hsmmc_info mmc[] = {
/* 8 bits (default) requires S6.3 == ON,
 * so the SIM card isn't used; else 4 bits.
 */
-   .wires  = 8,
+   .caps   = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
.gpio_wp= 4,
},
{
.mmc= 2,
-   .wires  = 8,
+   .caps   = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
.gpio_wp= 7,
},
{}  /* Terminator */
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index 9447644..e379bef 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -193,12 +193,12 @@ static struct omap_musb_board_data musb_board_data = {
 static struct omap2_hsmmc_info mmc[] = {
{
.mmc= 1,
-   .wires  = 8,
+   .caps   = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
.gpio_wp= -EINVAL,
},
{
.mmc= 2,
-   .wires  = 8,
+   .caps   =  MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
.gpio_cd= -EINVAL,
.gpio_wp= -EINVAL,
.nonremovable   = true,
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index e10bc10..b72009a 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -31,6 +31,7 @@
 #include linux/i2c/at24.h
 #include linux/i2c/twl.h
 #include linux/regulator/machine.h
+#include linux/mmc/host.h
 
 #include linux/spi/spi.h
 #include linux/spi/tdo24m.h
@@ -579,14 +580,14 @@ static struct twl4030_keypad_data cm_t35_kp_data = {
 static struct omap2_hsmmc_info mmc[] = {
{
.mmc= 1,
-   .wires  = 4,
+   .caps   = MMC_CAP_4_BIT_DATA,
.gpio_cd= -EINVAL,
.gpio_wp= -EINVAL

[PATCH RESEND v4 0/4] nand prefetch-irq support and ecc layout chanage

2010-09-16 Thread Sukumar Ghorai
  The following set of patches applies on linux-2.6.
   
   v4: resend of 
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32689.html
   
   v3: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32071.html
Rebase on latest codebase and previous patch(posted).   
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31963.html

   v2: Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31471.html

   v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg2.html



Sukumar Ghorai (5):
  Merge branches 'master' and 'master' of
git://git.kernel.org/.../torvalds/linux-2.6
  omap3: nand: prefetch in irq mode support
  omap3: nand: configurable fifo threshold to gain the throughput
  omap: nand: ecc layout select from board file
  omap: nand: making ecc layout as compatible with romcode ecc

 arch/arm/mach-omap2/board-flash.c  |5 +-
 arch/arm/mach-omap2/gpmc.c |   15 ++-
 arch/arm/plat-omap/include/plat/gpmc.h |9 +-
 arch/arm/plat-omap/include/plat/irqs.h |1 +
 arch/arm/plat-omap/include/plat/nand.h |7 +
 drivers/mtd/nand/Kconfig   |   14 ++-
 drivers/mtd/nand/omap2.c   |  277 ---
 7 files changed, 294 insertions(+), 34 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND v4 3/4] omap: nand: ecc layout select from board file

2010-09-16 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.  And hw ecc layout selected for
sdp and zoom boards, by default.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |3 ++-
 arch/arm/plat-omap/include/plat/nand.h |6 ++
 drivers/mtd/nand/omap2.c   |   29 +
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 4871d71..5f74c8f 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -144,7 +144,8 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
 {
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
-   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
 
gpmc_nand_init(board_nand_data);
 }
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 5e69463..2e026e4 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -23,6 +23,12 @@ struct omap_nand_platform_data {
int gpmc_irq;
unsigned long   phys_base;
int devsize;
+   enum {
+   OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT = 0,
+   /* 1-bit s/w ecc and layout different from romcode */
+   OMAP_ECC_HAMMING_CODE_HW,/* 1-bit ecc, romcode layout */
+   OMAP_ECC_HAMMING_CODE_SW,/* 1-bit ecc, romcode layout */
+   } ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index d457b9b..dbbd699 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -7,7 +7,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#define CONFIG_MTD_NAND_OMAP_HWECC
 
 #include linux/platform_device.h
 #include linux/dma-mapping.h
@@ -658,8 +657,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -879,8 +876,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
gpmc_enable_hwecc(info-gpmc_cs, mode, dev_width, info-nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
@@ -1059,17 +1054,19 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
-
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* selsect the ecc type */
+   if ((pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT) ||
+   (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW)) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
+
+   } else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_SW) {
+   info-nand.ecc.mode = NAND_ECC_SOFT;
+   }
 
/* DIP switches on some boards change between 8 and 16 bit
 * bus widths for flash.  Try the other width if the first try fails.
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND v4 2/4] omap3: nand: configurable fifo threshold to gain the throughput

2010-09-16 Thread Sukumar Ghorai
  Configure the FIFO THREASHOLD value different for read and write to keep busy
  both filling and to drain out of FIFO at reading and writing.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   11 +++
 arch/arm/plat-omap/include/plat/gpmc.h |5 -
 drivers/mtd/nand/omap2.c   |   24 +++-
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 86a6f78..8871a91 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -58,7 +58,6 @@
 #define GPMC_CHUNK_SHIFT   24  /* 16 MB */
 #define GPMC_SECTION_SHIFT 28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
 #define CS_NUM_SHIFT   24
 #define ENABLE_PREFETCH(0x1  7)
 #define DMA_MPU_MODE   2
@@ -592,15 +591,19 @@ EXPORT_SYMBOL(gpmc_nand_write);
 /**
  * gpmc_prefetch_enable - configures and starts prefetch transfer
  * @cs: cs (chip select) number
+ * @fifo_th: fifo threshold to be used for read/ write
  * @dma_mode: dma mode enable (1) or disable (0)
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   printk(KERN_ERR PREFETCH Fifo Threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -608,7 +611,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write)));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 054e704..fb82335 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -83,6 +83,9 @@
 #define GPMC_IRQ_FIFOEVENTENABLE   0x01
 #define GPMC_IRQ_COUNT_EVENT   0x02
 
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)(val  8)
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
@@ -133,7 +136,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index d834740..d457b9b 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -275,7 +275,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -319,7 +320,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -373,10 +375,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
dma_addr_t dma_addr;
int ret;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get a sync at each frame

[PATCH RESEND v4 4/4] omap: nand: making ecc layout as compatible with romcode ecc

2010-09-16 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-loader, u-boot and kernel.

This patch also enables to use romcode ecc for spd and zoom, by default.

This enables to flash x-loader, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/board-flash.c |2 +-
 drivers/mtd/nand/omap2.c  |   34 ++
 2 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 5f74c8f..d71c511 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -145,7 +145,7 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
board_nand_data.nr_parts= nr_parts;
-   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_HW;
 
gpmc_nand_init(board_nand_data);
 }
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index dbbd699..33c356b 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -128,6 +128,20 @@ const int use_dma;
 const int use_interrupt;
 #endif
 
+/* oob info generated runtime depending on ecc algorithm and layout selected */
+static struct nand_ecclayout omap_oobinfo;
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -945,6 +959,7 @@ static int __devinit omap_nand_probe(struct platform_device 
*pdev)
struct omap_nand_info   *info;
struct omap_nand_platform_data  *pdata;
int err;
+   int i, offset;
 
pdata = pdev-dev.platform_data;
if (pdata == NULL) {
@@ -1079,6 +1094,25 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
}
 
+   /* rom code layout */
+   if (pdata-ecc_opt != OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT) {
+   offset = (info-nand.options  NAND_BUSWIDTH_16) ? 2 : 1;
+   if (info-mtd.oobsize == 16) {
+   info-nand.badblock_pattern = bb_descrip_flashbased;
+   omap_oobinfo.eccbytes = 3;
+   } else
+   omap_oobinfo.eccbytes  = 3 * 4;
+
+   for (i = 0; i  omap_oobinfo.eccbytes; i++)
+   omap_oobinfo.eccpos[i] = i+offset;
+
+   omap_oobinfo.oobfree-offset = offset + omap_oobinfo.eccbytes;
+   omap_oobinfo.oobfree-length = info-mtd.oobsize -
+   (offset + omap_oobinfo.eccbytes);
+
+   info-nand.ecc.layout = omap_oobinfo;
+   }
+
 #ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(info-mtd, part_probes, info-parts, 0);
if (err  0)
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND v4 1/4] omap3: nand: prefetch in irq mode support

2010-09-16 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for NAND.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |2 +
 arch/arm/mach-omap2/gpmc.c |4 +
 arch/arm/plat-omap/include/plat/gpmc.h |4 +
 arch/arm/plat-omap/include/plat/irqs.h |1 +
 arch/arm/plat-omap/include/plat/nand.h |1 +
 drivers/mtd/nand/Kconfig   |   14 ++-
 drivers/mtd/nand/omap2.c   |  198 +++-
 7 files changed, 217 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index ac834aa..4871d71 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -17,6 +17,7 @@
 #include linux/mtd/physmap.h
 #include linux/io.h
 
+#include plat/irqs.h
 #include plat/gpmc.h
 #include plat/nand.h
 #include plat/onenand.h
@@ -133,6 +134,7 @@ static struct omap_nand_platform_data board_nand_data = {
.nand_setup = NULL,
.gpmc_t = nand_timings,
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
+   .gpmc_irq   = INT_34XX_GPMC_IRQ,
.dev_ready  = NULL,
.devsize= 0,/* '0' for 8-bit, '1' for 16-bit device */
 };
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index f46933b..86a6f78 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -487,6 +487,10 @@ int gpmc_cs_configure(int cs, int cmd, int wval)
u32 regval = 0;
 
switch (cmd) {
+   case GPMC_ENABLE_IRQ:
+   gpmc_write_reg(GPMC_IRQENABLE, wval);
+   break;
+
case GPMC_SET_IRQ_STATUS:
gpmc_write_reg(GPMC_IRQSTATUS, wval);
break;
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 9fd99b9..054e704 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -41,6 +41,8 @@
 #define GPMC_NAND_ADDRESS  0x000b
 #define GPMC_NAND_DATA 0x000c
 
+#define GPMC_ENABLE_IRQ0x000d
+
 /* ECC commands */
 #define GPMC_ECC_READ  0 /* Reset Hardware ECC for read */
 #define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */
@@ -78,6 +80,8 @@
 #define WR_RD_PIN_MONITORING   0x0060
 #define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val  24)  0x7F)
 #define GPMC_PREFETCH_STATUS_COUNT(val)(val  0x3fff)
+#define GPMC_IRQ_FIFOEVENTENABLE   0x01
+#define GPMC_IRQ_COUNT_EVENT   0x02
 
 /*
  * Note that all values in this struct are in nanoseconds, while
diff --git a/arch/arm/plat-omap/include/plat/irqs.h 
b/arch/arm/plat-omap/include/plat/irqs.h
index c01d9f0..fd6d677 100644
--- a/arch/arm/plat-omap/include/plat/irqs.h
+++ b/arch/arm/plat-omap/include/plat/irqs.h
@@ -318,6 +318,7 @@
 #define INT_34XX_PRCM_MPU_IRQ  11
 #define INT_34XX_MCBSP1_IRQ16
 #define INT_34XX_MCBSP2_IRQ17
+#define INT_34XX_GPMC_IRQ  20
 #define INT_34XX_MCBSP3_IRQ22
 #define INT_34XX_MCBSP4_IRQ23
 #define INT_34XX_CAM_IRQ   24
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd0..5e69463 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -20,6 +20,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
unsigned long   phys_base;
int devsize;
 };
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8b4b67c..88cea0c 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -112,6 +112,9 @@ config MTD_NAND_OMAP_PREFETCH
help
 The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
 to improve the performance.
+GPMC PREFETCH can be configured eigther in MPU interrupt mode or in DMA
+interrupt mode. If not selected any of them prefetch will be used in
+polling mode.
 
 config MTD_NAND_OMAP_PREFETCH_DMA
depends on MTD_NAND_OMAP_PREFETCH
@@ -120,7 +123,16 @@ config MTD_NAND_OMAP_PREFETCH_DMA
help
 The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
 or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
+Say y for DMA mode
+
+config MTD_NAND_OMAP_PREFETCH_IRQ
+   depends on MTD_NAND_OMAP_PREFETCH  !MTD_NAND_OMAP_PREFETCH_DMA
+   bool IRQ mode
+   default n
+   help
+The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
+or in DMA interrupt mode.
+Say y for IRQ mode
 
 config MTD_NAND_IDS
tristate
diff --git a/drivers

[PATCH v5 0/5] nand prefetch-irq support and ecc layout chanage

2010-09-27 Thread Sukumar Ghorai
  The following set of patches applies on linux-2.6.
 
The main motivations behind this patch series are -
1. support NAND I/O in irq mode.
2. support of different ECC schema. 
3. also to make ecc layout as like in romcode ecc layout

   v5: This address the input as to support the irq_chained in GPMC 

   v4: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg34882.html
   and resend of 
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32689.html
   
   v3: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32071.html
Rebase on latest codebase and previous patch(posted).   
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31963.html

   v2: Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31471.html

   v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg2.html



Sukumar Ghorai (5):
  omap gpmc: enable irq mode in gpmc
  omap3: nand: prefetch in irq mode support
  omap3: nand: configurable fifo threshold to gain the throughput
  omap: nand: ecc layout select from board file
  omap: nand: making ecc layout as compatible with romcode ecc

 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-flash.c  |5 +-
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |2 +
 arch/arm/mach-omap2/board-zoom3.c  |2 +
 arch/arm/mach-omap2/gpmc.c |   48 +-
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |   16 ++-
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 arch/arm/plat-omap/include/plat/nand.h |3 +
 drivers/mtd/nand/Kconfig   |   14 ++-
 drivers/mtd/nand/omap2.c   |  277 +---
 31 files changed, 367 insertions(+), 39 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 1/5] omap gpmc: enable irq mode in gpmc

2010-09-27 Thread Sukumar Ghorai
  add support the irq mode in GPMC.
  gpmc_init() function move after omap_init_irq() as it has dependecy on irq.

 Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |2 +
 arch/arm/mach-omap2/board-zoom3.c  |2 +
 arch/arm/mach-omap2/gpmc.c |   37 ++-
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |4 +++
 arch/arm/plat-omap/include/plat/irqs.h |9 ++-
 27 files changed, 79 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index 8538e41..a047a35 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -144,6 +144,7 @@ static void __init omap_2430sdp_init_irq(void)
omap_board_config_size = ARRAY_SIZE(sdp2430_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 67b95b5..549cd62 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -328,6 +328,7 @@ static void __init omap_3430sdp_init_irq(void)
omap3_pm_init_cpuidle(omap3_cpuidle_params_table);
omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index b359c3f..19cb423 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -76,6 +76,7 @@ static void __init omap_sdp_init_irq(void)
omap2_init_common_hw(h8mbx00u0mer0em_sdrc_params,
h8mbx00u0mer0em_sdrc_params);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index 9447644..5fc66eb 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -35,6 +35,7 @@
 #include plat/timer-gp.h
 #include plat/usb.h
 #include plat/mmc.h
+#include plat/gpmc.h
 #include hsmmc.h
 
 #define ETH_KS8851_IRQ 34
@@ -181,6 +182,7 @@ static void __init omap_4430sdp_init_irq(void)
omap2_gp_clockevent_set_gptimer(1);
 #endif
gic_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index 4d0f585..3a12571 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -35,6 +35,7 @@
 #include plat/control.h
 #include plat/usb.h
 #include plat/display.h
+#include plat/gpmc.h
 
 #include mux.h
 
@@ -372,6 +373,7 @@ static void __init am3517_evm_init_irq(void)
 
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index c6421a7..10fe693 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -280,6 +280,7 @@ static void __init omap_apollon_init_irq(void)
omap_board_config_size = ARRAY_SIZE(apollon_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
apollon_init_smc91x();
 }
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index e10bc10..8c32e34 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -687,6 +687,7 @@ static void __init cm_t35_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
 mt46h32m32lf6_sdrc_params

[PATCH v5 3/5] omap3: nand: configurable fifo threshold to gain the throughput

2010-09-27 Thread Sukumar Ghorai
  Configure the FIFO THREASHOLD value different for read and write to keep busy
  both filling and to drain out of FIFO at reading and writing.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   11 +++
 arch/arm/plat-omap/include/plat/gpmc.h |5 -
 drivers/mtd/nand/omap2.c   |   24 +++-
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 9ecb2a7..10ce5d5 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -59,7 +59,6 @@
 #define GPMC_CHUNK_SHIFT   24  /* 16 MB */
 #define GPMC_SECTION_SHIFT 28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
 #define CS_NUM_SHIFT   24
 #define ENABLE_PREFETCH(0x1  7)
 #define DMA_MPU_MODE   2
@@ -595,15 +594,19 @@ EXPORT_SYMBOL(gpmc_nand_write);
 /**
  * gpmc_prefetch_enable - configures and starts prefetch transfer
  * @cs: cs (chip select) number
+ * @fifo_th: fifo threshold to be used for read/ write
  * @dma_mode: dma mode enable (1) or disable (0)
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   printk(KERN_ERR PREFETCH Fifo Threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -611,7 +614,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write)));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 054e704..fb82335 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -83,6 +83,9 @@
 #define GPMC_IRQ_FIFOEVENTENABLE   0x01
 #define GPMC_IRQ_COUNT_EVENT   0x02
 
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)(val  8)
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
@@ -133,7 +136,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 72994e8..5ac7f7c 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -275,7 +275,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -319,7 +320,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -373,10 +375,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
dma_addr_t dma_addr;
int ret;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get a sync at each frame

[PATCH v5 5/5] omap: nand: making ecc layout as compatible with romcode ecc

2010-09-27 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-loader, u-boot and kernel.

This patch also enables to use romcode ecc for spd and zoom, by default.

This enables to flash x-loader, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 drivers/mtd/nand/omap2.c |   34 ++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 3fd9ee0..9ccfd88 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -128,6 +128,20 @@ const int use_dma;
 const int use_interrupt;
 #endif
 
+/* oob info generated runtime depending on ecc algorithm and layout selected */
+static struct nand_ecclayout omap_oobinfo;
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -946,6 +960,7 @@ static int __devinit omap_nand_probe(struct platform_device 
*pdev)
struct omap_nand_info   *info;
struct omap_nand_platform_data  *pdata;
int err;
+   int i, offset;
 
pdata = pdev-dev.platform_data;
if (pdata == NULL) {
@@ -1079,6 +1094,25 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
}
 
+   /* rom code layout */
+   if (pdata-ecc_opt != OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT) {
+   offset = (info-nand.options  NAND_BUSWIDTH_16) ? 2 : 1;
+   if (info-mtd.oobsize == 16) {
+   info-nand.badblock_pattern = bb_descrip_flashbased;
+   omap_oobinfo.eccbytes = 3;
+   } else
+   omap_oobinfo.eccbytes  = 3 * 4;
+
+   for (i = 0; i  omap_oobinfo.eccbytes; i++)
+   omap_oobinfo.eccpos[i] = i+offset;
+
+   omap_oobinfo.oobfree-offset = offset + omap_oobinfo.eccbytes;
+   omap_oobinfo.oobfree-length = info-mtd.oobsize -
+   (offset + omap_oobinfo.eccbytes);
+
+   info-nand.ecc.layout = omap_oobinfo;
+   }
+
 #ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(info-mtd, part_probes, info-parts, 0);
if (err  0)
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 2/5] omap3: nand: prefetch in irq mode support

2010-09-27 Thread Sukumar Ghorai
 This patch enable prefetch-irq mode for NAND.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |4 +-
 arch/arm/plat-omap/include/plat/nand.h |1 +
 drivers/mtd/nand/Kconfig   |   14 ++-
 drivers/mtd/nand/omap2.c   |  196 +++-
 4 files changed, 208 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index ac834aa..2355e4a 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -17,6 +17,7 @@
 #include linux/mtd/physmap.h
 #include linux/io.h
 
+#include plat/irqs.h
 #include plat/gpmc.h
 #include plat/nand.h
 #include plat/onenand.h
@@ -142,8 +143,9 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
 {
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
-   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.nr_parts= nr_parts;
 
+   board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
 #else
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd0..5e69463 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -20,6 +20,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
unsigned long   phys_base;
int devsize;
 };
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8b4b67c..88cea0c 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -112,6 +112,9 @@ config MTD_NAND_OMAP_PREFETCH
help
 The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
 to improve the performance.
+GPMC PREFETCH can be configured eigther in MPU interrupt mode or in DMA
+interrupt mode. If not selected any of them prefetch will be used in
+polling mode.
 
 config MTD_NAND_OMAP_PREFETCH_DMA
depends on MTD_NAND_OMAP_PREFETCH
@@ -120,7 +123,16 @@ config MTD_NAND_OMAP_PREFETCH_DMA
help
 The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
 or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
+Say y for DMA mode
+
+config MTD_NAND_OMAP_PREFETCH_IRQ
+   depends on MTD_NAND_OMAP_PREFETCH  !MTD_NAND_OMAP_PREFETCH_DMA
+   bool IRQ mode
+   default n
+   help
+The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
+or in DMA interrupt mode.
+Say y for IRQ mode
 
 config MTD_NAND_IDS
tristate
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 133d515..72994e8 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -12,6 +12,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -105,17 +106,27 @@ module_param(use_prefetch, bool, 0);
 MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
 
 #ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
+const int use_interrupt;
 static int use_dma = 1;
 
 /* modprobe ... use_dma=0 etc */
 module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
+MODULE_PARM_DESC(use_dma, enable/disable use of DMA mode);
+#elif defined(CONFIG_MTD_NAND_OMAP_PREFETCH_IRQ)
+const int use_dma;
+static int use_interrupt = 1;
+
+/* modprobe ... use_dma=0 etc */
+module_param(use_interrupt, bool, 0);
+MODULE_PARM_DESC(use_interrupt, enable/disable use of IRQ mode);
 #else
 const int use_dma;
+const int use_interrupt;
 #endif
 #else
 const int use_prefetch;
 const int use_dma;
+const int use_interrupt;
 #endif
 
 struct omap_nand_info {
@@ -130,6 +141,13 @@ struct omap_nand_info {
unsigned long   phys_base;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   enum {
+   OMAP_NAND_IO_READ = 0,  /* read */
+   OMAP_NAND_IO_WRITE, /* write */
+   } iomode;
+   u_char  *buf;
+   int buf_len;
 };
 
 /**
@@ -467,6 +485,153 @@ static void omap_write_buf_dma_pref(struct mtd_info *mtd,
omap_nand_dma_transfer(mtd, (u_char *) buf, len, 0x1);
 }
 
+/*
+ * omap_nand_irq - GMPC irq handler
+ * @this_irq: gpmc irq number
+ * @dev: omap_nand_info structure pointer is passed here
+ */
+static irqreturn_t omap_nand_irq

[PATCH v5 4/5] omap: nand: ecc layout select from board file

2010-09-27 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.  And hw ecc layout selected for
sdp and zoom boards, by default.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |1 +
 arch/arm/plat-omap/include/plat/gpmc.h |7 +++
 arch/arm/plat-omap/include/plat/nand.h |2 ++
 drivers/mtd/nand/omap2.c   |   29 +
 4 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 2355e4a..ecd41ae 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -144,6 +144,7 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
board_nand_data.nr_parts= nr_parts;
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
 
board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index fb82335..54902d8 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -86,6 +86,13 @@
 #define PREFETCH_FIFOTHRESHOLD_MAX 0x40
 #define PREFETCH_FIFOTHRESHOLD(val)(val  8)
 
+enum omap_ecc{
+   OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT = 0,
+   /* 1-bit s/w ecc and layout different from romcode */
+   OMAP_ECC_HAMMING_CODE_HW,/* 1-bit ecc, romcode layout */
+   OMAP_ECC_HAMMING_CODE_SW,/* 1-bit ecc, romcode layout */
+};
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 5e69463..d5b6fc6 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include plat/gpmc.h
 #include linux/mtd/partitions.h
 
 struct omap_nand_platform_data {
@@ -23,6 +24,7 @@ struct omap_nand_platform_data {
int gpmc_irq;
unsigned long   phys_base;
int devsize;
+   enum omap_ecc   ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 5ac7f7c..3fd9ee0 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -7,7 +7,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#define CONFIG_MTD_NAND_OMAP_HWECC
 
 #include linux/platform_device.h
 #include linux/dma-mapping.h
@@ -659,8 +658,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -880,8 +877,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
gpmc_enable_hwecc(info-gpmc_cs, mode, dev_width, info-nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
@@ -1059,17 +1054,19 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
-
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* selsect the ecc type */
+   if ((pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT) ||
+   (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW)) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
+
+   } else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_SW) {
+   info-nand.ecc.mode = NAND_ECC_SOFT;
+   }
 
/* DIP switches on some boards change between 8 and 16 bit
 * bus widths for flash.  Try the other width if the first try fails.
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More

[PATCH RESEND v5 0/5] nand prefetch-irq support and ecc layout chanage

2010-09-27 Thread Sukumar Ghorai
The following set of patches applies on linux-2.6.
 
The main motivations behind this patch series are -
1. support NAND I/O in irq mode.
2. support of different ECC schema. 
3. also to make ecc layout as like in romcode ecc layout

v5: This address the input as to support the irq_chained in GPMC.
And resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35848.html

v4: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg34882.html
and resend of 
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32689.html

v3: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32071.html
Rebase on latest codebase and previous patch(posted).   
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31963.html

v2: Rebase on latest codebase and previous patch(posted).   
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31471.html

v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg2.html

Sukumar Ghorai (5):
  omap gpmc: enable irq mode in gpmc
  omap3: nand: prefetch in irq mode support
  omap3: nand: configurable fifo threshold to gain the throughput
  omap: nand: ecc layout select from board file
  omap: nand: making ecc layout as compatible with romcode ecc

 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-flash.c  |5 +-
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |2 +
 arch/arm/mach-omap2/board-zoom3.c  |2 +
 arch/arm/mach-omap2/gpmc.c |   48 +-
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |   16 ++-
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 arch/arm/plat-omap/include/plat/nand.h |3 +
 drivers/mtd/nand/Kconfig   |   14 ++-
 drivers/mtd/nand/omap2.c   |  277 +---
 31 files changed, 367 insertions(+), 39 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND v5 3/5] omap3: nand: configurable fifo threshold to gain the throughput

2010-09-27 Thread Sukumar Ghorai
Configure the FIFO THREASHOLD value different for read and write to keep busy
both filling and to drain out of FIFO at reading and writing.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   11 +++
 arch/arm/plat-omap/include/plat/gpmc.h |5 -
 drivers/mtd/nand/omap2.c   |   24 +++-
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 9ecb2a7..10ce5d5 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -59,7 +59,6 @@
 #define GPMC_CHUNK_SHIFT   24  /* 16 MB */
 #define GPMC_SECTION_SHIFT 28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
 #define CS_NUM_SHIFT   24
 #define ENABLE_PREFETCH(0x1  7)
 #define DMA_MPU_MODE   2
@@ -595,15 +594,19 @@ EXPORT_SYMBOL(gpmc_nand_write);
 /**
  * gpmc_prefetch_enable - configures and starts prefetch transfer
  * @cs: cs (chip select) number
+ * @fifo_th: fifo threshold to be used for read/ write
  * @dma_mode: dma mode enable (1) or disable (0)
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   printk(KERN_ERR PREFETCH Fifo Threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -611,7 +614,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write)));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 054e704..fb82335 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -83,6 +83,9 @@
 #define GPMC_IRQ_FIFOEVENTENABLE   0x01
 #define GPMC_IRQ_COUNT_EVENT   0x02
 
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)(val  8)
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
@@ -133,7 +136,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 72994e8..5ac7f7c 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -275,7 +275,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -319,7 +320,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -373,10 +375,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
dma_addr_t dma_addr;
int ret;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get a sync at each frame

[PATCH RESEND v5 4/5] omap: nand: ecc layout select from board file

2010-09-27 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.  And hw ecc layout selected for
sdp and zoom boards, by default.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |1 +
 arch/arm/plat-omap/include/plat/gpmc.h |7 +++
 arch/arm/plat-omap/include/plat/nand.h |2 ++
 drivers/mtd/nand/omap2.c   |   29 +
 4 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 2355e4a..ecd41ae 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -144,6 +144,7 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
board_nand_data.nr_parts= nr_parts;
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
 
board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index fb82335..54902d8 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -86,6 +86,13 @@
 #define PREFETCH_FIFOTHRESHOLD_MAX 0x40
 #define PREFETCH_FIFOTHRESHOLD(val)(val  8)
 
+enum omap_ecc{
+   OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT = 0,
+   /* 1-bit s/w ecc and layout different from romcode */
+   OMAP_ECC_HAMMING_CODE_HW,/* 1-bit ecc, romcode layout */
+   OMAP_ECC_HAMMING_CODE_SW,/* 1-bit ecc, romcode layout */
+};
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 5e69463..d5b6fc6 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include plat/gpmc.h
 #include linux/mtd/partitions.h
 
 struct omap_nand_platform_data {
@@ -23,6 +24,7 @@ struct omap_nand_platform_data {
int gpmc_irq;
unsigned long   phys_base;
int devsize;
+   enum omap_ecc   ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 5ac7f7c..3fd9ee0 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -7,7 +7,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#define CONFIG_MTD_NAND_OMAP_HWECC
 
 #include linux/platform_device.h
 #include linux/dma-mapping.h
@@ -659,8 +658,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -880,8 +877,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
gpmc_enable_hwecc(info-gpmc_cs, mode, dev_width, info-nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
@@ -1059,17 +1054,19 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
-
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* selsect the ecc type */
+   if ((pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT) ||
+   (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW)) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
+
+   } else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_SW) {
+   info-nand.ecc.mode = NAND_ECC_SOFT;
+   }
 
/* DIP switches on some boards change between 8 and 16 bit
 * bus widths for flash.  Try the other width if the first try fails.
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo

[PATCH RESEND v5 2/5] omap3: nand: prefetch in irq mode support

2010-09-27 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for NAND.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |4 +-
 arch/arm/plat-omap/include/plat/nand.h |1 +
 drivers/mtd/nand/Kconfig   |   14 ++-
 drivers/mtd/nand/omap2.c   |  196 +++-
 4 files changed, 208 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index ac834aa..2355e4a 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -17,6 +17,7 @@
 #include linux/mtd/physmap.h
 #include linux/io.h
 
+#include plat/irqs.h
 #include plat/gpmc.h
 #include plat/nand.h
 #include plat/onenand.h
@@ -142,8 +143,9 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
 {
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
-   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.nr_parts= nr_parts;
 
+   board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
 #else
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd0..5e69463 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -20,6 +20,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
unsigned long   phys_base;
int devsize;
 };
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8b4b67c..88cea0c 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -112,6 +112,9 @@ config MTD_NAND_OMAP_PREFETCH
help
 The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
 to improve the performance.
+GPMC PREFETCH can be configured eigther in MPU interrupt mode or in DMA
+interrupt mode. If not selected any of them prefetch will be used in
+polling mode.
 
 config MTD_NAND_OMAP_PREFETCH_DMA
depends on MTD_NAND_OMAP_PREFETCH
@@ -120,7 +123,16 @@ config MTD_NAND_OMAP_PREFETCH_DMA
help
 The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
 or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
+Say y for DMA mode
+
+config MTD_NAND_OMAP_PREFETCH_IRQ
+   depends on MTD_NAND_OMAP_PREFETCH  !MTD_NAND_OMAP_PREFETCH_DMA
+   bool IRQ mode
+   default n
+   help
+The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
+or in DMA interrupt mode.
+Say y for IRQ mode
 
 config MTD_NAND_IDS
tristate
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 133d515..72994e8 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -12,6 +12,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -105,17 +106,27 @@ module_param(use_prefetch, bool, 0);
 MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
 
 #ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
+const int use_interrupt;
 static int use_dma = 1;
 
 /* modprobe ... use_dma=0 etc */
 module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
+MODULE_PARM_DESC(use_dma, enable/disable use of DMA mode);
+#elif defined(CONFIG_MTD_NAND_OMAP_PREFETCH_IRQ)
+const int use_dma;
+static int use_interrupt = 1;
+
+/* modprobe ... use_dma=0 etc */
+module_param(use_interrupt, bool, 0);
+MODULE_PARM_DESC(use_interrupt, enable/disable use of IRQ mode);
 #else
 const int use_dma;
+const int use_interrupt;
 #endif
 #else
 const int use_prefetch;
 const int use_dma;
+const int use_interrupt;
 #endif
 
 struct omap_nand_info {
@@ -130,6 +141,13 @@ struct omap_nand_info {
unsigned long   phys_base;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   enum {
+   OMAP_NAND_IO_READ = 0,  /* read */
+   OMAP_NAND_IO_WRITE, /* write */
+   } iomode;
+   u_char  *buf;
+   int buf_len;
 };
 
 /**
@@ -467,6 +485,153 @@ static void omap_write_buf_dma_pref(struct mtd_info *mtd,
omap_nand_dma_transfer(mtd, (u_char *) buf, len, 0x1);
 }
 
+/*
+ * omap_nand_irq - GMPC irq handler
+ * @this_irq: gpmc irq number
+ * @dev: omap_nand_info structure pointer is passed here
+ */
+static irqreturn_t omap_nand_irq

[PATCH RESEND v5 5/5] omap: nand: making ecc layout as compatible with romcode ecc

2010-09-27 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-loader, u-boot and kernel.

This patch also enables to use romcode ecc for spd and zoom, by default.

This enables to flash x-loader, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 drivers/mtd/nand/omap2.c |   34 ++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 3fd9ee0..9ccfd88 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -128,6 +128,20 @@ const int use_dma;
 const int use_interrupt;
 #endif
 
+/* oob info generated runtime depending on ecc algorithm and layout selected */
+static struct nand_ecclayout omap_oobinfo;
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -946,6 +960,7 @@ static int __devinit omap_nand_probe(struct platform_device 
*pdev)
struct omap_nand_info   *info;
struct omap_nand_platform_data  *pdata;
int err;
+   int i, offset;
 
pdata = pdev-dev.platform_data;
if (pdata == NULL) {
@@ -1079,6 +1094,25 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
}
 
+   /* rom code layout */
+   if (pdata-ecc_opt != OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT) {
+   offset = (info-nand.options  NAND_BUSWIDTH_16) ? 2 : 1;
+   if (info-mtd.oobsize == 16) {
+   info-nand.badblock_pattern = bb_descrip_flashbased;
+   omap_oobinfo.eccbytes = 3;
+   } else
+   omap_oobinfo.eccbytes  = 3 * 4;
+
+   for (i = 0; i  omap_oobinfo.eccbytes; i++)
+   omap_oobinfo.eccpos[i] = i+offset;
+
+   omap_oobinfo.oobfree-offset = offset + omap_oobinfo.eccbytes;
+   omap_oobinfo.oobfree-length = info-mtd.oobsize -
+   (offset + omap_oobinfo.eccbytes);
+
+   info-nand.ecc.layout = omap_oobinfo;
+   }
+
 #ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(info-mtd, part_probes, info-parts, 0);
if (err  0)
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND v5 1/5] omap gpmc: enable irq mode in gpmc

2010-09-27 Thread Sukumar Ghorai
add support the irq mode in GPMC.
gpmc_init() function move after omap_init_irq() as it has dependecy on irq.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |2 +
 arch/arm/mach-omap2/board-zoom3.c  |2 +
 arch/arm/mach-omap2/gpmc.c |   37 ++-
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |4 +++
 arch/arm/plat-omap/include/plat/irqs.h |9 ++-
 27 files changed, 79 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index 8538e41..a047a35 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -144,6 +144,7 @@ static void __init omap_2430sdp_init_irq(void)
omap_board_config_size = ARRAY_SIZE(sdp2430_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 67b95b5..549cd62 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -328,6 +328,7 @@ static void __init omap_3430sdp_init_irq(void)
omap3_pm_init_cpuidle(omap3_cpuidle_params_table);
omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index b359c3f..19cb423 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -76,6 +76,7 @@ static void __init omap_sdp_init_irq(void)
omap2_init_common_hw(h8mbx00u0mer0em_sdrc_params,
h8mbx00u0mer0em_sdrc_params);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index 9447644..5fc66eb 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -35,6 +35,7 @@
 #include plat/timer-gp.h
 #include plat/usb.h
 #include plat/mmc.h
+#include plat/gpmc.h
 #include hsmmc.h
 
 #define ETH_KS8851_IRQ 34
@@ -181,6 +182,7 @@ static void __init omap_4430sdp_init_irq(void)
omap2_gp_clockevent_set_gptimer(1);
 #endif
gic_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index 4d0f585..3a12571 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -35,6 +35,7 @@
 #include plat/control.h
 #include plat/usb.h
 #include plat/display.h
+#include plat/gpmc.h
 
 #include mux.h
 
@@ -372,6 +373,7 @@ static void __init am3517_evm_init_irq(void)
 
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index c6421a7..10fe693 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -280,6 +280,7 @@ static void __init omap_apollon_init_irq(void)
omap_board_config_size = ARRAY_SIZE(apollon_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
apollon_init_smc91x();
 }
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index e10bc10..8c32e34 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -687,6 +687,7 @@ static void __init cm_t35_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
 mt46h32m32lf6_sdrc_params

[PATCH] omap: nand: remove hardware ECC as default

2010-11-18 Thread Sukumar Ghorai
CONFIG_MTD_NAND_OMAP_HWECC defined wronly in patch submitted during 2.6.36
that using the hardware ECC by default

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 drivers/mtd/nand/omap2.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index cd41c58..15682ec 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -7,7 +7,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#define CONFIG_MTD_NAND_OMAP_HWECC
 
 #include linux/platform_device.h
 #include linux/dma-mapping.h
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2] omap: nand: remove hardware ECC as default

2010-11-19 Thread Sukumar Ghorai
CONFIG_MTD_NAND_OMAP_HWECC defined wrongly in patch submitted for 2.6.36.
This flag enables hw ecc by default. Boards like beagle and pandora uses
sw ecc for write (e.g. binary flushed from u-boot) and read from kernel.
https://patchwork.kernel.org/patch/111036/

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 drivers/mtd/nand/omap2.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index cd41c58..15682ec 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -7,7 +7,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#define CONFIG_MTD_NAND_OMAP_HWECC
 
 #include linux/platform_device.h
 #include linux/dma-mapping.h
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/7] omap3630: nand: fix device size to work in polled mode

2010-11-26 Thread Sukumar Ghorai
zoom3 and 3630-sdp having the x16 nand device.
This patch configure gpmc as x16 and select the currect function in driver
for polled mode (without prefetch enable) transfer.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index fd38c05..001c605 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -145,6 +145,9 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
board_nand_data.parts   = nand_parts;
board_nand_data.nr_parts= nr_parts;
 
+   if (cpu_is_omap3630())
+   board_nand_data.devsize = 1;
+
gpmc_nand_init(board_nand_data);
 }
 #else
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] omap3: nand: configurable transfer type per board

2010-11-26 Thread Sukumar Ghorai
nand transfer type (sDMA, Polled, prefetch) can be select from board file,
enabling all transfer type in driver, by default.

this helps in multi-omap build and to select different transfer type for
different board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/nand.h |7 +++
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |   92 +++
 3 files changed, 40 insertions(+), 76 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd0..78c0bdb 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -10,6 +10,12 @@
 
 #include linux/mtd/partitions.h
 
+enum nand_io {
+   NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
+   NAND_OMAP_POLLED,   /* polled mode, without prefetch */
+   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+};
+
 struct omap_nand_platform_data {
unsigned intoptions;
int cs;
@@ -20,6 +26,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
 };
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8229802..89bb297 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -105,23 +105,6 @@ config MTD_NAND_OMAP2
help
   Support for NAND flash on Texas Instruments OMAP2 and OMAP3 
platforms.
 
-config MTD_NAND_OMAP_PREFETCH
-   bool GPMC prefetch support for NAND Flash device
-   depends on MTD_NAND_OMAP2
-   default y
-   help
-The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
-to improve the performance.
-
-config MTD_NAND_OMAP_PREFETCH_DMA
-   depends on MTD_NAND_OMAP_PREFETCH
-   bool DMA mode
-   default n
-   help
-The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
-or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
-
 config MTD_NAND_IDS
tristate
 
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 15682ec..6011e90 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -96,27 +96,6 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH
-static int use_prefetch = 1;
-
-/* modprobe ... use_prefetch=0 etc */
-module_param(use_prefetch, bool, 0);
-MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
-
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
-static int use_dma = 1;
-
-/* modprobe ... use_dma=0 etc */
-module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
-#else
-static const int use_dma;
-#endif
-#else
-const int use_prefetch;
-static const int use_dma;
-#endif
-
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -324,7 +303,6 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
 /*
  * omap_nand_dma_cb: callback on the completion of dma transfer
  * @lch: logical channel
@@ -426,14 +404,6 @@ out_copy:
: omap_write_buf8(mtd, (u_char *) addr, len);
return 0;
 }
-#else
-static void omap_nand_dma_cb(int lch, u16 ch_status, void *data) {}
-static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
-   unsigned int len, int is_write)
-{
-   return 0;
-}
-#endif
 
 /**
  * omap_read_buf_dma_pref - read data from NAND controller into buffer
@@ -842,28 +812,13 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
info-nand.chip_delay = 50;
}
 
-   if (use_prefetch) {
-
+   switch (pdata-xfer_type) {
+   case NAND_OMAP_PREFETCH_POLLED:
info-nand.read_buf   = omap_read_buf_pref;
info-nand.write_buf  = omap_write_buf_pref;
-   if (use_dma) {
-   err = omap_request_dma(OMAP24XX_DMA_GPMC, NAND,
-   omap_nand_dma_cb, info-comp, info-dma_ch);
-   if (err  0) {
-   info-dma_ch = -1;
-   printk(KERN_WARNING DMA request failed.
-Non-dma data transfer mode\n);
-   } else {
-   omap_set_dma_dest_burst_mode(info-dma_ch,
-   OMAP_DMA_DATA_BURST_16);
-   omap_set_dma_src_burst_mode

[PATCH v6 0/7] nand prefetch-irq support and ecc layout chanage

2010-11-26 Thread Sukumar Ghorai
The following set of patches applies on linux-2.6.

The main motivations behind this patch series are -
1. support NAND I/O in irq mode.
2. support of different ECC schema.
3. also to make ecc layout as like in romcode ecc layout


v6: configurable transfer type from board file; 
#define irq number used for nand-irq

v5: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35860.html
This address the input as to support the irq_chained in GPMC.
And resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35848.html

v4: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg34882.html
and resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32689.html

v3: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32071.html
Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31963.html

v2: Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31471.html

v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg2.html

Sukumar Ghorai (7):
  omap3630: nand: fix device size to work in polled mode
  omap3: nand: configurable transfer type per board
  omap: gpmc: enable irq mode in gpmc
  omap3: nand: prefetch in irq mode support
  omap3: nand: configurable fifo threshold to gain the throughput
  omap: nand: ecc layout select from board file
  omap: nand: making ecc layout as compatible with romcode ecc

 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-flash.c  |7 +
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |2 +
 arch/arm/mach-omap2/board-zoom3.c  |2 +
 arch/arm/mach-omap2/gpmc.c |   50 -
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |   16 ++-
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 arch/arm/plat-omap/include/plat/nand.h |   11 +
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |  314 ++--
 31 files changed, 364 insertions(+), 94 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 6/7] omap: nand: ecc layout select from board file

2010-11-26 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.  And hw ecc layout selected for
sdp and zoom boards, by default.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |1 +
 arch/arm/plat-omap/include/plat/gpmc.h |7 +++
 arch/arm/plat-omap/include/plat/nand.h |2 ++
 drivers/mtd/nand/omap2.c   |5 +
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 78abcd9..3340427 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -150,6 +150,7 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
if (cpu_is_omap3630())
board_nand_data.devsize = 1;
 
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT;
board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index fb82335..ca6e8db 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -86,6 +86,13 @@
 #define PREFETCH_FIFOTHRESHOLD_MAX 0x40
 #define PREFETCH_FIFOTHRESHOLD(val)(val  8)
 
+enum omap_ecc {
+   OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT = 0,
+   /* 1-bit s/w ecc and layout different from romcode */
+   OMAP_ECC_HAMMING_CODE_HW,/* 1-bit ecc, romcode layout */
+   OMAP_ECC_HAMMING_CODE_SW,/* 1-bit ecc, romcode layout */
+};
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index ae5e053..d86d1ec 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include plat/gpmc.h
 #include linux/mtd/partitions.h
 
 enum nand_io {
@@ -31,6 +32,7 @@ struct omap_nand_platform_data {
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
+   enum omap_ecc   ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index fea9f59..0937001 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -7,6 +7,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#define CONFIG_MTD_NAND_OMAP_HWECC
 
 #include linux/platform_device.h
 #include linux/dma-mapping.h
@@ -618,8 +619,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -839,8 +838,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
gpmc_enable_hwecc(info-gpmc_cs, mode, dev_width, info-nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 5/7] omap3: nand: configurable fifo threshold to gain the throughput

2010-11-26 Thread Sukumar Ghorai
Configure the FIFO THREASHOLD value different for read and write to keep busy
both filling and to drain out of FIFO at reading and writing.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   11 +++
 arch/arm/plat-omap/include/plat/gpmc.h |5 -
 drivers/mtd/nand/omap2.c   |   24 +++-
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index cfaf357..b26b1a5 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -59,7 +59,6 @@
 #define GPMC_CHUNK_SHIFT   24  /* 16 MB */
 #define GPMC_SECTION_SHIFT 28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
 #define CS_NUM_SHIFT   24
 #define ENABLE_PREFETCH(0x1  7)
 #define DMA_MPU_MODE   2
@@ -595,15 +594,19 @@ EXPORT_SYMBOL(gpmc_nand_write);
 /**
  * gpmc_prefetch_enable - configures and starts prefetch transfer
  * @cs: cs (chip select) number
+ * @fifo_th: fifo threshold to be used for read/ write
  * @dma_mode: dma mode enable (1) or disable (0)
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   printk(KERN_ERR PREFETCH Fifo Threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -611,7 +614,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write)));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 054e704..fb82335 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -83,6 +83,9 @@
 #define GPMC_IRQ_FIFOEVENTENABLE   0x01
 #define GPMC_IRQ_COUNT_EVENT   0x02
 
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)(val  8)
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
@@ -133,7 +136,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index c4bbbd0..fea9f59 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -243,7 +243,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -287,7 +288,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -340,10 +342,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
dma_addr_t dma_addr;
int ret;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get a sync at each frame

[PATCH v6 7/7] omap: nand: making ecc layout as compatible with romcode ecc

2010-11-26 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-loader, u-boot and kernel.

This patch also enables to use romcode ecc for spd and zoom, by default.

This enables to flash x-loader, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 drivers/mtd/nand/omap2.c |   34 ++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 0937001..d4c508a 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -98,6 +98,20 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
+/* oob info generated runtime depending on ecc algorithm and layout selected */
+static struct nand_ecclayout omap_oobinfo;
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -907,6 +921,7 @@ static int __devinit omap_nand_probe(struct platform_device 
*pdev)
struct omap_nand_info   *info;
struct omap_nand_platform_data  *pdata;
int err;
+   int i, offset;
 
pdata = pdev-dev.platform_data;
if (pdata == NULL) {
@@ -1051,6 +1066,25 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
 
 
+   /* rom code layout */
+   if (pdata-ecc_opt != OMAP_ECC_HAMMING_CODE_DIFF_LAYOUT) {
+   offset = (info-nand.options  NAND_BUSWIDTH_16) ? 2 : 1;
+   if (info-mtd.oobsize == 16) {
+   info-nand.badblock_pattern = bb_descrip_flashbased;
+   omap_oobinfo.eccbytes = 3;
+   } else
+   omap_oobinfo.eccbytes  = 3 * 4;
+
+   for (i = 0; i  omap_oobinfo.eccbytes; i++)
+   omap_oobinfo.eccpos[i] = i+offset;
+
+   omap_oobinfo.oobfree-offset = offset + omap_oobinfo.eccbytes;
+   omap_oobinfo.oobfree-length = info-mtd.oobsize -
+   (offset + omap_oobinfo.eccbytes);
+
+   info-nand.ecc.layout = omap_oobinfo;
+   }
+
 #ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(info-mtd, part_probes, info-parts, 0);
if (err  0)
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 3/7] omap: gpmc: enable irq mode in gpmc

2010-11-26 Thread Sukumar Ghorai
add support the irq mode in GPMC.
gpmc_init() function move after omap_init_irq() as it has dependecy on irq.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |2 +
 arch/arm/mach-omap2/board-zoom3.c  |2 +
 arch/arm/mach-omap2/gpmc.c |   39 ++-
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |4 +++
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 27 files changed, 81 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index b527f8d..11c89dc 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -145,6 +145,7 @@ static void __init omap_2430sdp_init_irq(void)
omap_board_config_size = ARRAY_SIZE(sdp2430_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 4e3742c..a040165 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -328,6 +328,7 @@ static void __init omap_3430sdp_init_irq(void)
omap3_pm_init_cpuidle(omap3_cpuidle_params_table);
omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index bbcf580..17983ed 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -76,6 +76,7 @@ static void __init omap_sdp_init_irq(void)
omap2_init_common_hw(h8mbx00u0mer0em_sdrc_params,
h8mbx00u0mer0em_sdrc_params);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index df5a425..8d15604 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -34,6 +34,7 @@
 #include plat/common.h
 #include plat/usb.h
 #include plat/mmc.h
+#include plat/gpmc.h
 
 #include hsmmc.h
 #include timer-gp.h
@@ -222,6 +223,7 @@ static void __init omap_4430sdp_init_irq(void)
omap2_gp_clockevent_set_gptimer(1);
 #endif
gic_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index 0739950..460e3d1 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -35,6 +35,7 @@
 #include plat/common.h
 #include plat/usb.h
 #include plat/display.h
+#include plat/gpmc.h
 
 #include mux.h
 #include control.h
@@ -392,6 +393,7 @@ static void __init am3517_evm_init_irq(void)
 
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index 2c6db1a..8264e7a 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -280,6 +280,7 @@ static void __init omap_apollon_init_irq(void)
omap_board_config_size = ARRAY_SIZE(apollon_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
apollon_init_smc91x();
 }
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index 63f764e..7c9a834 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -686,6 +686,7 @@ static void __init cm_t35_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
 mt46h32m32lf6_sdrc_params

[PATCH v6 4/7] omap3: nand: prefetch in irq mode support

2010-11-26 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for nand transfer(read, write)

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |3 +
 arch/arm/plat-omap/include/plat/nand.h |4 +-
 drivers/mtd/nand/omap2.c   |  169 
 3 files changed, 175 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 001c605..78abcd9 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -16,7 +16,9 @@
 #include linux/platform_device.h
 #include linux/mtd/physmap.h
 #include linux/io.h
+#include plat/irqs.h
 
+#include plat/irqs.h
 #include plat/gpmc.h
 #include plat/nand.h
 #include plat/onenand.h
@@ -148,6 +150,7 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 
nr_parts, u8 cs)
if (cpu_is_omap3630())
board_nand_data.devsize = 1;
 
+   board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
 #else
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 78c0bdb..ae5e053 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -13,7 +13,8 @@
 enum nand_io {
NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
NAND_OMAP_POLLED,   /* polled mode, without prefetch */
-   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_DMA, /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_IRQ  /* prefetch enabled irq mode */
 };
 
 struct omap_nand_platform_data {
@@ -26,6 +27,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 6011e90..c4bbbd0 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -108,6 +109,13 @@ struct omap_nand_info {
unsigned long   phys_base;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   enum {
+   OMAP_NAND_IO_READ = 0,  /* read */
+   OMAP_NAND_IO_WRITE, /* write */
+   } iomode;
+   u_char  *buf;
+   int buf_len;
 };
 
 /**
@@ -436,6 +444,153 @@ static void omap_write_buf_dma_pref(struct mtd_info *mtd,
omap_nand_dma_transfer(mtd, (u_char *) buf, len, 0x1);
 }
 
+/*
+ * omap_nand_irq - GMPC irq handler
+ * @this_irq: gpmc irq number
+ * @dev: omap_nand_info structure pointer is passed here
+ */
+static irqreturn_t omap_nand_irq(int this_irq, void *dev)
+{
+   struct omap_nand_info *info = (struct omap_nand_info *) dev;
+   u32 bytes;
+   u32 irq_stat;
+
+   irq_stat = gpmc_read_status(GPMC_GET_IRQ_STATUS);
+   bytes = gpmc_read_status(GPMC_PREFETCH_FIFO_CNT);
+   bytes = bytes   0xFFFC; /* io in multiple of 4 bytes */
+   if (info-iomode == OMAP_NAND_IO_WRITE) { /* checks for write io */
+   if (irq_stat  0x2)
+   goto done;
+
+   if (info-buf_len  (info-buf_len  bytes))
+   bytes = info-buf_len;
+   else if (!info-buf_len)
+   bytes = 0;
+   iowrite32_rep(info-nand.IO_ADDR_W,
+   (u32 *)info-buf, bytes  2);
+   info-buf = info-buf + bytes;
+   info-buf_len -= bytes;
+
+   } else {
+   ioread32_rep(info-nand.IO_ADDR_R,
+   (u32 *)info-buf, bytes  2);
+   info-buf = info-buf + bytes;
+
+   if (irq_stat  0x2)
+   goto done;
+   }
+   gpmc_cs_configure(info-gpmc_cs, GPMC_SET_IRQ_STATUS, irq_stat);
+   irq_stat = gpmc_read_status(GPMC_GET_IRQ_STATUS);
+
+   return IRQ_HANDLED;
+
+done:
+   complete(info-comp);
+   /* disable irq */
+   gpmc_cs_configure(info-gpmc_cs, GPMC_ENABLE_IRQ, 0);
+
+   /* clear status */
+   gpmc_cs_configure(info-gpmc_cs, GPMC_SET_IRQ_STATUS, irq_stat);
+   irq_stat = gpmc_read_status(GPMC_GET_IRQ_STATUS);
+
+   return IRQ_HANDLED;
+}
+
+/*
+ * omap_read_buf_irq_pref - read data from NAND

[PATCH v7 0/7] nand prefetch-irq support and ecc layout chanage

2010-12-29 Thread Sukumar Ghorai
The following set of patches applies on linux-2.6.

The main motivations behind this patch series are -
1. support NAND I/O in irq mode.
2. support of different ECC schema.
3. also add support ecc layout as like in romcode ecc layout, but not 
enabled

v7: NAND type (x16 or x8) is board specific and not omap specific; this passed 
form board file.

v6: configurable transfer type from board file; 
#define irq number used for nand-irq
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg39397.html

v5: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35860.html
This address the input as to support the irq_chained in GPMC.
And resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35848.html

v4: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg34882.html
and resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32689.html

v3: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32071.html
Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31963.html

v2: Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31471.html

v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg2.html

Sukumar Ghorai (7):
  omap3630: nand: fix device size to work in polled mode
  omap3: nand: configurable transfer type per board
  omap: gpmc: enable irq mode in gpmc
  omap3: nand: prefetch in irq mode support
  omap3: nand: configurable fifo threshold to gain the throughput
  omap3: nand: ecc layout select from board file
  omap3: nand: making ecc layout as compatible with romcode ecc

 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|3 +-
 arch/arm/mach-omap2/board-3630sdp.c|4 +-
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-flash.c  |   13 +-
 arch/arm/mach-omap2/board-flash.h  |4 +-
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|3 +-
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |7 +-
 arch/arm/mach-omap2/board-zoom3.c  |7 +-
 arch/arm/mach-omap2/gpmc-nand.c|7 +-
 arch/arm/mach-omap2/gpmc.c |   50 -
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |   17 ++-
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 arch/arm/plat-omap/include/plat/nand.h |   11 +
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |  336 +---
 33 files changed, 396 insertions(+), 119 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 1/7] omap3630: nand: fix device size to work in polled mode

2010-12-29 Thread Sukumar Ghorai
zoom3 and 3630-sdp having the x16 nand device.
This patch configure gpmc as x16 and select the currect function in driver
for polled mode (without prefetch enable) transfer.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-3430sdp.c |2 +-
 arch/arm/mach-omap2/board-3630sdp.c |3 ++-
 arch/arm/mach-omap2/board-flash.c   |   10 ++
 arch/arm/mach-omap2/board-flash.h   |4 ++--
 arch/arm/mach-omap2/board-ldp.c |2 +-
 arch/arm/mach-omap2/board-zoom2.c   |5 +++--
 arch/arm/mach-omap2/board-zoom3.c   |5 +++--
 arch/arm/mach-omap2/gpmc-nand.c |7 +--
 drivers/mtd/nand/omap2.c|2 +-
 9 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 4e3742c..470872e 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -809,7 +809,7 @@ static void __init omap_3430sdp_init(void)
omap_serial_init();
usb_musb_init(musb_board_data);
board_smc91x_init();
-   board_flash_init(sdp_flash_partitions, chip_sel_3430);
+   board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
sdp3430_display_init();
enable_board_wakeup_source();
usb_ehci_init(ehci_pdata);
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index bbcf580..0a74141 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/input.h
 #include linux/gpio.h
+#include linux/mtd/nand.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -210,7 +211,7 @@ static void __init omap_sdp_init(void)
omap3_mux_init(board_mux, OMAP_PACKAGE_CBP);
zoom_peripherals_init();
board_smc91x_init();
-   board_flash_init(sdp_flash_partitions, chip_sel_sdp);
+   board_flash_init(sdp_flash_partitions, chip_sel_sdp, NAND_BUSWIDTH_16);
enable_board_wakeup_source();
usb_ehci_init(ehci_pdata);
 }
diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index fd38c05..f6b7253 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -139,11 +139,13 @@ static struct omap_nand_platform_data board_nand_data = {
 };
 
 void
-__init board_nand_init(struct mtd_partition *nand_parts, u8 nr_parts, u8 cs)
+__init board_nand_init(struct mtd_partition *nand_parts,
+   u8 nr_parts, u8 cs, int nand_type)
 {
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
-   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.devsize = nand_type;
 
gpmc_nand_init(board_nand_data);
 }
@@ -194,7 +196,7 @@ unmap:
  * @return - void.
  */
 void board_flash_init(struct flash_partitions partition_info[],
-   char chip_sel_board[][GPMC_CS_NUM])
+   char chip_sel_board[][GPMC_CS_NUM], int nand_type)
 {
u8  cs = 0;
u8  norcs = GPMC_CS_NUM + 1;
@@ -250,5 +252,5 @@ void board_flash_init(struct flash_partitions 
partition_info[],
in GPMC\n);
else
board_nand_init(partition_info[2].parts,
-   partition_info[2].nr_parts, nandcs);
+   partition_info[2].nr_parts, nandcs, nand_type);
 }
diff --git a/arch/arm/mach-omap2/board-flash.h 
b/arch/arm/mach-omap2/board-flash.h
index 69befe0..c240a3f 100644
--- a/arch/arm/mach-omap2/board-flash.h
+++ b/arch/arm/mach-omap2/board-flash.h
@@ -25,6 +25,6 @@ struct flash_partitions {
 };
 
 extern void board_flash_init(struct flash_partitions [],
-   char chip_sel[][GPMC_CS_NUM]);
+   char chip_sel[][GPMC_CS_NUM], int nand_type);
 extern void board_nand_init(struct mtd_partition *nand_parts,
-   u8 nr_parts, u8 cs);
+   u8 nr_parts, u8 cs, int nand_type);
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 001fd97..b088b1d 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -436,7 +436,7 @@ static void __init omap_ldp_init(void)
omap_serial_init();
usb_musb_init(musb_board_data);
board_nand_init(ldp_nand_partitions,
-   ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS);
+   ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
 
omap2_hsmmc_init(mmc);
/* link regulators to MMC adapters */
diff --git a/arch/arm/mach-omap2/board-zoom2.c 
b/arch/arm/mach-omap2/board-zoom2.c
index 2992a9f..994d286 100644
--- a/arch/arm/mach-omap2/board-zoom2.c
+++ b/arch/arm/mach-omap2/board-zoom2.c
@@ -15,6

[PATCH v7 5/7] omap3: nand: configurable fifo threshold to gain the throughput

2010-12-29 Thread Sukumar Ghorai
Configure the FIFO THREASHOLD value different for read and write to keep busy
both filling and to drain out of FIFO at reading and writing.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   11 +++
 arch/arm/plat-omap/include/plat/gpmc.h |5 -
 drivers/mtd/nand/omap2.c   |   22 ++
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index cfaf357..b26b1a5 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -59,7 +59,6 @@
 #define GPMC_CHUNK_SHIFT   24  /* 16 MB */
 #define GPMC_SECTION_SHIFT 28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
 #define CS_NUM_SHIFT   24
 #define ENABLE_PREFETCH(0x1  7)
 #define DMA_MPU_MODE   2
@@ -595,15 +594,19 @@ EXPORT_SYMBOL(gpmc_nand_write);
 /**
  * gpmc_prefetch_enable - configures and starts prefetch transfer
  * @cs: cs (chip select) number
+ * @fifo_th: fifo threshold to be used for read/ write
  * @dma_mode: dma mode enable (1) or disable (0)
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   printk(KERN_ERR PREFETCH Fifo Threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -611,7 +614,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write)));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 054e704..fb82335 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -83,6 +83,9 @@
 #define GPMC_IRQ_FIFOEVENTENABLE   0x01
 #define GPMC_IRQ_COUNT_EVENT   0x02
 
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)(val  8)
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
@@ -133,7 +136,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 007862e..384d89b 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -243,7 +243,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -287,7 +288,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -340,8 +342,9 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
dma_addr_t dma_addr;
int ret;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get a sync at each frame

[PATCH v7 7/7] omap3: nand: making ecc layout as compatible with romcode ecc

2010-12-29 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-loader, u-boot and kernel.

This enables to flash x-loader, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

This patch does not enables this feature by default and need to pass from
board file to enable for any board.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/gpmc.h |2 +
 drivers/mtd/nand/omap2.c   |   37 +++-
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 28a5607..fcc0530 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -90,6 +90,8 @@ enum omap_ecc {
/* 1-bit ecc: stored at end of spare area */
OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+   /* 1-bit ecc: stored at begining of spare area as romcode */
+   OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method  romcode layout */
 };
 
 /*
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index c6f3ea9..72af2d9 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -97,6 +97,20 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
+/* oob info generated runtime depending on ecc algorithm and layout selected */
+static struct nand_ecclayout omap_oobinfo;
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -906,6 +920,7 @@ static int __devinit omap_nand_probe(struct platform_device 
*pdev)
struct omap_nand_info   *info;
struct omap_nand_platform_data  *pdata;
int err;
+   int i, offset;
 
pdata = pdev-dev.platform_data;
if (pdata == NULL) {
@@ -1029,7 +1044,8 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
/* selsect the ecc type */
if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DEFAULT)
info-nand.ecc.mode = NAND_ECC_SOFT;
-   else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) {
+   else if ((pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) ||
+   (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE)) {
info-nand.ecc.bytes= 3;
info-nand.ecc.size = 512;
info-nand.ecc.calculate= omap_calculate_ecc;
@@ -1049,6 +1065,25 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
}
 
+   /* rom code layout */
+   if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE) {
+
+   if (info-nand.options  NAND_BUSWIDTH_16)
+   offset = 2;
+   else {
+   offset = 1;
+   info-nand.badblock_pattern = bb_descrip_flashbased;
+   }
+   omap_oobinfo.eccbytes = 3 * (info-mtd.oobsize/16);
+   for (i = 0; i  omap_oobinfo.eccbytes; i++)
+   omap_oobinfo.eccpos[i] = i+offset;
+
+   omap_oobinfo.oobfree-offset = offset + omap_oobinfo.eccbytes;
+   omap_oobinfo.oobfree-length = info-mtd.oobsize -
+   (offset + omap_oobinfo.eccbytes);
+
+   info-nand.ecc.layout = omap_oobinfo;
+   }
 
 #ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(info-mtd, part_probes, info-parts, 0);
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 4/7] omap3: nand: prefetch in irq mode support

2010-12-29 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for nand transfer(read, write)

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |2 +
 arch/arm/plat-omap/include/plat/nand.h |4 +-
 drivers/mtd/nand/omap2.c   |  169 
 3 files changed, 174 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index f6b7253..1964509 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -16,6 +16,7 @@
 #include linux/platform_device.h
 #include linux/mtd/physmap.h
 #include linux/io.h
+#include plat/irqs.h
 
 #include plat/gpmc.h
 #include plat/nand.h
@@ -147,6 +148,7 @@ __init board_nand_init(struct mtd_partition *nand_parts,
board_nand_data.nr_parts= nr_parts;
board_nand_data.devsize = nand_type;
 
+   board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
 #else
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 78c0bdb..ae5e053 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -13,7 +13,8 @@
 enum nand_io {
NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
NAND_OMAP_POLLED,   /* polled mode, without prefetch */
-   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_DMA, /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_IRQ  /* prefetch enabled irq mode */
 };
 
 struct omap_nand_platform_data {
@@ -26,6 +27,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 66b7428..007862e 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -108,6 +109,13 @@ struct omap_nand_info {
unsigned long   phys_base;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   enum {
+   OMAP_NAND_IO_READ = 0,  /* read */
+   OMAP_NAND_IO_WRITE, /* write */
+   } iomode;
+   u_char  *buf;
+   int buf_len;
 };
 
 /**
@@ -436,6 +444,153 @@ static void omap_write_buf_dma_pref(struct mtd_info *mtd,
omap_nand_dma_transfer(mtd, (u_char *) buf, len, 0x1);
 }
 
+/*
+ * omap_nand_irq - GMPC irq handler
+ * @this_irq: gpmc irq number
+ * @dev: omap_nand_info structure pointer is passed here
+ */
+static irqreturn_t omap_nand_irq(int this_irq, void *dev)
+{
+   struct omap_nand_info *info = (struct omap_nand_info *) dev;
+   u32 bytes;
+   u32 irq_stat;
+
+   irq_stat = gpmc_read_status(GPMC_GET_IRQ_STATUS);
+   bytes = gpmc_read_status(GPMC_PREFETCH_FIFO_CNT);
+   bytes = bytes   0xFFFC; /* io in multiple of 4 bytes */
+   if (info-iomode == OMAP_NAND_IO_WRITE) { /* checks for write io */
+   if (irq_stat  0x2)
+   goto done;
+
+   if (info-buf_len  (info-buf_len  bytes))
+   bytes = info-buf_len;
+   else if (!info-buf_len)
+   bytes = 0;
+   iowrite32_rep(info-nand.IO_ADDR_W,
+   (u32 *)info-buf, bytes  2);
+   info-buf = info-buf + bytes;
+   info-buf_len -= bytes;
+
+   } else {
+   ioread32_rep(info-nand.IO_ADDR_R,
+   (u32 *)info-buf, bytes  2);
+   info-buf = info-buf + bytes;
+
+   if (irq_stat  0x2)
+   goto done;
+   }
+   gpmc_cs_configure(info-gpmc_cs, GPMC_SET_IRQ_STATUS, irq_stat);
+   irq_stat = gpmc_read_status(GPMC_GET_IRQ_STATUS);
+
+   return IRQ_HANDLED;
+
+done:
+   complete(info-comp);
+   /* disable irq */
+   gpmc_cs_configure(info-gpmc_cs, GPMC_ENABLE_IRQ, 0);
+
+   /* clear status */
+   gpmc_cs_configure(info-gpmc_cs, GPMC_SET_IRQ_STATUS, irq_stat);
+   irq_stat = gpmc_read_status(GPMC_GET_IRQ_STATUS);
+
+   return IRQ_HANDLED;
+}
+
+/*
+ * omap_read_buf_irq_pref - read data from NAND controller into buffer
+ * @mtd: MTD device

[PATCH v7 6/7] omap3: nand: ecc layout select from board file

2010-12-29 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.  And hw ecc layout selected for
sdp and zoom boards, by default.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |1 +
 arch/arm/plat-omap/include/plat/gpmc.h |6 ++
 arch/arm/plat-omap/include/plat/nand.h |2 ++
 drivers/mtd/nand/omap2.c   |   26 +++---
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 1964509..a768198 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -148,6 +148,7 @@ __init board_nand_init(struct mtd_partition *nand_parts,
board_nand_data.nr_parts= nr_parts;
board_nand_data.devsize = nand_type;
 
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DEFAULT;
board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index fb82335..28a5607 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -86,6 +86,12 @@
 #define PREFETCH_FIFOTHRESHOLD_MAX 0x40
 #define PREFETCH_FIFOTHRESHOLD(val)(val  8)
 
+enum omap_ecc {
+   /* 1-bit ecc: stored at end of spare area */
+   OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
+   OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+};
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index ae5e053..d86d1ec 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include plat/gpmc.h
 #include linux/mtd/partitions.h
 
 enum nand_io {
@@ -31,6 +32,7 @@ struct omap_nand_platform_data {
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
+   enum omap_ecc   ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 384d89b..c6f3ea9 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -618,8 +618,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -839,8 +837,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
gpmc_enable_hwecc(info-gpmc_cs, mode, dev_width, info-nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
@@ -1030,17 +1026,17 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
 
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
-
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* selsect the ecc type */
+   if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DEFAULT)
+   info-nand.ecc.mode = NAND_ECC_SOFT;
+   else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
+   }
 
/* DIP switches on some boards change between 8 and 16 bit
 * bus widths for flash.  Try the other width if the first try fails.
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 2/7] omap3: nand: configurable transfer type per board

2010-12-29 Thread Sukumar Ghorai
nand transfer type (sDMA, Polled, prefetch) can be select from board file,
enabling all transfer type in driver, by default.

this helps in multi-omap build and to select different transfer type for
different board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/nand.h |7 +++
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |   92 +++
 3 files changed, 40 insertions(+), 76 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd0..78c0bdb 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -10,6 +10,12 @@
 
 #include linux/mtd/partitions.h
 
+enum nand_io {
+   NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
+   NAND_OMAP_POLLED,   /* polled mode, without prefetch */
+   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+};
+
 struct omap_nand_platform_data {
unsigned intoptions;
int cs;
@@ -20,6 +26,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
 };
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8229802..89bb297 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -105,23 +105,6 @@ config MTD_NAND_OMAP2
help
   Support for NAND flash on Texas Instruments OMAP2 and OMAP3 
platforms.
 
-config MTD_NAND_OMAP_PREFETCH
-   bool GPMC prefetch support for NAND Flash device
-   depends on MTD_NAND_OMAP2
-   default y
-   help
-The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
-to improve the performance.
-
-config MTD_NAND_OMAP_PREFETCH_DMA
-   depends on MTD_NAND_OMAP_PREFETCH
-   bool DMA mode
-   default n
-   help
-The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
-or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
-
 config MTD_NAND_IDS
tristate
 
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 7c04cd6..66b7428 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -96,27 +96,6 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH
-static int use_prefetch = 1;
-
-/* modprobe ... use_prefetch=0 etc */
-module_param(use_prefetch, bool, 0);
-MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
-
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
-static int use_dma = 1;
-
-/* modprobe ... use_dma=0 etc */
-module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
-#else
-static const int use_dma;
-#endif
-#else
-const int use_prefetch;
-static const int use_dma;
-#endif
-
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -324,7 +303,6 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
 /*
  * omap_nand_dma_cb: callback on the completion of dma transfer
  * @lch: logical channel
@@ -426,14 +404,6 @@ out_copy:
: omap_write_buf8(mtd, (u_char *) addr, len);
return 0;
 }
-#else
-static void omap_nand_dma_cb(int lch, u16 ch_status, void *data) {}
-static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
-   unsigned int len, int is_write)
-{
-   return 0;
-}
-#endif
 
 /**
  * omap_read_buf_dma_pref - read data from NAND controller into buffer
@@ -842,28 +812,13 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
info-nand.chip_delay = 50;
}
 
-   if (use_prefetch) {
-
+   switch (pdata-xfer_type) {
+   case NAND_OMAP_PREFETCH_POLLED:
info-nand.read_buf   = omap_read_buf_pref;
info-nand.write_buf  = omap_write_buf_pref;
-   if (use_dma) {
-   err = omap_request_dma(OMAP24XX_DMA_GPMC, NAND,
-   omap_nand_dma_cb, info-comp, info-dma_ch);
-   if (err  0) {
-   info-dma_ch = -1;
-   printk(KERN_WARNING DMA request failed.
-Non-dma data transfer mode\n);
-   } else {
-   omap_set_dma_dest_burst_mode(info-dma_ch,
-   OMAP_DMA_DATA_BURST_16);
-   omap_set_dma_src_burst_mode

[PATCH v7 3/7] omap: gpmc: enable irq mode in gpmc

2010-12-29 Thread Sukumar Ghorai
add support the irq mode in GPMC.
gpmc_init() function move after omap_init_irq() as it has dependecy on irq.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |2 +
 arch/arm/mach-omap2/board-zoom3.c  |2 +
 arch/arm/mach-omap2/gpmc.c |   39 ++-
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |4 +++
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 27 files changed, 81 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index b527f8d..11c89dc 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -145,6 +145,7 @@ static void __init omap_2430sdp_init_irq(void)
omap_board_config_size = ARRAY_SIZE(sdp2430_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 470872e..690fecd 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -328,6 +328,7 @@ static void __init omap_3430sdp_init_irq(void)
omap3_pm_init_cpuidle(omap3_cpuidle_params_table);
omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index 0a74141..46c1755 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -77,6 +77,7 @@ static void __init omap_sdp_init_irq(void)
omap2_init_common_hw(h8mbx00u0mer0em_sdrc_params,
h8mbx00u0mer0em_sdrc_params);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index df5a425..8d15604 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -34,6 +34,7 @@
 #include plat/common.h
 #include plat/usb.h
 #include plat/mmc.h
+#include plat/gpmc.h
 
 #include hsmmc.h
 #include timer-gp.h
@@ -222,6 +223,7 @@ static void __init omap_4430sdp_init_irq(void)
omap2_gp_clockevent_set_gptimer(1);
 #endif
gic_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index 0739950..460e3d1 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -35,6 +35,7 @@
 #include plat/common.h
 #include plat/usb.h
 #include plat/display.h
+#include plat/gpmc.h
 
 #include mux.h
 #include control.h
@@ -392,6 +393,7 @@ static void __init am3517_evm_init_irq(void)
 
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index 2c6db1a..8264e7a 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -280,6 +280,7 @@ static void __init omap_apollon_init_irq(void)
omap_board_config_size = ARRAY_SIZE(apollon_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
apollon_init_smc91x();
 }
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index 63f764e..7c9a834 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -686,6 +686,7 @@ static void __init cm_t35_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
 mt46h32m32lf6_sdrc_params

[PATCH v8 2/7] omap3: nand: configurable transfer type per board

2011-01-04 Thread Sukumar Ghorai
nand transfer type (sDMA, Polled, prefetch) can be select from board file,
enabling all transfer type in driver, by default.

this helps in multi-omap build and to select different transfer type for
different board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/nand.h |7 +++
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |   94 
 3 files changed, 41 insertions(+), 77 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd0..78c0bdb 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -10,6 +10,12 @@
 
 #include linux/mtd/partitions.h
 
+enum nand_io {
+   NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
+   NAND_OMAP_POLLED,   /* polled mode, without prefetch */
+   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+};
+
 struct omap_nand_platform_data {
unsigned intoptions;
int cs;
@@ -20,6 +26,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
 };
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8229802..89bb297 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -105,23 +105,6 @@ config MTD_NAND_OMAP2
help
   Support for NAND flash on Texas Instruments OMAP2 and OMAP3 
platforms.
 
-config MTD_NAND_OMAP_PREFETCH
-   bool GPMC prefetch support for NAND Flash device
-   depends on MTD_NAND_OMAP2
-   default y
-   help
-The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
-to improve the performance.
-
-config MTD_NAND_OMAP_PREFETCH_DMA
-   depends on MTD_NAND_OMAP_PREFETCH
-   bool DMA mode
-   default n
-   help
-The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
-or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
-
 config MTD_NAND_IDS
tristate
 
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 7c04cd6..60bac8e 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -96,27 +96,6 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH
-static int use_prefetch = 1;
-
-/* modprobe ... use_prefetch=0 etc */
-module_param(use_prefetch, bool, 0);
-MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
-
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
-static int use_dma = 1;
-
-/* modprobe ... use_dma=0 etc */
-module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
-#else
-static const int use_dma;
-#endif
-#else
-const int use_prefetch;
-static const int use_dma;
-#endif
-
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -324,7 +303,6 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
 /*
  * omap_nand_dma_cb: callback on the completion of dma transfer
  * @lch: logical channel
@@ -426,14 +404,6 @@ out_copy:
: omap_write_buf8(mtd, (u_char *) addr, len);
return 0;
 }
-#else
-static void omap_nand_dma_cb(int lch, u16 ch_status, void *data) {}
-static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
-   unsigned int len, int is_write)
-{
-   return 0;
-}
-#endif
 
 /**
  * omap_read_buf_dma_pref - read data from NAND controller into buffer
@@ -842,28 +812,13 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
info-nand.chip_delay = 50;
}
 
-   if (use_prefetch) {
-
+   switch (pdata-xfer_type) {
+   case NAND_OMAP_PREFETCH_POLLED:
info-nand.read_buf   = omap_read_buf_pref;
info-nand.write_buf  = omap_write_buf_pref;
-   if (use_dma) {
-   err = omap_request_dma(OMAP24XX_DMA_GPMC, NAND,
-   omap_nand_dma_cb, info-comp, info-dma_ch);
-   if (err  0) {
-   info-dma_ch = -1;
-   printk(KERN_WARNING DMA request failed.
-Non-dma data transfer mode\n);
-   } else {
-   omap_set_dma_dest_burst_mode(info-dma_ch,
-   OMAP_DMA_DATA_BURST_16);
-   omap_set_dma_src_burst_mode

[PATCH v8 1/7] omap3630: nand: fix device size to work in polled mode

2011-01-04 Thread Sukumar Ghorai
zoom3 and 3630-sdp having the x16 nand device.
This patch configure gpmc as x16 and select the currect function in driver
for polled mode (without prefetch enable) transfer.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-3430sdp.c |2 +-
 arch/arm/mach-omap2/board-3630sdp.c |3 ++-
 arch/arm/mach-omap2/board-flash.c   |   10 ++
 arch/arm/mach-omap2/board-flash.h   |4 ++--
 arch/arm/mach-omap2/board-ldp.c |2 +-
 arch/arm/mach-omap2/board-zoom2.c   |5 +++--
 arch/arm/mach-omap2/board-zoom3.c   |5 +++--
 arch/arm/mach-omap2/gpmc-nand.c |7 +--
 drivers/mtd/nand/omap2.c|2 +-
 9 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 4e3742c..470872e 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -809,7 +809,7 @@ static void __init omap_3430sdp_init(void)
omap_serial_init();
usb_musb_init(musb_board_data);
board_smc91x_init();
-   board_flash_init(sdp_flash_partitions, chip_sel_3430);
+   board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
sdp3430_display_init();
enable_board_wakeup_source();
usb_ehci_init(ehci_pdata);
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index bbcf580..0a74141 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/input.h
 #include linux/gpio.h
+#include linux/mtd/nand.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -210,7 +211,7 @@ static void __init omap_sdp_init(void)
omap3_mux_init(board_mux, OMAP_PACKAGE_CBP);
zoom_peripherals_init();
board_smc91x_init();
-   board_flash_init(sdp_flash_partitions, chip_sel_sdp);
+   board_flash_init(sdp_flash_partitions, chip_sel_sdp, NAND_BUSWIDTH_16);
enable_board_wakeup_source();
usb_ehci_init(ehci_pdata);
 }
diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index fd38c05..f6b7253 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -139,11 +139,13 @@ static struct omap_nand_platform_data board_nand_data = {
 };
 
 void
-__init board_nand_init(struct mtd_partition *nand_parts, u8 nr_parts, u8 cs)
+__init board_nand_init(struct mtd_partition *nand_parts,
+   u8 nr_parts, u8 cs, int nand_type)
 {
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
-   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.devsize = nand_type;
 
gpmc_nand_init(board_nand_data);
 }
@@ -194,7 +196,7 @@ unmap:
  * @return - void.
  */
 void board_flash_init(struct flash_partitions partition_info[],
-   char chip_sel_board[][GPMC_CS_NUM])
+   char chip_sel_board[][GPMC_CS_NUM], int nand_type)
 {
u8  cs = 0;
u8  norcs = GPMC_CS_NUM + 1;
@@ -250,5 +252,5 @@ void board_flash_init(struct flash_partitions 
partition_info[],
in GPMC\n);
else
board_nand_init(partition_info[2].parts,
-   partition_info[2].nr_parts, nandcs);
+   partition_info[2].nr_parts, nandcs, nand_type);
 }
diff --git a/arch/arm/mach-omap2/board-flash.h 
b/arch/arm/mach-omap2/board-flash.h
index 69befe0..c240a3f 100644
--- a/arch/arm/mach-omap2/board-flash.h
+++ b/arch/arm/mach-omap2/board-flash.h
@@ -25,6 +25,6 @@ struct flash_partitions {
 };
 
 extern void board_flash_init(struct flash_partitions [],
-   char chip_sel[][GPMC_CS_NUM]);
+   char chip_sel[][GPMC_CS_NUM], int nand_type);
 extern void board_nand_init(struct mtd_partition *nand_parts,
-   u8 nr_parts, u8 cs);
+   u8 nr_parts, u8 cs, int nand_type);
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 001fd97..b088b1d 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -436,7 +436,7 @@ static void __init omap_ldp_init(void)
omap_serial_init();
usb_musb_init(musb_board_data);
board_nand_init(ldp_nand_partitions,
-   ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS);
+   ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
 
omap2_hsmmc_init(mmc);
/* link regulators to MMC adapters */
diff --git a/arch/arm/mach-omap2/board-zoom2.c 
b/arch/arm/mach-omap2/board-zoom2.c
index 2992a9f..994d286 100644
--- a/arch/arm/mach-omap2/board-zoom2.c
+++ b/arch/arm/mach-omap2/board-zoom2.c
@@ -15,6

[PATCH v8 4/7] omap3: nand: prefetch in irq mode support

2011-01-04 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for nand transfer(read, write)

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |2 +
 arch/arm/plat-omap/include/plat/nand.h |4 +-
 drivers/mtd/nand/omap2.c   |  198 ++--
 3 files changed, 194 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index f6b7253..1964509 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -16,6 +16,7 @@
 #include linux/platform_device.h
 #include linux/mtd/physmap.h
 #include linux/io.h
+#include plat/irqs.h
 
 #include plat/gpmc.h
 #include plat/nand.h
@@ -147,6 +148,7 @@ __init board_nand_init(struct mtd_partition *nand_parts,
board_nand_data.nr_parts= nr_parts;
board_nand_data.devsize = nand_type;
 
+   board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
 #else
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 78c0bdb..ae5e053 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -13,7 +13,8 @@
 enum nand_io {
NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
NAND_OMAP_POLLED,   /* polled mode, without prefetch */
-   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_DMA, /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_IRQ  /* prefetch enabled irq mode */
 };
 
 struct omap_nand_platform_data {
@@ -26,6 +27,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 60bac8e..fbe8414 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -24,6 +25,7 @@
 #include plat/nand.h
 
 #defineDRIVER_NAME omap2-nand
+#defineOMAP_NAND_TIMEOUT_MS5000
 
 #define NAND_Ecc_P1e   (1  0)
 #define NAND_Ecc_P2e   (1  1)
@@ -108,6 +110,13 @@ struct omap_nand_info {
unsigned long   phys_base;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   enum {
+   OMAP_NAND_IO_READ = 0,  /* read */
+   OMAP_NAND_IO_WRITE, /* write */
+   } iomode;
+   u_char  *buf;
+   int buf_len;
 };
 
 /**
@@ -267,9 +276,10 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
 {
struct omap_nand_info *info = container_of(mtd,
struct omap_nand_info, mtd);
-   uint32_t pref_count = 0, w_count = 0;
+   uint32_t w_count = 0;
int i = 0, ret = 0;
u16 *p;
+   unsigned long tim, limit;
 
/* take care of subpage writes */
if (len % 2 != 0) {
@@ -295,9 +305,12 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
iowrite16(*p++, info-nand.IO_ADDR_W);
}
/* wait for data to flushed-out before reset the prefetch */
-   do {
-   pref_count = gpmc_read_status(GPMC_PREFETCH_COUNT);
-   } while (pref_count);
+   tim = 0;
+   limit = (loops_per_jiffy *
+   msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS));
+   while (gpmc_read_status(GPMC_PREFETCH_COUNT)  (tim++  limit))
+   cpu_relax();
+
/* disable and stop the PFPW engine */
gpmc_prefetch_reset(info-gpmc_cs);
}
@@ -326,11 +339,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
 {
struct omap_nand_info *info = container_of(mtd,
struct omap_nand_info, mtd);
-   uint32_t prefetch_status = 0;
enum dma_data_direction dir = is_write ? DMA_TO_DEVICE :
DMA_FROM_DEVICE;
dma_addr_t dma_addr;
int ret;
+   unsigned long tim, limit;
 
/* The fifo depth is 64 bytes. We have a sync at each frame and frame
 * length is 64 bytes.
@@ -376,7 +389,7 @@ static

[PATCH v8 6/7] omap3: nand: ecc layout select from board file

2011-01-04 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |1 +
 arch/arm/plat-omap/include/plat/gpmc.h |6 ++
 arch/arm/plat-omap/include/plat/nand.h |2 ++
 drivers/mtd/nand/omap2.c   |   26 +++---
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 1964509..a768198 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -148,6 +148,7 @@ __init board_nand_init(struct mtd_partition *nand_parts,
board_nand_data.nr_parts= nr_parts;
board_nand_data.devsize = nand_type;
 
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DEFAULT;
board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 9e4dc7a..bc325c5 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -86,6 +86,12 @@
 #define PREFETCH_FIFOTHRESHOLD_MAX 0x40
 #define PREFETCH_FIFOTHRESHOLD(val)((val)  8)
 
+enum omap_ecc {
+   /* 1-bit ecc: stored at end of spare area */
+   OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
+   OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+};
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index ae5e053..d86d1ec 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include plat/gpmc.h
 #include linux/mtd/partitions.h
 
 enum nand_io {
@@ -31,6 +32,7 @@ struct omap_nand_platform_data {
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
+   enum omap_ecc   ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index f1648fd..6d4a42e 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -626,8 +626,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -847,8 +845,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
gpmc_enable_hwecc(info-gpmc_cs, mode, dev_width, info-nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
@@ -1038,17 +1034,17 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
 
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
-
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* selsect the ecc type */
+   if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DEFAULT)
+   info-nand.ecc.mode = NAND_ECC_SOFT;
+   else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
+   }
 
/* DIP switches on some boards change between 8 and 16 bit
 * bus widths for flash.  Try the other width if the first try fails.
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 7/7] omap3: nand: making ecc layout as compatible with romcode ecc

2011-01-04 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-loader, u-boot and kernel.

This enables to flash x-loader, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

This patch does not enables this feature by default and need to pass from
board file to enable for any board.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/gpmc.h |2 +
 drivers/mtd/nand/omap2.c   |   37 +++-
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index bc325c5..c07f3f2 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -90,6 +90,8 @@ enum omap_ecc {
/* 1-bit ecc: stored at end of spare area */
OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+   /* 1-bit ecc: stored at begining of spare area as romcode */
+   OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method  romcode layout */
 };
 
 /*
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 6d4a42e..4e33972 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -98,6 +98,20 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
+/* oob info generated runtime depending on ecc algorithm and layout selected */
+static struct nand_ecclayout omap_oobinfo;
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -914,6 +928,7 @@ static int __devinit omap_nand_probe(struct platform_device 
*pdev)
struct omap_nand_info   *info;
struct omap_nand_platform_data  *pdata;
int err;
+   int i, offset;
 
pdata = pdev-dev.platform_data;
if (pdata == NULL) {
@@ -1037,7 +1052,8 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
/* selsect the ecc type */
if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DEFAULT)
info-nand.ecc.mode = NAND_ECC_SOFT;
-   else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) {
+   else if ((pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) ||
+   (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE)) {
info-nand.ecc.bytes= 3;
info-nand.ecc.size = 512;
info-nand.ecc.calculate= omap_calculate_ecc;
@@ -1057,6 +1073,25 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
}
 
+   /* rom code layout */
+   if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE) {
+
+   if (info-nand.options  NAND_BUSWIDTH_16)
+   offset = 2;
+   else {
+   offset = 1;
+   info-nand.badblock_pattern = bb_descrip_flashbased;
+   }
+   omap_oobinfo.eccbytes = 3 * (info-mtd.oobsize/16);
+   for (i = 0; i  omap_oobinfo.eccbytes; i++)
+   omap_oobinfo.eccpos[i] = i+offset;
+
+   omap_oobinfo.oobfree-offset = offset + omap_oobinfo.eccbytes;
+   omap_oobinfo.oobfree-length = info-mtd.oobsize -
+   (offset + omap_oobinfo.eccbytes);
+
+   info-nand.ecc.layout = omap_oobinfo;
+   }
 
 #ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(info-mtd, part_probes, info-parts, 0);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 3/7] omap: gpmc: enable irq mode in gpmc

2011-01-04 Thread Sukumar Ghorai
add support the irq mode in GPMC.
gpmc_init() function move after omap_init_irq() as it has dependecy on irq.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom2.c  |2 +
 arch/arm/mach-omap2/board-zoom3.c  |2 +
 arch/arm/mach-omap2/gpmc.c |   39 ++-
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |4 +++
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 27 files changed, 81 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index b527f8d..11c89dc 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -145,6 +145,7 @@ static void __init omap_2430sdp_init_irq(void)
omap_board_config_size = ARRAY_SIZE(sdp2430_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 470872e..690fecd 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -328,6 +328,7 @@ static void __init omap_3430sdp_init_irq(void)
omap3_pm_init_cpuidle(omap3_cpuidle_params_table);
omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index 0a74141..46c1755 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -77,6 +77,7 @@ static void __init omap_sdp_init_irq(void)
omap2_init_common_hw(h8mbx00u0mer0em_sdrc_params,
h8mbx00u0mer0em_sdrc_params);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index df5a425..8d15604 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -34,6 +34,7 @@
 #include plat/common.h
 #include plat/usb.h
 #include plat/mmc.h
+#include plat/gpmc.h
 
 #include hsmmc.h
 #include timer-gp.h
@@ -222,6 +223,7 @@ static void __init omap_4430sdp_init_irq(void)
omap2_gp_clockevent_set_gptimer(1);
 #endif
gic_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index 0739950..460e3d1 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -35,6 +35,7 @@
 #include plat/common.h
 #include plat/usb.h
 #include plat/display.h
+#include plat/gpmc.h
 
 #include mux.h
 #include control.h
@@ -392,6 +393,7 @@ static void __init am3517_evm_init_irq(void)
 
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index 2c6db1a..8264e7a 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -280,6 +280,7 @@ static void __init omap_apollon_init_irq(void)
omap_board_config_size = ARRAY_SIZE(apollon_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+   gpmc_init();
omap_gpio_init();
apollon_init_smc91x();
 }
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index 63f764e..7c9a834 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -686,6 +686,7 @@ static void __init cm_t35_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
 mt46h32m32lf6_sdrc_params

[PATCH v8 5/7] omap3: nand: configurable fifo threshold to gain the throughput

2011-01-04 Thread Sukumar Ghorai
Configure the FIFO THREASHOLD value different for read and write to keep busy
both filling and to drain out of FIFO at reading and writing.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   11 +++
 arch/arm/plat-omap/include/plat/gpmc.h |5 -
 drivers/mtd/nand/omap2.c   |   22 ++
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index a2df8b1..117ab29 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -59,7 +59,6 @@
 #define GPMC_CHUNK_SHIFT   24  /* 16 MB */
 #define GPMC_SECTION_SHIFT 28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
 #define CS_NUM_SHIFT   24
 #define ENABLE_PREFETCH(0x1  7)
 #define DMA_MPU_MODE   2
@@ -595,15 +594,19 @@ EXPORT_SYMBOL(gpmc_nand_write);
 /**
  * gpmc_prefetch_enable - configures and starts prefetch transfer
  * @cs: cs (chip select) number
+ * @fifo_th: fifo threshold to be used for read/ write
  * @dma_mode: dma mode enable (1) or disable (0)
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   pr_err(gpmc: fifo threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -611,7 +614,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write)));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 054e704..9e4dc7a 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -83,6 +83,9 @@
 #define GPMC_IRQ_FIFOEVENTENABLE   0x01
 #define GPMC_IRQ_COUNT_EVENT   0x02
 
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)((val)  8)
+
 /*
  * Note that all values in this struct are in nanoseconds, while
  * the register values are in gpmc_fck cycles.
@@ -133,7 +136,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index fbe8414..f1648fd 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -244,7 +244,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -289,7 +290,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -345,8 +347,9 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
int ret;
unsigned long tim, limit;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get a sync at each frame
+* and frame

[PATCH RESEND v8 0/7] nand prefetch-irq support and ecc layout chanage

2011-01-19 Thread Sukumar Ghorai
The following set of patches applies on linux-2.6.

The main motivations behind this patch series are -
1. support NAND I/O in irq mode.
2. support of different ECC schema.
3. also add support ecc layout as like in romcode ecc layout, but not 
enabled

v8: free_irq() added; usedtimeout for this while loop.
Rebase and resend of 
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg41614.html

v7: NAND type (x16 or x8) is board specific and not omap specific; this passed 
form board file.
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg41469.html

v6: configurable transfer type from board file; 
#define irq number used for nand-irq
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg39397.html

v5: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35860.html
This address the input as to support the irq_chained in GPMC.
And resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35848.html

v4: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg34882.html
and resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32689.html

v3: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32071.html
Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31963.html

v2: Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31471.html

v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg2.html

Sukumar Ghorai (7):
  omap3630: nand: fix device size to work in polled mode
  omap3: nand: configurable transfer type per board
  omap: gpmc: enable irq mode in gpmc
  omap3: nand: prefetch in irq mode support
  omap3: nand: configurable fifo threshold to gain the throughput
  omap3: nand: ecc layout select from board file
  omap3: nand: making ecc layout as compatible with romcode ecc

 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|3 +-
 arch/arm/mach-omap2/board-3630sdp.c|4 +-
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-flash.c  |   13 +-
 arch/arm/mach-omap2/board-flash.h  |4 +-
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|3 +-
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom.c   |7 +-
 arch/arm/mach-omap2/gpmc-nand.c|7 +-
 arch/arm/mach-omap2/gpmc.c |   50 -
 arch/arm/mach-omap2/io.c   |3 -
 arch/arm/plat-omap/include/plat/gpmc.h |   17 ++-
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 arch/arm/plat-omap/include/plat/nand.h |   11 +
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |  367 +---
 32 files changed, 411 insertions(+), 129 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND v8 1/7] omap3630: nand: fix device size to work in polled mode

2011-01-19 Thread Sukumar Ghorai
zoom3 and 3630-sdp having the x16 nand device.
This patch configure gpmc as x16 and select the currect function in driver
for polled mode (without prefetch enable) transfer.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-3430sdp.c |2 +-
 arch/arm/mach-omap2/board-3630sdp.c |3 ++-
 arch/arm/mach-omap2/board-flash.c   |   10 ++
 arch/arm/mach-omap2/board-flash.h   |4 ++--
 arch/arm/mach-omap2/board-ldp.c |2 +-
 arch/arm/mach-omap2/board-zoom.c|5 +++--
 arch/arm/mach-omap2/gpmc-nand.c |7 +--
 drivers/mtd/nand/omap2.c|2 +-
 8 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index d4e41ef..8fb5f43 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -813,7 +813,7 @@ static void __init omap_3430sdp_init(void)
omap_serial_init();
usb_musb_init(musb_board_data);
board_smc91x_init();
-   board_flash_init(sdp_flash_partitions, chip_sel_3430);
+   board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
sdp3430_display_init();
enable_board_wakeup_source();
usb_ehci_init(ehci_pdata);
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index 6264564..b4ca7fc 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/input.h
 #include linux/gpio.h
+#include linux/mtd/nand.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -209,7 +210,7 @@ static void __init omap_sdp_init(void)
zoom_peripherals_init();
zoom_display_init();
board_smc91x_init();
-   board_flash_init(sdp_flash_partitions, chip_sel_sdp);
+   board_flash_init(sdp_flash_partitions, chip_sel_sdp, NAND_BUSWIDTH_16);
enable_board_wakeup_source();
usb_ehci_init(ehci_pdata);
 }
diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index fd38c05..f6b7253 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -139,11 +139,13 @@ static struct omap_nand_platform_data board_nand_data = {
 };
 
 void
-__init board_nand_init(struct mtd_partition *nand_parts, u8 nr_parts, u8 cs)
+__init board_nand_init(struct mtd_partition *nand_parts,
+   u8 nr_parts, u8 cs, int nand_type)
 {
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
-   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.devsize = nand_type;
 
gpmc_nand_init(board_nand_data);
 }
@@ -194,7 +196,7 @@ unmap:
  * @return - void.
  */
 void board_flash_init(struct flash_partitions partition_info[],
-   char chip_sel_board[][GPMC_CS_NUM])
+   char chip_sel_board[][GPMC_CS_NUM], int nand_type)
 {
u8  cs = 0;
u8  norcs = GPMC_CS_NUM + 1;
@@ -250,5 +252,5 @@ void board_flash_init(struct flash_partitions 
partition_info[],
in GPMC\n);
else
board_nand_init(partition_info[2].parts,
-   partition_info[2].nr_parts, nandcs);
+   partition_info[2].nr_parts, nandcs, nand_type);
 }
diff --git a/arch/arm/mach-omap2/board-flash.h 
b/arch/arm/mach-omap2/board-flash.h
index 69befe0..c240a3f 100644
--- a/arch/arm/mach-omap2/board-flash.h
+++ b/arch/arm/mach-omap2/board-flash.h
@@ -25,6 +25,6 @@ struct flash_partitions {
 };
 
 extern void board_flash_init(struct flash_partitions [],
-   char chip_sel[][GPMC_CS_NUM]);
+   char chip_sel[][GPMC_CS_NUM], int nand_type);
 extern void board_nand_init(struct mtd_partition *nand_parts,
-   u8 nr_parts, u8 cs);
+   u8 nr_parts, u8 cs, int nand_type);
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index e5dc748..d986d32 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -434,7 +434,7 @@ static void __init omap_ldp_init(void)
omap_serial_init();
usb_musb_init(musb_board_data);
board_nand_init(ldp_nand_partitions,
-   ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS);
+   ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
 
omap2_hsmmc_init(mmc);
/* link regulators to MMC adapters */
diff --git a/arch/arm/mach-omap2/board-zoom.c b/arch/arm/mach-omap2/board-zoom.c
index e26754c..0242611 100644
--- a/arch/arm/mach-omap2/board-zoom.c
+++ b/arch/arm/mach-omap2/board-zoom.c
@@ -16,6 +16,7 @@
 #include linux/input.h
 #include linux/gpio.h
 #include linux/i2c

[PATCH RESEND v8 2/7] omap3: nand: configurable transfer type per board

2011-01-19 Thread Sukumar Ghorai
nand transfer type (sDMA, Polled, prefetch) can be select from board file,
enabling all transfer type in driver, by default.

this helps in multi-omap build and to select different transfer type for
different board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/nand.h |7 +++
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |   94 
 3 files changed, 41 insertions(+), 77 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd0..78c0bdb 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -10,6 +10,12 @@
 
 #include linux/mtd/partitions.h
 
+enum nand_io {
+   NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
+   NAND_OMAP_POLLED,   /* polled mode, without prefetch */
+   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+};
+
 struct omap_nand_platform_data {
unsigned intoptions;
int cs;
@@ -20,6 +26,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
 };
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index c895922..178e200 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -106,23 +106,6 @@ config MTD_NAND_OMAP2
help
   Support for NAND flash on Texas Instruments OMAP2 and OMAP3 
platforms.
 
-config MTD_NAND_OMAP_PREFETCH
-   bool GPMC prefetch support for NAND Flash device
-   depends on MTD_NAND_OMAP2
-   default y
-   help
-The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
-to improve the performance.
-
-config MTD_NAND_OMAP_PREFETCH_DMA
-   depends on MTD_NAND_OMAP_PREFETCH
-   bool DMA mode
-   default n
-   help
-The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
-or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
-
 config MTD_NAND_IDS
tristate
 
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 7c04cd6..60bac8e 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -96,27 +96,6 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH
-static int use_prefetch = 1;
-
-/* modprobe ... use_prefetch=0 etc */
-module_param(use_prefetch, bool, 0);
-MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
-
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
-static int use_dma = 1;
-
-/* modprobe ... use_dma=0 etc */
-module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
-#else
-static const int use_dma;
-#endif
-#else
-const int use_prefetch;
-static const int use_dma;
-#endif
-
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -324,7 +303,6 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
 /*
  * omap_nand_dma_cb: callback on the completion of dma transfer
  * @lch: logical channel
@@ -426,14 +404,6 @@ out_copy:
: omap_write_buf8(mtd, (u_char *) addr, len);
return 0;
 }
-#else
-static void omap_nand_dma_cb(int lch, u16 ch_status, void *data) {}
-static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
-   unsigned int len, int is_write)
-{
-   return 0;
-}
-#endif
 
 /**
  * omap_read_buf_dma_pref - read data from NAND controller into buffer
@@ -842,28 +812,13 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
info-nand.chip_delay = 50;
}
 
-   if (use_prefetch) {
-
+   switch (pdata-xfer_type) {
+   case NAND_OMAP_PREFETCH_POLLED:
info-nand.read_buf   = omap_read_buf_pref;
info-nand.write_buf  = omap_write_buf_pref;
-   if (use_dma) {
-   err = omap_request_dma(OMAP24XX_DMA_GPMC, NAND,
-   omap_nand_dma_cb, info-comp, info-dma_ch);
-   if (err  0) {
-   info-dma_ch = -1;
-   printk(KERN_WARNING DMA request failed.
-Non-dma data transfer mode\n);
-   } else {
-   omap_set_dma_dest_burst_mode(info-dma_ch,
-   OMAP_DMA_DATA_BURST_16);
-   omap_set_dma_src_burst_mode

[PATCH RESEND v8 5/7] omap3: nand: configurable fifo threshold to gain the throughput

2011-01-19 Thread Sukumar Ghorai
Configure the FIFO THREASHOLD value different for read and write to keep busy
both filling and to drain out of FIFO at reading and writing.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   11 +++
 arch/arm/plat-omap/include/plat/gpmc.h |5 -
 drivers/mtd/nand/omap2.c   |   22 ++
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index b198598..29c9732 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -59,7 +59,6 @@
 #define GPMC_CHUNK_SHIFT   24  /* 16 MB */
 #define GPMC_SECTION_SHIFT 28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
 #define CS_NUM_SHIFT   24
 #define ENABLE_PREFETCH(0x1  7)
 #define DMA_MPU_MODE   2
@@ -605,15 +604,19 @@ EXPORT_SYMBOL(gpmc_nand_write);
 /**
  * gpmc_prefetch_enable - configures and starts prefetch transfer
  * @cs: cs (chip select) number
+ * @fifo_th: fifo threshold to be used for read/ write
  * @dma_mode: dma mode enable (1) or disable (0)
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   pr_err(gpmc: fifo threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -621,7 +624,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write)));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index ffd2a24..1b4a095 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -83,6 +83,9 @@
 #define GPMC_IRQ_FIFOEVENTENABLE   0x01
 #define GPMC_IRQ_COUNT_EVENT   0x02
 
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)((val)  8)
+
 /*
  * Note that all values in this struct are in nanoseconds except sync_clk
  * (which is in picoseconds), while the register values are in gpmc_fck cycles.
@@ -134,7 +137,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index fbe8414..f1648fd 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -244,7 +244,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -289,7 +290,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -345,8 +347,9 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
int ret;
unsigned long tim, limit;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get

[PATCH RESEND v8 4/7] omap3: nand: prefetch in irq mode support

2011-01-19 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for nand transfer(read, write)

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |2 +
 arch/arm/plat-omap/include/plat/nand.h |4 +-
 drivers/mtd/nand/omap2.c   |  198 ++--
 3 files changed, 194 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index f6b7253..1964509 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -16,6 +16,7 @@
 #include linux/platform_device.h
 #include linux/mtd/physmap.h
 #include linux/io.h
+#include plat/irqs.h
 
 #include plat/gpmc.h
 #include plat/nand.h
@@ -147,6 +148,7 @@ __init board_nand_init(struct mtd_partition *nand_parts,
board_nand_data.nr_parts= nr_parts;
board_nand_data.devsize = nand_type;
 
+   board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
 #else
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 78c0bdb..ae5e053 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -13,7 +13,8 @@
 enum nand_io {
NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
NAND_OMAP_POLLED,   /* polled mode, without prefetch */
-   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_DMA, /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_IRQ  /* prefetch enabled irq mode */
 };
 
 struct omap_nand_platform_data {
@@ -26,6 +27,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 60bac8e..fbe8414 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -24,6 +25,7 @@
 #include plat/nand.h
 
 #defineDRIVER_NAME omap2-nand
+#defineOMAP_NAND_TIMEOUT_MS5000
 
 #define NAND_Ecc_P1e   (1  0)
 #define NAND_Ecc_P2e   (1  1)
@@ -108,6 +110,13 @@ struct omap_nand_info {
unsigned long   phys_base;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   enum {
+   OMAP_NAND_IO_READ = 0,  /* read */
+   OMAP_NAND_IO_WRITE, /* write */
+   } iomode;
+   u_char  *buf;
+   int buf_len;
 };
 
 /**
@@ -267,9 +276,10 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
 {
struct omap_nand_info *info = container_of(mtd,
struct omap_nand_info, mtd);
-   uint32_t pref_count = 0, w_count = 0;
+   uint32_t w_count = 0;
int i = 0, ret = 0;
u16 *p;
+   unsigned long tim, limit;
 
/* take care of subpage writes */
if (len % 2 != 0) {
@@ -295,9 +305,12 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
iowrite16(*p++, info-nand.IO_ADDR_W);
}
/* wait for data to flushed-out before reset the prefetch */
-   do {
-   pref_count = gpmc_read_status(GPMC_PREFETCH_COUNT);
-   } while (pref_count);
+   tim = 0;
+   limit = (loops_per_jiffy *
+   msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS));
+   while (gpmc_read_status(GPMC_PREFETCH_COUNT)  (tim++  limit))
+   cpu_relax();
+
/* disable and stop the PFPW engine */
gpmc_prefetch_reset(info-gpmc_cs);
}
@@ -326,11 +339,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
 {
struct omap_nand_info *info = container_of(mtd,
struct omap_nand_info, mtd);
-   uint32_t prefetch_status = 0;
enum dma_data_direction dir = is_write ? DMA_TO_DEVICE :
DMA_FROM_DEVICE;
dma_addr_t dma_addr;
int ret;
+   unsigned long tim, limit;
 
/* The fifo depth is 64 bytes. We have a sync at each frame and frame
 * length is 64 bytes.
@@ -376,7 +389,7 @@ static

[PATCH RESEND v8 3/7] omap: gpmc: enable irq mode in gpmc

2011-01-19 Thread Sukumar Ghorai
add support the irq mode in GPMC.
gpmc_init() function move after omap_init_irq() as it has dependecy on irq.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c|1 +
 arch/arm/mach-omap2/board-3430sdp.c|1 +
 arch/arm/mach-omap2/board-3630sdp.c|1 +
 arch/arm/mach-omap2/board-4430sdp.c|2 +
 arch/arm/mach-omap2/board-am3517evm.c  |2 +
 arch/arm/mach-omap2/board-apollon.c|1 +
 arch/arm/mach-omap2/board-cm-t35.c |1 +
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-generic.c|2 +
 arch/arm/mach-omap2/board-h4.c |1 +
 arch/arm/mach-omap2/board-igep0020.c   |1 +
 arch/arm/mach-omap2/board-ldp.c|1 +
 arch/arm/mach-omap2/board-n8x0.c   |2 +
 arch/arm/mach-omap2/board-omap3beagle.c|1 +
 arch/arm/mach-omap2/board-omap3evm.c   |2 +
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +
 arch/arm/mach-omap2/board-omap3stalker.c   |1 +
 arch/arm/mach-omap2/board-omap3touchbook.c |1 +
 arch/arm/mach-omap2/board-omap4panda.c |2 +
 arch/arm/mach-omap2/board-overo.c  |1 +
 arch/arm/mach-omap2/board-rx51.c   |1 +
 arch/arm/mach-omap2/board-zoom.c   |2 +
 arch/arm/mach-omap2/gpmc.c |   39 ++-
 arch/arm/mach-omap2/io.c   |3 --
 arch/arm/plat-omap/include/plat/gpmc.h |4 +++
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 26 files changed, 79 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index e066177..527374f 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -146,6 +146,7 @@ static void __init omap_2430sdp_init_irq(void)
omap2_init_common_infrastructure();
omap2_init_common_devices(NULL, NULL);
omap_init_irq();
+   gpmc_init();
 }
 
 static struct twl4030_gpio_platform_data sdp2430_gpio_data = {
diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index 8fb5f43..8304d16 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -335,6 +335,7 @@ static void __init omap_3430sdp_init_irq(void)
omap2_init_common_infrastructure();
omap2_init_common_devices(hyb18m512160af6_sdrc_params, NULL);
omap_init_irq();
+   gpmc_init();
 }
 
 static int sdp3430_batt_table[] = {
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index b4ca7fc..befebde 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -78,6 +78,7 @@ static void __init omap_sdp_init_irq(void)
omap2_init_common_devices(h8mbx00u0mer0em_sdrc_params,
  h8mbx00u0mer0em_sdrc_params);
omap_init_irq();
+   gpmc_init();
 }
 
 #ifdef CONFIG_OMAP_MUX
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index 07d1b20..2c125ab 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -35,6 +35,7 @@
 #include plat/common.h
 #include plat/usb.h
 #include plat/mmc.h
+#include plat/gpmc.h
 
 #include mux.h
 #include hsmmc.h
@@ -249,6 +250,7 @@ static void __init omap_4430sdp_init_irq(void)
omap2_gp_clockevent_set_gptimer(1);
 #endif
gic_init_irq();
+   gpmc_init();
 }
 
 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index 10d60b7..2d87087 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -35,6 +35,7 @@
 #include plat/common.h
 #include plat/usb.h
 #include plat/display.h
+#include plat/gpmc.h
 #include plat/panel-generic-dpi.h
 
 #include mux.h
@@ -403,6 +404,7 @@ static void __init am3517_evm_init_irq(void)
omap2_init_common_infrastructure();
omap2_init_common_devices(NULL, NULL);
omap_init_irq();
+   gpmc_init();
 }
 
 static struct omap_musb_board_data musb_board_data = {
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index 9f55b68..09f6322 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -281,6 +281,7 @@ static void __init omap_apollon_init_irq(void)
omap2_init_common_infrastructure();
omap2_init_common_devices(NULL, NULL);
omap_init_irq();
+   gpmc_init();
 }
 
 static void __init apollon_led_init(void)
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index dac1416..8aca46f 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -692,6 +692,7 @@ static void __init cm_t35_init_irq(void

[PATCH RESEND v8 7/7] omap3: nand: making ecc layout as compatible with romcode ecc

2011-01-19 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-loader, u-boot and kernel.

This enables to flash x-loader, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

This patch does not enables this feature by default and need to pass from
board file to enable for any board.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/gpmc.h |2 +
 drivers/mtd/nand/omap2.c   |   37 +++-
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 4626e7a..49aea09 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -90,6 +90,8 @@ enum omap_ecc {
/* 1-bit ecc: stored at end of spare area */
OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+   /* 1-bit ecc: stored at begining of spare area as romcode */
+   OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method  romcode layout */
 };
 
 /*
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 6d4a42e..4e33972 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -98,6 +98,20 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
+/* oob info generated runtime depending on ecc algorithm and layout selected */
+static struct nand_ecclayout omap_oobinfo;
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -914,6 +928,7 @@ static int __devinit omap_nand_probe(struct platform_device 
*pdev)
struct omap_nand_info   *info;
struct omap_nand_platform_data  *pdata;
int err;
+   int i, offset;
 
pdata = pdev-dev.platform_data;
if (pdata == NULL) {
@@ -1037,7 +1052,8 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
/* selsect the ecc type */
if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DEFAULT)
info-nand.ecc.mode = NAND_ECC_SOFT;
-   else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) {
+   else if ((pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) ||
+   (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE)) {
info-nand.ecc.bytes= 3;
info-nand.ecc.size = 512;
info-nand.ecc.calculate= omap_calculate_ecc;
@@ -1057,6 +1073,25 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
}
 
+   /* rom code layout */
+   if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE) {
+
+   if (info-nand.options  NAND_BUSWIDTH_16)
+   offset = 2;
+   else {
+   offset = 1;
+   info-nand.badblock_pattern = bb_descrip_flashbased;
+   }
+   omap_oobinfo.eccbytes = 3 * (info-mtd.oobsize/16);
+   for (i = 0; i  omap_oobinfo.eccbytes; i++)
+   omap_oobinfo.eccpos[i] = i+offset;
+
+   omap_oobinfo.oobfree-offset = offset + omap_oobinfo.eccbytes;
+   omap_oobinfo.oobfree-length = info-mtd.oobsize -
+   (offset + omap_oobinfo.eccbytes);
+
+   info-nand.ecc.layout = omap_oobinfo;
+   }
 
 #ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(info-mtd, part_probes, info-parts, 0);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND v8 6/7] omap3: nand: ecc layout select from board file

2011-01-19 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |1 +
 arch/arm/plat-omap/include/plat/gpmc.h |6 ++
 arch/arm/plat-omap/include/plat/nand.h |2 ++
 drivers/mtd/nand/omap2.c   |   26 +++---
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 1964509..a768198 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -148,6 +148,7 @@ __init board_nand_init(struct mtd_partition *nand_parts,
board_nand_data.nr_parts= nr_parts;
board_nand_data.devsize = nand_type;
 
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DEFAULT;
board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 1b4a095..4626e7a 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -86,6 +86,12 @@
 #define PREFETCH_FIFOTHRESHOLD_MAX 0x40
 #define PREFETCH_FIFOTHRESHOLD(val)((val)  8)
 
+enum omap_ecc {
+   /* 1-bit ecc: stored at end of spare area */
+   OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
+   OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+};
+
 /*
  * Note that all values in this struct are in nanoseconds except sync_clk
  * (which is in picoseconds), while the register values are in gpmc_fck cycles.
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index ae5e053..d86d1ec 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include plat/gpmc.h
 #include linux/mtd/partitions.h
 
 enum nand_io {
@@ -31,6 +32,7 @@ struct omap_nand_platform_data {
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
+   enum omap_ecc   ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index f1648fd..6d4a42e 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -626,8 +626,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -847,8 +845,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
gpmc_enable_hwecc(info-gpmc_cs, mode, dev_width, info-nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
@@ -1038,17 +1034,17 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
 
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
-
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* selsect the ecc type */
+   if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DEFAULT)
+   info-nand.ecc.mode = NAND_ECC_SOFT;
+   else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
+   }
 
/* DIP switches on some boards change between 8 and 16 bit
 * bus widths for flash.  Try the other width if the first try fails.
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] omap3: nand: bch ecc support added

2011-01-20 Thread Sukumar Ghorai
bch error correction (t=4 and t=8) for 512 bytes support added.
Tested in omap-3630 es-1.1 silicon.

Need to select the bch-ecc from board file. E.g.
arch/arm/mach-omap2/board-flash.c: board_nand_init()
board_nand_data.ecc_opt = OMAP_ECC_BCH4_CODE_HW

This patch has dependency on -
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg42658.html

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |  126 ---
 arch/arm/plat-omap/include/plat/gpmc.h |6 +-
 drivers/mtd/nand/Makefile  |1 +
 drivers/mtd/nand/omap2.c   |  119 --
 drivers/mtd/nand/omap_bch_decoder.c|  393 
 5 files changed, 583 insertions(+), 62 deletions(-)
 create mode 100644 drivers/mtd/nand/omap_bch_decoder.c

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 29c9732..91cfdca 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -48,6 +48,7 @@
 #define GPMC_ECC_CONTROL   0x1f8
 #define GPMC_ECC_SIZE_CONFIG   0x1fc
 #define GPMC_ECC1_RESULT0x200
+#define GPMC_ECC_BCH_RESULT_0  0x240
 
 #define GPMC_CS0_OFFSET0x60
 #define GPMC_CS_SIZE   0x30
@@ -94,7 +95,6 @@ static struct resourcegpmc_mem_root;
 static struct resource gpmc_cs_mem[GPMC_CS_NUM];
 static DEFINE_SPINLOCK(gpmc_mem_lock);
 static unsigned int gpmc_cs_map;   /* flag for cs which are initialized */
-static int gpmc_ecc_used = -EINVAL;/* cs using ecc engine */
 
 static void __iomem *gpmc_base;
 
@@ -832,52 +832,77 @@ void omap3_gpmc_restore_context(void)
 
 /**
  * gpmc_enable_hwecc - enable hardware ecc functionality
+ * @ecc_type: ecc type e.g. Hamming, BCH
  * @cs: chip select number
  * @mode: read/write mode
  * @dev_width: device bus width(1 for x16, 0 for x8)
  * @ecc_size: bytes for which ECC will be generated
  */
-int gpmc_enable_hwecc(int cs, int mode, int dev_width, int ecc_size)
+int gpmc_enable_hwecc(int ecc_type, int cs, int mode,
+   int dev_width, int ecc_size)
 {
-   unsigned int val;
-
-   /* check if ecc module is in used */
-   if (gpmc_ecc_used != -EINVAL)
-   return -EINVAL;
-
-   gpmc_ecc_used = cs;
-
-   /* clear ecc and enable bits */
-   val = ((0x00018) | 0x0001);
-   gpmc_write_reg(GPMC_ECC_CONTROL, val);
-
-   /* program ecc and result sizes */
-   val = ecc_size  1) - 1)  22) | (0x000F));
-   gpmc_write_reg(GPMC_ECC_SIZE_CONFIG, val);
+   unsigned int bch_mod = 0, bch_wrapmode = 0, eccsize1 = 0, eccsize0 = 0;
+   unsigned int ecc_conf_val = 0, ecc_size_conf_val = 0;
 
switch (mode) {
case GPMC_ECC_READ:
-   gpmc_write_reg(GPMC_ECC_CONTROL, 0x101);
+   if (ecc_type == OMAP_ECC_BCH4_CODE_HW) {
+   eccsize1 = 0xD; eccsize0 = 0x48;
+   bch_mod = 0;
+   bch_wrapmode = 0x09;
+   } else if (ecc_type == OMAP_ECC_BCH8_CODE_HW) {
+   eccsize1 = 0x1A; eccsize0 = 0x18;
+   bch_mod = 1;
+   bch_wrapmode = 0x04;
+   } else
+   eccsize1 = ((ecc_size  1) - 1)  22;
break;
+
case GPMC_ECC_READSYN:
-gpmc_write_reg(GPMC_ECC_CONTROL, 0x100);
break;
+
case GPMC_ECC_WRITE:
-   gpmc_write_reg(GPMC_ECC_CONTROL, 0x101);
+   if (ecc_type == OMAP_ECC_BCH4_CODE_HW) {
+   eccsize1 = 0x20; eccsize0 = 0x00;
+   bch_mod = 0;
+   bch_wrapmode = 0x06;
+   } else if (ecc_type == OMAP_ECC_BCH8_CODE_HW) {
+   eccsize1 = 0x20; eccsize0 = 0x00;
+   bch_mod = 1;
+   bch_wrapmode = 0x06;
+   } else
+   eccsize1 = ((ecc_size  1) - 1)  22;
break;
+
default:
printk(KERN_INFO Error: Unrecognized Mode[%d]!\n, mode);
break;
}
 
-   /* (ECC 16 or 8 bit col) | ( CS  )  | ECC Enable */
-   val = (dev_width  7) | (cs  1) | (0x1);
-   gpmc_write_reg(GPMC_ECC_CONFIG, val);
+   /* clear ecc and enable bits */
+   if ((ecc_type == OMAP_ECC_BCH4_CODE_HW) ||
+   (ecc_type == OMAP_ECC_BCH8_CODE_HW)) {
+   gpmc_write_reg(GPMC_ECC_CONTROL, 0x0001);
+   ecc_size_conf_val = (eccsize1  22) | (eccsize0  12);
+   ecc_conf_val = ((0x01  16) | (bch_mod  12)
+   | (bch_wrapmode  8) | (dev_width  7)
+   | (0x03  4) | (cs  1) | (0x1));
+   } else {
+   gpmc_write_reg(GPMC_ECC_CONTROL, 0x0101);
+   ecc_size_conf_val = (eccsize1  22) | 0x000F;
+   ecc_conf_val = (dev_width  7) | (cs  1) | (0x1);
+   }
+
+   gpmc_write_reg

[PATCH v9 0/7] nand prefetch-irq support and ecc layout chanage

2011-01-28 Thread Sukumar Ghorai
The following set of patches applies on linux-2.6.

The main motivations behind this patch series are -
1. support NAND I/O in irq mode.
2. support of different ECC schema.
3. also add support ecc layout as like in romcode ecc layout, but not 
enabled

v9: gpmc_init() changed to postcore_initcall(gpmc_init);

v8: free_irq() added; used timeout for while(tight loop)
And resend of 
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg41614.html

v7: NAND type (x16 or x8) is board specific and not omap specific; this passed 
form board file.
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg41469.html

v6: configurable transfer type from board file; 
#define irq number used for nand-irq
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg39397.html

v5: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35860.html
This address the input as to support the irq_chained in GPMC.
And resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35848.html

v4: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg34882.html
and resend of
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32689.html

v3: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32071.html
Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31963.html

v2: Rebase on latest codebase and previous patch(posted).
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg31471.html

v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg2.html

Sukumar Ghorai (7):
  omap3630: nand: fix device size to work in polled mode
  omap3: nand: configurable transfer type per board
  omap: gpmc: enable irq mode in gpmc
  omap3: nand: prefetch in irq mode support
  omap3: nand: configurable fifo threshold to gain the throughput
  omap3: nand: ecc layout select from board file
  omap3: nand: making ecc layout as compatible with romcode ecc

 arch/arm/mach-omap2/board-3430sdp.c|2 +-
 arch/arm/mach-omap2/board-3630sdp.c|3 +-
 arch/arm/mach-omap2/board-flash.c  |   13 +-
 arch/arm/mach-omap2/board-flash.h  |4 +-
 arch/arm/mach-omap2/board-ldp.c|2 +-
 arch/arm/mach-omap2/board-zoom.c   |5 +-
 arch/arm/mach-omap2/gpmc-nand.c|7 +-
 arch/arm/mach-omap2/gpmc.c |   56 +-
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |   18 ++-
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 arch/arm/plat-omap/include/plat/nand.h |   11 +
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |  367 
 14 files changed, 386 insertions(+), 130 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v9 1/7] omap3630: nand: fix device size to work in polled mode

2011-01-28 Thread Sukumar Ghorai
zoom3 and 3630-sdp having the x16 nand device.
This patch configure gpmc as x16 and select the currect function in driver
for polled mode (without prefetch enable) transfer.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-3430sdp.c |2 +-
 arch/arm/mach-omap2/board-3630sdp.c |3 ++-
 arch/arm/mach-omap2/board-flash.c   |   10 ++
 arch/arm/mach-omap2/board-flash.h   |4 ++--
 arch/arm/mach-omap2/board-ldp.c |2 +-
 arch/arm/mach-omap2/board-zoom.c|5 +++--
 arch/arm/mach-omap2/gpmc-nand.c |7 +--
 drivers/mtd/nand/omap2.c|2 +-
 8 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index d4e41ef..8fb5f43 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -813,7 +813,7 @@ static void __init omap_3430sdp_init(void)
omap_serial_init();
usb_musb_init(musb_board_data);
board_smc91x_init();
-   board_flash_init(sdp_flash_partitions, chip_sel_3430);
+   board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
sdp3430_display_init();
enable_board_wakeup_source();
usb_ehci_init(ehci_pdata);
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index 6264564..b4ca7fc 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/input.h
 #include linux/gpio.h
+#include linux/mtd/nand.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -209,7 +210,7 @@ static void __init omap_sdp_init(void)
zoom_peripherals_init();
zoom_display_init();
board_smc91x_init();
-   board_flash_init(sdp_flash_partitions, chip_sel_sdp);
+   board_flash_init(sdp_flash_partitions, chip_sel_sdp, NAND_BUSWIDTH_16);
enable_board_wakeup_source();
usb_ehci_init(ehci_pdata);
 }
diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index fd38c05..f6b7253 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -139,11 +139,13 @@ static struct omap_nand_platform_data board_nand_data = {
 };
 
 void
-__init board_nand_init(struct mtd_partition *nand_parts, u8 nr_parts, u8 cs)
+__init board_nand_init(struct mtd_partition *nand_parts,
+   u8 nr_parts, u8 cs, int nand_type)
 {
board_nand_data.cs  = cs;
board_nand_data.parts   = nand_parts;
-   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.nr_parts= nr_parts;
+   board_nand_data.devsize = nand_type;
 
gpmc_nand_init(board_nand_data);
 }
@@ -194,7 +196,7 @@ unmap:
  * @return - void.
  */
 void board_flash_init(struct flash_partitions partition_info[],
-   char chip_sel_board[][GPMC_CS_NUM])
+   char chip_sel_board[][GPMC_CS_NUM], int nand_type)
 {
u8  cs = 0;
u8  norcs = GPMC_CS_NUM + 1;
@@ -250,5 +252,5 @@ void board_flash_init(struct flash_partitions 
partition_info[],
in GPMC\n);
else
board_nand_init(partition_info[2].parts,
-   partition_info[2].nr_parts, nandcs);
+   partition_info[2].nr_parts, nandcs, nand_type);
 }
diff --git a/arch/arm/mach-omap2/board-flash.h 
b/arch/arm/mach-omap2/board-flash.h
index 69befe0..c240a3f 100644
--- a/arch/arm/mach-omap2/board-flash.h
+++ b/arch/arm/mach-omap2/board-flash.h
@@ -25,6 +25,6 @@ struct flash_partitions {
 };
 
 extern void board_flash_init(struct flash_partitions [],
-   char chip_sel[][GPMC_CS_NUM]);
+   char chip_sel[][GPMC_CS_NUM], int nand_type);
 extern void board_nand_init(struct mtd_partition *nand_parts,
-   u8 nr_parts, u8 cs);
+   u8 nr_parts, u8 cs, int nand_type);
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index e5dc748..d986d32 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -434,7 +434,7 @@ static void __init omap_ldp_init(void)
omap_serial_init();
usb_musb_init(musb_board_data);
board_nand_init(ldp_nand_partitions,
-   ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS);
+   ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
 
omap2_hsmmc_init(mmc);
/* link regulators to MMC adapters */
diff --git a/arch/arm/mach-omap2/board-zoom.c b/arch/arm/mach-omap2/board-zoom.c
index e26754c..0242611 100644
--- a/arch/arm/mach-omap2/board-zoom.c
+++ b/arch/arm/mach-omap2/board-zoom.c
@@ -16,6 +16,7 @@
 #include linux/input.h
 #include linux/gpio.h
 #include linux/i2c

[PATCH v9 2/7] omap3: nand: configurable transfer type per board

2011-01-28 Thread Sukumar Ghorai
nand transfer type (sDMA, Polled, prefetch) can be select from board file,
enabling all transfer type in driver, by default.

this helps in multi-omap build and to select different transfer type for
different board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/nand.h |7 +++
 drivers/mtd/nand/Kconfig   |   17 --
 drivers/mtd/nand/omap2.c   |   94 
 3 files changed, 41 insertions(+), 77 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd0..78c0bdb 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -10,6 +10,12 @@
 
 #include linux/mtd/partitions.h
 
+enum nand_io {
+   NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
+   NAND_OMAP_POLLED,   /* polled mode, without prefetch */
+   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+};
+
 struct omap_nand_platform_data {
unsigned intoptions;
int cs;
@@ -20,6 +26,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
 };
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index c895922..178e200 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -106,23 +106,6 @@ config MTD_NAND_OMAP2
help
   Support for NAND flash on Texas Instruments OMAP2 and OMAP3 
platforms.
 
-config MTD_NAND_OMAP_PREFETCH
-   bool GPMC prefetch support for NAND Flash device
-   depends on MTD_NAND_OMAP2
-   default y
-   help
-The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
-to improve the performance.
-
-config MTD_NAND_OMAP_PREFETCH_DMA
-   depends on MTD_NAND_OMAP_PREFETCH
-   bool DMA mode
-   default n
-   help
-The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
-or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
-
 config MTD_NAND_IDS
tristate
 
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 7c04cd6..60bac8e 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -96,27 +96,6 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH
-static int use_prefetch = 1;
-
-/* modprobe ... use_prefetch=0 etc */
-module_param(use_prefetch, bool, 0);
-MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
-
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
-static int use_dma = 1;
-
-/* modprobe ... use_dma=0 etc */
-module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
-#else
-static const int use_dma;
-#endif
-#else
-const int use_prefetch;
-static const int use_dma;
-#endif
-
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -324,7 +303,6 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
 /*
  * omap_nand_dma_cb: callback on the completion of dma transfer
  * @lch: logical channel
@@ -426,14 +404,6 @@ out_copy:
: omap_write_buf8(mtd, (u_char *) addr, len);
return 0;
 }
-#else
-static void omap_nand_dma_cb(int lch, u16 ch_status, void *data) {}
-static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
-   unsigned int len, int is_write)
-{
-   return 0;
-}
-#endif
 
 /**
  * omap_read_buf_dma_pref - read data from NAND controller into buffer
@@ -842,28 +812,13 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
info-nand.chip_delay = 50;
}
 
-   if (use_prefetch) {
-
+   switch (pdata-xfer_type) {
+   case NAND_OMAP_PREFETCH_POLLED:
info-nand.read_buf   = omap_read_buf_pref;
info-nand.write_buf  = omap_write_buf_pref;
-   if (use_dma) {
-   err = omap_request_dma(OMAP24XX_DMA_GPMC, NAND,
-   omap_nand_dma_cb, info-comp, info-dma_ch);
-   if (err  0) {
-   info-dma_ch = -1;
-   printk(KERN_WARNING DMA request failed.
-Non-dma data transfer mode\n);
-   } else {
-   omap_set_dma_dest_burst_mode(info-dma_ch,
-   OMAP_DMA_DATA_BURST_16);
-   omap_set_dma_src_burst_mode

[PATCH v9 3/7] omap: gpmc: enable irq mode in gpmc

2011-01-28 Thread Sukumar Ghorai
add support the irq mode in GPMC.
gpmc_init() function move after omap_init_irq() as it has dependecy on irq.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   45 +--
 arch/arm/mach-omap2/io.c   |2 -
 arch/arm/plat-omap/include/plat/gpmc.h |5 +++-
 arch/arm/plat-omap/include/plat/irqs.h |9 +-
 4 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 1b7b3e7..382dea8 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -14,6 +14,7 @@
  */
 #undef DEBUG
 
+#include linux/irq.h
 #include linux/kernel.h
 #include linux/init.h
 #include linux/err.h
@@ -22,6 +23,7 @@
 #include linux/spinlock.h
 #include linux/io.h
 #include linux/module.h
+#include linux/interrupt.h
 
 #include asm/mach-types.h
 #include plat/gpmc.h
@@ -100,6 +102,8 @@ static void __iomem *gpmc_base;
 
 static struct clk *gpmc_l3_clk;
 
+static irqreturn_t gpmc_handle_irq(int irq, void *dev);
+
 static void gpmc_write_reg(int idx, u32 val)
 {
__raw_writel(val, gpmc_base + idx);
@@ -497,6 +501,10 @@ int gpmc_cs_configure(int cs, int cmd, int wval)
u32 regval = 0;
 
switch (cmd) {
+   case GPMC_ENABLE_IRQ:
+   gpmc_write_reg(GPMC_IRQENABLE, wval);
+   break;
+
case GPMC_SET_IRQ_STATUS:
gpmc_write_reg(GPMC_IRQSTATUS, wval);
break;
@@ -678,9 +686,10 @@ static void __init gpmc_mem_init(void)
}
 }
 
-void __init gpmc_init(void)
+static int __init gpmc_init(void)
 {
-   u32 l;
+   u32 l, irq;
+   int cs, ret = -EINVAL;
char *ck = NULL;
 
if (cpu_is_omap24xx()) {
@@ -698,7 +707,7 @@ void __init gpmc_init(void)
}
 
if (WARN_ON(!ck))
-   return;
+   return ret;
 
gpmc_l3_clk = clk_get(NULL, ck);
if (IS_ERR(gpmc_l3_clk)) {
@@ -723,6 +732,36 @@ void __init gpmc_init(void)
l |= (0x02  3) | (1  0);
gpmc_write_reg(GPMC_SYSCONFIG, l);
gpmc_mem_init();
+
+   /* initalize the irq_chained */
+   irq = OMAP_GPMC_IRQ_BASE;
+   for (cs = 0; cs  GPMC_CS_NUM; cs++) {
+   set_irq_handler(irq, handle_simple_irq);
+   set_irq_flags(irq, IRQF_VALID);
+   irq++;
+   }
+
+   ret = request_irq(INT_34XX_GPMC_IRQ,
+   gpmc_handle_irq, IRQF_SHARED, gpmc, gpmc_base);
+   if (ret)
+   pr_err(gpmc: irq-%d could not claim: err %d\n,
+   INT_34XX_GPMC_IRQ, ret);
+   return ret;
+}
+postcore_initcall(gpmc_init);
+
+static irqreturn_t gpmc_handle_irq(int irq, void *dev)
+{
+   u8 cs;
+
+   if (irq != INT_34XX_GPMC_IRQ)
+   return IRQ_HANDLED;
+   /* check cs to invoke the irq */
+   cs = ((gpmc_read_reg(GPMC_PREFETCH_CONFIG1))  CS_NUM_SHIFT)  0x7;
+   if (OMAP_GPMC_IRQ_BASE+cs = OMAP_GPMC_IRQ_END)
+   generic_handle_irq(OMAP_GPMC_IRQ_BASE+cs);
+
+   return IRQ_HANDLED;
 }
 
 #ifdef CONFIG_ARCH_OMAP3
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index e66687b..b60287c 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -30,7 +30,6 @@
 
 #include plat/sram.h
 #include plat/sdrc.h
-#include plat/gpmc.h
 #include plat/serial.h
 
 #include clock2xxx.h
@@ -408,7 +407,6 @@ void __init omap2_init_common_devices(struct 
omap_sdrc_params *sdrc_cs0,
omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
_omap2_init_reprogram_sdrc();
}
-   gpmc_init();
 
omap_irq_base_init();
 }
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 85ded59..9c060da 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -41,6 +41,8 @@
 #define GPMC_NAND_ADDRESS  0x000b
 #define GPMC_NAND_DATA 0x000c
 
+#define GPMC_ENABLE_IRQ0x000d
+
 /* ECC commands */
 #define GPMC_ECC_READ  0 /* Reset Hardware ECC for read */
 #define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */
@@ -78,6 +80,8 @@
 #define WR_RD_PIN_MONITORING   0x0060
 #define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val  24)  0x7F)
 #define GPMC_PREFETCH_STATUS_COUNT(val)(val  0x3fff)
+#define GPMC_IRQ_FIFOEVENTENABLE   0x01
+#define GPMC_IRQ_COUNT_EVENT   0x02
 
 /*
  * Note that all values in this struct are in nanoseconds except sync_clk
@@ -135,7 +139,6 @@ extern int gpmc_prefetch_enable(int cs, int dma_mode,
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
 extern void omap3_gpmc_restore_context(void);
-extern void gpmc_init(void);
 extern int gpmc_read_status(int cmd);
 extern int gpmc_cs_configure(int cs, int cmd, int wval);
 extern int gpmc_nand_read(int cs, int cmd);
diff --git

[PATCH v9 6/7] omap3: nand: ecc layout select from board file

2011-01-28 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |1 +
 arch/arm/plat-omap/include/plat/gpmc.h |6 ++
 arch/arm/plat-omap/include/plat/nand.h |2 ++
 drivers/mtd/nand/omap2.c   |   26 +++---
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index 1964509..a768198 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -148,6 +148,7 @@ __init board_nand_init(struct mtd_partition *nand_parts,
board_nand_data.nr_parts= nr_parts;
board_nand_data.devsize = nand_type;
 
+   board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DEFAULT;
board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index a243463..773351b 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -86,6 +86,12 @@
 #define PREFETCH_FIFOTHRESHOLD_MAX 0x40
 #define PREFETCH_FIFOTHRESHOLD(val)((val)  8)
 
+enum omap_ecc {
+   /* 1-bit ecc: stored at end of spare area */
+   OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
+   OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+};
+
 /*
  * Note that all values in this struct are in nanoseconds except sync_clk
  * (which is in picoseconds), while the register values are in gpmc_fck cycles.
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index ae5e053..d86d1ec 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include plat/gpmc.h
 #include linux/mtd/partitions.h
 
 enum nand_io {
@@ -31,6 +32,7 @@ struct omap_nand_platform_data {
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
+   enum omap_ecc   ecc_opt;
 };
 
 /* minimum size for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index f1648fd..6d4a42e 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -626,8 +626,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-
 /**
  * gen_true_ecc - This function will generate true ECC value
  * @ecc_buf: buffer to store ecc code
@@ -847,8 +845,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
gpmc_enable_hwecc(info-gpmc_cs, mode, dev_width, info-nand.ecc.size);
 }
 
-#endif
-
 /**
  * omap_wait - wait until the command is done
  * @mtd: MTD device structure
@@ -1038,17 +1034,17 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
 
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
-
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* selsect the ecc type */
+   if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DEFAULT)
+   info-nand.ecc.mode = NAND_ECC_SOFT;
+   else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
+   }
 
/* DIP switches on some boards change between 8 and 16 bit
 * bus widths for flash.  Try the other width if the first try fails.
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v9 7/7] omap3: nand: making ecc layout as compatible with romcode ecc

2011-01-28 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-loader, u-boot and kernel.

This enables to flash x-loader, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

This patch does not enables this feature by default and need to pass from
board file to enable for any board.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/plat-omap/include/plat/gpmc.h |2 +
 drivers/mtd/nand/omap2.c   |   37 +++-
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 773351b..12b3161 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -90,6 +90,8 @@ enum omap_ecc {
/* 1-bit ecc: stored at end of spare area */
OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+   /* 1-bit ecc: stored at begining of spare area as romcode */
+   OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method  romcode layout */
 };
 
 /*
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 6d4a42e..4e33972 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -98,6 +98,20 @@
 static const char *part_probes[] = { cmdlinepart, NULL };
 #endif
 
+/* oob info generated runtime depending on ecc algorithm and layout selected */
+static struct nand_ecclayout omap_oobinfo;
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+
 struct omap_nand_info {
struct nand_hw_control  controller;
struct omap_nand_platform_data  *pdata;
@@ -914,6 +928,7 @@ static int __devinit omap_nand_probe(struct platform_device 
*pdev)
struct omap_nand_info   *info;
struct omap_nand_platform_data  *pdata;
int err;
+   int i, offset;
 
pdata = pdev-dev.platform_data;
if (pdata == NULL) {
@@ -1037,7 +1052,8 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
/* selsect the ecc type */
if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_DEFAULT)
info-nand.ecc.mode = NAND_ECC_SOFT;
-   else if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) {
+   else if ((pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW) ||
+   (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE)) {
info-nand.ecc.bytes= 3;
info-nand.ecc.size = 512;
info-nand.ecc.calculate= omap_calculate_ecc;
@@ -1057,6 +1073,25 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
}
 
+   /* rom code layout */
+   if (pdata-ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE) {
+
+   if (info-nand.options  NAND_BUSWIDTH_16)
+   offset = 2;
+   else {
+   offset = 1;
+   info-nand.badblock_pattern = bb_descrip_flashbased;
+   }
+   omap_oobinfo.eccbytes = 3 * (info-mtd.oobsize/16);
+   for (i = 0; i  omap_oobinfo.eccbytes; i++)
+   omap_oobinfo.eccpos[i] = i+offset;
+
+   omap_oobinfo.oobfree-offset = offset + omap_oobinfo.eccbytes;
+   omap_oobinfo.oobfree-length = info-mtd.oobsize -
+   (offset + omap_oobinfo.eccbytes);
+
+   info-nand.ecc.layout = omap_oobinfo;
+   }
 
 #ifdef CONFIG_MTD_PARTITIONS
err = parse_mtd_partitions(info-mtd, part_probes, info-parts, 0);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v9 5/7] omap3: nand: configurable fifo threshold to gain the throughput

2011-01-28 Thread Sukumar Ghorai
Configure the FIFO THREASHOLD value different for read and write to keep busy
both filling and to drain out of FIFO at reading and writing.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   11 +++
 arch/arm/plat-omap/include/plat/gpmc.h |5 -
 drivers/mtd/nand/omap2.c   |   22 ++
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 382dea8..6741743 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -60,7 +60,6 @@
 #define GPMC_CHUNK_SHIFT   24  /* 16 MB */
 #define GPMC_SECTION_SHIFT 28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
 #define CS_NUM_SHIFT   24
 #define ENABLE_PREFETCH(0x1  7)
 #define DMA_MPU_MODE   2
@@ -606,15 +605,19 @@ EXPORT_SYMBOL(gpmc_nand_write);
 /**
  * gpmc_prefetch_enable - configures and starts prefetch transfer
  * @cs: cs (chip select) number
+ * @fifo_th: fifo threshold to be used for read/ write
  * @dma_mode: dma mode enable (1) or disable (0)
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   pr_err(gpmc: fifo threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -622,7 +625,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write)));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 9c060da..a243463 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -83,6 +83,9 @@
 #define GPMC_IRQ_FIFOEVENTENABLE   0x01
 #define GPMC_IRQ_COUNT_EVENT   0x02
 
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)((val)  8)
+
 /*
  * Note that all values in this struct are in nanoseconds except sync_clk
  * (which is in picoseconds), while the register values are in gpmc_fck cycles.
@@ -134,7 +137,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern int gpmc_prefetch_reset(int cs);
 extern void omap3_gpmc_save_context(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index fbe8414..f1648fd 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -244,7 +244,8 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -289,7 +290,8 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs,
+   PREFETCH_FIFOTHRESHOLD_MAX, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -345,8 +347,9 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
int ret;
unsigned long tim, limit;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get

[PATCH v9 4/7] omap3: nand: prefetch in irq mode support

2011-01-28 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for nand transfer(read, write)

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-flash.c  |2 +
 arch/arm/plat-omap/include/plat/nand.h |4 +-
 drivers/mtd/nand/omap2.c   |  198 ++--
 3 files changed, 194 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/board-flash.c 
b/arch/arm/mach-omap2/board-flash.c
index f6b7253..1964509 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -16,6 +16,7 @@
 #include linux/platform_device.h
 #include linux/mtd/physmap.h
 #include linux/io.h
+#include plat/irqs.h
 
 #include plat/gpmc.h
 #include plat/nand.h
@@ -147,6 +148,7 @@ __init board_nand_init(struct mtd_partition *nand_parts,
board_nand_data.nr_parts= nr_parts;
board_nand_data.devsize = nand_type;
 
+   board_nand_data.gpmc_irq = OMAP_GPMC_IRQ_BASE + cs;
gpmc_nand_init(board_nand_data);
 }
 #else
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 78c0bdb..ae5e053 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -13,7 +13,8 @@
 enum nand_io {
NAND_OMAP_PREFETCH_POLLED = 0,  /* prefetch polled mode, default */
NAND_OMAP_POLLED,   /* polled mode, without prefetch */
-   NAND_OMAP_PREFETCH_DMA  /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_DMA, /* prefetch enabled sDMA mode */
+   NAND_OMAP_PREFETCH_IRQ  /* prefetch enabled irq mode */
 };
 
 struct omap_nand_platform_data {
@@ -26,6 +27,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
enum nand_ioxfer_type;
unsigned long   phys_base;
int devsize;
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 60bac8e..fbe8414 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -24,6 +25,7 @@
 #include plat/nand.h
 
 #defineDRIVER_NAME omap2-nand
+#defineOMAP_NAND_TIMEOUT_MS5000
 
 #define NAND_Ecc_P1e   (1  0)
 #define NAND_Ecc_P2e   (1  1)
@@ -108,6 +110,13 @@ struct omap_nand_info {
unsigned long   phys_base;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   enum {
+   OMAP_NAND_IO_READ = 0,  /* read */
+   OMAP_NAND_IO_WRITE, /* write */
+   } iomode;
+   u_char  *buf;
+   int buf_len;
 };
 
 /**
@@ -267,9 +276,10 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
 {
struct omap_nand_info *info = container_of(mtd,
struct omap_nand_info, mtd);
-   uint32_t pref_count = 0, w_count = 0;
+   uint32_t w_count = 0;
int i = 0, ret = 0;
u16 *p;
+   unsigned long tim, limit;
 
/* take care of subpage writes */
if (len % 2 != 0) {
@@ -295,9 +305,12 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
iowrite16(*p++, info-nand.IO_ADDR_W);
}
/* wait for data to flushed-out before reset the prefetch */
-   do {
-   pref_count = gpmc_read_status(GPMC_PREFETCH_COUNT);
-   } while (pref_count);
+   tim = 0;
+   limit = (loops_per_jiffy *
+   msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS));
+   while (gpmc_read_status(GPMC_PREFETCH_COUNT)  (tim++  limit))
+   cpu_relax();
+
/* disable and stop the PFPW engine */
gpmc_prefetch_reset(info-gpmc_cs);
}
@@ -326,11 +339,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
 {
struct omap_nand_info *info = container_of(mtd,
struct omap_nand_info, mtd);
-   uint32_t prefetch_status = 0;
enum dma_data_direction dir = is_write ? DMA_TO_DEVICE :
DMA_FROM_DEVICE;
dma_addr_t dma_addr;
int ret;
+   unsigned long tim, limit;
 
/* The fifo depth is 64 bytes. We have a sync at each frame and frame
 * length is 64 bytes.
@@ -376,7 +389,7 @@ static

[PATCH 0/2] OMAP: Flash device support 3630 sdp board

2010-04-06 Thread Sukumar Ghorai
Sukumar Ghorai (2):
  OMAP3630SDP: Add support for Flash
  OMAP3630SDP: enable Flash device support

 arch/arm/mach-omap2/Makefile  |1 +
 arch/arm/mach-omap2/board-3630sdp.c   |  111 +
 arch/arm/mach-omap2/board-sdp-flash.c |2 +
 arch/arm/configs/omap_3630sdp_defconfig |   77 ++-


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] OMAP3630SDP: Add support for Flash

2010-04-06 Thread Sukumar Ghorai
Add support for NAND, OneNAND, NOR on OMAP 3630-sdp board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
---
 arch/arm/mach-omap2/Makefile  |1 +
 arch/arm/mach-omap2/board-3630sdp.c   |  111 +
 arch/arm/mach-omap2/board-sdp-flash.c |2 +
 3 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 4b9fc57..0cf463c 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_MACH_OMAP_ZOOM3)   += 
board-zoom3.o \
   board-zoom-debugboard.o
 obj-$(CONFIG_MACH_OMAP_3630SDP)+= board-3630sdp.o \
   board-zoom-peripherals.o \
+  board-sdp-flash.o \
   hsmmc.o
 obj-$(CONFIG_MACH_CM_T35)  += board-cm-t35.o \
   hsmmc.o
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index 504d2bd..a2ce116 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -22,9 +22,11 @@
 #include plat/usb.h
 
 #include mach/board-zoom.h
+#include mach/board-sdp.h
 
 #include mux.h
 #include sdram-hynix-h8mbx00u0mer-0em.h
+extern void sdp_flash_init(struct flash_partitions[]);
 
 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
 
@@ -93,12 +95,121 @@ static struct omap_board_mux board_mux[] __initdata = {
 #define board_mux  NULL
 #endif
 
+static struct mtd_partition sdp_nor_partitions[] = {
+   /* bootloader (U-Boot, etc) in first sector */
+   {
+   .name   = Bootloader-NOR,
+   .offset = 0,
+   .size   = SZ_256K,
+   .mask_flags = MTD_WRITEABLE, /* force read-only */
+   },
+   /* bootloader params in the next sector */
+   {
+   .name   = Params-NOR,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = SZ_256K,
+   .mask_flags = 0,
+   },
+   /* kernel */
+   {
+   .name   = Kernel-NOR,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = SZ_2M,
+   .mask_flags = 0
+   },
+   /* file system */
+   {
+   .name   = Filesystem-NOR,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = MTDPART_SIZ_FULL,
+   .mask_flags = 0
+   }
+};
+
+static struct mtd_partition sdp_onenand_partitions[] = {
+   {
+   .name   = X-Loader-OneNAND,
+   .offset = 0,
+   .size   = 4 * (64 * 2048),
+   .mask_flags = MTD_WRITEABLE  /* force read-only */
+   },
+   {
+   .name   = U-Boot-OneNAND,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = 2 * (64 * 2048),
+   .mask_flags = MTD_WRITEABLE  /* force read-only */
+   },
+   {
+   .name   = U-Boot Environment-OneNAND,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = 1 * (64 * 2048),
+   },
+   {
+   .name   = Kernel-OneNAND,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = 16 * (64 * 2048),
+   },
+   {
+   .name   = File System-OneNAND,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = MTDPART_SIZ_FULL,
+   },
+};
+
+static struct mtd_partition sdp_nand_partitions[] = {
+   /* All the partition sizes are listed in terms of NAND block size */
+   {
+   .name   = X-Loader-NAND,
+   .offset = 0,
+   .size   = 4 * (64 * 2048),
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = U-Boot-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x8 */
+   .size   = 10 * (64 * 2048),
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = Boot Env-NAND,
+
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1c */
+   .size   = 6 * (64 * 2048),
+   },
+   {
+   .name   = Kernel-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x28 */
+   .size   = 40 * (64 * 2048),
+   },
+   {
+   .name   = File System - NAND,
+   .size   = MTDPART_SIZ_FULL,
+   .offset = MTDPART_OFS_APPEND,   /* Offset

[PATCH 2/2] OMAP3630SDP: enable Flash device support

2010-04-06 Thread Sukumar Ghorai
update config file to support for NAND, OneNAND, NOR on OMAP 3630-sdp board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
---
 arch/arm/configs/omap_3630sdp_defconfig |   77 ++-
 1 files changed, 76 insertions(+), 1 deletions(-)

diff --git a/arch/arm/configs/omap_3630sdp_defconfig 
b/arch/arm/configs/omap_3630sdp_defconfig
index 609f348..a623927 100644
--- a/arch/arm/configs/omap_3630sdp_defconfig
+++ b/arch/arm/configs/omap_3630sdp_defconfig
@@ -461,7 +461,82 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_SYS_HYPERVISOR is not set
 CONFIG_CONNECTOR=y
 CONFIG_PROC_EVENTS=y
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+CONFIG_MTD_CONCAT=y
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_ARM_INTEGRATOR is not set
+# CONFIG_MTD_PLATRAM is not set
+
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+# CONFIG_MTD_NAND_GPIO is not set
+CONFIG_MTD_NAND_OMAP2=y
+CONFIG_MTD_NAND_OMAP_PREFETCH=y
+# CONFIG_MTD_NAND_OMAP_PREFETCH_DMA is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+# CONFIG_MTD_ALAUDA is not set
+CONFIG_MTD_ONENAND=y
+# CONFIG_MTD_ONENAND_VERIFY_WRITE is not set
+# CONFIG_MTD_ONENAND_GENERIC is not set
+CONFIG_MTD_ONENAND_OMAP2=y
+# CONFIG_MTD_ONENAND_OTP is not set
+# CONFIG_MTD_ONENAND_2X_PROGRAM is not set
+# CONFIG_MTD_ONENAND_SIM is not set
 # CONFIG_PARPORT is not set
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] nand support on omap3 boards

2010-04-13 Thread Sukumar Ghorai
   The following set of patches applies on top of the Tony's master branch.
   And these are the patches required to enable nand (nor and onenand for sdp
   only) for different platform.

Sukumar Ghorai (3):
  OMAP: ZOOM: Introducing 'board-zoom-flash.c'
  omap3: add support for NAND on zoom2 board
  omap3: add support for NAND on zoom3 board
  omap-3630-sdp : Add support for Flash
  omap-3630-sdp: enable Flash device support
  omap3: add support for NAND on LDP board
  zoom2: enable NAND support
  zoom3: enable NAND support

 arch/arm/configs/omap_3630sdp_defconfig   |   77 +-
 arch/arm/configs/omap_zoom2_defconfig |   90 -
 arch/arm/configs/omap_zoom3_defconfig |   90 -
 arch/arm/mach-omap2/Makefile  |4 +
 arch/arm/mach-omap2/board-3630sdp.c   |  110 +
 arch/arm/mach-omap2/board-ldp.c   |   41 +
 arch/arm/mach-omap2/board-sdp-flash.c |2 +
 arch/arm/mach-omap2/board-zoom-flash.c|   82 ++
 arch/arm/mach-omap2/board-zoom2.c |   49 +++
 arch/arm/mach-omap2/board-zoom3.c |   48 +++
 arch/arm/mach-omap2/include/mach/board-zoom.h |   11 +++
 11 files changed, 601 insertions(+), 3 deletions(-) create mode 100644 
arch/arm/mach-omap2/board-zoom-flash.c

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/8] omap3: add support for NAND on zoom3 board

2010-04-13 Thread Sukumar Ghorai
patch adds NAND support to zoom3 board.

Signed-off-by: SUkumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/Makefile  |1 +
 arch/arm/mach-omap2/board-zoom3.c |   48 +
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index f8d9a42..57f418b 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -129,6 +129,7 @@ obj-$(CONFIG_MACH_OMAP_ZOOM2)   += 
board-zoom2.o \
   hsmmc.o \
   board-zoom-debugboard.o
 obj-$(CONFIG_MACH_OMAP_ZOOM3)  += board-zoom3.o \
+  board-zoom-flash.o \
   board-zoom-peripherals.o \
   hsmmc.o \
   board-zoom-debugboard.o
diff --git a/arch/arm/mach-omap2/board-zoom3.c 
b/arch/arm/mach-omap2/board-zoom3.c
index cd3e40c..8a9811e 100644
--- a/arch/arm/mach-omap2/board-zoom3.c
+++ b/arch/arm/mach-omap2/board-zoom3.c
@@ -34,6 +34,53 @@ static void __init omap_zoom_map_io(void)
 static struct omap_board_config_kernel zoom_config[] __initdata = {
 };
 
+static struct mtd_partition zoom_nand_partitions[] = {
+   /* All the partition sizes are listed in terms of NAND block size */
+   {
+   .name   = X-Loader-NAND,
+   .offset = 0,
+   .size   = 4 * (64 * 2048),  /* 512KB, 0x8 */
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = U-Boot-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x8 */
+   .size   = 10 * (64 * 2048), /* 1.25MB, 0x14 */
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = Boot Env-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1c */
+   .size   = 2 * (64 * 2048),  /* 256KB, 0x4 */
+   },
+   {
+   .name   = Kernel-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x020*/
+   .size   = 240 * (64 * 2048),/* 30M, 0x1E0 */
+   },
+   {
+   .name   = system,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x200 */
+   .size   = 3328 * (64 * 2048),   /* 416M, 0x1A00 */
+   },
+   {
+   .name   = userdata,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1C00*/
+   .size   = 256 * (64 * 2048),/* 32M, 0x200 */
+   },
+   {
+   .name   = cache,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1E00*/
+   .size   = 256 * (64 * 2048),/* 32M, 0x200 */
+   },
+};
+
+static struct flash_partitions zoom_flash_partitions[] = {
+   {
+   .parts = zoom_nand_partitions,
+   .nr_parts = ARRAY_SIZE(zoom_nand_partitions),
+   },
+};
 static void __init omap_zoom_init_irq(void)
 {
omap_board_config = zoom_config;
@@ -66,6 +113,7 @@ static void __init omap_zoom_init(void)
 {
omap3_mux_init(board_mux, OMAP_PACKAGE_CBP);
zoom_peripherals_init();
+   zoom_flash_init(zoom_flash_partitions, ZOOM_NAND_CS);
zoom_debugboard_init();
 
omap_mux_init_gpio(64, OMAP_PIN_OUTPUT);
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/8] zoom2: enable NAND support

2010-04-13 Thread Sukumar Ghorai
update config file to support for NAND in zoom2.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/configs/omap_zoom2_defconfig |   90 -
 1 files changed, 89 insertions(+), 1 deletions(-)

diff --git a/arch/arm/configs/omap_zoom2_defconfig 
b/arch/arm/configs/omap_zoom2_defconfig
old mode 100644
new mode 100755
index 881faea..29f6f71
--- a/arch/arm/configs/omap_zoom2_defconfig
+++ b/arch/arm/configs/omap_zoom2_defconfig
@@ -440,7 +440,95 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_SYS_HYPERVISOR is not set
 CONFIG_CONNECTOR=y
 CONFIG_PROC_EVENTS=y
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+CONFIG_MTD_CONCAT=y
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+# CONFIG_MTD_NAND_GPIO is not set
+CONFIG_MTD_NAND_OMAP2=y
+CONFIG_MTD_NAND_OMAP_PREFETCH=y
+# CONFIG_MTD_NAND_OMAP_PREFETCH_DMA is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+# CONFIG_MTD_ALAUDA is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
+#
+# UBI - Unsorted block images
+#
+# CONFIG_MTD_UBI is not set
 # CONFIG_PARPORT is not set
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 5/8] omap-3630-sdp: enable Flash device support

2010-04-13 Thread Sukumar Ghorai
update config file to support for NAND, OneNAND, NOR on omap 3630-sdp board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/configs/omap_3630sdp_defconfig |   77 ++-
 1 files changed, 76 insertions(+), 1 deletions(-)

diff --git a/arch/arm/configs/omap_3630sdp_defconfig 
b/arch/arm/configs/omap_3630sdp_defconfig
index 609f348..a623927 100644
--- a/arch/arm/configs/omap_3630sdp_defconfig
+++ b/arch/arm/configs/omap_3630sdp_defconfig
@@ -461,7 +461,82 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_SYS_HYPERVISOR is not set
 CONFIG_CONNECTOR=y
 CONFIG_PROC_EVENTS=y
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+CONFIG_MTD_CONCAT=y
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_ARM_INTEGRATOR is not set
+# CONFIG_MTD_PLATRAM is not set
+
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+# CONFIG_MTD_NAND_GPIO is not set
+CONFIG_MTD_NAND_OMAP2=y
+CONFIG_MTD_NAND_OMAP_PREFETCH=y
+# CONFIG_MTD_NAND_OMAP_PREFETCH_DMA is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+# CONFIG_MTD_ALAUDA is not set
+CONFIG_MTD_ONENAND=y
+# CONFIG_MTD_ONENAND_VERIFY_WRITE is not set
+# CONFIG_MTD_ONENAND_GENERIC is not set
+CONFIG_MTD_ONENAND_OMAP2=y
+# CONFIG_MTD_ONENAND_OTP is not set
+# CONFIG_MTD_ONENAND_2X_PROGRAM is not set
+# CONFIG_MTD_ONENAND_SIM is not set
 # CONFIG_PARPORT is not set
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] omap: NAND: ecc layout select from board file

2010-04-13 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.  And hw ecc layout selected for
sdp and zoom boards, by default.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/board-sdp-flash.c  |1 +
 arch/arm/mach-omap2/board-zoom-flash.c |1 +
 arch/arm/plat-omap/include/plat/nand.h |4 
 drivers/mtd/nand/omap2.c   |   28 
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/board-sdp-flash.c 
b/arch/arm/mach-omap2/board-sdp-flash.c
index 663c9c2..29e0768 
--- a/arch/arm/mach-omap2/board-sdp-flash.c
+++ b/arch/arm/mach-omap2/board-sdp-flash.c
@@ -162,6 +162,7 @@ __init board_nand_init(struct flash_partitions 
sdp_nand_parts, u8 cs)
sdp_nand_data.cs= cs;
sdp_nand_data.parts = sdp_nand_parts.parts;
sdp_nand_data.nr_parts  = sdp_nand_parts.nr_parts;
+   sdp_nand_data.ecc_opt   = 0x1; /* HW ECC in default layout */
if (cpu_is_omap3630())
sdp_nand_data.devsize = 1; /* 0: 8-bit, 1: 16-bit device */
 
diff --git a/arch/arm/mach-omap2/board-zoom-flash.c 
b/arch/arm/mach-omap2/board-zoom-flash.c
index 6a5dcf4..1547bdb
--- a/arch/arm/mach-omap2/board-zoom-flash.c
+++ b/arch/arm/mach-omap2/board-zoom-flash.c
@@ -71,6 +71,7 @@ void __init zoom_flash_init(struct flash_partitions 
zoom_nand_parts[], int cs)
zoom_nand_data.cs   = cs;
zoom_nand_data.parts= zoom_nand_parts[0].parts;
zoom_nand_data.nr_parts = zoom_nand_parts[0].nr_parts;
+   zoom_nand_data.ecc_opt  = 0x1; /* HW ECC in default layout */
zoom_nand_data.gpmc_baseaddr= (void *)(gpmc_base_add);
zoom_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
GPMC_CS0_BASE + cs * GPMC_CS_SIZE);
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 8ba2e3e..b2ccd68 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -25,6 +25,10 @@ struct omap_nand_platform_data {
void __iomem*gpmc_cs_baseaddr;
void __iomem*gpmc_baseaddr;
int devsize;
+   int ecc_opt; /* 0x0 - sw ecc
+ * 0x1 - hw ecc default ecc layout
+ * 0x2 - hw ecc in romcode layout
+ */
 };
 
 /* size (4 KiB) for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 5b49c84..b42d058
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -31,7 +31,6 @@
 #defineGPMC_BUF_FULL   0x0001
 #defineGPMC_BUF_EMPTY  0x
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
 #define NAND_Ecc_P1e   (1  0)
 #define NAND_Ecc_P2e   (1  1)
 #define NAND_Ecc_P4e   (1  2)
@@ -98,7 +97,6 @@
 
 #define P4e_s(a)   (TF(a  NAND_Ecc_P4e)0)
 #define P4o_s(a)   (TF(a  NAND_Ecc_P4o)1)
-#endif /* CONFIG_MTD_NAND_OMAP_HWECC */
 
 #ifdef CONFIG_MTD_PARTITIONS
 static const char *part_probes[] = { cmdlinepart, NULL };
@@ -679,7 +677,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
 /**
  * omap_hwecc_init - Initialize the HW ECC for NAND flash in GPMC controller
  * @mtd: MTD device structure
@@ -957,7 +954,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
 
__raw_writel(val, info-gpmc_baseaddr + GPMC_ECC_CONFIG);
 }
-#endif
 
 /**
  * omap_wait - wait until the command is done
@@ -1145,19 +1141,19 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
+   if (pdata-ecc_opt  0x3) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
 
-   /* init HW ECC */
-   omap_hwecc_init(info-mtd);
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* init HW ECC */
+   omap_hwecc_init(info-mtd

[PATCH] omap: NAND: Making ecc layout as compatible with romcode ecc

2010-04-13 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-laod, u-boot and kernel.

This patch also enables to use romcode ecc for spd and zoom, by default.

This enables to flash x-load, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/board-sdp-flash.c  |2 +-
 arch/arm/mach-omap2/board-zoom-flash.c |2 +-
 drivers/mtd/nand/omap2.c   |   42 
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/board-sdp-flash.c 
b/arch/arm/mach-omap2/board-sdp-flash.c
index 29e0768..f1002cf 100644
--- a/arch/arm/mach-omap2/board-sdp-flash.c
+++ b/arch/arm/mach-omap2/board-sdp-flash.c
@@ -162,7 +162,7 @@ __init board_nand_init(struct flash_partitions 
sdp_nand_parts, u8 cs)
sdp_nand_data.cs= cs;
sdp_nand_data.parts = sdp_nand_parts.parts;
sdp_nand_data.nr_parts  = sdp_nand_parts.nr_parts;
-   sdp_nand_data.ecc_opt   = 0x1; /* HW ECC in default layout */
+   sdp_nand_data.ecc_opt   = 0x2; /* HW ECC layout as in ROMCODE */
if (cpu_is_omap3630())
sdp_nand_data.devsize = 1; /* 0: 8-bit, 1: 16-bit device */
 
diff --git a/arch/arm/mach-omap2/board-zoom-flash.c 
b/arch/arm/mach-omap2/board-zoom-flash.c
index 1547bdb..53eeaa6 100644
--- a/arch/arm/mach-omap2/board-zoom-flash.c
+++ b/arch/arm/mach-omap2/board-zoom-flash.c
@@ -71,7 +71,7 @@ void __init zoom_flash_init(struct flash_partitions 
zoom_nand_parts[], int cs)
zoom_nand_data.cs   = cs;
zoom_nand_data.parts= zoom_nand_parts[0].parts;
zoom_nand_data.nr_parts = zoom_nand_parts[0].nr_parts;
-   zoom_nand_data.ecc_opt  = 0x1; /* HW ECC in default layout */
+   zoom_nand_data.ecc_opt  = 0x2; /* HW ECC in romcode layout */
zoom_nand_data.gpmc_baseaddr= (void *)(gpmc_base_add);
zoom_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
GPMC_CS0_BASE + cs * GPMC_CS_SIZE);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index b42d058..1ff5609 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -152,6 +152,39 @@ struct omap_nand_info {
u_char  *buf;
 };
 
+static struct nand_ecclayout hw_x8_romcode_oob_64 = {
+   .eccbytes = 12,
+   .eccpos = {
+   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
+ },
+   .oobfree = {
+   {.offset = 13,
+.length = 51}
+  }
+};
+
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+static struct nand_ecclayout hw_x16_romcode_oob_64 = {
+   .eccbytes = 12,
+   .eccpos = {
+   2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
+ },
+   .oobfree = {
+   {.offset = 14,
+.length = 50}
+  }
+};
+
 /**
  * omap_nand_wp - This function enable or disable the Write Protect feature
  * @mtd: MTD device structure
@@ -1142,6 +1175,15 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
info-nand.verify_buf = omap_verify_buf;
 
if (pdata-ecc_opt  0x3) {
+   if (pdata-ecc_opt == 0x2) {
+   if (info-nand.options  NAND_BUSWIDTH_16) {
+   info-nand.ecc.layout = hw_x16_romcode_oob_64;
+   } else {
+   info-nand.ecc.layout = hw_x8_romcode_oob_64;
+   info-nand.badblock_pattern =
+   bb_descrip_flashbased;
+   }
+   }
info-nand.ecc.bytes= 3;
info-nand.ecc.size = 512;
info-nand.ecc.calculate= omap_calculate_ecc;
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] omap-3630 NAND: enable NAND io in prefetch-irq mode

2010-04-13 Thread Sukumar Ghorai
Update config file to enable NAND in prefetch IRQ mode for ZOOM3 and 3630SDP .

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/configs/omap_3630sdp_defconfig |1 +
 arch/arm/configs/omap_zoom3_defconfig   |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/configs/omap_3630sdp_defconfig 
b/arch/arm/configs/omap_3630sdp_defconfig
index a623927..9dfce1a
--- a/arch/arm/configs/omap_3630sdp_defconfig
+++ b/arch/arm/configs/omap_3630sdp_defconfig
@@ -525,6 +525,7 @@ CONFIG_MTD_NAND=y
 CONFIG_MTD_NAND_OMAP2=y
 CONFIG_MTD_NAND_OMAP_PREFETCH=y
 # CONFIG_MTD_NAND_OMAP_PREFETCH_DMA is not set
+CONFIG_MTD_NAND_OMAP_PREFETCH_IRQ=y
 CONFIG_MTD_NAND_IDS=y
 # CONFIG_MTD_NAND_DISKONCHIP is not set
 # CONFIG_MTD_NAND_NANDSIM is not set
diff --git a/arch/arm/configs/omap_zoom3_defconfig 
b/arch/arm/configs/omap_zoom3_defconfig
index 1a12e3e..27b16ed
--- a/arch/arm/configs/omap_zoom3_defconfig
+++ b/arch/arm/configs/omap_zoom3_defconfig
@@ -534,6 +534,7 @@ CONFIG_MTD_NAND=y
 CONFIG_MTD_NAND_OMAP2=y
 CONFIG_MTD_NAND_OMAP_PREFETCH=y
 # CONFIG_MTD_NAND_OMAP_PREFETCH_DMA is not set
+CONFIG_MTD_NAND_OMAP_PREFETCH_IRQ=y
 CONFIG_MTD_NAND_IDS=y
 # CONFIG_MTD_NAND_DISKONCHIP is not set
 # CONFIG_MTD_NAND_NANDSIM is not set
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] omap3: NAND Prefetch in IRQ mode support

2010-04-13 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for NAND.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-sdp-flash.c  |1 +
 arch/arm/mach-omap2/board-zoom-flash.c |1 +
 arch/arm/plat-omap/include/plat/nand.h |1 +
 drivers/mtd/nand/Kconfig   |   14 ++-
 drivers/mtd/nand/omap2.c   |  190 +++-
 5 files changed, 201 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-sdp-flash.c 
b/arch/arm/mach-omap2/board-sdp-flash.c
index 0604cfb..663c9c2 100644
--- a/arch/arm/mach-omap2/board-sdp-flash.c
+++ b/arch/arm/mach-omap2/board-sdp-flash.c
@@ -151,6 +151,7 @@ static struct omap_nand_platform_data sdp_nand_data = {
.nand_setup = NULL,
.gpmc_t = nand_timings,
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
+   .gpmc_irq   = 20,
.dev_ready  = NULL,
.devsize= 0,/* '0' for 8-bit, '1' for 16-bit device */
 };
diff --git a/arch/arm/mach-omap2/board-zoom-flash.c 
b/arch/arm/mach-omap2/board-zoom-flash.c
index 55e173b..6a5dcf4 100644
--- a/arch/arm/mach-omap2/board-zoom-flash.c
+++ b/arch/arm/mach-omap2/board-zoom-flash.c
@@ -54,6 +54,7 @@ static struct omap_nand_platform_data zoom_nand_data = {
.nand_setup = NULL,
.gpmc_t = nand_timings,
.dma_channel= 3,/* disable DMA in OMAP NAND driver */
+   .gpmc_irq   = 20,
.dev_ready  = NULL,
.devsize= 1,/* '0' for 8-bit, '1' for 16-bit device */
 };
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6ba88d2..8ba2e3e 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -20,6 +20,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
unsigned long   phys_base;
void __iomem*gpmc_cs_baseaddr;
void __iomem*gpmc_baseaddr;
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 42e5ea4..376da8c 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -85,6 +85,9 @@ config MTD_NAND_OMAP_PREFETCH
help
 The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
 to improve the performance.
+GPMC PREFETCH can be configured eigther in MPU interrupt mode or in DMA
+interrupt mode. If not selected any of them prefetch will be used in
+polling mode.
 
 config MTD_NAND_OMAP_PREFETCH_DMA
depends on MTD_NAND_OMAP_PREFETCH
@@ -93,7 +96,16 @@ config MTD_NAND_OMAP_PREFETCH_DMA
help
 The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
 or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
+Say y for DMA mode
+
+config MTD_NAND_OMAP_PREFETCH_IRQ
+   depends on MTD_NAND_OMAP_PREFETCH  !MTD_NAND_OMAP_PREFETCH_DMA
+   bool IRQ mode
+   default n
+   help
+The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
+or in DMA interrupt mode.
+Say y for IRQ mode
 
 config MTD_NAND_TS7250
tristate NAND Flash device on TS-7250 board
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index ceb3877..5b49c84 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -111,17 +112,27 @@ module_param(use_prefetch, bool, 0);
 MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
 
 #ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
+const int use_interrupt;
 static int use_dma = 1;
 
 /* modprobe ... use_dma=0 etc */
 module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
+MODULE_PARM_DESC(use_dma, enable/disable use of DMA mode);
+#elif defined(CONFIG_MTD_NAND_OMAP_PREFETCH_IRQ)
+const int use_dma;
+static int use_interrupt = 1;
+
+/* modprobe ... use_dma=0 etc */
+module_param(use_interrupt, bool, 0);
+MODULE_PARM_DESC(use_interrupt, enable/disable use of IRQ mode);
 #else
 const int use_dma;
+const int use_interrupt;
 #endif
 #else
 const int use_prefetch;
 const int use_dma;
+const int use_interrupt;
 #endif
 
 struct omap_nand_info {
@@ -139,6 +150,8 @@ struct omap_nand_info {
void __iomem*nand_pref_fifo_add;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   u_char  *buf

[PATCH v2 6/8] omap3: add support for NAND on LDP board

2010-04-13 Thread Sukumar Ghorai
patch adds NAND support to LDP board.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/Makefile|1 +
 arch/arm/mach-omap2/board-ldp.c |   41 +++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 0cf463c..7556e72
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -108,6 +108,7 @@ obj-$(CONFIG_MACH_OMAP3_BEAGLE) += 
board-omap3beagle.o \
 obj-$(CONFIG_MACH_DEVKIT8000)  += board-devkit8000.o \
hsmmc.o
 obj-$(CONFIG_MACH_OMAP_LDP)+= board-ldp.o \
+  board-zoom-flash.o \
   hsmmc.o
 obj-$(CONFIG_MACH_OVERO)   += board-overo.o \
   hsmmc.o
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 5fcb52e..0976bd9 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -38,6 +38,7 @@
 #include plat/board.h
 #include plat/common.h
 #include plat/gpmc.h
+#include mach/board-zoom.h
 
 #include asm/delay.h
 #include plat/control.h
@@ -389,6 +390,45 @@ static struct omap_musb_board_data musb_board_data = {
.power  = 100,
 };
 
+static struct mtd_partition zoom_nand_partitions[] = {
+   /* All the partition sizes are listed in terms of NAND block size */
+   {
+   .name   = X-Loader-NAND,
+   .offset = 0,
+   .size   = 4 * (64 * 2048),  /* 512KB, 0x8 */
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = U-Boot-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x8 */
+   .size   = 10 * (64 * 2048), /* 1.25MB, 0x14 */
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = Boot Env-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1c */
+   .size   = 2 * (64 * 2048),  /* 256KB, 0x4 */
+   },
+   {
+   .name   = Kernel-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x020*/
+   .size   = 240 * (64 * 2048),/* 30M, 0x1E0 */
+   },
+   {
+   .name   = File System - NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x200 */
+   .size   = MTDPART_SIZ_FULL, /* 96MB, 0x600 */
+   },
+
+};
+
+static struct flash_partitions zoom_flash_partitions[] = {
+   {
+   .parts = zoom_nand_partitions,
+   .nr_parts = ARRAY_SIZE(zoom_nand_partitions),
+   },
+};
+
 static void __init omap_ldp_init(void)
 {
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
@@ -401,6 +441,7 @@ static void __init omap_ldp_init(void)
ads7846_dev_init();
omap_serial_init();
usb_musb_init(musb_board_data);
+   zoom_flash_init(zoom_flash_partitions, ZOOM_NAND_CS);
 
omap2_hsmmc_init(mmc);
/* link regulators to MMC adapters */
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/8] omap3: zoom: Introducing 'board-zoom-flash.c'

2010-04-13 Thread Sukumar Ghorai
This patch adds 'board-zoom-flash.c', which could be utilized by boards similar
to ZOOM2. (For ex: LDP, ZOOM2, ZOOM3). This does initialization for NAND device
based on the 'cs' number and partition information passed from board file
(ex: board-zoom2.c).

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-zoom-flash.c|   82 +
 arch/arm/mach-omap2/include/mach/board-zoom.h |   11 +++
 2 files changed, 93 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-zoom-flash.c

diff --git a/arch/arm/mach-omap2/board-zoom-flash.c 
b/arch/arm/mach-omap2/board-zoom-flash.c
new file mode 100644
index 000..55e173b
--- /dev/null
+++ b/arch/arm/mach-omap2/board-zoom-flash.c
@@ -0,0 +1,82 @@
+/*
+ * board-zoom-flash.c
+ *
+ * Copyright (C) 2009 Texas Instruments Inc.
+ * Vimal Singh vimalsi...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/kernel.h
+#include linux/delay.h
+#include linux/platform_device.h
+#include linux/mtd/nand.h
+#include linux/types.h
+#include linux/io.h
+
+#include asm/mach/flash.h
+#include plat/board.h
+#include plat/gpmc.h
+#include plat/nand.h
+
+#include mach/board-zoom.h
+
+#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
+
+/* Note that all values in this struct are in nanoseconds */
+static struct gpmc_timings nand_timings = {
+
+   .sync_clk = 0,
+
+   .cs_on = 0,
+   .cs_rd_off = 36,
+   .cs_wr_off = 36,
+
+   .adv_on = 6,
+   .adv_rd_off = 24,
+   .adv_wr_off = 36,
+
+   .we_off = 30,
+   .oe_off = 48,
+
+   .access = 54,
+   .rd_cycle = 72,
+   .wr_cycle = 72,
+
+   .wr_access = 30,
+   .wr_data_mux_bus = 0,
+};
+
+/* NAND chip access: 16 bit */
+static struct omap_nand_platform_data zoom_nand_data = {
+   .nand_setup = NULL,
+   .gpmc_t = nand_timings,
+   .dma_channel= 3,/* disable DMA in OMAP NAND driver */
+   .dev_ready  = NULL,
+   .devsize= 1,/* '0' for 8-bit, '1' for 16-bit device */
+};
+
+/**
+ * zoom_flash_init - Identify devices connected to GPMC and register.
+ *
+ * @return - void.
+ */
+void __init zoom_flash_init(struct flash_partitions zoom_nand_parts[], int cs)
+{
+   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
+
+   zoom_nand_data.cs   = cs;
+   zoom_nand_data.parts= zoom_nand_parts[0].parts;
+   zoom_nand_data.nr_parts = zoom_nand_parts[0].nr_parts;
+   zoom_nand_data.gpmc_baseaddr= (void *)(gpmc_base_add);
+   zoom_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
+   GPMC_CS0_BASE + cs * GPMC_CS_SIZE);
+   gpmc_nand_init(zoom_nand_data);
+}
+#else
+void __init zoom_flash_init(struct flash_partitions zoom_nand_parts[], int cs)
+{
+}
+#endif /* CONFIG_MTD_NAND_OMAP2 ||  CONFIG_MTD_NAND_OMAP2_MODULE */
diff --git a/arch/arm/mach-omap2/include/mach/board-zoom.h 
b/arch/arm/mach-omap2/include/mach/board-zoom.h
index c93b29e..f4469d3 100644
--- a/arch/arm/mach-omap2/include/mach/board-zoom.h
+++ b/arch/arm/mach-omap2/include/mach/board-zoom.h
@@ -1,5 +1,16 @@
 /*
  * Defines for zoom boards
  */
+#include linux/mtd/mtd.h
+#include linux/mtd/partitions.h
+
+struct flash_partitions {
+   struct mtd_partition *parts;
+   int nr_parts;
+};
+
+#define ZOOM_NAND_CS   0
+
+extern void __init zoom_flash_init(struct flash_partitions [], int);
 extern int __init zoom_debugboard_init(void);
 extern void __init zoom_peripherals_init(void);
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 4/8] omap-3630-sdp : Add support for Flash

2010-04-13 Thread Sukumar Ghorai
add support for NAND, OneNAND, NOR on omap 3630-sdp board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/Makefile  |1 +
 arch/arm/mach-omap2/board-3630sdp.c   |  110 +
 arch/arm/mach-omap2/board-sdp-flash.c |2 +
 3 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 57f418b..0b0481d
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -135,6 +135,7 @@ obj-$(CONFIG_MACH_OMAP_ZOOM3)   += 
board-zoom3.o \
   board-zoom-debugboard.o
 obj-$(CONFIG_MACH_OMAP_3630SDP)+= board-3630sdp.o \
   board-zoom-peripherals.o \
+  board-sdp-flash.o \
   hsmmc.o
 obj-$(CONFIG_MACH_CM_T35)  += board-cm-t35.o \
   hsmmc.o
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index 504d2bd..0919dca
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -25,6 +25,7 @@
 
 #include mux.h
 #include sdram-hynix-h8mbx00u0mer-0em.h
+extern void sdp_flash_init(struct flash_partitions[]);
 
 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
 
@@ -93,12 +94,121 @@ static struct omap_board_mux board_mux[] __initdata = {
 #define board_mux  NULL
 #endif
 
+static struct mtd_partition sdp_nor_partitions[] = {
+   /* bootloader (U-Boot, etc) in first sector */
+   {
+   .name   = Bootloader-NOR,
+   .offset = 0,
+   .size   = SZ_256K,
+   .mask_flags = MTD_WRITEABLE, /* force read-only */
+   },
+   /* bootloader params in the next sector */
+   {
+   .name   = Params-NOR,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = SZ_256K,
+   .mask_flags = 0,
+   },
+   /* kernel */
+   {
+   .name   = Kernel-NOR,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = SZ_2M,
+   .mask_flags = 0
+   },
+   /* file system */
+   {
+   .name   = Filesystem-NOR,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = MTDPART_SIZ_FULL,
+   .mask_flags = 0
+   }
+};
+
+static struct mtd_partition sdp_onenand_partitions[] = {
+   {
+   .name   = X-Loader-OneNAND,
+   .offset = 0,
+   .size   = 4 * (64 * 2048),
+   .mask_flags = MTD_WRITEABLE  /* force read-only */
+   },
+   {
+   .name   = U-Boot-OneNAND,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = 2 * (64 * 2048),
+   .mask_flags = MTD_WRITEABLE  /* force read-only */
+   },
+   {
+   .name   = U-Boot Environment-OneNAND,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = 1 * (64 * 2048),
+   },
+   {
+   .name   = Kernel-OneNAND,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = 16 * (64 * 2048),
+   },
+   {
+   .name   = File System-OneNAND,
+   .offset = MTDPART_OFS_APPEND,
+   .size   = MTDPART_SIZ_FULL,
+   },
+};
+
+static struct mtd_partition sdp_nand_partitions[] = {
+   /* All the partition sizes are listed in terms of NAND block size */
+   {
+   .name   = X-Loader-NAND,
+   .offset = 0,
+   .size   = 4 * (64 * 2048),
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = U-Boot-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x8 */
+   .size   = 10 * (64 * 2048),
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = Boot Env-NAND,
+
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1c */
+   .size   = 6 * (64 * 2048),
+   },
+   {
+   .name   = Kernel-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x28 */
+   .size   = 40 * (64 * 2048),
+   },
+   {
+   .name   = File System - NAND,
+   .size   = MTDPART_SIZ_FULL,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x78 */
+   },
+};
+
+static struct flash_partitions sdp_flash_partitions

[PATCH 8/8] zoom3: enable NAND support

2010-04-13 Thread Sukumar Ghorai
update config file to support for NAND on zoom3 board.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/configs/omap_zoom3_defconfig |   90 -
 1 files changed, 89 insertions(+), 1 deletions(-)

diff --git a/arch/arm/configs/omap_zoom3_defconfig 
b/arch/arm/configs/omap_zoom3_defconfig
index 5e55b55..1a12e3e
--- a/arch/arm/configs/omap_zoom3_defconfig
+++ b/arch/arm/configs/omap_zoom3_defconfig
@@ -461,7 +461,95 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_SYS_HYPERVISOR is not set
 CONFIG_CONNECTOR=y
 CONFIG_PROC_EVENTS=y
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+CONFIG_MTD_CONCAT=y
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+# CONFIG_MTD_NAND_GPIO is not set
+CONFIG_MTD_NAND_OMAP2=y
+CONFIG_MTD_NAND_OMAP_PREFETCH=y
+# CONFIG_MTD_NAND_OMAP_PREFETCH_DMA is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+# CONFIG_MTD_ALAUDA is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
+#
+# UBI - Unsorted block images
+#
+# CONFIG_MTD_UBI is not set
 # CONFIG_PARPORT is not set
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] nand support on omap3 boards

2010-04-13 Thread Sukumar Ghorai
   The following set of patches applies on top of the Tony's master branch. 
   And dependency on following series of patch -


Sukumar Ghorai (3):
  omap3: GPMC register definition at common location
  omap3: NAND Prefetch in IRQ mode support
  omap-3630 NAND: enable NAND io in prefetch-irq mode
  omap: NAND: ecc layout select from board file
  omap: NAND: Making ecc layout as compatible with romcode ecc

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/8] omap3: GPMC register definition at common location

2010-04-13 Thread Sukumar Ghorai
GPMC register definition move to common place in gpmc.h.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   38 +--
 arch/arm/plat-omap/include/plat/gpmc.h |   36 +++--
 drivers/mtd/nand/omap2.c   |   14 ---
 3 files changed, 40 insertions(+), 48 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5bc3ca0..9c77af0 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -28,40 +28,6 @@
 
 #include plat/sdrc.h
 
-/* GPMC register offsets */
-#define GPMC_REVISION  0x00
-#define GPMC_SYSCONFIG 0x10
-#define GPMC_SYSSTATUS 0x14
-#define GPMC_IRQSTATUS 0x18
-#define GPMC_IRQENABLE 0x1c
-#define GPMC_TIMEOUT_CONTROL   0x40
-#define GPMC_ERR_ADDRESS   0x44
-#define GPMC_ERR_TYPE  0x48
-#define GPMC_CONFIG0x50
-#define GPMC_STATUS0x54
-#define GPMC_PREFETCH_CONFIG1  0x1e0
-#define GPMC_PREFETCH_CONFIG2  0x1e4
-#define GPMC_PREFETCH_CONTROL  0x1ec
-#define GPMC_PREFETCH_STATUS   0x1f0
-#define GPMC_ECC_CONFIG0x1f4
-#define GPMC_ECC_CONTROL   0x1f8
-#define GPMC_ECC_SIZE_CONFIG   0x1fc
-
-#define GPMC_CS0   0x60
-#define GPMC_CS_SIZE   0x30
-
-#define GPMC_MEM_START 0x
-#define GPMC_MEM_END   0x3FFF
-#define BOOT_ROM_SPACE 0x10/* 1MB */
-
-#define GPMC_CHUNK_SHIFT   24  /* 16 MB */
-#define GPMC_SECTION_SHIFT 28  /* 128 MB */
-
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
-#define CS_NUM_SHIFT   24
-#define ENABLE_PREFETCH(0x1  7)
-#define DMA_MPU_MODE   2
-
 /* Structure to save gpmc cs context */
 struct gpmc_cs_config {
u32 config1;
@@ -112,7 +78,7 @@ void gpmc_cs_write_reg(int cs, int idx, u32 val)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
__raw_writel(val, reg_addr);
 }
 
@@ -120,7 +86,7 @@ u32 gpmc_cs_read_reg(int cs, int idx)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
return __raw_readl(reg_addr);
 }
 
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 145838a..347d212 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -25,10 +25,40 @@
 #define GPMC_CS_NAND_ADDRESS   0x20
 #define GPMC_CS_NAND_DATA  0x24
 
-#define GPMC_CONFIG0x50
-#define GPMC_STATUS0x54
+/* GPMC register offsets */
+#define GPMC_REVISION   0x00
+#define GPMC_SYSCONFIG  0x10
+#define GPMC_SYSSTATUS  0x14
+#define GPMC_IRQSTATUS  0x18
+#define GPMC_IRQENABLE  0x1c
+#define GPMC_TIMEOUT_CONTROL0x40
+#define GPMC_ERR_ADDRESS0x44
+#define GPMC_ERR_TYPE   0x48
+#define GPMC_CONFIG 0x50
+#define GPMC_STATUS 0x54
+#define GPMC_PREFETCH_CONFIG1   0x1e0
+#define GPMC_PREFETCH_CONFIG2   0x1e4
+#define GPMC_PREFETCH_CONTROL   0x1ec
+#define GPMC_PREFETCH_STATUS0x1f0
+#define GPMC_ECC_CONFIG 0x1f4
+#define GPMC_ECC_CONTROL0x1f8
+#define GPMC_ECC_SIZE_CONFIG0x1fc
+#define GPMC_ECC1_RESULT0x200
+
 #define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
+#define GPMC_CS_SIZE0x30
+
+#define GPMC_MEM_START  0x
+#define GPMC_MEM_END0x3FFF
+#define BOOT_ROM_SPACE  0x10/* 1MB */
+
+#define GPMC_CHUNK_SHIFT24  /* 16 MB */
+#define GPMC_SECTION_SHIFT  28  /* 128 MB */
+
+#define PREFETCH_FIFOTHRESHOLD  (0x40  8)
+#define CS_NUM_SHIFT24
+#define ENABLE_PREFETCH (0x1  7)
+#define DMA_MPU_MODE2
 
 #define GPMC_CONFIG1_WRAPBURST_SUPP (1  31)
 #define GPMC_CONFIG1_READMULTIPLE_SUPP  (1  30)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 26aec00..ceb3877 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -22,12 +22,6 @@
 #include plat/gpmc.h
 #include plat/nand.h
 
-#define GPMC_IRQ_STATUS0x18
-#define GPMC_ECC_CONFIG0x1F4
-#define GPMC_ECC_CONTROL   0x1F8
-#define GPMC_ECC_SIZE_CONFIG   0x1FC
-#define GPMC_ECC1_RESULT   0x200
-
 #defineDRIVER_NAME omap2-nand
 
 #defineNAND_WP_OFF 0
@@ -36,6 +30,7 @@
 #defineGPMC_BUF_FULL   0x0001
 #defineGPMC_BUF_EMPTY  0x
 
+#ifdef CONFIG_MTD_NAND_OMAP_HWECC
 #define NAND_Ecc_P1e   (1  0)
 #define NAND_Ecc_P2e   (1  1)
 #define NAND_Ecc_P4e   (1  2)
@@ -102,6

[PATCH v3 2/8] omap3: add support for NAND on zoom2 board

2010-04-13 Thread Sukumar Ghorai
This patch adds NAND support to ZOOM2 board.
This uses 'board-zoom-flash.c' for NAND initialization.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/Makefile  |1 +
 arch/arm/mach-omap2/board-zoom2.c |   49 +
 2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 4b9fc57..f8d9a42 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -124,6 +124,7 @@ obj-$(CONFIG_MACH_NOKIA_RX51)   += board-rx51.o 
\
   board-rx51-peripherals.o \
   hsmmc.o
 obj-$(CONFIG_MACH_OMAP_ZOOM2)  += board-zoom2.o \
+  board-zoom-flash.o \
   board-zoom-peripherals.o \
   hsmmc.o \
   board-zoom-debugboard.o
diff --git a/arch/arm/mach-omap2/board-zoom2.c 
b/arch/arm/mach-omap2/board-zoom2.c
index 9a26f84..e0f4901 100644
--- a/arch/arm/mach-omap2/board-zoom2.c
+++ b/arch/arm/mach-omap2/board-zoom2.c
@@ -77,10 +77,59 @@ static struct omap_board_mux board_mux[] __initdata = {
 #define board_mux  NULL
 #endif
 
+static struct mtd_partition zoom_nand_partitions[] = {
+   /* All the partition sizes are listed in terms of NAND block size */
+   {
+   .name   = X-Loader-NAND,
+   .offset = 0,
+   .size   = 4 * (64 * 2048),  /* 512KB, 0x8 */
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = U-Boot-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x8 */
+   .size   = 10 * (64 * 2048), /* 1.25MB, 0x14 */
+   .mask_flags = MTD_WRITEABLE,/* force read-only */
+   },
+   {
+   .name   = Boot Env-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1c */
+   .size   = 2 * (64 * 2048),  /* 256KB, 0x4 */
+   },
+   {
+   .name   = Kernel-NAND,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x020*/
+   .size   = 240 * (64 * 2048),/* 30M, 0x1E0 */
+   },
+   {
+   .name   = system,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x200 */
+   .size   = 3328 * (64 * 2048),   /* 416M, 0x1A00 */
+   },
+   {
+   .name   = userdata,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1C00*/
+   .size   = 256 * (64 * 2048),/* 32M, 0x200 */
+   },
+   {
+   .name   = cache,
+   .offset = MTDPART_OFS_APPEND,   /* Offset = 0x1E00*/
+   .size   = 256 * (64 * 2048),/* 32M, 0x200 */
+   },
+};
+
+static struct flash_partitions zoom_flash_partitions[] = {
+   {
+   .parts = zoom_nand_partitions,
+   .nr_parts = ARRAY_SIZE(zoom_nand_partitions),
+   },
+};
+
 static void __init omap_zoom2_init(void)
 {
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
zoom_peripherals_init();
+   zoom_flash_init(zoom_flash_partitions, ZOOM_NAND_CS);
zoom_debugboard_init();
 }
 
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] nand support on omap3 boards

2010-04-13 Thread Sukumar Ghorai
   The following set of patches applies on top of the Tony's master branch.
   And these are the patches required to enable nand (nor and onenand for sdp
   only) for different platform.

Sukumar Ghorai (3):
  OMAP: ZOOM: Introducing 'board-zoom-flash.c'
  omap3: add support for NAND on zoom2 board
  omap3: add support for NAND on zoom3 board
  omap-3630-sdp : Add support for Flash
  omap-3630-sdp: enable Flash device support
  omap3: add support for NAND on LDP board
  zoom2: enable NAND support
  zoom3: enable NAND support

 arch/arm/configs/omap_3630sdp_defconfig   |   77 +-
 arch/arm/configs/omap_zoom2_defconfig |   90 -
 arch/arm/configs/omap_zoom3_defconfig |   90 -
 arch/arm/mach-omap2/Makefile  |4 +
 arch/arm/mach-omap2/board-3630sdp.c   |  110 +
 arch/arm/mach-omap2/board-ldp.c   |   41 +
 arch/arm/mach-omap2/board-sdp-flash.c |2 +
 arch/arm/mach-omap2/board-zoom-flash.c|   82 ++
 arch/arm/mach-omap2/board-zoom2.c |   49 +++
 arch/arm/mach-omap2/board-zoom3.c |   48 +++
 arch/arm/mach-omap2/include/mach/board-zoom.h |   11 +++
 11 files changed, 601 insertions(+), 3 deletions(-) create mode 100644 
arch/arm/mach-omap2/board-zoom-flash.c

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/6] nand prefetch-irq support and ecc layout chanage

2010-04-16 Thread Sukumar Ghorai
   The main motivations behind this patch series are -
1. support NAND I/O in irq mode.
2. support of different ECC schema. 
3. also to make ecc layout as like in romcode ecc layout

   The following set of patches applies on top of the master branch. And
   is dependent on the following patches not yet applied onto this branch.
https://patchwork.kernel.org/patch/92220/
https://patchwork.kernel.org/patch/92232/
https://patchwork.kernel.org/patch/92221/
https://patchwork.kernel.org/patch/92230/
https://patchwork.kernel.org/patch/92224/
https://patchwork.kernel.org/patch/9/
https://patchwork.kernel.org/patch/92223/
https://patchwork.kernel.org/patch/92229/

Sukumar Ghorai (6):
omap: NAND: Making ecc layout as compatible with romcode ecc 
omap: NAND: ecc layout select from board file 
omap-3630 NAND: enable NAND io in prefetch-irq mode 
OMAP NAND: configurable fifo threshold to gain the throughput
omap3: NAND Prefetch in IRQ mode support
omap3: GPMC register definition at common location

 arch/arm/configs/omap_3630sdp_defconfig |1 +
 arch/arm/configs/omap_zoom3_defconfig   |1 +
 arch/arm/mach-omap2/board-sdp-flash.c   |2 +
 arch/arm/mach-omap2/board-zoom-flash.c  |2 +
 arch/arm/mach-omap2/gpmc.c  |   47 +-
 arch/arm/plat-omap/include/plat/gpmc.h  |   41 -
 arch/arm/plat-omap/include/plat/nand.h  |5 +
 drivers/mtd/nand/Kconfig|   14 ++-
 drivers/mtd/nand/omap2.c|  275 +++
 9 files changed, 309 insertions(+), 79 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] omap3: GPMC register definition at common location

2010-04-16 Thread Sukumar Ghorai
GPMC register definition move to common place in gpmc.h.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   38 +--
 arch/arm/plat-omap/include/plat/gpmc.h |   36 +++--
 drivers/mtd/nand/omap2.c   |   14 ---
 3 files changed, 40 insertions(+), 48 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5bc3ca0..9c77af0
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -28,40 +28,6 @@
 
 #include plat/sdrc.h
 
-/* GPMC register offsets */
-#define GPMC_REVISION  0x00
-#define GPMC_SYSCONFIG 0x10
-#define GPMC_SYSSTATUS 0x14
-#define GPMC_IRQSTATUS 0x18
-#define GPMC_IRQENABLE 0x1c
-#define GPMC_TIMEOUT_CONTROL   0x40
-#define GPMC_ERR_ADDRESS   0x44
-#define GPMC_ERR_TYPE  0x48
-#define GPMC_CONFIG0x50
-#define GPMC_STATUS0x54
-#define GPMC_PREFETCH_CONFIG1  0x1e0
-#define GPMC_PREFETCH_CONFIG2  0x1e4
-#define GPMC_PREFETCH_CONTROL  0x1ec
-#define GPMC_PREFETCH_STATUS   0x1f0
-#define GPMC_ECC_CONFIG0x1f4
-#define GPMC_ECC_CONTROL   0x1f8
-#define GPMC_ECC_SIZE_CONFIG   0x1fc
-
-#define GPMC_CS0   0x60
-#define GPMC_CS_SIZE   0x30
-
-#define GPMC_MEM_START 0x
-#define GPMC_MEM_END   0x3FFF
-#define BOOT_ROM_SPACE 0x10/* 1MB */
-
-#define GPMC_CHUNK_SHIFT   24  /* 16 MB */
-#define GPMC_SECTION_SHIFT 28  /* 128 MB */
-
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
-#define CS_NUM_SHIFT   24
-#define ENABLE_PREFETCH(0x1  7)
-#define DMA_MPU_MODE   2
-
 /* Structure to save gpmc cs context */
 struct gpmc_cs_config {
u32 config1;
@@ -112,7 +78,7 @@ void gpmc_cs_write_reg(int cs, int idx, u32 val)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
__raw_writel(val, reg_addr);
 }
 
@@ -120,7 +86,7 @@ u32 gpmc_cs_read_reg(int cs, int idx)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
return __raw_readl(reg_addr);
 }
 
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 145838a..347d212 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -25,10 +25,40 @@
 #define GPMC_CS_NAND_ADDRESS   0x20
 #define GPMC_CS_NAND_DATA  0x24
 
-#define GPMC_CONFIG0x50
-#define GPMC_STATUS0x54
+/* GPMC register offsets */
+#define GPMC_REVISION   0x00
+#define GPMC_SYSCONFIG  0x10
+#define GPMC_SYSSTATUS  0x14
+#define GPMC_IRQSTATUS  0x18
+#define GPMC_IRQENABLE  0x1c
+#define GPMC_TIMEOUT_CONTROL0x40
+#define GPMC_ERR_ADDRESS0x44
+#define GPMC_ERR_TYPE   0x48
+#define GPMC_CONFIG 0x50
+#define GPMC_STATUS 0x54
+#define GPMC_PREFETCH_CONFIG1   0x1e0
+#define GPMC_PREFETCH_CONFIG2   0x1e4
+#define GPMC_PREFETCH_CONTROL   0x1ec
+#define GPMC_PREFETCH_STATUS0x1f0
+#define GPMC_ECC_CONFIG 0x1f4
+#define GPMC_ECC_CONTROL0x1f8
+#define GPMC_ECC_SIZE_CONFIG0x1fc
+#define GPMC_ECC1_RESULT0x200
+
 #define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
+#define GPMC_CS_SIZE0x30
+
+#define GPMC_MEM_START  0x
+#define GPMC_MEM_END0x3FFF
+#define BOOT_ROM_SPACE  0x10/* 1MB */
+
+#define GPMC_CHUNK_SHIFT24  /* 16 MB */
+#define GPMC_SECTION_SHIFT  28  /* 128 MB */
+
+#define PREFETCH_FIFOTHRESHOLD  (0x40  8)
+#define CS_NUM_SHIFT24
+#define ENABLE_PREFETCH (0x1  7)
+#define DMA_MPU_MODE2
 
 #define GPMC_CONFIG1_WRAPBURST_SUPP (1  31)
 #define GPMC_CONFIG1_READMULTIPLE_SUPP  (1  30)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index ad07d39..09a89f9
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -22,12 +22,6 @@
 #include plat/gpmc.h
 #include plat/nand.h
 
-#define GPMC_IRQ_STATUS0x18
-#define GPMC_ECC_CONFIG0x1F4
-#define GPMC_ECC_CONTROL   0x1F8
-#define GPMC_ECC_SIZE_CONFIG   0x1FC
-#define GPMC_ECC1_RESULT   0x200
-
 #defineDRIVER_NAME omap2-nand
 
 #defineNAND_WP_OFF 0
@@ -36,6 +30,7 @@
 #defineGPMC_BUF_FULL   0x0001
 #defineGPMC_BUF_EMPTY  0x
 
+#ifdef CONFIG_MTD_NAND_OMAP_HWECC
 #define NAND_Ecc_P1e   (1  0)
 #define NAND_Ecc_P2e   (1  1)
 #define NAND_Ecc_P4e   (1  2)
@@ -102,6 +97,7

[PATCH 2/6] omap3: NAND Prefetch in IRQ mode support

2010-04-16 Thread Sukumar Ghorai
This patch enable prefetch-irq mode for NAND.

Signed-off-by: Vimal Singh vimalsi...@ti.com
Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-sdp-flash.c  |1 +
 arch/arm/mach-omap2/board-zoom-flash.c |1 +
 arch/arm/plat-omap/include/plat/nand.h |1 +
 drivers/mtd/nand/Kconfig   |   14 +++-
 drivers/mtd/nand/omap2.c   |  180 +++-
 5 files changed, 191 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-sdp-flash.c 
b/arch/arm/mach-omap2/board-sdp-flash.c
index 57116e6..81b83ce
--- a/arch/arm/mach-omap2/board-sdp-flash.c
+++ b/arch/arm/mach-omap2/board-sdp-flash.c
@@ -151,6 +151,7 @@ static struct omap_nand_platform_data sdp_nand_data = {
.nand_setup = NULL,
.gpmc_t = nand_timings,
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
+   .gpmc_irq   = 20,
.dev_ready  = NULL,
.devsize= 0,/* '0' for 8-bit, '1' for 16-bit device */
 };
diff --git a/arch/arm/mach-omap2/board-zoom-flash.c 
b/arch/arm/mach-omap2/board-zoom-flash.c
index 55e173b..6a5dcf4 100644
--- a/arch/arm/mach-omap2/board-zoom-flash.c
+++ b/arch/arm/mach-omap2/board-zoom-flash.c
@@ -54,6 +54,7 @@ static struct omap_nand_platform_data zoom_nand_data = {
.nand_setup = NULL,
.gpmc_t = nand_timings,
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
+   .gpmc_irq   = 20,
.dev_ready  = NULL,
.devsize= 1,/* '0' for 8-bit, '1' for 16-bit device */
 };
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 6ba88d2..8ba2e3e 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -20,6 +20,7 @@ struct omap_nand_platform_data {
int (*nand_setup)(void);
int (*dev_ready)(struct omap_nand_platform_data *);
int dma_channel;
+   int gpmc_irq;
unsigned long   phys_base;
void __iomem*gpmc_cs_baseaddr;
void __iomem*gpmc_baseaddr;
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index b712aed..ee9abbd
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -94,6 +94,9 @@ config MTD_NAND_OMAP_PREFETCH
help
 The NAND device can be accessed for Read/Write using GPMC PREFETCH 
engine
 to improve the performance.
+GPMC PREFETCH can be configured eigther in MPU interrupt mode or in DMA
+interrupt mode. If not selected any of them prefetch will be used in
+polling mode.
 
 config MTD_NAND_OMAP_PREFETCH_DMA
depends on MTD_NAND_OMAP_PREFETCH
@@ -102,7 +105,16 @@ config MTD_NAND_OMAP_PREFETCH_DMA
help
 The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
 or in DMA interrupt mode.
-Say y for DMA mode or MPU mode will be used
+Say y for DMA mode
+
+config MTD_NAND_OMAP_PREFETCH_IRQ
+   depends on MTD_NAND_OMAP_PREFETCH  !MTD_NAND_OMAP_PREFETCH_DMA
+   bool IRQ mode
+   default n
+   help
+The GPMC PREFETCH engine can be configured eigther in MPU interrupt 
mode
+or in DMA interrupt mode.
+Say y for IRQ mode
 
 config MTD_NAND_IDS
tristate
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 09a89f9..de9b058 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -11,6 +11,7 @@
 #include linux/platform_device.h
 #include linux/dma-mapping.h
 #include linux/delay.h
+#include linux/interrupt.h
 #include linux/jiffies.h
 #include linux/sched.h
 #include linux/mtd/mtd.h
@@ -111,17 +112,27 @@ module_param(use_prefetch, bool, 0);
 MODULE_PARM_DESC(use_prefetch, enable/disable use of PREFETCH);
 
 #ifdef CONFIG_MTD_NAND_OMAP_PREFETCH_DMA
+const int use_interrupt;
 static int use_dma = 1;
 
 /* modprobe ... use_dma=0 etc */
 module_param(use_dma, bool, 0);
-MODULE_PARM_DESC(use_dma, enable/disable use of DMA);
+MODULE_PARM_DESC(use_dma, enable/disable use of DMA mode);
+#elif defined(CONFIG_MTD_NAND_OMAP_PREFETCH_IRQ)
+const int use_dma;
+static int use_interrupt = 1;
+
+/* modprobe ... use_dma=0 etc */
+module_param(use_interrupt, bool, 0);
+MODULE_PARM_DESC(use_interrupt, enable/disable use of IRQ mode);
 #else
 const int use_dma;
+const int use_interrupt;
 #endif
 #else
 const int use_prefetch;
 const int use_dma;
+const int use_interrupt;
 #endif
 
 struct omap_nand_info {
@@ -139,6 +150,8 @@ struct omap_nand_info {
void __iomem*nand_pref_fifo_add;
struct completion   comp;
int dma_ch;
+   int gpmc_irq;
+   u_char  *buf;
 };
 
 /**
@@ -503,6 +516,141 @@ static void

[PATCH 3/6] OMAP NAND: configurable fifo threshold to gain the throughput

2010-04-16 Thread Sukumar Ghorai
  Configure the FIFO THREASHOLD value to 50% (32 bytes) to keep busy both
  filling and to drain out of FIFO at reading and writing.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |9 ++---
 arch/arm/plat-omap/include/plat/gpmc.h |7 +--
 drivers/mtd/nand/omap2.c   |   25 +
 3 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 9c77af0..1380886 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -391,12 +391,15 @@ EXPORT_SYMBOL(gpmc_cs_free);
  * @u32_count: number of bytes to be transferred
  * @is_write: prefetch read(0) or write post(1) mode
  */
-int gpmc_prefetch_enable(int cs, int dma_mode,
+int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write)
 {
uint32_t prefetch_config1;
 
-   if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
+   if (fifo_th  PREFETCH_FIFOTHRESHOLD_MAX) {
+   printk(KERN_ERR PREFETCH Fifo Threshold is not supported\n);
+   return -1;
+   } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
/* Set the amount of bytes to be prefetched */
gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
 
@@ -404,7 +407,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode,
 * enable the engine. Set which cs is has requested for.
 */
prefetch_config1 = ((cs  CS_NUM_SHIFT) |
-   PREFETCH_FIFOTHRESHOLD |
+   PREFETCH_FIFOTHRESHOLD(fifo_th) |
ENABLE_PREFETCH |
(dma_mode  DMA_MPU_MODE) |
(0x1  is_write));
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 347d212..a36a046 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -55,10 +55,13 @@
 #define GPMC_CHUNK_SHIFT24  /* 16 MB */
 #define GPMC_SECTION_SHIFT  28  /* 128 MB */
 
-#define PREFETCH_FIFOTHRESHOLD  (0x40  8)
+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
+#define PREFETCH_FIFOTHRESHOLD(val)(val  8)
 #define CS_NUM_SHIFT24
 #define ENABLE_PREFETCH (0x1  7)
 #define DMA_MPU_MODE2
+#define PREFETCH_FIFOTHRESHOLD_READ32 /* threashold size for read */
+#define PREFETCH_FIFOTHRESHOLD_WRITE   32 /* threashold size for write */
 
 #define GPMC_CONFIG1_WRAPBURST_SUPP (1  31)
 #define GPMC_CONFIG1_READMULTIPLE_SUPP  (1  30)
@@ -136,7 +139,7 @@ extern int gpmc_cs_request(int cs, unsigned long size, 
unsigned long *base);
 extern void gpmc_cs_free(int cs);
 extern int gpmc_cs_set_reserved(int cs, int reserved);
 extern int gpmc_cs_reserved(int cs);
-extern int gpmc_prefetch_enable(int cs, int dma_mode,
+extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
unsigned int u32_count, int is_write);
 extern void gpmc_prefetch_reset(void);
 extern int gpmc_prefetch_status(void);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index de9b058..61c0c01
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -310,7 +310,7 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char 
*buf, int len)
}
 
/* configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x0);
+   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x40, 0x0, len, 0x0);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -354,7 +354,7 @@ static void omap_write_buf_pref(struct mtd_info *mtd,
}
 
/*  configure and start prefetch transfer */
-   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x0, len, 0x1);
+   ret = gpmc_prefetch_enable(info-gpmc_cs, 0x40, 0x0, len, 0x1);
if (ret) {
/* PFPW engine is busy, use cpu copy method */
if (info-nand.options  NAND_BUSWIDTH_16)
@@ -405,10 +405,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr,
dma_addr_t dma_addr;
int ret;
 
-   /* The fifo depth is 64 bytes. We have a sync at each frame and frame
-* length is 64 bytes.
+   /* The fifo depth is 64 bytes max.
+* But configure the FIFO-threahold to 32 to get a sync at each frame
+* and frame length is 32 bytes.
 */
-   int buf_len = len  6;
+   int buf_len = len  5;
 
if (addr = high_memory) {
struct page *p1;
@@ -447,7 +448,7 @@ static inline int omap_nand_dma_transfer(struct mtd_info 
*mtd, void *addr

[PATCH 4/6] omap-3630 NAND: enable NAND io in prefetch-irq mode

2010-04-16 Thread Sukumar Ghorai
Update config file to enable NAND in prefetch IRQ mode for ZOOM3 and 3630SDP .

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/configs/omap_3630sdp_defconfig |1 +
 arch/arm/configs/omap_zoom3_defconfig   |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/configs/omap_3630sdp_defconfig 
b/arch/arm/configs/omap_3630sdp_defconfig
index a623927..9dfce1a
--- a/arch/arm/configs/omap_3630sdp_defconfig
+++ b/arch/arm/configs/omap_3630sdp_defconfig
@@ -525,6 +525,7 @@ CONFIG_MTD_NAND=y
 CONFIG_MTD_NAND_OMAP2=y
 CONFIG_MTD_NAND_OMAP_PREFETCH=y
 # CONFIG_MTD_NAND_OMAP_PREFETCH_DMA is not set
+CONFIG_MTD_NAND_OMAP_PREFETCH_IRQ=y
 CONFIG_MTD_NAND_IDS=y
 # CONFIG_MTD_NAND_DISKONCHIP is not set
 # CONFIG_MTD_NAND_NANDSIM is not set
diff --git a/arch/arm/configs/omap_zoom3_defconfig 
b/arch/arm/configs/omap_zoom3_defconfig
index 1a12e3e..27b16ed
--- a/arch/arm/configs/omap_zoom3_defconfig
+++ b/arch/arm/configs/omap_zoom3_defconfig
@@ -534,6 +534,7 @@ CONFIG_MTD_NAND=y
 CONFIG_MTD_NAND_OMAP2=y
 CONFIG_MTD_NAND_OMAP_PREFETCH=y
 # CONFIG_MTD_NAND_OMAP_PREFETCH_DMA is not set
+CONFIG_MTD_NAND_OMAP_PREFETCH_IRQ=y
 CONFIG_MTD_NAND_IDS=y
 # CONFIG_MTD_NAND_DISKONCHIP is not set
 # CONFIG_MTD_NAND_NANDSIM is not set
-- 
1.5.4.7

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] omap: NAND: ecc layout select from board file

2010-04-16 Thread Sukumar Ghorai
This patch makes it possible to select sw or hw (different layout options)
ecc scheme supported by omap nand driver.  And hw ecc layout selected for
sdp and zoom boards, by default.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
Signed-off-by: Vimal Singh vimalsi...@ti.com
---
 arch/arm/mach-omap2/board-sdp-flash.c  |1 +
 arch/arm/mach-omap2/board-zoom-flash.c |1 +
 arch/arm/plat-omap/include/plat/nand.h |4 
 drivers/mtd/nand/omap2.c   |   28 
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/board-sdp-flash.c 
b/arch/arm/mach-omap2/board-sdp-flash.c
index 81b83ce..437a1a4
--- a/arch/arm/mach-omap2/board-sdp-flash.c
+++ b/arch/arm/mach-omap2/board-sdp-flash.c
@@ -162,6 +162,7 @@ __init board_nand_init(struct flash_partitions 
sdp_nand_parts, u8 cs)
sdp_nand_data.cs= cs;
sdp_nand_data.parts = sdp_nand_parts.parts;
sdp_nand_data.nr_parts  = sdp_nand_parts.nr_parts;
+   sdp_nand_data.ecc_opt   = 0x1; /* HW ECC in default layout */
if (cpu_is_omap3630())
sdp_nand_data.devsize = 1; /* 0: 8-bit, 1: 16-bit device */
 
diff --git a/arch/arm/mach-omap2/board-zoom-flash.c 
b/arch/arm/mach-omap2/board-zoom-flash.c
index 6a5dcf4..1547bdb
--- a/arch/arm/mach-omap2/board-zoom-flash.c
+++ b/arch/arm/mach-omap2/board-zoom-flash.c
@@ -71,6 +71,7 @@ void __init zoom_flash_init(struct flash_partitions 
zoom_nand_parts[], int cs)
zoom_nand_data.cs   = cs;
zoom_nand_data.parts= zoom_nand_parts[0].parts;
zoom_nand_data.nr_parts = zoom_nand_parts[0].nr_parts;
+   zoom_nand_data.ecc_opt  = 0x1; /* HW ECC in default layout */
zoom_nand_data.gpmc_baseaddr= (void *)(gpmc_base_add);
zoom_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
GPMC_CS0_BASE + cs * GPMC_CS_SIZE);
diff --git a/arch/arm/plat-omap/include/plat/nand.h 
b/arch/arm/plat-omap/include/plat/nand.h
index 8ba2e3e..b2ccd68
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -25,6 +25,10 @@ struct omap_nand_platform_data {
void __iomem*gpmc_cs_baseaddr;
void __iomem*gpmc_baseaddr;
int devsize;
+   int ecc_opt; /* 0x0 - sw ecc
+ * 0x1 - hw ecc default ecc layout
+ * 0x2 - hw ecc in romcode layout
+ */
 };
 
 /* size (4 KiB) for IO mapping */
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 61c0c01..207fb3c
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -31,7 +31,6 @@
 #defineGPMC_BUF_FULL   0x0001
 #defineGPMC_BUF_EMPTY  0x
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
 #define NAND_Ecc_P1e   (1  0)
 #define NAND_Ecc_P2e   (1  1)
 #define NAND_Ecc_P4e   (1  2)
@@ -98,7 +97,6 @@
 
 #define P4e_s(a)   (TF(a  NAND_Ecc_P4e)0)
 #define P4o_s(a)   (TF(a  NAND_Ecc_P4o)1)
-#endif /* CONFIG_MTD_NAND_OMAP_HWECC */
 
 #ifdef CONFIG_MTD_PARTITIONS
 static const char *part_probes[] = { cmdlinepart, NULL };
@@ -673,7 +671,6 @@ static int omap_verify_buf(struct mtd_info *mtd, const 
u_char * buf, int len)
return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
 /**
  * omap_hwecc_init - Initialize the HW ECC for NAND flash in GPMC controller
  * @mtd: MTD device structure
@@ -951,7 +948,6 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int 
mode)
 
__raw_writel(val, info-gpmc_baseaddr + GPMC_ECC_CONFIG);
 }
-#endif
 
 /**
  * omap_wait - wait until the command is done
@@ -1139,19 +1135,19 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
}
info-nand.verify_buf = omap_verify_buf;
 
-#ifdef CONFIG_MTD_NAND_OMAP_HWECC
-   info-nand.ecc.bytes= 3;
-   info-nand.ecc.size = 512;
-   info-nand.ecc.calculate= omap_calculate_ecc;
-   info-nand.ecc.hwctl= omap_enable_hwecc;
-   info-nand.ecc.correct  = omap_correct_data;
-   info-nand.ecc.mode = NAND_ECC_HW;
+   if (pdata-ecc_opt  0x3) {
+   info-nand.ecc.bytes= 3;
+   info-nand.ecc.size = 512;
+   info-nand.ecc.calculate= omap_calculate_ecc;
+   info-nand.ecc.hwctl= omap_enable_hwecc;
+   info-nand.ecc.correct  = omap_correct_data;
+   info-nand.ecc.mode = NAND_ECC_HW;
 
-   /* init HW ECC */
-   omap_hwecc_init(info-mtd);
-#else
-   info-nand.ecc.mode = NAND_ECC_SOFT;
-#endif
+   /* init HW ECC */
+   omap_hwecc_init(info-mtd);
+   } else

[PATCH 6/6] omap: NAND: Making ecc layout as compatible with romcode ecc

2010-04-16 Thread Sukumar Ghorai
This patch overrides nand ecc layout and bad block descriptor (for 8-bit
device) to support hw ecc in romcode layout. So as to have in sync with ecc
layout throughout; i.e. x-laod, u-boot and kernel.

This patch also enables to use romcode ecc for spd and zoom, by default.

This enables to flash x-load, u-boot, kernel, FS images from kernel itself
and compatiable with other tools.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-sdp-flash.c  |2 +-
 arch/arm/mach-omap2/board-zoom-flash.c |2 +-
 drivers/mtd/nand/omap2.c   |   42 
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/board-sdp-flash.c 
b/arch/arm/mach-omap2/board-sdp-flash.c
index 437a1a4..ac891ea
--- a/arch/arm/mach-omap2/board-sdp-flash.c
+++ b/arch/arm/mach-omap2/board-sdp-flash.c
@@ -162,7 +162,7 @@ __init board_nand_init(struct flash_partitions 
sdp_nand_parts, u8 cs)
sdp_nand_data.cs= cs;
sdp_nand_data.parts = sdp_nand_parts.parts;
sdp_nand_data.nr_parts  = sdp_nand_parts.nr_parts;
-   sdp_nand_data.ecc_opt   = 0x1; /* HW ECC in default layout */
+   sdp_nand_data.ecc_opt   = 0x2; /* HW ECC layout as in ROMCODE */
if (cpu_is_omap3630())
sdp_nand_data.devsize = 1; /* 0: 8-bit, 1: 16-bit device */
 
diff --git a/arch/arm/mach-omap2/board-zoom-flash.c 
b/arch/arm/mach-omap2/board-zoom-flash.c
index 1547bdb..53eeaa6
--- a/arch/arm/mach-omap2/board-zoom-flash.c
+++ b/arch/arm/mach-omap2/board-zoom-flash.c
@@ -71,7 +71,7 @@ void __init zoom_flash_init(struct flash_partitions 
zoom_nand_parts[], int cs)
zoom_nand_data.cs   = cs;
zoom_nand_data.parts= zoom_nand_parts[0].parts;
zoom_nand_data.nr_parts = zoom_nand_parts[0].nr_parts;
-   zoom_nand_data.ecc_opt  = 0x1; /* HW ECC in default layout */
+   zoom_nand_data.ecc_opt  = 0x2; /* HW ECC in romcode layout */
zoom_nand_data.gpmc_baseaddr= (void *)(gpmc_base_add);
zoom_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
GPMC_CS0_BASE + cs * GPMC_CS_SIZE);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 207fb3c..f5d2c53
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -152,6 +152,39 @@ struct omap_nand_info {
u_char  *buf;
 };
 
+static struct nand_ecclayout hw_x8_romcode_oob_64 = {
+   .eccbytes = 12,
+   .eccpos = {
+   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
+ },
+   .oobfree = {
+   {.offset = 13,
+.length = 51}
+  }
+};
+
+/* Define some generic bad / good block scan pattern which are used
+ * while scanning a device for factory marked good / bad blocks
+ */
+static uint8_t scan_ff_pattern[] = { 0xff };
+static struct nand_bbt_descr bb_descrip_flashbased = {
+   .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES,
+   .offs = 0,
+   .len = 1,
+   .pattern = scan_ff_pattern,
+};
+
+static struct nand_ecclayout hw_x16_romcode_oob_64 = {
+   .eccbytes = 12,
+   .eccpos = {
+   2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
+ },
+   .oobfree = {
+   {.offset = 14,
+.length = 50}
+  }
+};
+
 /**
  * omap_nand_wp - This function enable or disable the Write Protect feature
  * @mtd: MTD device structure
@@ -1136,6 +1169,15 @@ static int __devinit omap_nand_probe(struct 
platform_device *pdev)
info-nand.verify_buf = omap_verify_buf;
 
if (pdata-ecc_opt  0x3) {
+   if (pdata-ecc_opt == 0x2) {
+   if (info-nand.options  NAND_BUSWIDTH_16) {
+   info-nand.ecc.layout = hw_x16_romcode_oob_64;
+   } else {
+   info-nand.ecc.layout = hw_x8_romcode_oob_64;
+   info-nand.badblock_pattern =
+   bb_descrip_flashbased;
+   }
+   }
info-nand.ecc.bytes= 3;
info-nand.ecc.size = 512;
info-nand.ecc.calculate= omap_calculate_ecc;
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] omap3: GPMC register definition at common location

2010-05-12 Thread Sukumar Ghorai
GPMC register definition move to common place in gpmc.h.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |   38 +--
 arch/arm/plat-omap/include/plat/gpmc.h |   36 +++--
 drivers/mtd/nand/omap2.c   |   14 ---
 3 files changed, 40 insertions(+), 48 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5bc3ca0..9c77af0
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -28,40 +28,6 @@
 
 #include plat/sdrc.h
 
-/* GPMC register offsets */
-#define GPMC_REVISION  0x00
-#define GPMC_SYSCONFIG 0x10
-#define GPMC_SYSSTATUS 0x14
-#define GPMC_IRQSTATUS 0x18
-#define GPMC_IRQENABLE 0x1c
-#define GPMC_TIMEOUT_CONTROL   0x40
-#define GPMC_ERR_ADDRESS   0x44
-#define GPMC_ERR_TYPE  0x48
-#define GPMC_CONFIG0x50
-#define GPMC_STATUS0x54
-#define GPMC_PREFETCH_CONFIG1  0x1e0
-#define GPMC_PREFETCH_CONFIG2  0x1e4
-#define GPMC_PREFETCH_CONTROL  0x1ec
-#define GPMC_PREFETCH_STATUS   0x1f0
-#define GPMC_ECC_CONFIG0x1f4
-#define GPMC_ECC_CONTROL   0x1f8
-#define GPMC_ECC_SIZE_CONFIG   0x1fc
-
-#define GPMC_CS0   0x60
-#define GPMC_CS_SIZE   0x30
-
-#define GPMC_MEM_START 0x
-#define GPMC_MEM_END   0x3FFF
-#define BOOT_ROM_SPACE 0x10/* 1MB */
-
-#define GPMC_CHUNK_SHIFT   24  /* 16 MB */
-#define GPMC_SECTION_SHIFT 28  /* 128 MB */
-
-#define PREFETCH_FIFOTHRESHOLD (0x40  8)
-#define CS_NUM_SHIFT   24
-#define ENABLE_PREFETCH(0x1  7)
-#define DMA_MPU_MODE   2
-
 /* Structure to save gpmc cs context */
 struct gpmc_cs_config {
u32 config1;
@@ -112,7 +78,7 @@ void gpmc_cs_write_reg(int cs, int idx, u32 val)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
__raw_writel(val, reg_addr);
 }
 
@@ -120,7 +86,7 @@ u32 gpmc_cs_read_reg(int cs, int idx)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
return __raw_readl(reg_addr);
 }
 
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 145838a..347d212 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -25,10 +25,40 @@
 #define GPMC_CS_NAND_ADDRESS   0x20
 #define GPMC_CS_NAND_DATA  0x24
 
-#define GPMC_CONFIG0x50
-#define GPMC_STATUS0x54
+/* GPMC register offsets */
+#define GPMC_REVISION   0x00
+#define GPMC_SYSCONFIG  0x10
+#define GPMC_SYSSTATUS  0x14
+#define GPMC_IRQSTATUS  0x18
+#define GPMC_IRQENABLE  0x1c
+#define GPMC_TIMEOUT_CONTROL0x40
+#define GPMC_ERR_ADDRESS0x44
+#define GPMC_ERR_TYPE   0x48
+#define GPMC_CONFIG 0x50
+#define GPMC_STATUS 0x54
+#define GPMC_PREFETCH_CONFIG1   0x1e0
+#define GPMC_PREFETCH_CONFIG2   0x1e4
+#define GPMC_PREFETCH_CONTROL   0x1ec
+#define GPMC_PREFETCH_STATUS0x1f0
+#define GPMC_ECC_CONFIG 0x1f4
+#define GPMC_ECC_CONTROL0x1f8
+#define GPMC_ECC_SIZE_CONFIG0x1fc
+#define GPMC_ECC1_RESULT0x200
+
 #define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
+#define GPMC_CS_SIZE0x30
+
+#define GPMC_MEM_START  0x
+#define GPMC_MEM_END0x3FFF
+#define BOOT_ROM_SPACE  0x10/* 1MB */
+
+#define GPMC_CHUNK_SHIFT24  /* 16 MB */
+#define GPMC_SECTION_SHIFT  28  /* 128 MB */
+
+#define PREFETCH_FIFOTHRESHOLD  (0x40  8)
+#define CS_NUM_SHIFT24
+#define ENABLE_PREFETCH (0x1  7)
+#define DMA_MPU_MODE2
 
 #define GPMC_CONFIG1_WRAPBURST_SUPP (1  31)
 #define GPMC_CONFIG1_READMULTIPLE_SUPP  (1  30)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 7545568..258bf06
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -23,12 +23,6 @@
 #include plat/gpmc.h
 #include plat/nand.h
 
-#define GPMC_IRQ_STATUS0x18
-#define GPMC_ECC_CONFIG0x1F4
-#define GPMC_ECC_CONTROL   0x1F8
-#define GPMC_ECC_SIZE_CONFIG   0x1FC
-#define GPMC_ECC1_RESULT   0x200
-
 #defineDRIVER_NAME omap2-nand
 
 #defineNAND_WP_OFF 0
@@ -37,6 +31,7 @@
 #defineGPMC_BUF_FULL   0x0001
 #defineGPMC_BUF_EMPTY  0x
 
+#ifdef CONFIG_MTD_NAND_OMAP_HWECC
 #define NAND_Ecc_P1e   (1  0)
 #define NAND_Ecc_P2e   (1  1)
 #define NAND_Ecc_P4e   (1  2)
@@ -103,6 +98,7 @@
 
 #define P4e_s(a)   (TF(a  NAND_Ecc_P4e

[PATCH 3/3] omap3 nand: fix issue in board file to detect the nand

2010-05-12 Thread Sukumar Ghorai
Board file modified to pass the GMPC phys_base address to nand driver. This is
required to adopt the _prob function as in omap2.c

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-cm-t35.c |   16 +---
 arch/arm/mach-omap2/board-devkit8000.c |   16 +---
 arch/arm/mach-omap2/board-omap3beagle.c|   16 +---
 arch/arm/mach-omap2/board-omap3touchbook.c |   16 +---
 arch/arm/mach-omap2/board-overo.c  |   17 +
 5 files changed, 5 insertions(+), 76 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index fb23122..0544294
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -224,23 +224,9 @@ static struct omap_nand_platform_data cm_t35_nand_data = {
 
 };
 
-static struct resource cm_t35_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device cm_t35_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .num_resources  = 1,
-   .resource   = cm_t35_nand_resource,
-   .dev= {
-   .platform_data  = cm_t35_nand_data,
-   },
-};
-
 static void __init cm_t35_init_nand(void)
 {
-   if (platform_device_register(cm_t35_nand_device)  0)
+   if (gpmc_nand_init(cm_t35_nand_data)  0)
pr_err(CM-T35: Unable to register NAND device\n);
 }
 #else
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index be50d18..a6fcb48
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -101,20 +101,6 @@ static struct omap_nand_platform_data devkit8000_nand_data 
= {
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
 };
 
-static struct resource devkit8000_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device devkit8000_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .dev= {
-   .platform_data  = devkit8000_nand_data,
-   },
-   .num_resources  = 1,
-   .resource   = devkit8000_nand_resource,
-};
-
 static struct omap2_hsmmc_info mmc[] = {
{
.mmc= 1,
@@ -601,7 +587,7 @@ static void __init devkit8000_flash_init(void)
devkit8000_nand_data.cs = nandcs;
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
-   if (platform_device_register(devkit8000_nand_device)  0)
+   if (gpmc_nand_init(devkit8000_nand_data)  0)
printk(KERN_ERR Unable to register NAND device\n);
}
 }
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index becaebe..bf31b7c
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -89,20 +89,6 @@ static struct omap_nand_platform_data omap3beagle_nand_data 
= {
.dev_ready  = NULL,
 };
 
-static struct resource omap3beagle_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device omap3beagle_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .dev= {
-   .platform_data  = omap3beagle_nand_data,
-   },
-   .num_resources  = 1,
-   .resource   = omap3beagle_nand_resource,
-};
-
 #include sdram-micron-mt46h32m32lf-6.h
 
 static struct omap2_hsmmc_info mmc[] = {
@@ -397,7 +383,7 @@ static void __init omap3beagle_flash_init(void)
omap3beagle_nand_data.cs = nandcs;
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
-   if (platform_device_register(omap3beagle_nand_device)  0)
+   if (gpmc_nand_init(omap3beagle_nand_data)  0)
printk(KERN_ERR Unable to register NAND device\n);
}
 }
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c 
b/arch/arm/mach-omap2/board-omap3touchbook.c
index d6f1b12..e8ad30c
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -103,20 +103,6 @@ static struct omap_nand_platform_data 
omap3touchbook_nand_data = {
.dev_ready  = NULL,
 };
 
-static struct resource omap3touchbook_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device omap3touchbook_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .dev= {
-   .platform_data  = omap3touchbook_nand_data,
-   },
-   .num_resources  = 1,
-   .resource   = omap3touchbook_nand_resource,
-};
-
 #include sdram-micron-mt46h32m32lf-6.h
 
 static struct omap2_hsmmc_info mmc[] = {
@@ -479,7 +465,7 @@ static void __init omap3touchbook_flash_init(void)
omap3touchbook_nand_data.cs = nandcs

[PATCH 0/3] omap3 nand: cleanup exiting platform related code

2010-05-12 Thread Sukumar Ghorai
   The following set of patches applies on top of master branch.
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git
   Patches verified on: omap3430-SDP, omap3630-sdp, zoom3 and beagle board

   And these are the patches required to address the following input -
 1. The NAND driver needs to stop tinkering with the GPMC registers
The omap General Purpose Memory Controller (GPMC) registers are omap
specific, and not driver specific. Tinkering with these registers can
cause issues with the other devices on the GPMC.

 2. Passing hardcoded GPMC_CS0_BASE needs to go from the board files
Passing hardcoded GPMC virtual addressess is sure way to mess up things.
This should all become unnecessary once the NAND drivers stops messing
with the GPMC registers directly.

Sukumar Ghorai (3):
omap3: GPMC register definition at common location
omap3 nand: cleanup for not to use GPMC virtual address
omap3 nand: fix issue in board file to detect the nand

 arch/arm/mach-omap2/board-cm-t35.c |   20 +
 arch/arm/mach-omap2/board-devkit8000.c |   25 +--
 arch/arm/mach-omap2/board-omap3beagle.c|   24 +-
 arch/arm/mach-omap2/board-omap3touchbook.c |   25 +--
 arch/arm/mach-omap2/board-overo.c  |   24 +-
 arch/arm/mach-omap2/gpmc.c |   67 +---
 arch/arm/plat-omap/include/plat/gpmc.h |   41 -
 arch/arm/plat-omap/include/plat/nand.h |6 +-
 drivers/mtd/nand/omap2.c   |  125 ++--
 9 files changed, 109 insertions(+), 248 deletions(-)


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] omap3 nand: cleanup for not to use GPMC virtual address

2010-05-12 Thread Sukumar Ghorai
Necessary function added in GPMC module and used by nand driver. This is for
not to use GPMC address directly from nand driver. Also it was passing GPMC
base address from board files and that is removed.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-cm-t35.c |4 -
 arch/arm/mach-omap2/board-devkit8000.c |9 --
 arch/arm/mach-omap2/board-omap3beagle.c|8 --
 arch/arm/mach-omap2/board-omap3touchbook.c |9 --
 arch/arm/mach-omap2/board-overo.c  |7 --
 arch/arm/mach-omap2/gpmc.c |   29 ---
 arch/arm/plat-omap/include/plat/gpmc.h |5 +-
 arch/arm/plat-omap/include/plat/nand.h |6 +-
 drivers/mtd/nand/omap2.c   |  117 ++-
 9 files changed, 67 insertions(+), 127 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index e679a2c..fb23122
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -61,8 +61,6 @@
 #define SB_T35_SMSC911X_GPIO   65
 
 #define NAND_BLOCK_SIZESZ_128K
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS0_BASE_ADDR (OMAP34XX_GPMC_VIRT + GPMC_CS0_BASE)
 
 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 #include linux/smsc911x.h
@@ -223,8 +221,6 @@ static struct omap_nand_platform_data cm_t35_nand_data = {
.nr_parts   = ARRAY_SIZE(cm_t35_nand_partitions),
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
.cs = 0,
-   .gpmc_cs_baseaddr   = (void __iomem *)GPMC_CS0_BASE_ADDR,
-   .gpmc_baseaddr  = (void __iomem *)OMAP34XX_GPMC_VIRT,
 
 };
 
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index 47e3af2..be50d18
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -58,9 +58,6 @@
 #include mux.h
 #include hsmmc.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 #define OMAP_DM9000_GPIO_IRQ   25
@@ -581,8 +578,6 @@ static void __init devkit8000_flash_init(void)
u8 cs = 0;
u8 nandcs = GPMC_CS_NUM + 1;
 
-   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
-
/* find out the chip-select on which NAND exists */
while (cs  GPMC_CS_NUM) {
u32 ret = 0;
@@ -604,10 +599,6 @@ static void __init devkit8000_flash_init(void)
 
if (nandcs  GPMC_CS_NUM) {
devkit8000_nand_data.cs = nandcs;
-   devkit8000_nand_data.gpmc_cs_baseaddr = (void *)
-   (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
-   devkit8000_nand_data.gpmc_baseaddr = (void *)
-   (gpmc_base_add);
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
if (platform_device_register(devkit8000_nand_device)  0)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 962d377..becaebe
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -47,9 +47,6 @@
 #include mux.h
 #include hsmmc.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 static struct mtd_partition omap3beagle_nand_partitions[] = {
@@ -377,8 +374,6 @@ static void __init omap3beagle_flash_init(void)
u8 cs = 0;
u8 nandcs = GPMC_CS_NUM + 1;
 
-   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
-
/* find out the chip-select on which NAND exists */
while (cs  GPMC_CS_NUM) {
u32 ret = 0;
@@ -400,9 +395,6 @@ static void __init omap3beagle_flash_init(void)
 
if (nandcs  GPMC_CS_NUM) {
omap3beagle_nand_data.cs = nandcs;
-   omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
-   (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
-   omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
if (platform_device_register(omap3beagle_nand_device)  0)
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c 
b/arch/arm/mach-omap2/board-omap3touchbook.c
index 2504d41..d6f1b12
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -54,9 +54,6 @@
 
 #include asm/setup.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 #define OMAP3_AC_GPIO  136
@@ -459,8 +456,6 @@ static void __init omap3touchbook_flash_init(void)
u8 cs = 0;
u8 nandcs = GPMC_CS_NUM + 1;
 
-   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
-
/* find out the chip-select on which NAND exists */
while (cs  GPMC_CS_NUM) {
u32 ret = 0;
@@ -482,10 +477,6 @@ static void

[PATCH v2 0/2] omap3 nand: cleanup exiting platform related code

2010-05-14 Thread Sukumar Ghorai
  v2:
   The following set of patches applies on top of master branch.
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git
   Patches verified on: omap3430-SDP, omap3630-sdp, zoom3 and beagle board

   And these are the patches required to address the following input -
 1. The NAND driver needs to stop tinkering with the GPMC registers
The omap General Purpose Memory Controller (GPMC) registers are omap
specific, and not driver specific. Tinkering with these registers can
cause issues with the other devices on the GPMC.

 2. Passing hardcoded GPMC_CS0_BASE needs to go from the board files
Passing hardcoded GPMC virtual addressess is sure way to mess up things.
This should all become unnecessary once the NAND drivers stops messing
with the GPMC registers directly.

  v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg28164.html

Sukumar Ghorai (2):
omap3 nand: cleanup for not to use GPMC virtual address
omap3 nand: fix issue in board file to detect the nand

 arch/arm/mach-omap2/board-cm-t35.c |   20 +---
 arch/arm/mach-omap2/board-devkit8000.c |   25 +---
 arch/arm/mach-omap2/board-omap3beagle.c|   24 +---
 arch/arm/mach-omap2/board-omap3touchbook.c |   25 +---
 arch/arm/mach-omap2/board-overo.c  |   24 +---
 arch/arm/mach-omap2/gpmc-nand.c|   38 ++
 arch/arm/mach-omap2/gpmc-onenand.c |2 +-
 arch/arm/mach-omap2/gpmc.c |  244 
 arch/arm/plat-omap/include/plat/gpmc.h |   36 -
 arch/arm/plat-omap/include/plat/nand.h |6 +-
 drivers/mtd/nand/omap2.c   |  190 ++
 11 files changed, 306 insertions(+), 328 deletions(-)


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] omap3 nand: fix issue in board file to detect the nand

2010-05-14 Thread Sukumar Ghorai
Board file modified to pass the GMPC phys_base address to nand driver. This is
required to adopt the _prob function as in omap2.c

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-cm-t35.c |   16 +---
 arch/arm/mach-omap2/board-devkit8000.c |   16 +---
 arch/arm/mach-omap2/board-omap3beagle.c|   16 +---
 arch/arm/mach-omap2/board-omap3touchbook.c |   16 +---
 arch/arm/mach-omap2/board-overo.c  |   17 +
 5 files changed, 5 insertions(+), 76 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index fb23122..0544294
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -224,23 +224,9 @@ static struct omap_nand_platform_data cm_t35_nand_data = {
 
 };
 
-static struct resource cm_t35_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device cm_t35_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .num_resources  = 1,
-   .resource   = cm_t35_nand_resource,
-   .dev= {
-   .platform_data  = cm_t35_nand_data,
-   },
-};
-
 static void __init cm_t35_init_nand(void)
 {
-   if (platform_device_register(cm_t35_nand_device)  0)
+   if (gpmc_nand_init(cm_t35_nand_data)  0)
pr_err(CM-T35: Unable to register NAND device\n);
 }
 #else
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index ca4e409..9a8135d
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -101,20 +101,6 @@ static struct omap_nand_platform_data devkit8000_nand_data 
= {
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
 };
 
-static struct resource devkit8000_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device devkit8000_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .dev= {
-   .platform_data  = devkit8000_nand_data,
-   },
-   .num_resources  = 1,
-   .resource   = devkit8000_nand_resource,
-};
-
 static struct omap2_hsmmc_info mmc[] = {
{
.mmc= 1,
@@ -601,7 +587,7 @@ static void __init devkit8000_flash_init(void)
devkit8000_nand_data.cs = nandcs;
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
-   if (platform_device_register(devkit8000_nand_device)  0)
+   if (gpmc_nand_init(devkit8000_nand_data)  0)
printk(KERN_ERR Unable to register NAND device\n);
}
 }
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index becaebe..bf31b7c
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -89,20 +89,6 @@ static struct omap_nand_platform_data omap3beagle_nand_data 
= {
.dev_ready  = NULL,
 };
 
-static struct resource omap3beagle_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device omap3beagle_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .dev= {
-   .platform_data  = omap3beagle_nand_data,
-   },
-   .num_resources  = 1,
-   .resource   = omap3beagle_nand_resource,
-};
-
 #include sdram-micron-mt46h32m32lf-6.h
 
 static struct omap2_hsmmc_info mmc[] = {
@@ -397,7 +383,7 @@ static void __init omap3beagle_flash_init(void)
omap3beagle_nand_data.cs = nandcs;
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
-   if (platform_device_register(omap3beagle_nand_device)  0)
+   if (gpmc_nand_init(omap3beagle_nand_data)  0)
printk(KERN_ERR Unable to register NAND device\n);
}
 }
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c 
b/arch/arm/mach-omap2/board-omap3touchbook.c
index d6f1b12..e8ad30c
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -103,20 +103,6 @@ static struct omap_nand_platform_data 
omap3touchbook_nand_data = {
.dev_ready  = NULL,
 };
 
-static struct resource omap3touchbook_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device omap3touchbook_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .dev= {
-   .platform_data  = omap3touchbook_nand_data,
-   },
-   .num_resources  = 1,
-   .resource   = omap3touchbook_nand_resource,
-};
-
 #include sdram-micron-mt46h32m32lf-6.h
 
 static struct omap2_hsmmc_info mmc[] = {
@@ -479,7 +465,7 @@ static void __init omap3touchbook_flash_init(void)
omap3touchbook_nand_data.cs = nandcs

[PATCH v2 1/2] omap3 nand: cleanup for not to use GPMC virtual address

2010-05-14 Thread Sukumar Ghorai
Necessary function added in GPMC module and used by nand driver. This is for
not to use GPMC address directly from nand driver. Also it was passing GPMC
base address from board files and that is removed.

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-cm-t35.c |4 -
 arch/arm/mach-omap2/board-devkit8000.c |9 -
 arch/arm/mach-omap2/board-omap3beagle.c|8 -
 arch/arm/mach-omap2/board-omap3touchbook.c |9 -
 arch/arm/mach-omap2/board-overo.c  |7 -
 arch/arm/mach-omap2/gpmc-nand.c|   38 ++
 arch/arm/mach-omap2/gpmc-onenand.c |2 +-
 arch/arm/mach-omap2/gpmc.c |  244 
 arch/arm/plat-omap/include/plat/gpmc.h |   36 -
 arch/arm/plat-omap/include/plat/nand.h |6 +-
 drivers/mtd/nand/omap2.c   |  190 ++
 11 files changed, 301 insertions(+), 252 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index f4e8063..87bed2a
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -61,8 +61,6 @@
 #define SB_T35_SMSC911X_GPIO   65
 
 #define NAND_BLOCK_SIZESZ_128K
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS0_BASE_ADDR (OMAP34XX_GPMC_VIRT + GPMC_CS0_BASE)
 
 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 #include linux/smsc911x.h
@@ -223,8 +221,6 @@ static struct omap_nand_platform_data cm_t35_nand_data = {
.nr_parts   = ARRAY_SIZE(cm_t35_nand_partitions),
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
.cs = 0,
-   .gpmc_cs_baseaddr   = (void __iomem *)GPMC_CS0_BASE_ADDR,
-   .gpmc_baseaddr  = (void __iomem *)OMAP34XX_GPMC_VIRT,
 
 };
 
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index 6d910df..ef9b677
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -58,9 +58,6 @@
 #include mux.h
 #include hsmmc.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 #define OMAP_DM9000_GPIO_IRQ   25
@@ -581,8 +578,6 @@ static void __init devkit8000_flash_init(void)
u8 cs = 0;
u8 nandcs = GPMC_CS_NUM + 1;
 
-   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
-
/* find out the chip-select on which NAND exists */
while (cs  GPMC_CS_NUM) {
u32 ret = 0;
@@ -604,10 +599,6 @@ static void __init devkit8000_flash_init(void)
 
if (nandcs  GPMC_CS_NUM) {
devkit8000_nand_data.cs = nandcs;
-   devkit8000_nand_data.gpmc_cs_baseaddr = (void *)
-   (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
-   devkit8000_nand_data.gpmc_baseaddr = (void *)
-   (gpmc_base_add);
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
if (platform_device_register(devkit8000_nand_device)  0)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 5df89f6..e90dd2a
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -47,9 +47,6 @@
 #include mux.h
 #include hsmmc.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 static struct mtd_partition omap3beagle_nand_partitions[] = {
@@ -377,8 +374,6 @@ static void __init omap3beagle_flash_init(void)
u8 cs = 0;
u8 nandcs = GPMC_CS_NUM + 1;
 
-   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
-
/* find out the chip-select on which NAND exists */
while (cs  GPMC_CS_NUM) {
u32 ret = 0;
@@ -400,9 +395,6 @@ static void __init omap3beagle_flash_init(void)
 
if (nandcs  GPMC_CS_NUM) {
omap3beagle_nand_data.cs = nandcs;
-   omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
-   (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
-   omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
if (platform_device_register(omap3beagle_nand_device)  0)
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c 
b/arch/arm/mach-omap2/board-omap3touchbook.c
index c59050d..4a6c984
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -54,9 +54,6 @@
 
 #include asm/setup.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 #define OMAP3_AC_GPIO  136
@@ -459,8 +456,6 @@ static void __init omap3touchbook_flash_init(void)
u8 cs = 0;
u8 nandcs = GPMC_CS_NUM + 1;
 
-   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
-
/* find out the chip

[PATCH v3 0/3] omap3 nand: cleanup exiting platform related code

2010-05-18 Thread Sukumar Ghorai
   The following set of patches applies on top of for-next branch.
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git
   Patches verified on: omap3430-SDP, omap3630-sdp, zoom3 and beagle board

   And these are the patches required to address the following input -
 1. The NAND driver needs to stop tinkering with the GPMC registers
The omap General Purpose Memory Controller (GPMC) registers are omap
specific, and not driver specific. Tinkering with these registers can
cause issues with the other devices on the GPMC.

 2. Passing hardcoded GPMC_CS0_BASE needs to go from the board files
Passing hardcoded GPMC virtual addressess is sure way to mess up things.
This should all become unnecessary once the NAND drivers stops messing
with the GPMC registers directly.

  v2: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg28467.html
Few functionality was missing  like - There should be some locking 
as only one chipselect can use the ECC or prefetch engine at a time. 
If you have NAND in two chipselects, bad things would happen.

  v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg28164.html
Additionally, it was needed to implement more functions for the
platform init code to use.


Sukumar Ghorai (3):
omap3 gpmc: functionality enhancement
omap3 nand: cleanup virtual address usages
omap3 nand: fix issue in board file to detect nand

 arch/arm/mach-omap2/board-cm-t35.c |   20 +---
 arch/arm/mach-omap2/board-devkit8000.c |   25 +---
 arch/arm/mach-omap2/board-omap3beagle.c|   24 +---
 arch/arm/mach-omap2/board-omap3touchbook.c |   25 +---
 arch/arm/mach-omap2/board-overo.c  |   24 +---
 arch/arm/mach-omap2/gpmc-nand.c|   39 ++
 arch/arm/mach-omap2/gpmc.c |9 -
 arch/arm/plat-omap/include/plat/gpmc.h |7 +-
 arch/arm/plat-omap/include/plat/nand.h |6 +-
 drivers/mtd/nand/omap2.c   |  242 +---
 10 files changed, 93 insertions(+), 328 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/3] omap3 gpmc: functionality enhancement

2010-05-18 Thread Sukumar Ghorai
few functions added in gpmc module and to be used by other drivers like NAND.
E.g.: - ioctl function
  - ecc functions

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |  246 +++-
 arch/arm/plat-omap/include/plat/gpmc.h |   35 -
 drivers/mtd/nand/omap2.c   |4 +-
 3 files changed, 274 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5bc3ca0..7e6d821
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -46,8 +46,9 @@
 #define GPMC_ECC_CONFIG0x1f4
 #define GPMC_ECC_CONTROL   0x1f8
 #define GPMC_ECC_SIZE_CONFIG   0x1fc
+#define GPMC_ECC1_RESULT0x200
 
-#define GPMC_CS0   0x60
+#define GPMC_CS0_BASE  0x60
 #define GPMC_CS_SIZE   0x30
 
 #define GPMC_MEM_START 0x
@@ -92,7 +93,9 @@ struct omap3_gpmc_regs {
 static struct resource gpmc_mem_root;
 static struct resource gpmc_cs_mem[GPMC_CS_NUM];
 static DEFINE_SPINLOCK(gpmc_mem_lock);
-static unsignedgpmc_cs_map;
+static unsignedint gpmc_cs_map;/* flag for cs which are 
initialized */
+static int gpmc_pref_used = -EINVAL;   /* cs using prefetch engine */
+static int gpmc_ecc_used = -EINVAL;/* cs using ecc engine */
 
 static void __iomem *gpmc_base;
 
@@ -108,11 +111,27 @@ static u32 gpmc_read_reg(int idx)
return __raw_readl(gpmc_base + idx);
 }
 
+static void gpmc_cs_write_byte(int cs, int idx, u8 val)
+{
+   void __iomem *reg_addr;
+
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
+   __raw_writeb(val, reg_addr);
+}
+
+static u8 gpmc_cs_read_byte(int cs, int idx)
+{
+   void __iomem *reg_addr;
+
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
+   return __raw_readb(reg_addr);
+}
+
 void gpmc_cs_write_reg(int cs, int idx, u32 val)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
__raw_writel(val, reg_addr);
 }
 
@@ -120,7 +139,7 @@ u32 gpmc_cs_read_reg(int cs, int idx)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
return __raw_readl(reg_addr);
 }
 
@@ -419,8 +438,100 @@ void gpmc_cs_free(int cs)
 EXPORT_SYMBOL(gpmc_cs_free);
 
 /**
+ * gpmc_hwcontrol - hardware specific access (read/ write) control
+ * @cs: chip select number
+ * @cmd: command type
+ * @write: 1 for write; 0 for read
+ * @wval: value to write
+ * @rval: read pointer
+ */
+int gpmc_hwcontrol(int cs, int cmd, int write, int wval, int *rval)
+{
+   u32 regval = 0;
+
+   if (!write  !rval)
+   return -EINVAL;
+
+   switch (cmd) {
+   case GPMC_STATUS_BUFFER:
+   regval = gpmc_read_reg(GPMC_STATUS);
+   /* 1 : buffer is available to write */
+   *rval = regval  GPMC_STATUS_BUFF_EMPTY;
+   break;
+
+   case GPMC_GET_SET_IRQ_STATUS:
+   if (write)
+   gpmc_write_reg(GPMC_IRQSTATUS, wval);
+   else
+   *rval = gpmc_read_reg(GPMC_IRQSTATUS);
+   break;
+
+   case GPMC_PREFETCH_FIFO_CNT:
+   regval = gpmc_read_reg(GPMC_PREFETCH_STATUS);
+   *rval = GPMC_PREFETCH_STATUS_FIFO_CNT(regval);
+   break;
+
+   case GPMC_PREFETCH_COUNT:
+   regval = gpmc_read_reg(GPMC_PREFETCH_STATUS);
+   *rval = GPMC_PREFETCH_STATUS_COUNT(regval);
+   break;
+
+   case GPMC_CONFIG_WP:
+   regval = gpmc_read_reg(GPMC_CONFIG);
+   if (wval)
+   regval = ~GPMC_CONFIG_WRITEPROTECT; /* WP is ON */
+   else
+   regval |= GPMC_CONFIG_WRITEPROTECT;  /* WP is OFF */
+   gpmc_write_reg(GPMC_CONFIG, regval);
+   break;
+
+   case GPMC_CONFIG_RDY_BSY:
+   regval  = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
+   regval |= WR_RD_PIN_MONITORING;
+   gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
+   break;
+
+   case GPMC_CONFIG_DEV_SIZE:
+   regval  = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
+   regval |= GPMC_CONFIG1_DEVICESIZE(wval);
+   gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
+   break;
+
+   case GPMC_CONFIG_DEV_TYPE:
+   regval  = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
+   regval |= GPMC_CONFIG1_DEVICETYPE(wval);
+   if (wval == GPMC_DEVICETYPE_NOR)
+   regval |= GPMC_CONFIG1_MUXADDDATA;
+   gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
+   break;
+
+   case GPMC_NAND_COMMAND

[PATCH v3 3/3] omap3 nand: fix issue in board file to detect nand

2010-05-18 Thread Sukumar Ghorai
Board file modified for not to provide gpmc phys_base address to nand driver.
The gpmc_nand_init funciton is now used to detect the nand and required to
adopt _prob function as in nand/omap2.c

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-cm-t35.c |   20 +---
 arch/arm/mach-omap2/board-devkit8000.c |   25 +
 arch/arm/mach-omap2/board-omap3beagle.c|   24 +---
 arch/arm/mach-omap2/board-omap3touchbook.c |   25 +
 arch/arm/mach-omap2/board-overo.c  |   24 +---
 5 files changed, 5 insertions(+), 113 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index f4e8063..8a41268
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -61,8 +61,6 @@
 #define SB_T35_SMSC911X_GPIO   65
 
 #define NAND_BLOCK_SIZESZ_128K
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS0_BASE_ADDR (OMAP34XX_GPMC_VIRT + GPMC_CS0_BASE)
 
 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 #include linux/smsc911x.h
@@ -223,28 +221,12 @@ static struct omap_nand_platform_data cm_t35_nand_data = {
.nr_parts   = ARRAY_SIZE(cm_t35_nand_partitions),
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
.cs = 0,
-   .gpmc_cs_baseaddr   = (void __iomem *)GPMC_CS0_BASE_ADDR,
-   .gpmc_baseaddr  = (void __iomem *)OMAP34XX_GPMC_VIRT,
 
 };
 
-static struct resource cm_t35_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device cm_t35_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .num_resources  = 1,
-   .resource   = cm_t35_nand_resource,
-   .dev= {
-   .platform_data  = cm_t35_nand_data,
-   },
-};
-
 static void __init cm_t35_init_nand(void)
 {
-   if (platform_device_register(cm_t35_nand_device)  0)
+   if (gpmc_nand_init(cm_t35_nand_data)  0)
pr_err(CM-T35: Unable to register NAND device\n);
 }
 #else
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index 6d910df..b172414
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -58,9 +58,6 @@
 #include mux.h
 #include hsmmc.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 #define OMAP_DM9000_GPIO_IRQ   25
@@ -104,20 +101,6 @@ static struct omap_nand_platform_data devkit8000_nand_data 
= {
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
 };
 
-static struct resource devkit8000_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device devkit8000_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .dev= {
-   .platform_data  = devkit8000_nand_data,
-   },
-   .num_resources  = 1,
-   .resource   = devkit8000_nand_resource,
-};
-
 static struct omap2_hsmmc_info mmc[] = {
{
.mmc= 1,
@@ -581,8 +564,6 @@ static void __init devkit8000_flash_init(void)
u8 cs = 0;
u8 nandcs = GPMC_CS_NUM + 1;
 
-   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
-
/* find out the chip-select on which NAND exists */
while (cs  GPMC_CS_NUM) {
u32 ret = 0;
@@ -604,13 +585,9 @@ static void __init devkit8000_flash_init(void)
 
if (nandcs  GPMC_CS_NUM) {
devkit8000_nand_data.cs = nandcs;
-   devkit8000_nand_data.gpmc_cs_baseaddr = (void *)
-   (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
-   devkit8000_nand_data.gpmc_baseaddr = (void *)
-   (gpmc_base_add);
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
-   if (platform_device_register(devkit8000_nand_device)  0)
+   if (gpmc_nand_init(devkit8000_nand_data)  0)
printk(KERN_ERR Unable to register NAND device\n);
}
 }
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 5df89f6..9ec3ef8 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -47,9 +47,6 @@
 #include mux.h
 #include hsmmc.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 static struct mtd_partition omap3beagle_nand_partitions[] = {
@@ -92,20 +89,6 @@ static struct omap_nand_platform_data omap3beagle_nand_data 
= {
.dev_ready  = NULL,
 };
 
-static struct resource omap3beagle_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device

[PATCH v3 2/3] omap3 nand: cleanup virtual address usages

2010-05-18 Thread Sukumar Ghorai
This patch removes direct reference of gpmc address from generic nand platform 
code.
Nand platform code now uses wrapper functions which are implemented in gpmc 
module. 

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc-nand.c|   39 ++
 arch/arm/mach-omap2/gpmc.c |9 --
 arch/arm/plat-omap/include/plat/gpmc.h |7 +-
 arch/arm/plat-omap/include/plat/nand.h |6 +-
 drivers/mtd/nand/omap2.c   |  242 ++--
 5 files changed, 88 insertions(+), 215 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c
index e57fb29..80f5d94
--- a/arch/arm/mach-omap2/gpmc-nand.c
+++ b/arch/arm/mach-omap2/gpmc-nand.c
@@ -19,8 +19,6 @@
 #include plat/board.h
 #include plat/gpmc.h
 
-#define WR_RD_PIN_MONITORING   0x0060
-
 static struct omap_nand_platform_data *gpmc_nand_data;
 
 static struct resource gpmc_nand_resource = {
@@ -71,10 +69,10 @@ static int omap2_nand_gpmc_retime(void)
t.wr_cycle  = gpmc_round_ns_to_ticks(gpmc_nand_data-gpmc_t-wr_cycle);
 
/* Configure GPMC */
-   gpmc_cs_write_reg(gpmc_nand_data-cs, GPMC_CS_CONFIG1,
-   GPMC_CONFIG1_DEVICESIZE(gpmc_nand_data-devsize) |
-   GPMC_CONFIG1_DEVICETYPE_NAND);
-
+   gpmc_hwcontrol(gpmc_nand_data-cs,
+   GPMC_CONFIG_DEV_SIZE, 1, gpmc_nand_data-devsize, NULL);
+   gpmc_hwcontrol(gpmc_nand_data-cs,
+   GPMC_CONFIG_DEV_TYPE, 1, GPMC_DEVICETYPE_NAND, NULL);
err = gpmc_cs_set_timings(gpmc_nand_data-cs, t);
if (err)
return err;
@@ -82,27 +80,13 @@ static int omap2_nand_gpmc_retime(void)
return 0;
 }
 
-static int gpmc_nand_setup(void)
-{
-   struct device *dev = gpmc_nand_device.dev;
-
-   /* Set timings in GPMC */
-   if (omap2_nand_gpmc_retime()  0) {
-   dev_err(dev, Unable to set gpmc timings\n);
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
 int __init gpmc_nand_init(struct omap_nand_platform_data *_nand_data)
 {
-   unsigned int val;
int err = 0;
struct device *dev = gpmc_nand_device.dev;
 
gpmc_nand_data = _nand_data;
-   gpmc_nand_data-nand_setup = gpmc_nand_setup;
+   gpmc_nand_data-nand_setup = omap2_nand_gpmc_retime;
gpmc_nand_device.dev.platform_data = gpmc_nand_data;
 
err = gpmc_cs_request(gpmc_nand_data-cs, NAND_IO_SIZE,
@@ -112,19 +96,17 @@ int __init gpmc_nand_init(struct omap_nand_platform_data 
*_nand_data)
return err;
}
 
-   err = gpmc_nand_setup();
+/* Set timings in GPMC */
+   err = omap2_nand_gpmc_retime();
if (err  0) {
-   dev_err(dev, NAND platform setup failed: %d\n, err);
+   dev_err(dev, Unable to set gpmc timings: %d\n, err);
return err;
}
 
/* Enable RD PIN Monitoring Reg */
if (gpmc_nand_data-dev_ready) {
-   val  = gpmc_cs_read_reg(gpmc_nand_data-cs,
-GPMC_CS_CONFIG1);
-   val |= WR_RD_PIN_MONITORING;
-   gpmc_cs_write_reg(gpmc_nand_data-cs,
-   GPMC_CS_CONFIG1, val);
+   gpmc_hwcontrol(gpmc_nand_data-cs,
+   GPMC_CONFIG_RDY_BSY, 1, 1, NULL);
}
 
err = platform_device_register(gpmc_nand_device);
@@ -140,3 +122,4 @@ out_free_cs:
 
return err;
 }
+
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index f414aeb..cbe0efb
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -589,15 +589,6 @@ int gpmc_prefetch_reset(int cs)
 }
 EXPORT_SYMBOL(gpmc_prefetch_reset);
 
-/**
- * gpmc_prefetch_status - reads prefetch status of engine
- */
-int  gpmc_prefetch_status(void)
-{
-   return gpmc_read_reg(GPMC_PREFETCH_STATUS);
-}
-EXPORT_SYMBOL(gpmc_prefetch_status);
-
 static void __init gpmc_mem_init(void)
 {
int cs;
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h 
b/arch/arm/plat-omap/include/plat/gpmc.h
index 67a3442..2386ff6
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -25,9 +25,6 @@
 #define GPMC_CS_NAND_ADDRESS   0x20
 #define GPMC_CS_NAND_DATA  0x24
 
-#define GPMC_CONFIG0x50
-#define GPMC_STATUS0x54
-
 /* Control Commands */
 #define GPMC_CONFIG_WP 0x0001
 #define GPMC_CONFIG_RDY_BSY0x0002
@@ -63,7 +60,6 @@
 #define GPMC_CONFIG1_DEVICESIZE_16  GPMC_CONFIG1_DEVICESIZE(1)
 #define GPMC_CONFIG1_DEVICETYPE(val)((val  3)  10)
 #define GPMC_CONFIG1_DEVICETYPE_NOR GPMC_CONFIG1_DEVICETYPE(0)
-#define GPMC_CONFIG1_DEVICETYPE_NANDGPMC_CONFIG1_DEVICETYPE(2)
 #define GPMC_CONFIG1_MUXADDDATA (1  9)
 #define GPMC_CONFIG1_TIME_PARA_GRAN (1  4)
 #define GPMC_CONFIG1_FCLK_DIV(val)  (val  3)
@@ -77,7 +73,7

[PATCH v4 0/3] omap3 nand: cleanup exiting platform related code

2010-05-27 Thread Sukumar Ghorai
   The following set of patches applies on top of for-next branch.
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git
   Patches verified on: omap3430-SDP, omap3630-sdp, zoom3 and beagle board

   And these are the patches required to address the following input -
 1. The NAND driver needs to stop tinkering with the GPMC registers
The omap General Purpose Memory Controller (GPMC) registers are omap
specific, and not driver specific. Tinkering with these registers can
cause issues with the other devices on the GPMC.

 2. Passing hardcoded GPMC_CS0_BASE needs to go from the board files
Passing hardcoded GPMC virtual addressess is sure way to mess up things.
This should all become unnecessary once the NAND drivers stops messing
with the GPMC registers directly.
 Discussion: 
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg27630.html

  v3: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg28715.html
Functions related to ecc and prefetch engine are optimized.

  v2: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg28467.html
Few functionality was missing  like - There should be some locking 
as only one chipselect can use the ECC or prefetch engine at a time. 
If you have NAND in two chipselects, bad things would happen.

  v1: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg28164.html
Additionally, it was needed to implement more functions for the
platform init code to use.


Sukumar Ghorai (3):
omap3 gpmc: functionality enhancement
omap3 nand: cleanup virtual address usages
omap3 nand: fix issue in board file to detect nand
 arch/arm/mach-omap2/board-cm-t35.c |   20 +---
 arch/arm/mach-omap2/board-devkit8000.c |   25 +---
 arch/arm/mach-omap2/board-omap3beagle.c|   24 +---
 arch/arm/mach-omap2/board-omap3touchbook.c |   25 +---
 arch/arm/mach-omap2/board-overo.c  |   24 +---
 arch/arm/mach-omap2/gpmc-nand.c|   39 ++
 arch/arm/mach-omap2/gpmc.c |  219 +--
 arch/arm/plat-omap/include/plat/gpmc.h |   36 -
 arch/arm/plat-omap/include/plat/nand.h |6 +-
 drivers/mtd/nand/omap2.c   |  229 
 10 files changed, 320 insertions(+), 327 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/3] omap3 gpmc: functionality enhancement

2010-05-27 Thread Sukumar Ghorai
few functions added in gpmc module and to be used by other drivers like NAND.
E.g.: - ioctl function
  - ecc functions

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/gpmc.c |  219 ++--
 arch/arm/plat-omap/include/plat/gpmc.h |   33 +-
 drivers/mtd/nand/omap2.c   |4 +-
 3 files changed, 239 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5bc3ca0..48b5af0
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -46,8 +46,9 @@
 #define GPMC_ECC_CONFIG0x1f4
 #define GPMC_ECC_CONTROL   0x1f8
 #define GPMC_ECC_SIZE_CONFIG   0x1fc
+#define GPMC_ECC1_RESULT0x200
 
-#define GPMC_CS0   0x60
+#define GPMC_CS0_BASE  0x60
 #define GPMC_CS_SIZE   0x30
 
 #define GPMC_MEM_START 0x
@@ -92,7 +93,8 @@ struct omap3_gpmc_regs {
 static struct resource gpmc_mem_root;
 static struct resource gpmc_cs_mem[GPMC_CS_NUM];
 static DEFINE_SPINLOCK(gpmc_mem_lock);
-static unsignedgpmc_cs_map;
+static unsignedint gpmc_cs_map;/* flag for cs which are 
initialized */
+static int gpmc_ecc_used = -EINVAL;/* cs using ecc engine */
 
 static void __iomem *gpmc_base;
 
@@ -108,11 +110,27 @@ static u32 gpmc_read_reg(int idx)
return __raw_readl(gpmc_base + idx);
 }
 
+static void gpmc_cs_write_byte(int cs, int idx, u8 val)
+{
+   void __iomem *reg_addr;
+
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
+   __raw_writeb(val, reg_addr);
+}
+
+static u8 gpmc_cs_read_byte(int cs, int idx)
+{
+   void __iomem *reg_addr;
+
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
+   return __raw_readb(reg_addr);
+}
+
 void gpmc_cs_write_reg(int cs, int idx, u32 val)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
__raw_writel(val, reg_addr);
 }
 
@@ -120,7 +138,7 @@ u32 gpmc_cs_read_reg(int cs, int idx)
 {
void __iomem *reg_addr;
 
-   reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
+   reg_addr = gpmc_base + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE) + idx;
return __raw_readl(reg_addr);
 }
 
@@ -419,8 +437,100 @@ void gpmc_cs_free(int cs)
 EXPORT_SYMBOL(gpmc_cs_free);
 
 /**
+ * gpmc_hwcontrol - hardware specific access (read/ write) control
+ * @cs: chip select number
+ * @cmd: command type
+ * @write: 1 for write; 0 for read
+ * @wval: value to write
+ * @rval: read pointer
+ */
+int gpmc_hwcontrol(int cs, int cmd, int write, int wval, int *rval)
+{
+   u32 regval = 0;
+
+   if (!write  !rval)
+   return -EINVAL;
+
+   switch (cmd) {
+   case GPMC_STATUS_BUFFER:
+   regval = gpmc_read_reg(GPMC_STATUS);
+   /* 1 : buffer is available to write */
+   *rval = regval  GPMC_STATUS_BUFF_EMPTY;
+   break;
+
+   case GPMC_GET_SET_IRQ_STATUS:
+   if (write)
+   gpmc_write_reg(GPMC_IRQSTATUS, wval);
+   else
+   *rval = gpmc_read_reg(GPMC_IRQSTATUS);
+   break;
+
+   case GPMC_PREFETCH_FIFO_CNT:
+   regval = gpmc_read_reg(GPMC_PREFETCH_STATUS);
+   *rval = GPMC_PREFETCH_STATUS_FIFO_CNT(regval);
+   break;
+
+   case GPMC_PREFETCH_COUNT:
+   regval = gpmc_read_reg(GPMC_PREFETCH_STATUS);
+   *rval = GPMC_PREFETCH_STATUS_COUNT(regval);
+   break;
+
+   case GPMC_CONFIG_WP:
+   regval = gpmc_read_reg(GPMC_CONFIG);
+   if (wval)
+   regval = ~GPMC_CONFIG_WRITEPROTECT; /* WP is ON */
+   else
+   regval |= GPMC_CONFIG_WRITEPROTECT;  /* WP is OFF */
+   gpmc_write_reg(GPMC_CONFIG, regval);
+   break;
+
+   case GPMC_CONFIG_RDY_BSY:
+   regval  = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
+   regval |= WR_RD_PIN_MONITORING;
+   gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
+   break;
+
+   case GPMC_CONFIG_DEV_SIZE:
+   regval  = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
+   regval |= GPMC_CONFIG1_DEVICESIZE(wval);
+   gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
+   break;
+
+   case GPMC_CONFIG_DEV_TYPE:
+   regval  = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
+   regval |= GPMC_CONFIG1_DEVICETYPE(wval);
+   if (wval == GPMC_DEVICETYPE_NOR)
+   regval |= GPMC_CONFIG1_MUXADDDATA;
+   gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, regval);
+   break;
+
+   case GPMC_NAND_COMMAND:
+   gpmc_cs_write_byte(cs, GPMC_CS_NAND_COMMAND, wval

[PATCH v4 3/3] omap3 nand: fix issue in board file to detect nand

2010-05-27 Thread Sukumar Ghorai
Board file modified for not to provide gpmc phys_base address to nand driver.
The gpmc_nand_init funciton is now used to detect the nand and required to
adopt _prob function as in nand/omap2.c

Signed-off-by: Sukumar Ghorai s-gho...@ti.com
---
 arch/arm/mach-omap2/board-cm-t35.c |   20 +---
 arch/arm/mach-omap2/board-devkit8000.c |   25 +
 arch/arm/mach-omap2/board-omap3beagle.c|   24 +---
 arch/arm/mach-omap2/board-omap3touchbook.c |   25 +
 arch/arm/mach-omap2/board-overo.c  |   24 +---
 5 files changed, 5 insertions(+), 113 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index e679a2c..0544294
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -61,8 +61,6 @@
 #define SB_T35_SMSC911X_GPIO   65
 
 #define NAND_BLOCK_SIZESZ_128K
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS0_BASE_ADDR (OMAP34XX_GPMC_VIRT + GPMC_CS0_BASE)
 
 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 #include linux/smsc911x.h
@@ -223,28 +221,12 @@ static struct omap_nand_platform_data cm_t35_nand_data = {
.nr_parts   = ARRAY_SIZE(cm_t35_nand_partitions),
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
.cs = 0,
-   .gpmc_cs_baseaddr   = (void __iomem *)GPMC_CS0_BASE_ADDR,
-   .gpmc_baseaddr  = (void __iomem *)OMAP34XX_GPMC_VIRT,
 
 };
 
-static struct resource cm_t35_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device cm_t35_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .num_resources  = 1,
-   .resource   = cm_t35_nand_resource,
-   .dev= {
-   .platform_data  = cm_t35_nand_data,
-   },
-};
-
 static void __init cm_t35_init_nand(void)
 {
-   if (platform_device_register(cm_t35_nand_device)  0)
+   if (gpmc_nand_init(cm_t35_nand_data)  0)
pr_err(CM-T35: Unable to register NAND device\n);
 }
 #else
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index 77022b5..9a8135d
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -58,9 +58,6 @@
 #include mux.h
 #include hsmmc.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 #define OMAP_DM9000_GPIO_IRQ   25
@@ -104,20 +101,6 @@ static struct omap_nand_platform_data devkit8000_nand_data 
= {
.dma_channel= -1,   /* disable DMA in OMAP NAND driver */
 };
 
-static struct resource devkit8000_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device devkit8000_nand_device = {
-   .name   = omap2-nand,
-   .id = -1,
-   .dev= {
-   .platform_data  = devkit8000_nand_data,
-   },
-   .num_resources  = 1,
-   .resource   = devkit8000_nand_resource,
-};
-
 static struct omap2_hsmmc_info mmc[] = {
{
.mmc= 1,
@@ -581,8 +564,6 @@ static void __init devkit8000_flash_init(void)
u8 cs = 0;
u8 nandcs = GPMC_CS_NUM + 1;
 
-   u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
-
/* find out the chip-select on which NAND exists */
while (cs  GPMC_CS_NUM) {
u32 ret = 0;
@@ -604,13 +585,9 @@ static void __init devkit8000_flash_init(void)
 
if (nandcs  GPMC_CS_NUM) {
devkit8000_nand_data.cs = nandcs;
-   devkit8000_nand_data.gpmc_cs_baseaddr = (void *)
-   (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
-   devkit8000_nand_data.gpmc_baseaddr = (void *)
-   (gpmc_base_add);
 
printk(KERN_INFO Registering NAND on CS%d\n, nandcs);
-   if (platform_device_register(devkit8000_nand_device)  0)
+   if (gpmc_nand_init(devkit8000_nand_data)  0)
printk(KERN_ERR Unable to register NAND device\n);
}
 }
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 69b154c..dc5a7e8
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -48,9 +48,6 @@
 #include mux.h
 #include hsmmc.h
 
-#define GPMC_CS0_BASE  0x60
-#define GPMC_CS_SIZE   0x30
-
 #define NAND_BLOCK_SIZESZ_128K
 
 static struct mtd_partition omap3beagle_nand_partitions[] = {
@@ -93,20 +90,6 @@ static struct omap_nand_platform_data omap3beagle_nand_data 
= {
.dev_ready  = NULL,
 };
 
-static struct resource omap3beagle_nand_resource = {
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct platform_device omap3beagle_nand_device

  1   2   >