bcm27xx: add linux 5.4 support
[oweals/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0029-irqchip-irq-bcm2836-Remove-regmap-and-syscon-use.patch
1 From fef7d3ecae689f5f6eeb75da93f431d1a8a3200b Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Tue, 23 Jan 2018 16:52:45 +0000
4 Subject: [PATCH] irqchip: irq-bcm2836: Remove regmap and syscon use
5
6 The syscon node defines a register range that duplicates that used by
7 the local_intc node on bcm2836/7. Since irq-bcm2835 and irq-bcm2836 are
8 built in and always present together (both drivers are enabled by
9 CONFIG_ARCH_BCM2835), it is possible to replace the syscon usage with a
10 global variable that simplifies the code. Doing so does lose the
11 locking provided by regmap, but as only one side is using the regmap
12 interface (irq-bcm2835 uses readl and write) there is no loss of
13 atomicity.
14
15 See: https://github.com/raspberrypi/firmware/issues/926
16
17 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
18 ---
19  drivers/irqchip/irq-bcm2835.c | 32 ++++++++++++--------------------
20  drivers/irqchip/irq-bcm2836.c |  5 +++++
21  2 files changed, 17 insertions(+), 20 deletions(-)
22
23 --- a/drivers/irqchip/irq-bcm2835.c
24 +++ b/drivers/irqchip/irq-bcm2835.c
25 @@ -41,8 +41,6 @@
26  #include <linux/of_irq.h>
27  #include <linux/irqchip.h>
28  #include <linux/irqdomain.h>
29 -#include <linux/mfd/syscon.h>
30 -#include <linux/regmap.h>
31  
32  #include <asm/exception.h>
33  #include <asm/mach/irq.h>
34 @@ -91,7 +89,7 @@ struct armctrl_ic {
35         void __iomem *enable[NR_BANKS];
36         void __iomem *disable[NR_BANKS];
37         struct irq_domain *domain;
38 -       struct regmap *local_regmap;
39 +       void __iomem *local_base;
40  };
41  
42  static struct armctrl_ic intc __read_mostly;
43 @@ -128,24 +126,20 @@ static void armctrl_unmask_irq(struct ir
44         if (d->hwirq >= NUMBER_IRQS) {
45                 if (num_online_cpus() > 1) {
46                         unsigned int data;
47 -                       int ret;
48  
49 -                       if (!intc.local_regmap) {
50 -                               pr_err("FIQ is disabled due to missing regmap\n");
51 +                       if (!intc.local_base) {
52 +                               pr_err("FIQ is disabled due to missing arm_local_intc\n");
53                                 return;
54                         }
55  
56 -                       ret = regmap_read(intc.local_regmap,
57 -                                         ARM_LOCAL_GPU_INT_ROUTING, &data);
58 -                       if (ret) {
59 -                               pr_err("Failed to read int routing %d\n", ret);
60 -                               return;
61 -                       }
62 +                       data = readl_relaxed(intc.local_base +
63 +                                            ARM_LOCAL_GPU_INT_ROUTING);
64  
65                         data &= ~0xc;
66                         data |= (1 << 2);
67 -                       regmap_write(intc.local_regmap,
68 -                                    ARM_LOCAL_GPU_INT_ROUTING, data);
69 +                       writel_relaxed(data,
70 +                                      intc.local_base +
71 +                                      ARM_LOCAL_GPU_INT_ROUTING);
72                 }
73  
74                 writel_relaxed(REG_FIQ_ENABLE | hwirq_to_fiq(d->hwirq),
75 @@ -231,12 +225,10 @@ static int __init armctrl_of_init(struct
76         }
77  
78         if (is_2836) {
79 -               intc.local_regmap =
80 -                       syscon_regmap_lookup_by_compatible("brcm,bcm2836-arm-local");
81 -               if (IS_ERR(intc.local_regmap)) {
82 -                       pr_err("Failed to get local register map. FIQ is disabled for cpus > 1\n");
83 -                       intc.local_regmap = NULL;
84 -               }
85 +               extern void __iomem * __attribute__((weak)) arm_local_intc;
86 +               intc.local_base = arm_local_intc;
87 +               if (!intc.local_base)
88 +                       pr_err("Failed to get local intc base. FIQ is disabled for cpus > 1\n");
89         }
90  
91         /* Make a duplicate irq range which is used to enable FIQ */
92 --- a/drivers/irqchip/irq-bcm2836.c
93 +++ b/drivers/irqchip/irq-bcm2836.c
94 @@ -21,6 +21,9 @@ struct bcm2836_arm_irqchip_intc {
95  
96  static struct bcm2836_arm_irqchip_intc intc  __read_mostly;
97  
98 +void __iomem *arm_local_intc;
99 +EXPORT_SYMBOL_GPL(arm_local_intc);
100 +
101  static void bcm2836_arm_irqchip_mask_per_cpu_irq(unsigned int reg_offset,
102                                                  unsigned int bit,
103                                                  int cpu)
104 @@ -225,6 +228,8 @@ static int __init bcm2836_arm_irqchip_l1
105                 panic("%pOF: unable to map local interrupt registers\n", node);
106         }
107  
108 +       arm_local_intc = intc.base;
109 +
110         bcm2835_init_local_timer_frequency();
111  
112         intc.domain = irq_domain_add_linear(node, LAST_IRQ + 1,