Merge remote-tracking branch 'regulator/topic/core' into regulator-next
[sfrench/cifs-2.6.git] / arch / arm / mach-kirkwood / irq.c
1 /*
2  * arch/arm/mach-kirkwood/irq.c
3  *
4  * Kirkwood IRQ handling.
5  *
6  * This file is licensed under the terms of the GNU General Public
7  * License version 2.  This program is licensed "as is" without any
8  * warranty of any kind, whether express or implied.
9  */
10 #include <asm/exception.h>
11 #include <linux/gpio.h>
12 #include <linux/kernel.h>
13 #include <linux/irq.h>
14 #include <linux/io.h>
15 #include <mach/bridge-regs.h>
16 #include <plat/orion-gpio.h>
17 #include <plat/irq.h>
18 #include "common.h"
19
20 static int __initdata gpio0_irqs[4] = {
21         IRQ_KIRKWOOD_GPIO_LOW_0_7,
22         IRQ_KIRKWOOD_GPIO_LOW_8_15,
23         IRQ_KIRKWOOD_GPIO_LOW_16_23,
24         IRQ_KIRKWOOD_GPIO_LOW_24_31,
25 };
26
27 static int __initdata gpio1_irqs[4] = {
28         IRQ_KIRKWOOD_GPIO_HIGH_0_7,
29         IRQ_KIRKWOOD_GPIO_HIGH_8_15,
30         IRQ_KIRKWOOD_GPIO_HIGH_16_23,
31         0,
32 };
33
34 #ifdef CONFIG_MULTI_IRQ_HANDLER
35 /*
36  * Compiling with both non-DT and DT support enabled, will
37  * break asm irq handler used by non-DT boards. Therefore,
38  * we provide a C-style irq handler even for non-DT boards,
39  * if MULTI_IRQ_HANDLER is set.
40  */
41
42 static void __iomem *kirkwood_irq_base = IRQ_VIRT_BASE;
43
44 asmlinkage void
45 __exception_irq_entry kirkwood_legacy_handle_irq(struct pt_regs *regs)
46 {
47         u32 stat;
48
49         stat = readl_relaxed(kirkwood_irq_base + IRQ_CAUSE_LOW_OFF);
50         stat &= readl_relaxed(kirkwood_irq_base + IRQ_MASK_LOW_OFF);
51         if (stat) {
52                 unsigned int hwirq = __fls(stat);
53                 handle_IRQ(hwirq, regs);
54                 return;
55         }
56         stat = readl_relaxed(kirkwood_irq_base + IRQ_CAUSE_HIGH_OFF);
57         stat &= readl_relaxed(kirkwood_irq_base + IRQ_MASK_HIGH_OFF);
58         if (stat) {
59                 unsigned int hwirq = 32 + __fls(stat);
60                 handle_IRQ(hwirq, regs);
61                 return;
62         }
63 }
64 #endif
65
66 void __init kirkwood_init_irq(void)
67 {
68         orion_irq_init(0, IRQ_VIRT_BASE + IRQ_MASK_LOW_OFF);
69         orion_irq_init(32, IRQ_VIRT_BASE + IRQ_MASK_HIGH_OFF);
70
71 #ifdef CONFIG_MULTI_IRQ_HANDLER
72         set_handle_irq(kirkwood_legacy_handle_irq);
73 #endif
74
75         /*
76          * Initialize gpiolib for GPIOs 0-49.
77          */
78         orion_gpio_init(NULL, 0, 32, GPIO_LOW_VIRT_BASE, 0,
79                         IRQ_KIRKWOOD_GPIO_START, gpio0_irqs);
80         orion_gpio_init(NULL, 32, 18, GPIO_HIGH_VIRT_BASE, 0,
81                         IRQ_KIRKWOOD_GPIO_START + 32, gpio1_irqs);
82 }