diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2011-06-07 01:59:14 -0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-07-07 04:01:07 -0400 |
commit | 8b6c44f10087fedfb2e041e964b373df53c65514 (patch) | |
tree | 10517911ef01f7beca7c837ca22ded52ed5c12fb /arch/arm/plat-mxc | |
parent | 53b8ff9d3781fe6ff74494ecaea735b322d9ef8e (diff) |
ARM: mxc: convert tzic to use generic irq chip
The patch converts mxc tzic interrupt controller to use generic irq
chip.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/plat-mxc')
-rw-r--r-- | arch/arm/plat-mxc/irq-common.c | 13 | ||||
-rw-r--r-- | arch/arm/plat-mxc/tzic.c | 97 |
2 files changed, 31 insertions, 79 deletions
diff --git a/arch/arm/plat-mxc/irq-common.c b/arch/arm/plat-mxc/irq-common.c index e1c6eff7258a..96953e2e4f11 100644 --- a/arch/arm/plat-mxc/irq-common.c +++ b/arch/arm/plat-mxc/irq-common.c | |||
@@ -42,17 +42,16 @@ EXPORT_SYMBOL(imx_irq_set_priority); | |||
42 | 42 | ||
43 | int mxc_set_irq_fiq(unsigned int irq, unsigned int type) | 43 | int mxc_set_irq_fiq(unsigned int irq, unsigned int type) |
44 | { | 44 | { |
45 | struct mxc_irq_chip *chip; | 45 | struct irq_chip_generic *gc; |
46 | struct irq_chip *base; | 46 | int (*set_irq_fiq)(unsigned int, unsigned int); |
47 | int ret; | 47 | int ret; |
48 | 48 | ||
49 | ret = -ENOSYS; | 49 | ret = -ENOSYS; |
50 | 50 | ||
51 | base = irq_get_chip(irq); | 51 | gc = irq_get_chip_data(irq); |
52 | if (base) { | 52 | if (gc && gc->private) { |
53 | chip = container_of(base, struct mxc_irq_chip, base); | 53 | set_irq_fiq = gc->private; |
54 | if (chip->set_irq_fiq) | 54 | ret = set_irq_fiq(irq, type); |
55 | ret = chip->set_irq_fiq(irq, type); | ||
56 | } | 55 | } |
57 | 56 | ||
58 | return ret; | 57 | return ret; |
diff --git a/arch/arm/plat-mxc/tzic.c b/arch/arm/plat-mxc/tzic.c index 710f2e7da4ce..f257fccdc394 100644 --- a/arch/arm/plat-mxc/tzic.c +++ b/arch/arm/plat-mxc/tzic.c | |||
@@ -68,78 +68,34 @@ static int tzic_set_irq_fiq(unsigned int irq, unsigned int type) | |||
68 | 68 | ||
69 | return 0; | 69 | return 0; |
70 | } | 70 | } |
71 | #else | ||
72 | #define tzic_set_irq_fiq NULL | ||
71 | #endif | 73 | #endif |
72 | 74 | ||
73 | /** | 75 | static unsigned int *wakeup_intr[4]; |
74 | * tzic_mask_irq() - Disable interrupt source "d" in the TZIC | ||
75 | * | ||
76 | * @param d interrupt source | ||
77 | */ | ||
78 | static void tzic_mask_irq(struct irq_data *d) | ||
79 | { | ||
80 | int index, off; | ||
81 | |||
82 | index = d->irq >> 5; | ||
83 | off = d->irq & 0x1F; | ||
84 | __raw_writel(1 << off, tzic_base + TZIC_ENCLEAR0(index)); | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * tzic_unmask_irq() - Enable interrupt source "d" in the TZIC | ||
89 | * | ||
90 | * @param d interrupt source | ||
91 | */ | ||
92 | static void tzic_unmask_irq(struct irq_data *d) | ||
93 | { | ||
94 | int index, off; | ||
95 | |||
96 | index = d->irq >> 5; | ||
97 | off = d->irq & 0x1F; | ||
98 | __raw_writel(1 << off, tzic_base + TZIC_ENSET0(index)); | ||
99 | } | ||
100 | |||
101 | static unsigned int wakeup_intr[4]; | ||
102 | 76 | ||
103 | /** | 77 | static __init void tzic_init_gc(unsigned int irq_start) |
104 | * tzic_set_wake_irq() - Set interrupt source "d" in the TZIC as a wake-up source. | ||
105 | * | ||
106 | * @param d interrupt source | ||
107 | * @param enable enable as wake-up if equal to non-zero | ||
108 | * disble as wake-up if equal to zero | ||
109 | * | ||
110 | * @return This function returns 0 on success. | ||
111 | */ | ||
112 | static int tzic_set_wake_irq(struct irq_data *d, unsigned int enable) | ||
113 | { | 78 | { |
114 | unsigned int index, off; | 79 | struct irq_chip_generic *gc; |
115 | 80 | struct irq_chip_type *ct; | |
116 | index = d->irq >> 5; | 81 | int idx = irq_start >> 5; |
117 | off = d->irq & 0x1F; | 82 | |
118 | 83 | gc = irq_alloc_generic_chip("tzic", 1, irq_start, tzic_base, | |
119 | if (index > 3) | 84 | handle_level_irq); |
120 | return -EINVAL; | 85 | gc->private = tzic_set_irq_fiq; |
121 | 86 | gc->wake_enabled = IRQ_MSK(32); | |
122 | if (enable) | 87 | wakeup_intr[idx] = &gc->wake_active; |
123 | wakeup_intr[index] |= (1 << off); | 88 | |
124 | else | 89 | ct = gc->chip_types; |
125 | wakeup_intr[index] &= ~(1 << off); | 90 | ct->chip.irq_mask = irq_gc_mask_disable_reg; |
126 | 91 | ct->chip.irq_unmask = irq_gc_unmask_enable_reg; | |
127 | return 0; | 92 | ct->chip.irq_set_wake = irq_gc_set_wake; |
93 | ct->regs.disable = TZIC_ENCLEAR0(idx); | ||
94 | ct->regs.enable = TZIC_ENSET0(idx); | ||
95 | |||
96 | irq_setup_generic_chip(gc, IRQ_MSK(32), 0, IRQ_NOREQUEST, 0); | ||
128 | } | 97 | } |
129 | 98 | ||
130 | static struct mxc_irq_chip mxc_tzic_chip = { | ||
131 | .base = { | ||
132 | .name = "MXC_TZIC", | ||
133 | .irq_ack = tzic_mask_irq, | ||
134 | .irq_mask = tzic_mask_irq, | ||
135 | .irq_unmask = tzic_unmask_irq, | ||
136 | .irq_set_wake = tzic_set_wake_irq, | ||
137 | }, | ||
138 | #ifdef CONFIG_FIQ | ||
139 | .set_irq_fiq = tzic_set_irq_fiq, | ||
140 | #endif | ||
141 | }; | ||
142 | |||
143 | /* | 99 | /* |
144 | * This function initializes the TZIC hardware and disables all the | 100 | * This function initializes the TZIC hardware and disables all the |
145 | * interrupts. It registers the interrupt enable and disable functions | 101 | * interrupts. It registers the interrupt enable and disable functions |
@@ -168,11 +124,8 @@ void __init tzic_init_irq(void __iomem *irqbase) | |||
168 | 124 | ||
169 | /* all IRQ no FIQ Warning :: No selection */ | 125 | /* all IRQ no FIQ Warning :: No selection */ |
170 | 126 | ||
171 | for (i = 0; i < TZIC_NUM_IRQS; i++) { | 127 | for (i = 0; i < TZIC_NUM_IRQS; i += 32) |
172 | irq_set_chip_and_handler(i, &mxc_tzic_chip.base, | 128 | tzic_init_gc(i); |
173 | handle_level_irq); | ||
174 | set_irq_flags(i, IRQF_VALID); | ||
175 | } | ||
176 | 129 | ||
177 | #ifdef CONFIG_FIQ | 130 | #ifdef CONFIG_FIQ |
178 | /* Initialize FIQ */ | 131 | /* Initialize FIQ */ |
@@ -199,7 +152,7 @@ int tzic_enable_wake(int is_idle) | |||
199 | 152 | ||
200 | for (i = 0; i < 4; i++) { | 153 | for (i = 0; i < 4; i++) { |
201 | v = is_idle ? __raw_readl(tzic_base + TZIC_ENSET0(i)) : | 154 | v = is_idle ? __raw_readl(tzic_base + TZIC_ENSET0(i)) : |
202 | wakeup_intr[i]; | 155 | *wakeup_intr[i]; |
203 | __raw_writel(v, tzic_base + TZIC_WAKEUP0(i)); | 156 | __raw_writel(v, tzic_base + TZIC_WAKEUP0(i)); |
204 | } | 157 | } |
205 | 158 | ||