aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/ath79
diff options
context:
space:
mode:
authorAlban Bedel <albeu@free.fr>2016-01-23 07:57:46 -0500
committerJason Cooper <jason@lakedaemon.net>2016-02-17 08:44:31 -0500
commit07ba4b061a79896315a7be4b123de12df6a9d2bd (patch)
tree5c8d3b6e7dc02196ec8da111c79016e7f476170a /arch/mips/ath79
parent92e963f50fc74041b5e9e744c330dca48e04f08d (diff)
irqchip/ath79-misc: Move the MISC driver from arch/mips/ath79/
The driver stays the same but the initialization changes a bit. For OF boards we now get the memory map from the OF node and use a linear mapping instead of the legacy mapping. For legacy boards we still use a legacy mapping and just pass down all the parameters from the board init code. Signed-off-by: Alban Bedel <albeu@free.fr> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Link: https://lkml.kernel.org/r/1453553867-27003-1-git-send-email-albeu@free.fr Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Diffstat (limited to 'arch/mips/ath79')
-rw-r--r--arch/mips/ath79/irq.c163
1 files changed, 15 insertions, 148 deletions
diff --git a/arch/mips/ath79/irq.c b/arch/mips/ath79/irq.c
index 511c06560dc1..05b45140bc1f 100644
--- a/arch/mips/ath79/irq.c
+++ b/arch/mips/ath79/irq.c
@@ -26,90 +26,6 @@
26#include "common.h" 26#include "common.h"
27#include "machtypes.h" 27#include "machtypes.h"
28 28
29static void __init ath79_misc_intc_domain_init(
30 struct device_node *node, int irq);
31
32static void ath79_misc_irq_handler(struct irq_desc *desc)
33{
34 struct irq_domain *domain = irq_desc_get_handler_data(desc);
35 void __iomem *base = domain->host_data;
36 u32 pending;
37
38 pending = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_STATUS) &
39 __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
40
41 if (!pending) {
42 spurious_interrupt();
43 return;
44 }
45
46 while (pending) {
47 int bit = __ffs(pending);
48
49 generic_handle_irq(irq_linear_revmap(domain, bit));
50 pending &= ~BIT(bit);
51 }
52}
53
54static void ar71xx_misc_irq_unmask(struct irq_data *d)
55{
56 void __iomem *base = irq_data_get_irq_chip_data(d);
57 unsigned int irq = d->hwirq;
58 u32 t;
59
60 t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
61 __raw_writel(t | (1 << irq), base + AR71XX_RESET_REG_MISC_INT_ENABLE);
62
63 /* flush write */
64 __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
65}
66
67static void ar71xx_misc_irq_mask(struct irq_data *d)
68{
69 void __iomem *base = irq_data_get_irq_chip_data(d);
70 unsigned int irq = d->hwirq;
71 u32 t;
72
73 t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
74 __raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_MISC_INT_ENABLE);
75
76 /* flush write */
77 __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
78}
79
80static void ar724x_misc_irq_ack(struct irq_data *d)
81{
82 void __iomem *base = irq_data_get_irq_chip_data(d);
83 unsigned int irq = d->hwirq;
84 u32 t;
85
86 t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_STATUS);
87 __raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_MISC_INT_STATUS);
88
89 /* flush write */
90 __raw_readl(base + AR71XX_RESET_REG_MISC_INT_STATUS);
91}
92
93static struct irq_chip ath79_misc_irq_chip = {
94 .name = "MISC",
95 .irq_unmask = ar71xx_misc_irq_unmask,
96 .irq_mask = ar71xx_misc_irq_mask,
97};
98
99static void __init ath79_misc_irq_init(void)
100{
101 if (soc_is_ar71xx() || soc_is_ar913x())
102 ath79_misc_irq_chip.irq_mask_ack = ar71xx_misc_irq_mask;
103 else if (soc_is_ar724x() ||
104 soc_is_ar933x() ||
105 soc_is_ar934x() ||
106 soc_is_qca955x())
107 ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
108 else
109 BUG();
110
111 ath79_misc_intc_domain_init(NULL, ATH79_CPU_IRQ(6));
112}
113 29
114static void ar934x_ip2_irq_dispatch(struct irq_desc *desc) 30static void ar934x_ip2_irq_dispatch(struct irq_desc *desc)
115{ 31{
@@ -248,69 +164,6 @@ asmlinkage void plat_irq_dispatch(void)
248 } 164 }
249} 165}
250 166
251static int misc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
252{
253 irq_set_chip_and_handler(irq, &ath79_misc_irq_chip, handle_level_irq);
254 irq_set_chip_data(irq, d->host_data);
255 return 0;
256}
257
258static const struct irq_domain_ops misc_irq_domain_ops = {
259 .xlate = irq_domain_xlate_onecell,
260 .map = misc_map,
261};
262
263static void __init ath79_misc_intc_domain_init(
264 struct device_node *node, int irq)
265{
266 void __iomem *base = ath79_reset_base;
267 struct irq_domain *domain;
268
269 domain = irq_domain_add_legacy(node, ATH79_MISC_IRQ_COUNT,
270 ATH79_MISC_IRQ_BASE, 0, &misc_irq_domain_ops, base);
271 if (!domain)
272 panic("Failed to add MISC irqdomain");
273
274 /* Disable and clear all interrupts */
275 __raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_ENABLE);
276 __raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_STATUS);
277
278 irq_set_chained_handler_and_data(irq, ath79_misc_irq_handler, domain);
279}
280
281static int __init ath79_misc_intc_of_init(
282 struct device_node *node, struct device_node *parent)
283{
284 int irq;
285
286 irq = irq_of_parse_and_map(node, 0);
287 if (!irq)
288 panic("Failed to get MISC IRQ");
289
290 ath79_misc_intc_domain_init(node, irq);
291 return 0;
292}
293
294static int __init ar7100_misc_intc_of_init(
295 struct device_node *node, struct device_node *parent)
296{
297 ath79_misc_irq_chip.irq_mask_ack = ar71xx_misc_irq_mask;
298 return ath79_misc_intc_of_init(node, parent);
299}
300
301IRQCHIP_DECLARE(ar7100_misc_intc, "qca,ar7100-misc-intc",
302 ar7100_misc_intc_of_init);
303
304static int __init ar7240_misc_intc_of_init(
305 struct device_node *node, struct device_node *parent)
306{
307 ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
308 return ath79_misc_intc_of_init(node, parent);
309}
310
311IRQCHIP_DECLARE(ar7240_misc_intc, "qca,ar7240-misc-intc",
312 ar7240_misc_intc_of_init);
313
314static int __init ar79_cpu_intc_of_init( 167static int __init ar79_cpu_intc_of_init(
315 struct device_node *node, struct device_node *parent) 168 struct device_node *node, struct device_node *parent)
316{ 169{
@@ -348,6 +201,8 @@ IRQCHIP_DECLARE(ar79_cpu_intc, "qca,ar7100-cpu-intc",
348 201
349void __init arch_init_irq(void) 202void __init arch_init_irq(void)
350{ 203{
204 bool misc_is_ar71xx;
205
351 if (mips_machtype == ATH79_MACH_GENERIC_OF) { 206 if (mips_machtype == ATH79_MACH_GENERIC_OF) {
352 irqchip_init(); 207 irqchip_init();
353 return; 208 return;
@@ -362,7 +217,19 @@ void __init arch_init_irq(void)
362 } 217 }
363 218
364 mips_cpu_irq_init(); 219 mips_cpu_irq_init();
365 ath79_misc_irq_init(); 220
221 if (soc_is_ar71xx() || soc_is_ar913x())
222 misc_is_ar71xx = true;
223 else if (soc_is_ar724x() ||
224 soc_is_ar933x() ||
225 soc_is_ar934x() ||
226 soc_is_qca955x())
227 misc_is_ar71xx = false;
228 else
229 BUG();
230 ath79_misc_irq_init(
231 ath79_reset_base + AR71XX_RESET_REG_MISC_INT_STATUS,
232 ATH79_CPU_IRQ(6), ATH79_MISC_IRQ_BASE, misc_is_ar71xx);
366 233
367 if (soc_is_ar934x()) 234 if (soc_is_ar934x())
368 ar934x_ip2_irq_init(); 235 ar934x_ip2_irq_init();