diff options
Diffstat (limited to 'arch/arm/mach-omap2/gpmc.c')
-rw-r--r-- | arch/arm/mach-omap2/gpmc.c | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 1b7b3e7d02f7..674174365f78 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c | |||
@@ -14,6 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | #undef DEBUG | 15 | #undef DEBUG |
16 | 16 | ||
17 | #include <linux/irq.h> | ||
17 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | 19 | #include <linux/init.h> |
19 | #include <linux/err.h> | 20 | #include <linux/err.h> |
@@ -22,6 +23,7 @@ | |||
22 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
23 | #include <linux/io.h> | 24 | #include <linux/io.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/interrupt.h> | ||
25 | 27 | ||
26 | #include <asm/mach-types.h> | 28 | #include <asm/mach-types.h> |
27 | #include <plat/gpmc.h> | 29 | #include <plat/gpmc.h> |
@@ -58,7 +60,6 @@ | |||
58 | #define GPMC_CHUNK_SHIFT 24 /* 16 MB */ | 60 | #define GPMC_CHUNK_SHIFT 24 /* 16 MB */ |
59 | #define GPMC_SECTION_SHIFT 28 /* 128 MB */ | 61 | #define GPMC_SECTION_SHIFT 28 /* 128 MB */ |
60 | 62 | ||
61 | #define PREFETCH_FIFOTHRESHOLD (0x40 << 8) | ||
62 | #define CS_NUM_SHIFT 24 | 63 | #define CS_NUM_SHIFT 24 |
63 | #define ENABLE_PREFETCH (0x1 << 7) | 64 | #define ENABLE_PREFETCH (0x1 << 7) |
64 | #define DMA_MPU_MODE 2 | 65 | #define DMA_MPU_MODE 2 |
@@ -100,6 +101,8 @@ static void __iomem *gpmc_base; | |||
100 | 101 | ||
101 | static struct clk *gpmc_l3_clk; | 102 | static struct clk *gpmc_l3_clk; |
102 | 103 | ||
104 | static irqreturn_t gpmc_handle_irq(int irq, void *dev); | ||
105 | |||
103 | static void gpmc_write_reg(int idx, u32 val) | 106 | static void gpmc_write_reg(int idx, u32 val) |
104 | { | 107 | { |
105 | __raw_writel(val, gpmc_base + idx); | 108 | __raw_writel(val, gpmc_base + idx); |
@@ -497,6 +500,10 @@ int gpmc_cs_configure(int cs, int cmd, int wval) | |||
497 | u32 regval = 0; | 500 | u32 regval = 0; |
498 | 501 | ||
499 | switch (cmd) { | 502 | switch (cmd) { |
503 | case GPMC_ENABLE_IRQ: | ||
504 | gpmc_write_reg(GPMC_IRQENABLE, wval); | ||
505 | break; | ||
506 | |||
500 | case GPMC_SET_IRQ_STATUS: | 507 | case GPMC_SET_IRQ_STATUS: |
501 | gpmc_write_reg(GPMC_IRQSTATUS, wval); | 508 | gpmc_write_reg(GPMC_IRQSTATUS, wval); |
502 | break; | 509 | break; |
@@ -598,15 +605,19 @@ EXPORT_SYMBOL(gpmc_nand_write); | |||
598 | /** | 605 | /** |
599 | * gpmc_prefetch_enable - configures and starts prefetch transfer | 606 | * gpmc_prefetch_enable - configures and starts prefetch transfer |
600 | * @cs: cs (chip select) number | 607 | * @cs: cs (chip select) number |
608 | * @fifo_th: fifo threshold to be used for read/ write | ||
601 | * @dma_mode: dma mode enable (1) or disable (0) | 609 | * @dma_mode: dma mode enable (1) or disable (0) |
602 | * @u32_count: number of bytes to be transferred | 610 | * @u32_count: number of bytes to be transferred |
603 | * @is_write: prefetch read(0) or write post(1) mode | 611 | * @is_write: prefetch read(0) or write post(1) mode |
604 | */ | 612 | */ |
605 | int gpmc_prefetch_enable(int cs, int dma_mode, | 613 | int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode, |
606 | unsigned int u32_count, int is_write) | 614 | unsigned int u32_count, int is_write) |
607 | { | 615 | { |
608 | 616 | ||
609 | if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) { | 617 | if (fifo_th > PREFETCH_FIFOTHRESHOLD_MAX) { |
618 | pr_err("gpmc: fifo threshold is not supported\n"); | ||
619 | return -1; | ||
620 | } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) { | ||
610 | /* Set the amount of bytes to be prefetched */ | 621 | /* Set the amount of bytes to be prefetched */ |
611 | gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count); | 622 | gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count); |
612 | 623 | ||
@@ -614,7 +625,7 @@ int gpmc_prefetch_enable(int cs, int dma_mode, | |||
614 | * enable the engine. Set which cs is has requested for. | 625 | * enable the engine. Set which cs is has requested for. |
615 | */ | 626 | */ |
616 | gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs << CS_NUM_SHIFT) | | 627 | gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs << CS_NUM_SHIFT) | |
617 | PREFETCH_FIFOTHRESHOLD | | 628 | PREFETCH_FIFOTHRESHOLD(fifo_th) | |
618 | ENABLE_PREFETCH | | 629 | ENABLE_PREFETCH | |
619 | (dma_mode << DMA_MPU_MODE) | | 630 | (dma_mode << DMA_MPU_MODE) | |
620 | (0x1 & is_write))); | 631 | (0x1 & is_write))); |
@@ -678,9 +689,10 @@ static void __init gpmc_mem_init(void) | |||
678 | } | 689 | } |
679 | } | 690 | } |
680 | 691 | ||
681 | void __init gpmc_init(void) | 692 | static int __init gpmc_init(void) |
682 | { | 693 | { |
683 | u32 l; | 694 | u32 l, irq; |
695 | int cs, ret = -EINVAL; | ||
684 | char *ck = NULL; | 696 | char *ck = NULL; |
685 | 697 | ||
686 | if (cpu_is_omap24xx()) { | 698 | if (cpu_is_omap24xx()) { |
@@ -698,7 +710,7 @@ void __init gpmc_init(void) | |||
698 | } | 710 | } |
699 | 711 | ||
700 | if (WARN_ON(!ck)) | 712 | if (WARN_ON(!ck)) |
701 | return; | 713 | return ret; |
702 | 714 | ||
703 | gpmc_l3_clk = clk_get(NULL, ck); | 715 | gpmc_l3_clk = clk_get(NULL, ck); |
704 | if (IS_ERR(gpmc_l3_clk)) { | 716 | if (IS_ERR(gpmc_l3_clk)) { |
@@ -723,6 +735,36 @@ void __init gpmc_init(void) | |||
723 | l |= (0x02 << 3) | (1 << 0); | 735 | l |= (0x02 << 3) | (1 << 0); |
724 | gpmc_write_reg(GPMC_SYSCONFIG, l); | 736 | gpmc_write_reg(GPMC_SYSCONFIG, l); |
725 | gpmc_mem_init(); | 737 | gpmc_mem_init(); |
738 | |||
739 | /* initalize the irq_chained */ | ||
740 | irq = OMAP_GPMC_IRQ_BASE; | ||
741 | for (cs = 0; cs < GPMC_CS_NUM; cs++) { | ||
742 | set_irq_handler(irq, handle_simple_irq); | ||
743 | set_irq_flags(irq, IRQF_VALID); | ||
744 | irq++; | ||
745 | } | ||
746 | |||
747 | ret = request_irq(INT_34XX_GPMC_IRQ, | ||
748 | gpmc_handle_irq, IRQF_SHARED, "gpmc", gpmc_base); | ||
749 | if (ret) | ||
750 | pr_err("gpmc: irq-%d could not claim: err %d\n", | ||
751 | INT_34XX_GPMC_IRQ, ret); | ||
752 | return ret; | ||
753 | } | ||
754 | postcore_initcall(gpmc_init); | ||
755 | |||
756 | static irqreturn_t gpmc_handle_irq(int irq, void *dev) | ||
757 | { | ||
758 | u8 cs; | ||
759 | |||
760 | if (irq != INT_34XX_GPMC_IRQ) | ||
761 | return IRQ_HANDLED; | ||
762 | /* check cs to invoke the irq */ | ||
763 | cs = ((gpmc_read_reg(GPMC_PREFETCH_CONFIG1)) >> CS_NUM_SHIFT) & 0x7; | ||
764 | if (OMAP_GPMC_IRQ_BASE+cs <= OMAP_GPMC_IRQ_END) | ||
765 | generic_handle_irq(OMAP_GPMC_IRQ_BASE+cs); | ||
766 | |||
767 | return IRQ_HANDLED; | ||
726 | } | 768 | } |
727 | 769 | ||
728 | #ifdef CONFIG_ARCH_OMAP3 | 770 | #ifdef CONFIG_ARCH_OMAP3 |