3a114d0699d69d0e1ca5cc9264db14c84ea24320
[openwrt/openwrt.git] / target / linux / ramips / patches-3.14 / 0025-MIPS-ralink-allow-loading-irq-registers-from-the-dev.patch
1 From b1cc9a15f6ead8dbd849257e42d69a5799fb7597 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 6 Aug 2014 18:24:36 +0200
4 Subject: [PATCH 25/57] MIPS: ralink: allow loading irq registers from the
5 devicetree
6
7 Signed-off-by: John Crispin <blogic@openwrt.org>
8 ---
9 arch/mips/ralink/irq.c | 33 +++++++++++++++++++++++----------
10 1 file changed, 23 insertions(+), 10 deletions(-)
11
12 diff --git a/arch/mips/ralink/irq.c b/arch/mips/ralink/irq.c
13 index 781b3d1..82c3146 100644
14 --- a/arch/mips/ralink/irq.c
15 +++ b/arch/mips/ralink/irq.c
16 @@ -20,14 +20,6 @@
17
18 #include "common.h"
19
20 -/* INTC register offsets */
21 -#define INTC_REG_STATUS0 0x00
22 -#define INTC_REG_STATUS1 0x04
23 -#define INTC_REG_TYPE 0x20
24 -#define INTC_REG_RAW_STATUS 0x30
25 -#define INTC_REG_ENABLE 0x34
26 -#define INTC_REG_DISABLE 0x38
27 -
28 #define INTC_INT_GLOBAL BIT(31)
29
30 #define RALINK_CPU_IRQ_INTC (MIPS_CPU_IRQ_BASE + 2)
31 @@ -44,16 +36,34 @@
32
33 #define RALINK_INTC_IRQ_PERFC (RALINK_INTC_IRQ_BASE + 9)
34
35 +enum rt_intc_regs_enum {
36 + INTC_REG_STATUS0 = 0,
37 + INTC_REG_STATUS1,
38 + INTC_REG_TYPE,
39 + INTC_REG_RAW_STATUS,
40 + INTC_REG_ENABLE,
41 + INTC_REG_DISABLE,
42 +};
43 +
44 +static u32 rt_intc_regs[] = {
45 + [INTC_REG_STATUS0] = 0x00,
46 + [INTC_REG_STATUS1] = 0x04,
47 + [INTC_REG_TYPE] = 0x20,
48 + [INTC_REG_RAW_STATUS] = 0x30,
49 + [INTC_REG_ENABLE] = 0x34,
50 + [INTC_REG_DISABLE] = 0x38,
51 +};
52 +
53 static void __iomem *rt_intc_membase;
54
55 static inline void rt_intc_w32(u32 val, unsigned reg)
56 {
57 - __raw_writel(val, rt_intc_membase + reg);
58 + __raw_writel(val, rt_intc_membase + rt_intc_regs[reg]);
59 }
60
61 static inline u32 rt_intc_r32(unsigned reg)
62 {
63 - return __raw_readl(rt_intc_membase + reg);
64 + return __raw_readl(rt_intc_membase + rt_intc_regs[reg]);
65 }
66
67 static void ralink_intc_irq_unmask(struct irq_data *d)
68 @@ -134,6 +144,9 @@ static int __init intc_of_init(struct device_node *node,
69 struct irq_domain *domain;
70 int irq;
71
72 + if (!of_property_read_u32_array(node, "ralink,intc-registers", rt_intc_regs, 6))
73 + pr_info("intc: using register map from devicetree\n");
74 +
75 irq = irq_of_parse_and_map(node, 0);
76 if (!irq)
77 panic("Failed to get INTC IRQ");
78 --
79 1.7.10.4
80