diff options
Diffstat (limited to 'arch/arm/mach-omap2/gpmc.c')
-rw-r--r-- | arch/arm/mach-omap2/gpmc.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 1b7b3e7d02f7..382dea83e4f0 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> |
@@ -100,6 +102,8 @@ static void __iomem *gpmc_base; | |||
100 | 102 | ||
101 | static struct clk *gpmc_l3_clk; | 103 | static struct clk *gpmc_l3_clk; |
102 | 104 | ||
105 | static irqreturn_t gpmc_handle_irq(int irq, void *dev); | ||
106 | |||
103 | static void gpmc_write_reg(int idx, u32 val) | 107 | static void gpmc_write_reg(int idx, u32 val) |
104 | { | 108 | { |
105 | __raw_writel(val, gpmc_base + idx); | 109 | __raw_writel(val, gpmc_base + idx); |
@@ -497,6 +501,10 @@ int gpmc_cs_configure(int cs, int cmd, int wval) | |||
497 | u32 regval = 0; | 501 | u32 regval = 0; |
498 | 502 | ||
499 | switch (cmd) { | 503 | switch (cmd) { |
504 | case GPMC_ENABLE_IRQ: | ||
505 | gpmc_write_reg(GPMC_IRQENABLE, wval); | ||
506 | break; | ||
507 | |||
500 | case GPMC_SET_IRQ_STATUS: | 508 | case GPMC_SET_IRQ_STATUS: |
501 | gpmc_write_reg(GPMC_IRQSTATUS, wval); | 509 | gpmc_write_reg(GPMC_IRQSTATUS, wval); |
502 | break; | 510 | break; |
@@ -678,9 +686,10 @@ static void __init gpmc_mem_init(void) | |||
678 | } | 686 | } |
679 | } | 687 | } |
680 | 688 | ||
681 | void __init gpmc_init(void) | 689 | static int __init gpmc_init(void) |
682 | { | 690 | { |
683 | u32 l; | 691 | u32 l, irq; |
692 | int cs, ret = -EINVAL; | ||
684 | char *ck = NULL; | 693 | char *ck = NULL; |
685 | 694 | ||
686 | if (cpu_is_omap24xx()) { | 695 | if (cpu_is_omap24xx()) { |
@@ -698,7 +707,7 @@ void __init gpmc_init(void) | |||
698 | } | 707 | } |
699 | 708 | ||
700 | if (WARN_ON(!ck)) | 709 | if (WARN_ON(!ck)) |
701 | return; | 710 | return ret; |
702 | 711 | ||
703 | gpmc_l3_clk = clk_get(NULL, ck); | 712 | gpmc_l3_clk = clk_get(NULL, ck); |
704 | if (IS_ERR(gpmc_l3_clk)) { | 713 | if (IS_ERR(gpmc_l3_clk)) { |
@@ -723,6 +732,36 @@ void __init gpmc_init(void) | |||
723 | l |= (0x02 << 3) | (1 << 0); | 732 | l |= (0x02 << 3) | (1 << 0); |
724 | gpmc_write_reg(GPMC_SYSCONFIG, l); | 733 | gpmc_write_reg(GPMC_SYSCONFIG, l); |
725 | gpmc_mem_init(); | 734 | gpmc_mem_init(); |
735 | |||
736 | /* initalize the irq_chained */ | ||
737 | irq = OMAP_GPMC_IRQ_BASE; | ||
738 | for (cs = 0; cs < GPMC_CS_NUM; cs++) { | ||
739 | set_irq_handler(irq, handle_simple_irq); | ||
740 | set_irq_flags(irq, IRQF_VALID); | ||
741 | irq++; | ||
742 | } | ||
743 | |||
744 | ret = request_irq(INT_34XX_GPMC_IRQ, | ||
745 | gpmc_handle_irq, IRQF_SHARED, "gpmc", gpmc_base); | ||
746 | if (ret) | ||
747 | pr_err("gpmc: irq-%d could not claim: err %d\n", | ||
748 | INT_34XX_GPMC_IRQ, ret); | ||
749 | return ret; | ||
750 | } | ||
751 | postcore_initcall(gpmc_init); | ||
752 | |||
753 | static irqreturn_t gpmc_handle_irq(int irq, void *dev) | ||
754 | { | ||
755 | u8 cs; | ||
756 | |||
757 | if (irq != INT_34XX_GPMC_IRQ) | ||
758 | return IRQ_HANDLED; | ||
759 | /* check cs to invoke the irq */ | ||
760 | cs = ((gpmc_read_reg(GPMC_PREFETCH_CONFIG1)) >> CS_NUM_SHIFT) & 0x7; | ||
761 | if (OMAP_GPMC_IRQ_BASE+cs <= OMAP_GPMC_IRQ_END) | ||
762 | generic_handle_irq(OMAP_GPMC_IRQ_BASE+cs); | ||
763 | |||
764 | return IRQ_HANDLED; | ||
726 | } | 765 | } |
727 | 766 | ||
728 | #ifdef CONFIG_ARCH_OMAP3 | 767 | #ifdef CONFIG_ARCH_OMAP3 |