aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/gpmc.c
diff options
context:
space:
mode:
authorvimal singh <vimalsingh@ti.com>2009-07-13 06:56:24 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-09-19 16:20:51 -0400
commit59e9c5ae17179fe561103fbe0808fac5976ca1bd (patch)
treecc1f155a2569d09ae5d1d232046bb188c6b38d4c /arch/arm/mach-omap2/gpmc.c
parent8bff82cbc30884fc52969608d090d874641e7196 (diff)
mtd: omap: add support for nand prefetch-read and post-write
This patch adds prefetch support to access nand flash in mpu mode. This patch also adds 8-bit nand support (omap_read/write_buf8). Prefetch can be used for both 8- and 16-bit devices. Signed-off-by: Vimal Singh <vimalsingh@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'arch/arm/mach-omap2/gpmc.c')
-rw-r--r--arch/arm/mach-omap2/gpmc.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index f91934b2b092..15876828db23 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -57,6 +57,11 @@
57#define GPMC_CHUNK_SHIFT 24 /* 16 MB */ 57#define GPMC_CHUNK_SHIFT 24 /* 16 MB */
58#define GPMC_SECTION_SHIFT 28 /* 128 MB */ 58#define GPMC_SECTION_SHIFT 28 /* 128 MB */
59 59
60#define PREFETCH_FIFOTHRESHOLD (0x40 << 8)
61#define CS_NUM_SHIFT 24
62#define ENABLE_PREFETCH (0x1 << 7)
63#define DMA_MPU_MODE 2
64
60static struct resource gpmc_mem_root; 65static struct resource gpmc_mem_root;
61static struct resource gpmc_cs_mem[GPMC_CS_NUM]; 66static struct resource gpmc_cs_mem[GPMC_CS_NUM];
62static DEFINE_SPINLOCK(gpmc_mem_lock); 67static DEFINE_SPINLOCK(gpmc_mem_lock);
@@ -386,6 +391,63 @@ void gpmc_cs_free(int cs)
386} 391}
387EXPORT_SYMBOL(gpmc_cs_free); 392EXPORT_SYMBOL(gpmc_cs_free);
388 393
394/**
395 * gpmc_prefetch_enable - configures and starts prefetch transfer
396 * @cs: nand cs (chip select) number
397 * @dma_mode: dma mode enable (1) or disable (0)
398 * @u32_count: number of bytes to be transferred
399 * @is_write: prefetch read(0) or write post(1) mode
400 */
401int gpmc_prefetch_enable(int cs, int dma_mode,
402 unsigned int u32_count, int is_write)
403{
404 uint32_t prefetch_config1;
405
406 if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
407 /* Set the amount of bytes to be prefetched */
408 gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
409
410 /* Set dma/mpu mode, the prefetch read / post write and
411 * enable the engine. Set which cs is has requested for.
412 */
413 prefetch_config1 = ((cs << CS_NUM_SHIFT) |
414 PREFETCH_FIFOTHRESHOLD |
415 ENABLE_PREFETCH |
416 (dma_mode << DMA_MPU_MODE) |
417 (0x1 & is_write));
418 gpmc_write_reg(GPMC_PREFETCH_CONFIG1, prefetch_config1);
419 } else {
420 return -EBUSY;
421 }
422 /* Start the prefetch engine */
423 gpmc_write_reg(GPMC_PREFETCH_CONTROL, 0x1);
424
425 return 0;
426}
427EXPORT_SYMBOL(gpmc_prefetch_enable);
428
429/**
430 * gpmc_prefetch_reset - disables and stops the prefetch engine
431 */
432void gpmc_prefetch_reset(void)
433{
434 /* Stop the PFPW engine */
435 gpmc_write_reg(GPMC_PREFETCH_CONTROL, 0x0);
436
437 /* Reset/disable the PFPW engine */
438 gpmc_write_reg(GPMC_PREFETCH_CONFIG1, 0x0);
439}
440EXPORT_SYMBOL(gpmc_prefetch_reset);
441
442/**
443 * gpmc_prefetch_status - reads prefetch status of engine
444 */
445int gpmc_prefetch_status(void)
446{
447 return gpmc_read_reg(GPMC_PREFETCH_STATUS);
448}
449EXPORT_SYMBOL(gpmc_prefetch_status);
450
389static void __init gpmc_mem_init(void) 451static void __init gpmc_mem_init(void)
390{ 452{
391 int cs; 453 int cs;
@@ -452,6 +514,5 @@ void __init gpmc_init(void)
452 l &= 0x03 << 3; 514 l &= 0x03 << 3;
453 l |= (0x02 << 3) | (1 << 0); 515 l |= (0x02 << 3) | (1 << 0);
454 gpmc_write_reg(GPMC_SYSCONFIG, l); 516 gpmc_write_reg(GPMC_SYSCONFIG, l);
455
456 gpmc_mem_init(); 517 gpmc_mem_init();
457} 518}