diff options
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/gpmc.c | 63 |
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 | |||
60 | static struct resource gpmc_mem_root; | 65 | static struct resource gpmc_mem_root; |
61 | static struct resource gpmc_cs_mem[GPMC_CS_NUM]; | 66 | static struct resource gpmc_cs_mem[GPMC_CS_NUM]; |
62 | static DEFINE_SPINLOCK(gpmc_mem_lock); | 67 | static DEFINE_SPINLOCK(gpmc_mem_lock); |
@@ -386,6 +391,63 @@ void gpmc_cs_free(int cs) | |||
386 | } | 391 | } |
387 | EXPORT_SYMBOL(gpmc_cs_free); | 392 | EXPORT_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 | */ | ||
401 | int 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 | } | ||
427 | EXPORT_SYMBOL(gpmc_prefetch_enable); | ||
428 | |||
429 | /** | ||
430 | * gpmc_prefetch_reset - disables and stops the prefetch engine | ||
431 | */ | ||
432 | void 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 | } | ||
440 | EXPORT_SYMBOL(gpmc_prefetch_reset); | ||
441 | |||
442 | /** | ||
443 | * gpmc_prefetch_status - reads prefetch status of engine | ||
444 | */ | ||
445 | int gpmc_prefetch_status(void) | ||
446 | { | ||
447 | return gpmc_read_reg(GPMC_PREFETCH_STATUS); | ||
448 | } | ||
449 | EXPORT_SYMBOL(gpmc_prefetch_status); | ||
450 | |||
389 | static void __init gpmc_mem_init(void) | 451 | static 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 | } |