diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-02-18 14:59:04 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-05-07 10:15:45 -0400 |
commit | 84c9fa43040af08126326ac8b2a2b18f804eb1e8 (patch) | |
tree | 110d599ae3de28c3effc41d1133410dbb0c349a0 /arch/arm/plat-mxc | |
parent | ec996ba9b5cc2a085ca6938678317c4ff9c954d1 (diff) |
mxc irq: make architecture runtime dependent
Currently we depend on hardcoded base addresses for the interrupt
controller. This prevents us from compiling in more than one i.MX
architecture at a time. This patch changes the base address to a
runtime calculated one.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/plat-mxc')
-rw-r--r-- | arch/arm/plat-mxc/irq.c | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/arch/arm/plat-mxc/irq.c b/arch/arm/plat-mxc/irq.c index 931a0eefaf96..8aee76304f8f 100644 --- a/arch/arm/plat-mxc/irq.c +++ b/arch/arm/plat-mxc/irq.c | |||
@@ -24,26 +24,27 @@ | |||
24 | #include <asm/mach/irq.h> | 24 | #include <asm/mach/irq.h> |
25 | #include <mach/hardware.h> | 25 | #include <mach/hardware.h> |
26 | 26 | ||
27 | #define AVIC_BASE IO_ADDRESS(AVIC_BASE_ADDR) | 27 | #define AVIC_INTCNTL 0x00 /* int control reg */ |
28 | #define AVIC_INTCNTL (AVIC_BASE + 0x00) /* int control reg */ | 28 | #define AVIC_NIMASK 0x04 /* int mask reg */ |
29 | #define AVIC_NIMASK (AVIC_BASE + 0x04) /* int mask reg */ | 29 | #define AVIC_INTENNUM 0x08 /* int enable number reg */ |
30 | #define AVIC_INTENNUM (AVIC_BASE + 0x08) /* int enable number reg */ | 30 | #define AVIC_INTDISNUM 0x0C /* int disable number reg */ |
31 | #define AVIC_INTDISNUM (AVIC_BASE + 0x0C) /* int disable number reg */ | 31 | #define AVIC_INTENABLEH 0x10 /* int enable reg high */ |
32 | #define AVIC_INTENABLEH (AVIC_BASE + 0x10) /* int enable reg high */ | 32 | #define AVIC_INTENABLEL 0x14 /* int enable reg low */ |
33 | #define AVIC_INTENABLEL (AVIC_BASE + 0x14) /* int enable reg low */ | 33 | #define AVIC_INTTYPEH 0x18 /* int type reg high */ |
34 | #define AVIC_INTTYPEH (AVIC_BASE + 0x18) /* int type reg high */ | 34 | #define AVIC_INTTYPEL 0x1C /* int type reg low */ |
35 | #define AVIC_INTTYPEL (AVIC_BASE + 0x1C) /* int type reg low */ | 35 | #define AVIC_NIPRIORITY(x) (0x20 + 4 * (7 - (x))) /* int priority */ |
36 | #define AVIC_NIPRIORITY(x) (AVIC_BASE + (0x20 + 4 * (7 - (x)))) /* int priority */ | 36 | #define AVIC_NIVECSR 0x40 /* norm int vector/status */ |
37 | #define AVIC_NIVECSR (AVIC_BASE + 0x40) /* norm int vector/status */ | 37 | #define AVIC_FIVECSR 0x44 /* fast int vector/status */ |
38 | #define AVIC_FIVECSR (AVIC_BASE + 0x44) /* fast int vector/status */ | 38 | #define AVIC_INTSRCH 0x48 /* int source reg high */ |
39 | #define AVIC_INTSRCH (AVIC_BASE + 0x48) /* int source reg high */ | 39 | #define AVIC_INTSRCL 0x4C /* int source reg low */ |
40 | #define AVIC_INTSRCL (AVIC_BASE + 0x4C) /* int source reg low */ | 40 | #define AVIC_INTFRCH 0x50 /* int force reg high */ |
41 | #define AVIC_INTFRCH (AVIC_BASE + 0x50) /* int force reg high */ | 41 | #define AVIC_INTFRCL 0x54 /* int force reg low */ |
42 | #define AVIC_INTFRCL (AVIC_BASE + 0x54) /* int force reg low */ | 42 | #define AVIC_NIPNDH 0x58 /* norm int pending high */ |
43 | #define AVIC_NIPNDH (AVIC_BASE + 0x58) /* norm int pending high */ | 43 | #define AVIC_NIPNDL 0x5C /* norm int pending low */ |
44 | #define AVIC_NIPNDL (AVIC_BASE + 0x5C) /* norm int pending low */ | 44 | #define AVIC_FIPNDH 0x60 /* fast int pending high */ |
45 | #define AVIC_FIPNDH (AVIC_BASE + 0x60) /* fast int pending high */ | 45 | #define AVIC_FIPNDL 0x64 /* fast int pending low */ |
46 | #define AVIC_FIPNDL (AVIC_BASE + 0x64) /* fast int pending low */ | 46 | |
47 | static void __iomem *avic_base; | ||
47 | 48 | ||
48 | int imx_irq_set_priority(unsigned char irq, unsigned char prio) | 49 | int imx_irq_set_priority(unsigned char irq, unsigned char prio) |
49 | { | 50 | { |
@@ -54,11 +55,11 @@ int imx_irq_set_priority(unsigned char irq, unsigned char prio) | |||
54 | if (irq >= MXC_INTERNAL_IRQS) | 55 | if (irq >= MXC_INTERNAL_IRQS) |
55 | return -EINVAL;; | 56 | return -EINVAL;; |
56 | 57 | ||
57 | temp = __raw_readl(AVIC_NIPRIORITY(irq / 8)); | 58 | temp = __raw_readl(avic_base + AVIC_NIPRIORITY(irq / 8)); |
58 | temp &= ~mask; | 59 | temp &= ~mask; |
59 | temp |= prio & mask; | 60 | temp |= prio & mask; |
60 | 61 | ||
61 | __raw_writel(temp, AVIC_NIPRIORITY(irq / 8)); | 62 | __raw_writel(temp, avic_base + AVIC_NIPRIORITY(irq / 8)); |
62 | 63 | ||
63 | return 0; | 64 | return 0; |
64 | #else | 65 | #else |
@@ -76,12 +77,12 @@ int mxc_set_irq_fiq(unsigned int irq, unsigned int type) | |||
76 | return -EINVAL; | 77 | return -EINVAL; |
77 | 78 | ||
78 | if (irq < MXC_INTERNAL_IRQS / 2) { | 79 | if (irq < MXC_INTERNAL_IRQS / 2) { |
79 | irqt = __raw_readl(AVIC_INTTYPEL) & ~(1 << irq); | 80 | irqt = __raw_readl(avic_base + AVIC_INTTYPEL) & ~(1 << irq); |
80 | __raw_writel(irqt | (!!type << irq), AVIC_INTTYPEL); | 81 | __raw_writel(irqt | (!!type << irq), avic_base + AVIC_INTTYPEL); |
81 | } else { | 82 | } else { |
82 | irq -= MXC_INTERNAL_IRQS / 2; | 83 | irq -= MXC_INTERNAL_IRQS / 2; |
83 | irqt = __raw_readl(AVIC_INTTYPEH) & ~(1 << irq); | 84 | irqt = __raw_readl(avic_base + AVIC_INTTYPEH) & ~(1 << irq); |
84 | __raw_writel(irqt | (!!type << irq), AVIC_INTTYPEH); | 85 | __raw_writel(irqt | (!!type << irq), avic_base + AVIC_INTTYPEH); |
85 | } | 86 | } |
86 | 87 | ||
87 | return 0; | 88 | return 0; |
@@ -92,13 +93,13 @@ EXPORT_SYMBOL(mxc_set_irq_fiq); | |||
92 | /* Disable interrupt number "irq" in the AVIC */ | 93 | /* Disable interrupt number "irq" in the AVIC */ |
93 | static void mxc_mask_irq(unsigned int irq) | 94 | static void mxc_mask_irq(unsigned int irq) |
94 | { | 95 | { |
95 | __raw_writel(irq, AVIC_INTDISNUM); | 96 | __raw_writel(irq, avic_base + AVIC_INTDISNUM); |
96 | } | 97 | } |
97 | 98 | ||
98 | /* Enable interrupt number "irq" in the AVIC */ | 99 | /* Enable interrupt number "irq" in the AVIC */ |
99 | static void mxc_unmask_irq(unsigned int irq) | 100 | static void mxc_unmask_irq(unsigned int irq) |
100 | { | 101 | { |
101 | __raw_writel(irq, AVIC_INTENNUM); | 102 | __raw_writel(irq, avic_base + AVIC_INTENNUM); |
102 | } | 103 | } |
103 | 104 | ||
104 | static struct irq_chip mxc_avic_chip = { | 105 | static struct irq_chip mxc_avic_chip = { |
@@ -116,19 +117,21 @@ void __init mxc_init_irq(void) | |||
116 | { | 117 | { |
117 | int i; | 118 | int i; |
118 | 119 | ||
120 | avic_base = IO_ADDRESS(AVIC_BASE_ADDR); | ||
121 | |||
119 | /* put the AVIC into the reset value with | 122 | /* put the AVIC into the reset value with |
120 | * all interrupts disabled | 123 | * all interrupts disabled |
121 | */ | 124 | */ |
122 | __raw_writel(0, AVIC_INTCNTL); | 125 | __raw_writel(0, avic_base + AVIC_INTCNTL); |
123 | __raw_writel(0x1f, AVIC_NIMASK); | 126 | __raw_writel(0x1f, avic_base + AVIC_NIMASK); |
124 | 127 | ||
125 | /* disable all interrupts */ | 128 | /* disable all interrupts */ |
126 | __raw_writel(0, AVIC_INTENABLEH); | 129 | __raw_writel(0, avic_base + AVIC_INTENABLEH); |
127 | __raw_writel(0, AVIC_INTENABLEL); | 130 | __raw_writel(0, avic_base + AVIC_INTENABLEL); |
128 | 131 | ||
129 | /* all IRQ no FIQ */ | 132 | /* all IRQ no FIQ */ |
130 | __raw_writel(0, AVIC_INTTYPEH); | 133 | __raw_writel(0, avic_base + AVIC_INTTYPEH); |
131 | __raw_writel(0, AVIC_INTTYPEL); | 134 | __raw_writel(0, avic_base + AVIC_INTTYPEL); |
132 | for (i = 0; i < MXC_INTERNAL_IRQS; i++) { | 135 | for (i = 0; i < MXC_INTERNAL_IRQS; i++) { |
133 | set_irq_chip(i, &mxc_avic_chip); | 136 | set_irq_chip(i, &mxc_avic_chip); |
134 | set_irq_handler(i, handle_level_irq); | 137 | set_irq_handler(i, handle_level_irq); |
@@ -137,7 +140,7 @@ void __init mxc_init_irq(void) | |||
137 | 140 | ||
138 | /* Set default priority value (0) for all IRQ's */ | 141 | /* Set default priority value (0) for all IRQ's */ |
139 | for (i = 0; i < 8; i++) | 142 | for (i = 0; i < 8; i++) |
140 | __raw_writel(0, AVIC_NIPRIORITY(i)); | 143 | __raw_writel(0, avic_base + AVIC_NIPRIORITY(i)); |
141 | 144 | ||
142 | /* init architectures chained interrupt handler */ | 145 | /* init architectures chained interrupt handler */ |
143 | mxc_register_gpios(); | 146 | mxc_register_gpios(); |
@@ -149,3 +152,4 @@ void __init mxc_init_irq(void) | |||
149 | 152 | ||
150 | printk(KERN_INFO "MXC IRQ initialized\n"); | 153 | printk(KERN_INFO "MXC IRQ initialized\n"); |
151 | } | 154 | } |
155 | |||