* [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
2010-09-27 13:37 [PATCH v5 0/5] nand prefetch-irq support and ecc layout chanage Sukumar Ghorai
@ 2010-09-27 13:37 ` Sukumar Ghorai
2010-09-28 22:27 ` Tony Lindgren
2010-09-27 13:37 ` [PATCH v5 2/5] omap3: nand: prefetch in irq mode support Sukumar Ghorai
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Sukumar Ghorai @ 2010-09-27 13:37 UTC (permalink / raw)
To: linux-omap; +Cc: linux-mtd, linux-arm-kernel, 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-ghorai@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);
omap_init_irq();
+ gpmc_init();
omap_gpio_init();
}
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index a07086d..8963561 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -449,6 +449,7 @@ static void __init devkit8000_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
mt46h32m32lf6_sdrc_params);
omap_init_irq();
+ gpmc_init();
#ifdef CONFIG_OMAP_32K_TIMER
omap2_gp_clockevent_set_gptimer(12);
#endif
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 3482b99..8dca149 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -29,6 +29,7 @@
#include <plat/usb.h>
#include <plat/board.h>
#include <plat/common.h>
+#include <plat/gpmc.h>
static struct omap_board_config_kernel generic_config[] = {
};
@@ -39,6 +40,7 @@ static void __init omap_generic_init_irq(void)
omap_board_config_size = ARRAY_SIZE(generic_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+ gpmc_init();
}
static void __init omap_generic_init(void)
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index e09bd68..a6790ba 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -293,6 +293,7 @@ static void __init omap_h4_init_irq(void)
omap_board_config_size = ARRAY_SIZE(h4_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+ gpmc_init();
omap_gpio_init();
h4_init_flash();
}
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index 175f043..6c3e7e0 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -406,6 +406,7 @@ static void __init igep2_init_irq(void)
omap_board_config_size = ARRAY_SIZE(igep2_config);
omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
omap_init_irq();
+ gpmc_init();
omap_gpio_init();
}
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 00d9b13..b31d8e1 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -292,6 +292,7 @@ static void __init omap_ldp_init_irq(void)
omap_board_config_size = ARRAY_SIZE(ldp_config);
omap2_init_common_hw(NULL, NULL);
omap_init_irq();
+ gpmc_init();
omap_gpio_init();
ldp_init_smsc911x();
}
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index a3e2b49..c3d842b 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -32,6 +32,7 @@
#include <plat/onenand.h>
#include <plat/mmc.h>
#include <plat/serial.h>
+#include <plat/gpmc.h>
#include "mux.h"
@@ -648,6 +649,7 @@ static void __init n8x0_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-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 87969c7..3a8bd5c 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -390,6 +390,7 @@ static void __init omap3_beagle_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
mt46h32m32lf6_sdrc_params);
omap_init_irq();
+ gpmc_init();
#ifdef CONFIG_OMAP_32K_TIMER
omap2_gp_clockevent_set_gptimer(12);
#endif
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index f76d9c0..f916fbd 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -42,6 +42,7 @@
#include <plat/common.h>
#include <plat/mcspi.h>
#include <plat/display.h>
+#include <plat/gpmc.h>
#include "mux.h"
#include "sdram-micron-mt46h32m32lf-6.h"
@@ -624,6 +625,7 @@ static void __init omap3_evm_init_irq(void)
omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL);
omap_init_irq();
+ gpmc_init();
omap_gpio_init();
}
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index dd3af2b..d6d6590 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -45,6 +45,7 @@
#include <plat/mcspi.h>
#include <plat/usb.h>
#include <plat/display.h>
+#include <plat/gpmc.h>
#include <plat/nand.h>
#include "mux.h"
@@ -604,6 +605,7 @@ static void __init omap3pandora_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
mt46h32m32lf6_sdrc_params);
omap_init_irq();
+ gpmc_init();
omap_gpio_init();
}
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index bcd01d2..85b30a2 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -585,6 +585,7 @@ static void __init omap3_stalker_init_irq(void)
omap_board_config_size = ARRAY_SIZE(omap3_stalker_config);
omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL);
omap_init_irq();
+ gpmc_init();
#ifdef CONFIG_OMAP_32K_TIMER
omap2_gp_clockevent_set_gptimer(12);
#endif
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 663c62d..28e3bf6 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -424,6 +424,7 @@ static void __init omap3_touchbook_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
mt46h32m32lf6_sdrc_params);
omap_init_irq();
+ gpmc_init();
#ifdef CONFIG_OMAP_32K_TIMER
omap2_gp_clockevent_set_gptimer(12);
#endif
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index c03d1d5..f4eea61 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -37,6 +37,7 @@
#include <plat/timer-gp.h>
#include <plat/usb.h>
#include <plat/mmc.h>
+#include <plat/gpmc.h>
#include "hsmmc.h"
@@ -44,6 +45,7 @@ static void __init omap4_panda_init_irq(void)
{
omap2_init_common_hw(NULL, NULL);
gic_init_irq();
+ gpmc_init();
omap_gpio_init();
}
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 4c48436..05d51de 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -415,6 +415,7 @@ static void __init overo_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
mt46h32m32lf6_sdrc_params);
omap_init_irq();
+ gpmc_init();
omap_gpio_init();
}
diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index a58e8cb..fe71a34 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -107,6 +107,7 @@ static void __init rx51_init_irq(void)
omap3_pm_init_cpuidle(rx51_cpuidle_params);
sdrc_params = rx51_get_sdram_timings();
omap2_init_common_hw(sdrc_params, sdrc_params);
+ gpmc_init();
omap_init_irq();
omap_gpio_init();
}
diff --git a/arch/arm/mach-omap2/board-zoom2.c b/arch/arm/mach-omap2/board-zoom2.c
index 3ad9ecf..9c7293c 100644
--- a/arch/arm/mach-omap2/board-zoom2.c
+++ b/arch/arm/mach-omap2/board-zoom2.c
@@ -20,6 +20,7 @@
#include <plat/common.h>
#include <plat/board.h>
+#include <plat/gpmc.h>
#include <mach/board-zoom.h>
@@ -31,6 +32,7 @@ static void __init omap_zoom2_init_irq(void)
omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
mt46h32m32lf6_sdrc_params);
omap_init_irq();
+ gpmc_init();
omap_gpio_init();
}
diff --git a/arch/arm/mach-omap2/board-zoom3.c b/arch/arm/mach-omap2/board-zoom3.c
index 6ca0b83..67c88ca 100644
--- a/arch/arm/mach-omap2/board-zoom3.c
+++ b/arch/arm/mach-omap2/board-zoom3.c
@@ -21,6 +21,7 @@
#include <plat/common.h>
#include <plat/board.h>
#include <plat/usb.h>
+#include <plat/gpmc.h>
#include "mux.h"
#include "sdram-hynix-h8mbx00u0mer-0em.h"
@@ -76,6 +77,7 @@ static void __init omap_zoom_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/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index f46933b..9ecb2a7 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,12 +23,12 @@
#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>
#include <plat/sdrc.h>
-
/* GPMC register offsets */
#define GPMC_REVISION 0x00
#define GPMC_SYSCONFIG 0x10
@@ -100,6 +101,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);
@@ -487,6 +490,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;
@@ -670,7 +677,8 @@ static void __init gpmc_mem_init(void)
void __init gpmc_init(void)
{
- u32 l;
+ u32 l, irq;
+ int cs;
char *ck = NULL;
if (cpu_is_omap24xx()) {
@@ -713,6 +721,31 @@ 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++;
+ }
+
+ if (request_irq(20, gpmc_handle_irq, IRQF_SHARED, "gpmc", gpmc_base))
+ printk(KERN_ERR "gpmc: irq-%d could not claim: err %d\n",
+ INT_34XX_GPMC_IRQ, irq);
+}
+
+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;
+ 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 b9ea70b..da2815f 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"
@@ -349,5 +348,4 @@ void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
_omap2_init_reprogram_sdrc();
}
- gpmc_init();
}
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 0x0000000b
#define GPMC_NAND_DATA 0x0000000c
+#define GPMC_ENABLE_IRQ 0x0000000d
+
/* 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 0x00600000
#define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F)
#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)
+#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..ea2a979 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_IRQ 16
#define INT_34XX_MCBSP2_IRQ 17
+#define INT_34XX_GPMC_IRQ 20
#define INT_34XX_MCBSP3_IRQ 22
#define INT_34XX_MCBSP4_IRQ 23
#define INT_34XX_CAM_IRQ 24
@@ -409,7 +410,13 @@
#define TWL_IRQ_END TWL6030_IRQ_END
#endif
-#define NR_IRQS TWL_IRQ_END
+/* GPMC related */
+#define OMAP_GPMC_IRQ_BASE (TWL_IRQ_END)
+#define OMAP_GPMC_NR_IRQS 7
+#define OMAP_GPMC_IRQ_END (OMAP_GPMC_IRQ_BASE + OMAP_GPMC_NR_IRQS)
+
+
+#define NR_IRQS OMAP_GPMC_IRQ_END
#define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32))
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
2010-09-27 13:37 ` [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc Sukumar Ghorai
@ 2010-09-28 22:27 ` Tony Lindgren
2010-09-29 6:37 ` Ghorai, Sukumar
2010-10-28 14:11 ` Ghorai, Sukumar
0 siblings, 2 replies; 15+ messages in thread
From: Tony Lindgren @ 2010-09-28 22:27 UTC (permalink / raw)
To: Sukumar Ghorai; +Cc: linux-omap, linux-mtd, linux-arm-kernel
* Sukumar Ghorai <s-ghorai@ti.com> [100927 06:30]:
> add support the irq mode in GPMC.
> gpmc_init() function move after omap_init_irq() as it has dependecy on irq.
> --- 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();
> }
...
You can avoid adding gpmc_init() by making it a subsys_initcall().
Just make sure you return early from it with if (!cpu_class_is_omap2()).
> --- a/arch/arm/mach-omap2/gpmc.c
> +++ b/arch/arm/mach-omap2/gpmc.c
> @@ -713,6 +721,31 @@ 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++;
> + }
> +
> + if (request_irq(20, gpmc_handle_irq, IRQF_SHARED, "gpmc", gpmc_base))
> + printk(KERN_ERR "gpmc: irq-%d could not claim: err %d\n",
> + INT_34XX_GPMC_IRQ, irq);
> +}
Hmm, this does not look right.. Shouldn't you call set_irq_chained_handler()
somewhere too? Also, are you sure the interrupt is 20 for all of mach-omap2?
It should be added to the irqs.h files.
> +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;
> + generic_handle_irq(OMAP_GPMC_IRQ_BASE+cs);
> +
> + return IRQ_HANDLED;
> }
Doesn't doing OMAP_GPMC_IRQ_BASE + cs overlap with some other irq?
Regards,
Tony
^ permalink raw reply [flat|nested] 15+ messages in thread* RE: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
2010-09-28 22:27 ` Tony Lindgren
@ 2010-09-29 6:37 ` Ghorai, Sukumar
2010-10-28 14:11 ` Ghorai, Sukumar
1 sibling, 0 replies; 15+ messages in thread
From: Ghorai, Sukumar @ 2010-09-29 6:37 UTC (permalink / raw)
To: Tony Lindgren
Cc: linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Wednesday, September 29, 2010 3:57 AM
> To: Ghorai, Sukumar
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org
> Subject: Re: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
>
> * Sukumar Ghorai <s-ghorai@ti.com> [100927 06:30]:
> > add support the irq mode in GPMC.
> > gpmc_init() function move after omap_init_irq() as it has dependecy on
> irq.
>
> > --- 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();
> > }
> ...
>
> You can avoid adding gpmc_init() by making it a subsys_initcall().
> Just make sure you return early from it with if (!cpu_class_is_omap2()).
[Ghorai] will do
>
> > --- a/arch/arm/mach-omap2/gpmc.c
> > +++ b/arch/arm/mach-omap2/gpmc.c
> > @@ -713,6 +721,31 @@ 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++;
> > + }
> > +
> > + if (request_irq(20, gpmc_handle_irq, IRQF_SHARED, "gpmc",
> gpmc_base))
> > + printk(KERN_ERR "gpmc: irq-%d could not claim: err %d\n",
> > + INT_34XX_GPMC_IRQ, irq);
> > +}
>
> Hmm, this does not look right.. Shouldn't you call
> set_irq_chained_handler()
> somewhere too?
[Ghorai] its not use, as multi-lebel irq is not there.
>Also, are you sure the interrupt is 20 for all of mach-
> omap2?
> It should be added to the irqs.h files.
[Ghorai] it's added in irqs.h, and will remove the hard coded value. Last minute mistake.
>
> > +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;
> > + generic_handle_irq(OMAP_GPMC_IRQ_BASE+cs);
> > +
> > + return IRQ_HANDLED;
> > }
>
> Doesn't doing OMAP_GPMC_IRQ_BASE + cs overlap with some other irq?
[Ghorai] will check the boundary condition too -
if(OMAP_GPMC_IRQ_BASE + cs <= OMAP_GPMC_IRQ_END)
And will re-submit.
>
> Regards,
>
> Tony
^ permalink raw reply [flat|nested] 15+ messages in thread* RE: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
2010-09-28 22:27 ` Tony Lindgren
2010-09-29 6:37 ` Ghorai, Sukumar
@ 2010-10-28 14:11 ` Ghorai, Sukumar
2010-11-05 21:12 ` Tony Lindgren
1 sibling, 1 reply; 15+ messages in thread
From: Ghorai, Sukumar @ 2010-10-28 14:11 UTC (permalink / raw)
To: Tony Lindgren
Cc: linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Tony,
> -----Original Message-----
> From: Ghorai, Sukumar
> Sent: Wednesday, September 29, 2010 12:08 PM
> To: 'Tony Lindgren'
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org
> Subject: RE: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
>
>
[..snip..]
> > > 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();
> > > }
> > ...
> >
> > You can avoid adding gpmc_init() by making it a subsys_initcall().
> > Just make sure you return early from it with if (!cpu_class_is_omap2()).
> [Ghorai] will do
> >
[Ghorai] I was trying this and no success, as nand_init() get called before subsys_initcall(gpmc_init);
126 MACHINE_START(OMAP_ZOOM3, "OMAP Zoom3 board")
..
130 .init_irq = omap_zoom_init_irq,
131 .init_machine = omap_zoom_init,
..
Step-(n):
kernel_init() -> customize_machine()
-> omap_zoom_init() -> gpmc_nand_init() -> which call gpmc
functions, that's crashing, as gpmc is not initialized.
Step-(n+1):
Followed by subsys_initcall(gpmc_init)
So I will incorporate the other input and will re-submit.
[..snip..]
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
2010-10-28 14:11 ` Ghorai, Sukumar
@ 2010-11-05 21:12 ` Tony Lindgren
2010-11-16 14:32 ` Ghorai, Sukumar
0 siblings, 1 reply; 15+ messages in thread
From: Tony Lindgren @ 2010-11-05 21:12 UTC (permalink / raw)
To: Ghorai, Sukumar
Cc: linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
* Ghorai, Sukumar <s-ghorai@ti.com> [101028 07:02]:
> Tony,
>
> > -----Original Message-----
> > From: Ghorai, Sukumar
> > Sent: Wednesday, September 29, 2010 12:08 PM
> > To: 'Tony Lindgren'
> > Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> > kernel@lists.infradead.org
> > Subject: RE: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
> >
> >
> [..snip..]
>
> > > > 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();
> > > > }
> > > ...
> > >
> > > You can avoid adding gpmc_init() by making it a subsys_initcall().
> > > Just make sure you return early from it with if (!cpu_class_is_omap2()).
> > [Ghorai] will do
> > >
> [Ghorai] I was trying this and no success, as nand_init() get called before subsys_initcall(gpmc_init);
>
> 126 MACHINE_START(OMAP_ZOOM3, "OMAP Zoom3 board")
> ..
> 130 .init_irq = omap_zoom_init_irq,
> 131 .init_machine = omap_zoom_init,
> ..
>
> Step-(n):
> kernel_init() -> customize_machine()
> -> omap_zoom_init() -> gpmc_nand_init() -> which call gpmc
> functions, that's crashing, as gpmc is not initialized.
>
> Step-(n+1):
> Followed by subsys_initcall(gpmc_init)
>
> So I will incorporate the other input and will re-submit.
> [..snip..]
I don't see why you could not make gpmc_nand_init happen later?
Also, some of these calls can be moved to omap2_init_common_hw()?
Tony
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
2010-11-05 21:12 ` Tony Lindgren
@ 2010-11-16 14:32 ` Ghorai, Sukumar
0 siblings, 0 replies; 15+ messages in thread
From: Ghorai, Sukumar @ 2010-11-16 14:32 UTC (permalink / raw)
To: Tony Lindgren
Cc: linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Saturday, November 06, 2010 2:43 AM
> To: Ghorai, Sukumar
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org
> Subject: Re: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
>
> * Ghorai, Sukumar <s-ghorai@ti.com> [101028 07:02]:
> > Tony,
> >
> > > -----Original Message-----
> > > From: Ghorai, Sukumar
> > > Sent: Wednesday, September 29, 2010 12:08 PM
> > > To: 'Tony Lindgren'
> > > Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-
> arm-
> > > kernel@lists.infradead.org
> > > Subject: RE: [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc
> > >
> > >
> > [..snip..]
> >
> > > > > 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();
> > > > > }
> > > > ...
> > > >
> > > > You can avoid adding gpmc_init() by making it a subsys_initcall().
> > > > Just make sure you return early from it with if
> (!cpu_class_is_omap2()).
> > > [Ghorai] will do
> > > >
> > [Ghorai] I was trying this and no success, as nand_init() get called
> before subsys_initcall(gpmc_init);
> >
> > 126 MACHINE_START(OMAP_ZOOM3, "OMAP Zoom3 board")
> > ..
> > 130 .init_irq = omap_zoom_init_irq,
> > 131 .init_machine = omap_zoom_init,
> > ..
> >
> > Step-(n):
> > kernel_init() -> customize_machine()
> > -> omap_zoom_init() -> gpmc_nand_init() -> which call gpmc
> > functions, that's crashing, as gpmc is not initialized.
> >
> > Step-(n+1):
> > Followed by subsys_initcall(gpmc_init)
> >
> > So I will incorporate the other input and will re-submit.
> > [..snip..]
>
> I don't see why you could not make gpmc_nand_init happen later?
> Also, some of these calls can be moved to omap2_init_common_hw()?
>
[Ghorai] is it that gpmc_nand_init() better to call inside omap2_init_common_hw()?
27 files used the omap2_init_common_hw(); including omap4, and
15 files used the gpmc_nand_init directly or via board_nand_init()
Just thinking how to put gpmc_nand_init() inside omap2_init_common_hw(), when board may not have the nand.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v5 2/5] omap3: nand: prefetch in irq mode support
2010-09-27 13:37 [PATCH v5 0/5] nand prefetch-irq support and ecc layout chanage Sukumar Ghorai
2010-09-27 13:37 ` [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc Sukumar Ghorai
@ 2010-09-27 13:37 ` Sukumar Ghorai
2010-09-28 22:29 ` Tony Lindgren
2010-09-27 13:37 ` [PATCH v5 3/5] omap3: nand: configurable fifo threshold to gain the throughput Sukumar Ghorai
` (2 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Sukumar Ghorai @ 2010-09-27 13:37 UTC (permalink / raw)
To: linux-omap; +Cc: Vimal Singh, linux-mtd, linux-arm-kernel, Sukumar Ghorai
This patch enable prefetch-irq mode for NAND.
Signed-off-by: Vimal Singh <vimalsingh@ti.com>
Signed-off-by: Sukumar Ghorai <s-ghorai@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(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 structure
+ * @buf: buffer to store date
+ * @len: number of bytes to read
+ */
+static void omap_read_buf_irq_pref(struct mtd_info *mtd, u_char *buf, int len)
+{
+ struct omap_nand_info *info = container_of(mtd,
+ struct omap_nand_info, mtd);
+ int ret = 0;
+
+ if (len <= mtd->oobsize) {
+ omap_read_buf_pref(mtd, buf, len);
+ return;
+ }
+
+ info->iomode = OMAP_NAND_IO_READ;
+ info->buf = buf;
+ init_completion(&info->comp);
+
+ /* configure and start prefetch transfer */
+ ret = gpmc_prefetch_enable(info->gpmc_cs, 0x0, len, 0x0);
+ if (ret)
+ /* PFPW engine is busy, use cpu copy methode */
+ goto out_copy;
+
+ info->buf_len = len;
+ /* enable irq */
+ gpmc_cs_configure(info->gpmc_cs, GPMC_ENABLE_IRQ,
+ (GPMC_IRQ_FIFOEVENTENABLE | GPMC_IRQ_COUNT_EVENT));
+
+ /* waiting for read to complete */
+ wait_for_completion(&info->comp);
+
+ /* disable and stop the PFPW engine */
+ gpmc_prefetch_reset(info->gpmc_cs);
+ return;
+
+out_copy:
+ if (info->nand.options & NAND_BUSWIDTH_16)
+ omap_read_buf16(mtd, buf, len);
+ else
+ omap_read_buf8(mtd, buf, len);
+}
+
+/*
+ * omap_write_buf_irq_pref - write buffer to NAND controller
+ * @mtd: MTD device structure
+ * @buf: data buffer
+ * @len: number of bytes to write
+ */
+static void omap_write_buf_irq_pref(struct mtd_info *mtd,
+ const u_char *buf, int len)
+{
+ struct omap_nand_info *info = container_of(mtd,
+ struct omap_nand_info, mtd);
+ int ret = 0;
+ if (len <= mtd->oobsize) {
+ omap_write_buf_pref(mtd, buf, len);
+ return;
+ }
+
+ info->iomode = OMAP_NAND_IO_WRITE;
+ info->buf = (u_char *) buf;
+ init_completion(&info->comp);
+
+ /* configure and start prefetch transfer */
+ ret = gpmc_prefetch_enable(info->gpmc_cs, 0x0, len, 0x1);
+ if (ret)
+ /* PFPW engine is busy, use cpu copy methode */
+ goto out_copy;
+
+ info->buf_len = len;
+ /* enable irq */
+ gpmc_cs_configure(info->gpmc_cs, GPMC_ENABLE_IRQ,
+ (GPMC_IRQ_FIFOEVENTENABLE | GPMC_IRQ_COUNT_EVENT));
+
+ /* waiting for write to complete */
+ wait_for_completion(&info->comp);
+ /* wait for data to flushed-out before reset the prefetch */
+ do {
+ ret = gpmc_read_status(GPMC_PREFETCH_COUNT);
+ } while (ret);
+ /* disable and stop the PFPW engine */
+ gpmc_prefetch_reset(info->gpmc_cs);
+ return;
+
+out_copy:
+ if (info->nand.options & NAND_BUSWIDTH_16)
+ omap_write_buf16(mtd, buf, len);
+ else
+ omap_write_buf8(mtd, buf, len);
+}
+
/**
* omap_verify_buf - Verify chip data against buffer
* @mtd: MTD device structure
@@ -800,6 +965,7 @@ static int __devinit omap_nand_probe(struct platform_device *pdev)
info->gpmc_cs = pdata->cs;
info->phys_base = pdata->phys_base;
+ info->gpmc_irq = pdata->gpmc_irq;
info->mtd.priv = &info->nand;
info->mtd.name = dev_name(&pdev->dev);
@@ -863,7 +1029,19 @@ static int __devinit omap_nand_probe(struct platform_device *pdev)
info->nand.read_buf = omap_read_buf_dma_pref;
info->nand.write_buf = omap_write_buf_dma_pref;
}
+ } else if (use_interrupt) {
+ err = request_irq(info->gpmc_irq, omap_nand_irq,
+ IRQF_SHARED, "gpmc-nand", info);
+ if (err) {
+ printk(KERN_INFO "requesting irq %i. err %d"
+ " Prefetch will work in mpu poling mode\n",
+ info->gpmc_irq, err);
+ } else {
+ info->nand.read_buf = omap_read_buf_irq_pref;
+ info->nand.write_buf = omap_write_buf_irq_pref;
+ }
}
+
} else {
if (info->nand.options & NAND_BUSWIDTH_16) {
info->nand.read_buf = omap_read_buf16;
@@ -953,11 +1131,19 @@ static int __init omap_nand_init(void)
/* This check is required if driver is being
* loaded run time as a module
*/
- if ((1 == use_dma) && (0 == use_prefetch)) {
- printk(KERN_INFO"Wrong parameters: 'use_dma' can not be 1 "
- "without use_prefetch'. Prefetch will not be"
- " used in either mode (mpu or dma)\n");
+
+ if ((0 == use_prefetch) && (1 == (use_dma | use_interrupt))) {
+ printk(KERN_INFO "Wrong parameters: Neither 'dma' nor 'irq' "
+ "can used without 'use_prefetch' selected.\n");
+ printk(KERN_INFO "Prefetch will not be used in any mode: "
+ "poll, mpu or dma\n");
+ } else if ((1 == use_prefetch) && (1 == (use_interrupt & use_dma))) {
+ printk(KERN_INFO "Wrong parameters: Both DMA and IRQ"
+ " modes can not be used together.\n");
+ printk(KERN_INFO "It has to be selected at compile "
+ "time and same will be used.\n");
}
+
return platform_driver_register(&omap_nand_driver);
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v5 2/5] omap3: nand: prefetch in irq mode support
2010-09-27 13:37 ` [PATCH v5 2/5] omap3: nand: prefetch in irq mode support Sukumar Ghorai
@ 2010-09-28 22:29 ` Tony Lindgren
2010-09-29 6:02 ` Ghorai, Sukumar
0 siblings, 1 reply; 15+ messages in thread
From: Tony Lindgren @ 2010-09-28 22:29 UTC (permalink / raw)
To: Sukumar Ghorai; +Cc: Vimal Singh, linux-omap, linux-mtd, linux-arm-kernel
* Sukumar Ghorai <s-ghorai@ti.com> [100927 06:30]:
> This patch enable prefetch-irq mode for NAND.
> --- 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
The configuration to use the prefetch IRQ should be passed in the platform_data
from the board-*.c files. What if you want to to boot a distro kernel on
omap2, 3 and 4 and only some of the boards can use the prefetch interrupt?
Tony
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v5 2/5] omap3: nand: prefetch in irq mode support
2010-09-28 22:29 ` Tony Lindgren
@ 2010-09-29 6:02 ` Ghorai, Sukumar
0 siblings, 0 replies; 15+ messages in thread
From: Ghorai, Sukumar @ 2010-09-29 6:02 UTC (permalink / raw)
To: Tony Lindgren
Cc: Vimal Singh, linux-omap@vger.kernel.org,
linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
> -----Original Message-----
> From: Tony Lindgren [mailto:tony@atomide.com]
> Sent: Wednesday, September 29, 2010 4:00 AM
> To: Ghorai, Sukumar
> Cc: linux-omap@vger.kernel.org; linux-mtd@lists.infradead.org; linux-arm-
> kernel@lists.infradead.org; Vimal Singh
> Subject: Re: [PATCH v5 2/5] omap3: nand: prefetch in irq mode support
>
> * Sukumar Ghorai <s-ghorai@ti.com> [100927 06:30]:
> > This patch enable prefetch-irq mode for NAND.
>
> > --- 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
>
> The configuration to use the prefetch IRQ should be passed in the
> platform_data
> from the board-*.c files. What if you want to to boot a distro kernel on
> omap2, 3 and 4 and only some of the boards can use the prefetch interrupt?
[Ghorai] thanks.. we will provide the interface to select the io mode and ecc mode from board file.
>
> Tony
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v5 3/5] omap3: nand: configurable fifo threshold to gain the throughput
2010-09-27 13:37 [PATCH v5 0/5] nand prefetch-irq support and ecc layout chanage Sukumar Ghorai
2010-09-27 13:37 ` [PATCH v5 1/5] omap gpmc: enable irq mode in gpmc Sukumar Ghorai
2010-09-27 13:37 ` [PATCH v5 2/5] omap3: nand: prefetch in irq mode support Sukumar Ghorai
@ 2010-09-27 13:37 ` Sukumar Ghorai
2010-09-27 13:37 ` [PATCH v5 4/5] omap: nand: ecc layout select from board file Sukumar Ghorai
2010-09-27 13:37 ` [PATCH v5 5/5] omap: nand: making ecc layout as compatible with romcode ecc Sukumar Ghorai
4 siblings, 0 replies; 15+ messages in thread
From: Sukumar Ghorai @ 2010-09-27 13:37 UTC (permalink / raw)
To: linux-omap; +Cc: Vimal Singh, linux-mtd, linux-arm-kernel, 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 <vimalsingh@ti.com>
Signed-off-by: Sukumar Ghorai <s-ghorai@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
+ * and frame length is 32 bytes.
*/
- int buf_len = len >> 6;
+ int buf_len = len >> 5;
if (addr >= high_memory) {
struct page *p1;
@@ -415,7 +418,8 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,
OMAP24XX_DMA_GPMC, OMAP_DMA_SRC_SYNC);
}
/* configure and start prefetch transfer */
- ret = gpmc_prefetch_enable(info->gpmc_cs, 0x1, len, is_write);
+ ret = gpmc_prefetch_enable(info->gpmc_cs,
+ PREFETCH_FIFOTHRESHOLD_MAX/2, 0x1, len, is_write);
if (ret)
/* PFPW engine is busy, use cpu copy methode */
goto out_copy;
@@ -559,7 +563,8 @@ static void omap_read_buf_irq_pref(struct mtd_info *mtd, u_char *buf, int len)
init_completion(&info->comp);
/* 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/2, 0x0, len, 0x0);
if (ret)
/* PFPW engine is busy, use cpu copy methode */
goto out_copy;
@@ -604,8 +609,9 @@ static void omap_write_buf_irq_pref(struct mtd_info *mtd,
info->buf = (u_char *) buf;
init_completion(&info->comp);
- /* configure and start prefetch transfer */
- ret = gpmc_prefetch_enable(info->gpmc_cs, 0x0, len, 0x1);
+ /* configure and start prefetch transfer : size=24 */
+ ret = gpmc_prefetch_enable(info->gpmc_cs,
+ (PREFETCH_FIFOTHRESHOLD_MAX*3)/8, 0x0, len, 0x1);
if (ret)
/* PFPW engine is busy, use cpu copy methode */
goto out_copy;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v5 4/5] omap: nand: ecc layout select from board file
2010-09-27 13:37 [PATCH v5 0/5] nand prefetch-irq support and ecc layout chanage Sukumar Ghorai
` (2 preceding siblings ...)
2010-09-27 13:37 ` [PATCH v5 3/5] omap3: nand: configurable fifo threshold to gain the throughput Sukumar Ghorai
@ 2010-09-27 13:37 ` Sukumar Ghorai
2010-09-27 13:37 ` [PATCH v5 5/5] omap: nand: making ecc layout as compatible with romcode ecc Sukumar Ghorai
4 siblings, 0 replies; 15+ messages in thread
From: Sukumar Ghorai @ 2010-09-27 13:37 UTC (permalink / raw)
To: linux-omap; +Cc: Vimal Singh, linux-mtd, linux-arm-kernel, 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 <vimalsingh@ti.com>
Signed-off-by: Sukumar Ghorai <s-ghorai@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
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v5 5/5] omap: nand: making ecc layout as compatible with romcode ecc
2010-09-27 13:37 [PATCH v5 0/5] nand prefetch-irq support and ecc layout chanage Sukumar Ghorai
` (3 preceding siblings ...)
2010-09-27 13:37 ` [PATCH v5 4/5] omap: nand: ecc layout select from board file Sukumar Ghorai
@ 2010-09-27 13:37 ` Sukumar Ghorai
2010-09-27 13:58 ` Premi, Sanjeev
4 siblings, 1 reply; 15+ messages in thread
From: Sukumar Ghorai @ 2010-09-27 13:37 UTC (permalink / raw)
To: linux-omap; +Cc: Vimal Singh, linux-mtd, linux-arm-kernel, 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 <vimalsingh@ti.com>
Signed-off-by: Sukumar Ghorai <s-ghorai@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
^ permalink raw reply related [flat|nested] 15+ messages in thread* RE: [PATCH v5 5/5] omap: nand: making ecc layout as compatible with romcode ecc
2010-09-27 13:37 ` [PATCH v5 5/5] omap: nand: making ecc layout as compatible with romcode ecc Sukumar Ghorai
@ 2010-09-27 13:58 ` Premi, Sanjeev
2010-09-27 14:02 ` Ghorai, Sukumar
0 siblings, 1 reply; 15+ messages in thread
From: Premi, Sanjeev @ 2010-09-27 13:58 UTC (permalink / raw)
To: Ghorai, Sukumar, linux-omap@vger.kernel.org
Cc: Vimal Singh, linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, Ghorai, Sukumar
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org
> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Sukumar Ghorai
> Sent: Monday, September 27, 2010 7:07 PM
> To: linux-omap@vger.kernel.org
> Cc: linux-mtd@lists.infradead.org;
> linux-arm-kernel@lists.infradead.org; Ghorai, Sukumar; Vimal Singh
> Subject: [PATCH v5 5/5] omap: nand: making ecc layout as
> compatible with romcode ecc
>
> 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.
>
The description seems to start with different whitespace indents
in this patch series.
~sanjeev
[snip]...[snip]
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v5 5/5] omap: nand: making ecc layout as compatible with romcode ecc
2010-09-27 13:58 ` Premi, Sanjeev
@ 2010-09-27 14:02 ` Ghorai, Sukumar
0 siblings, 0 replies; 15+ messages in thread
From: Ghorai, Sukumar @ 2010-09-27 14:02 UTC (permalink / raw)
To: Premi, Sanjeev, linux-omap@vger.kernel.org
Cc: Vimal Singh, linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
> -----Original Message-----
> From: Premi, Sanjeev
> Sent: Monday, September 27, 2010 7:29 PM
> To: Ghorai, Sukumar; linux-omap@vger.kernel.org
> Cc: linux-mtd@lists.infradead.org; linux-arm-kernel@lists.infradead.org;
> Ghorai, Sukumar; Vimal Singh
> Subject: RE: [PATCH v5 5/5] omap: nand: making ecc layout as compatible
> with romcode ecc
>
> > -----Original Message-----
> > From: linux-omap-owner@vger.kernel.org
> > [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Sukumar Ghorai
> > Sent: Monday, September 27, 2010 7:07 PM
> > To: linux-omap@vger.kernel.org
> > Cc: linux-mtd@lists.infradead.org;
> > linux-arm-kernel@lists.infradead.org; Ghorai, Sukumar; Vimal Singh
> > Subject: [PATCH v5 5/5] omap: nand: making ecc layout as
> > compatible with romcode ecc
> >
> > 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.
> >
> The description seems to start with different whitespace indents
> in this patch series.
>
[Ghorai] Thanks. I will RESEND.
> ~sanjeev
>
> [snip]...[snip]
^ permalink raw reply [flat|nested] 15+ messages in thread