aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorSukumar Ghorai <s-ghorai@ti.com>2011-01-28 05:12:05 -0500
committerTony Lindgren <tony@atomide.com>2011-02-17 18:32:53 -0500
commitdb97eb7dfe13f6c04f0a0e77c32e2691f563ab8b (patch)
tree116c66fc27f6f493fca9def7414366fd30b23343 /arch/arm
parent1b0b323c70cd5fdca967d89ed3a03dfebd84ada7 (diff)
omap: gpmc: enable irq mode in gpmc
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> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-omap2/gpmc.c45
-rw-r--r--arch/arm/mach-omap2/io.c2
-rw-r--r--arch/arm/plat-omap/include/plat/gpmc.h5
-rw-r--r--arch/arm/plat-omap/include/plat/irqs.h9
4 files changed, 54 insertions, 7 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
101static struct clk *gpmc_l3_clk; 103static struct clk *gpmc_l3_clk;
102 104
105static irqreturn_t gpmc_handle_irq(int irq, void *dev);
106
103static void gpmc_write_reg(int idx, u32 val) 107static 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
681void __init gpmc_init(void) 689static 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}
751postcore_initcall(gpmc_init);
752
753static 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
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index b8b49e4ae928..657f3c84687c 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -30,7 +30,6 @@
30 30
31#include <plat/sram.h> 31#include <plat/sram.h>
32#include <plat/sdrc.h> 32#include <plat/sdrc.h>
33#include <plat/gpmc.h>
34#include <plat/serial.h> 33#include <plat/serial.h>
35 34
36#include "clock2xxx.h" 35#include "clock2xxx.h"
@@ -422,7 +421,6 @@ void __init omap2_init_common_devices(struct omap_sdrc_params *sdrc_cs0,
422 omap2_sdrc_init(sdrc_cs0, sdrc_cs1); 421 omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
423 _omap2_init_reprogram_sdrc(); 422 _omap2_init_reprogram_sdrc();
424 } 423 }
425 gpmc_init();
426 424
427 omap_irq_base_init(); 425 omap_irq_base_init();
428} 426}
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h b/arch/arm/plat-omap/include/plat/gpmc.h
index 85ded598853e..9c060da0a873 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -41,6 +41,8 @@
41#define GPMC_NAND_ADDRESS 0x0000000b 41#define GPMC_NAND_ADDRESS 0x0000000b
42#define GPMC_NAND_DATA 0x0000000c 42#define GPMC_NAND_DATA 0x0000000c
43 43
44#define GPMC_ENABLE_IRQ 0x0000000d
45
44/* ECC commands */ 46/* ECC commands */
45#define GPMC_ECC_READ 0 /* Reset Hardware ECC for read */ 47#define GPMC_ECC_READ 0 /* Reset Hardware ECC for read */
46#define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */ 48#define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */
@@ -78,6 +80,8 @@
78#define WR_RD_PIN_MONITORING 0x00600000 80#define WR_RD_PIN_MONITORING 0x00600000
79#define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F) 81#define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F)
80#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff) 82#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)
83#define GPMC_IRQ_FIFOEVENTENABLE 0x01
84#define GPMC_IRQ_COUNT_EVENT 0x02
81 85
82/* 86/*
83 * Note that all values in this struct are in nanoseconds except sync_clk 87 * Note that all values in this struct are in nanoseconds except sync_clk
@@ -135,7 +139,6 @@ extern int gpmc_prefetch_enable(int cs, int dma_mode,
135extern int gpmc_prefetch_reset(int cs); 139extern int gpmc_prefetch_reset(int cs);
136extern void omap3_gpmc_save_context(void); 140extern void omap3_gpmc_save_context(void);
137extern void omap3_gpmc_restore_context(void); 141extern void omap3_gpmc_restore_context(void);
138extern void gpmc_init(void);
139extern int gpmc_read_status(int cmd); 142extern int gpmc_read_status(int cmd);
140extern int gpmc_cs_configure(int cs, int cmd, int wval); 143extern int gpmc_cs_configure(int cs, int cmd, int wval);
141extern int gpmc_nand_read(int cs, int cmd); 144extern int gpmc_nand_read(int cs, int cmd);
diff --git a/arch/arm/plat-omap/include/plat/irqs.h b/arch/arm/plat-omap/include/plat/irqs.h
index 2910de921c52..1b911681e911 100644
--- a/arch/arm/plat-omap/include/plat/irqs.h
+++ b/arch/arm/plat-omap/include/plat/irqs.h
@@ -318,6 +318,7 @@
318#define INT_34XX_PRCM_MPU_IRQ 11 318#define INT_34XX_PRCM_MPU_IRQ 11
319#define INT_34XX_MCBSP1_IRQ 16 319#define INT_34XX_MCBSP1_IRQ 16
320#define INT_34XX_MCBSP2_IRQ 17 320#define INT_34XX_MCBSP2_IRQ 17
321#define INT_34XX_GPMC_IRQ 20
321#define INT_34XX_MCBSP3_IRQ 22 322#define INT_34XX_MCBSP3_IRQ 22
322#define INT_34XX_MCBSP4_IRQ 23 323#define INT_34XX_MCBSP4_IRQ 23
323#define INT_34XX_CAM_IRQ 24 324#define INT_34XX_CAM_IRQ 24
@@ -411,7 +412,13 @@
411#define TWL_IRQ_END TWL6030_IRQ_END 412#define TWL_IRQ_END TWL6030_IRQ_END
412#endif 413#endif
413 414
414#define NR_IRQS TWL_IRQ_END 415/* GPMC related */
416#define OMAP_GPMC_IRQ_BASE (TWL_IRQ_END)
417#define OMAP_GPMC_NR_IRQS 7
418#define OMAP_GPMC_IRQ_END (OMAP_GPMC_IRQ_BASE + OMAP_GPMC_NR_IRQS)
419
420
421#define NR_IRQS OMAP_GPMC_IRQ_END
415 422
416#define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32)) 423#define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32))
417 424