Steven J. Hill | 2299c49 | 2012-08-31 16:13:07 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 2008 Ralf Baechle (ralf@linux-mips.org) |
| 7 | * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. |
| 8 | */ |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 9 | #include <linux/bitmap.h> |
Andrew Bresticker | fb8f7be1 | 2014-10-20 12:03:55 -0700 | [diff] [blame] | 10 | #include <linux/clocksource.h> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 11 | #include <linux/init.h> |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 12 | #include <linux/interrupt.h> |
Andrew Bresticker | fb8f7be1 | 2014-10-20 12:03:55 -0700 | [diff] [blame] | 13 | #include <linux/irq.h> |
Andrew Bresticker | 4060bbe | 2014-10-20 12:03:53 -0700 | [diff] [blame] | 14 | #include <linux/irqchip/mips-gic.h> |
Andrew Bresticker | a705727 | 2014-11-12 11:43:38 -0800 | [diff] [blame] | 15 | #include <linux/of_address.h> |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 16 | #include <linux/sched.h> |
Ralf Baechle | 631330f | 2009-06-19 14:05:26 +0100 | [diff] [blame] | 17 | #include <linux/smp.h> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 18 | |
Andrew Bresticker | a705727 | 2014-11-12 11:43:38 -0800 | [diff] [blame] | 19 | #include <asm/mips-cm.h> |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 20 | #include <asm/setup.h> |
| 21 | #include <asm/traps.h> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 22 | |
Andrew Bresticker | a705727 | 2014-11-12 11:43:38 -0800 | [diff] [blame] | 23 | #include <dt-bindings/interrupt-controller/mips-gic.h> |
| 24 | |
| 25 | #include "irqchip.h" |
| 26 | |
Steven J. Hill | ff86714 | 2013-04-10 16:27:04 -0500 | [diff] [blame] | 27 | unsigned int gic_present; |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 28 | |
Jeffrey Deans | 822350b | 2014-07-17 09:20:53 +0100 | [diff] [blame] | 29 | struct gic_pcpu_mask { |
Andrew Bresticker | fbd5524 | 2014-09-18 14:47:25 -0700 | [diff] [blame] | 30 | DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS); |
Jeffrey Deans | 822350b | 2014-07-17 09:20:53 +0100 | [diff] [blame] | 31 | }; |
| 32 | |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 33 | static void __iomem *gic_base; |
Steven J. Hill | 0b271f5 | 2012-08-31 16:05:37 -0500 | [diff] [blame] | 34 | static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 35 | static DEFINE_SPINLOCK(gic_lock); |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 36 | static struct irq_domain *gic_irq_domain; |
Andrew Bresticker | fbd5524 | 2014-09-18 14:47:25 -0700 | [diff] [blame] | 37 | static int gic_shared_intrs; |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 38 | static int gic_vpes; |
Andrew Bresticker | 3263d08 | 2014-09-18 14:47:28 -0700 | [diff] [blame] | 39 | static unsigned int gic_cpu_pin; |
James Hogan | 1b6af71 | 2015-01-19 15:38:24 +0000 | [diff] [blame] | 40 | static unsigned int timer_cpu_pin; |
Andrew Bresticker | 4a6a3ea3 | 2014-09-18 14:47:26 -0700 | [diff] [blame] | 41 | static struct irq_chip gic_level_irq_controller, gic_edge_irq_controller; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 42 | |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 43 | static void __gic_irq_dispatch(void); |
| 44 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 45 | static inline u32 gic_read32(unsigned int reg) |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 46 | { |
| 47 | return __raw_readl(gic_base + reg); |
| 48 | } |
| 49 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 50 | static inline u64 gic_read64(unsigned int reg) |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 51 | { |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 52 | return __raw_readq(gic_base + reg); |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 55 | static inline unsigned long gic_read(unsigned int reg) |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 56 | { |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 57 | if (!mips_cm_is64) |
| 58 | return gic_read32(reg); |
| 59 | else |
| 60 | return gic_read64(reg); |
| 61 | } |
| 62 | |
| 63 | static inline void gic_write32(unsigned int reg, u32 val) |
| 64 | { |
| 65 | return __raw_writel(val, gic_base + reg); |
| 66 | } |
| 67 | |
| 68 | static inline void gic_write64(unsigned int reg, u64 val) |
| 69 | { |
| 70 | return __raw_writeq(val, gic_base + reg); |
| 71 | } |
| 72 | |
| 73 | static inline void gic_write(unsigned int reg, unsigned long val) |
| 74 | { |
| 75 | if (!mips_cm_is64) |
| 76 | return gic_write32(reg, (u32)val); |
| 77 | else |
| 78 | return gic_write64(reg, (u64)val); |
| 79 | } |
| 80 | |
| 81 | static inline void gic_update_bits(unsigned int reg, unsigned long mask, |
| 82 | unsigned long val) |
| 83 | { |
| 84 | unsigned long regval; |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 85 | |
| 86 | regval = gic_read(reg); |
| 87 | regval &= ~mask; |
| 88 | regval |= val; |
| 89 | gic_write(reg, regval); |
| 90 | } |
| 91 | |
| 92 | static inline void gic_reset_mask(unsigned int intr) |
| 93 | { |
| 94 | gic_write(GIC_REG(SHARED, GIC_SH_RMASK) + GIC_INTR_OFS(intr), |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 95 | 1ul << GIC_INTR_BIT(intr)); |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | static inline void gic_set_mask(unsigned int intr) |
| 99 | { |
| 100 | gic_write(GIC_REG(SHARED, GIC_SH_SMASK) + GIC_INTR_OFS(intr), |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 101 | 1ul << GIC_INTR_BIT(intr)); |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | static inline void gic_set_polarity(unsigned int intr, unsigned int pol) |
| 105 | { |
| 106 | gic_update_bits(GIC_REG(SHARED, GIC_SH_SET_POLARITY) + |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 107 | GIC_INTR_OFS(intr), 1ul << GIC_INTR_BIT(intr), |
| 108 | (unsigned long)pol << GIC_INTR_BIT(intr)); |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | static inline void gic_set_trigger(unsigned int intr, unsigned int trig) |
| 112 | { |
| 113 | gic_update_bits(GIC_REG(SHARED, GIC_SH_SET_TRIGGER) + |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 114 | GIC_INTR_OFS(intr), 1ul << GIC_INTR_BIT(intr), |
| 115 | (unsigned long)trig << GIC_INTR_BIT(intr)); |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | static inline void gic_set_dual_edge(unsigned int intr, unsigned int dual) |
| 119 | { |
| 120 | gic_update_bits(GIC_REG(SHARED, GIC_SH_SET_DUAL) + GIC_INTR_OFS(intr), |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 121 | 1ul << GIC_INTR_BIT(intr), |
| 122 | (unsigned long)dual << GIC_INTR_BIT(intr)); |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | static inline void gic_map_to_pin(unsigned int intr, unsigned int pin) |
| 126 | { |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 127 | gic_write32(GIC_REG(SHARED, GIC_SH_INTR_MAP_TO_PIN_BASE) + |
| 128 | GIC_SH_MAP_TO_PIN(intr), GIC_MAP_TO_PIN_MSK | pin); |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | static inline void gic_map_to_vpe(unsigned int intr, unsigned int vpe) |
| 132 | { |
| 133 | gic_write(GIC_REG(SHARED, GIC_SH_INTR_MAP_TO_VPE_BASE) + |
| 134 | GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe), |
| 135 | GIC_SH_MAP_TO_VPE_REG_BIT(vpe)); |
| 136 | } |
| 137 | |
Andrew Bresticker | a331ce6 | 2014-10-20 12:03:59 -0700 | [diff] [blame] | 138 | #ifdef CONFIG_CLKSRC_MIPS_GIC |
Steven J. Hill | dfa762e | 2013-04-10 16:28:36 -0500 | [diff] [blame] | 139 | cycle_t gic_read_count(void) |
| 140 | { |
| 141 | unsigned int hi, hi2, lo; |
| 142 | |
| 143 | do { |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 144 | hi = gic_read32(GIC_REG(SHARED, GIC_SH_COUNTER_63_32)); |
| 145 | lo = gic_read32(GIC_REG(SHARED, GIC_SH_COUNTER_31_00)); |
| 146 | hi2 = gic_read32(GIC_REG(SHARED, GIC_SH_COUNTER_63_32)); |
Steven J. Hill | dfa762e | 2013-04-10 16:28:36 -0500 | [diff] [blame] | 147 | } while (hi2 != hi); |
| 148 | |
| 149 | return (((cycle_t) hi) << 32) + lo; |
| 150 | } |
Raghu Gandham | 0ab2b7d | 2013-04-10 16:30:12 -0500 | [diff] [blame] | 151 | |
Andrew Bresticker | 387904f | 2014-10-20 12:03:49 -0700 | [diff] [blame] | 152 | unsigned int gic_get_count_width(void) |
| 153 | { |
| 154 | unsigned int bits, config; |
| 155 | |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 156 | config = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG)); |
Andrew Bresticker | 387904f | 2014-10-20 12:03:49 -0700 | [diff] [blame] | 157 | bits = 32 + 4 * ((config & GIC_SH_CONFIG_COUNTBITS_MSK) >> |
| 158 | GIC_SH_CONFIG_COUNTBITS_SHF); |
| 159 | |
| 160 | return bits; |
| 161 | } |
| 162 | |
Raghu Gandham | 0ab2b7d | 2013-04-10 16:30:12 -0500 | [diff] [blame] | 163 | void gic_write_compare(cycle_t cnt) |
| 164 | { |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 165 | gic_write32(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_HI), |
Raghu Gandham | 0ab2b7d | 2013-04-10 16:30:12 -0500 | [diff] [blame] | 166 | (int)(cnt >> 32)); |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 167 | gic_write32(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_LO), |
Raghu Gandham | 0ab2b7d | 2013-04-10 16:30:12 -0500 | [diff] [blame] | 168 | (int)(cnt & 0xffffffff)); |
| 169 | } |
| 170 | |
Paul Burton | 414408d0 | 2014-03-05 11:35:53 +0000 | [diff] [blame] | 171 | void gic_write_cpu_compare(cycle_t cnt, int cpu) |
| 172 | { |
| 173 | unsigned long flags; |
| 174 | |
| 175 | local_irq_save(flags); |
| 176 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 177 | gic_write32(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), cpu); |
| 178 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_HI), |
Paul Burton | 414408d0 | 2014-03-05 11:35:53 +0000 | [diff] [blame] | 179 | (int)(cnt >> 32)); |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 180 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_LO), |
Paul Burton | 414408d0 | 2014-03-05 11:35:53 +0000 | [diff] [blame] | 181 | (int)(cnt & 0xffffffff)); |
| 182 | |
| 183 | local_irq_restore(flags); |
| 184 | } |
| 185 | |
Raghu Gandham | 0ab2b7d | 2013-04-10 16:30:12 -0500 | [diff] [blame] | 186 | cycle_t gic_read_compare(void) |
| 187 | { |
| 188 | unsigned int hi, lo; |
| 189 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 190 | hi = gic_read32(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_HI)); |
| 191 | lo = gic_read32(GIC_REG(VPE_LOCAL, GIC_VPE_COMPARE_LO)); |
Raghu Gandham | 0ab2b7d | 2013-04-10 16:30:12 -0500 | [diff] [blame] | 192 | |
| 193 | return (((cycle_t) hi) << 32) + lo; |
| 194 | } |
Markos Chandras | 8fa4b93 | 2015-03-23 12:32:01 +0000 | [diff] [blame] | 195 | |
| 196 | void gic_start_count(void) |
| 197 | { |
| 198 | u32 gicconfig; |
| 199 | |
| 200 | /* Start the counter */ |
| 201 | gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG)); |
| 202 | gicconfig &= ~(1 << GIC_SH_CONFIG_COUNTSTOP_SHF); |
| 203 | gic_write(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig); |
| 204 | } |
| 205 | |
| 206 | void gic_stop_count(void) |
| 207 | { |
| 208 | u32 gicconfig; |
| 209 | |
| 210 | /* Stop the counter */ |
| 211 | gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG)); |
| 212 | gicconfig |= 1 << GIC_SH_CONFIG_COUNTSTOP_SHF; |
| 213 | gic_write(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig); |
| 214 | } |
| 215 | |
Steven J. Hill | dfa762e | 2013-04-10 16:28:36 -0500 | [diff] [blame] | 216 | #endif |
| 217 | |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 218 | static bool gic_local_irq_is_routable(int intr) |
| 219 | { |
| 220 | u32 vpe_ctl; |
| 221 | |
| 222 | /* All local interrupts are routable in EIC mode. */ |
| 223 | if (cpu_has_veic) |
| 224 | return true; |
| 225 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 226 | vpe_ctl = gic_read32(GIC_REG(VPE_LOCAL, GIC_VPE_CTL)); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 227 | switch (intr) { |
| 228 | case GIC_LOCAL_INT_TIMER: |
| 229 | return vpe_ctl & GIC_VPE_CTL_TIMER_RTBL_MSK; |
| 230 | case GIC_LOCAL_INT_PERFCTR: |
| 231 | return vpe_ctl & GIC_VPE_CTL_PERFCNT_RTBL_MSK; |
| 232 | case GIC_LOCAL_INT_FDC: |
| 233 | return vpe_ctl & GIC_VPE_CTL_FDC_RTBL_MSK; |
| 234 | case GIC_LOCAL_INT_SWINT0: |
| 235 | case GIC_LOCAL_INT_SWINT1: |
| 236 | return vpe_ctl & GIC_VPE_CTL_SWINT_RTBL_MSK; |
| 237 | default: |
| 238 | return true; |
| 239 | } |
| 240 | } |
| 241 | |
Andrew Bresticker | 3263d08 | 2014-09-18 14:47:28 -0700 | [diff] [blame] | 242 | static void gic_bind_eic_interrupt(int irq, int set) |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 243 | { |
| 244 | /* Convert irq vector # to hw int # */ |
| 245 | irq -= GIC_PIN_TO_VEC_OFFSET; |
| 246 | |
| 247 | /* Set irq to use shadow set */ |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 248 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_EIC_SHADOW_SET_BASE) + |
| 249 | GIC_VPE_EIC_SS(irq), set); |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 250 | } |
| 251 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 252 | void gic_send_ipi(unsigned int intr) |
| 253 | { |
Andrew Bresticker | 53a7bc8 | 2014-10-20 12:03:57 -0700 | [diff] [blame] | 254 | gic_write(GIC_REG(SHARED, GIC_SH_WEDGE), GIC_SH_WEDGE_SET(intr)); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 255 | } |
| 256 | |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 257 | int gic_get_c0_compare_int(void) |
| 258 | { |
| 259 | if (!gic_local_irq_is_routable(GIC_LOCAL_INT_TIMER)) |
| 260 | return MIPS_CPU_IRQ_BASE + cp0_compare_irq; |
| 261 | return irq_create_mapping(gic_irq_domain, |
| 262 | GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_TIMER)); |
| 263 | } |
| 264 | |
| 265 | int gic_get_c0_perfcount_int(void) |
| 266 | { |
| 267 | if (!gic_local_irq_is_routable(GIC_LOCAL_INT_PERFCTR)) { |
James Hogan | 7e3e6cb | 2015-01-27 21:45:50 +0000 | [diff] [blame] | 268 | /* Is the performance counter shared with the timer? */ |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 269 | if (cp0_perfcount_irq < 0) |
| 270 | return -1; |
| 271 | return MIPS_CPU_IRQ_BASE + cp0_perfcount_irq; |
| 272 | } |
| 273 | return irq_create_mapping(gic_irq_domain, |
| 274 | GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_PERFCTR)); |
| 275 | } |
| 276 | |
James Hogan | 6429e2b | 2015-01-29 11:14:09 +0000 | [diff] [blame] | 277 | int gic_get_c0_fdc_int(void) |
| 278 | { |
| 279 | if (!gic_local_irq_is_routable(GIC_LOCAL_INT_FDC)) { |
| 280 | /* Is the FDC IRQ even present? */ |
| 281 | if (cp0_fdc_irq < 0) |
| 282 | return -1; |
| 283 | return MIPS_CPU_IRQ_BASE + cp0_fdc_irq; |
| 284 | } |
| 285 | |
James Hogan | 6429e2b | 2015-01-29 11:14:09 +0000 | [diff] [blame] | 286 | return irq_create_mapping(gic_irq_domain, |
| 287 | GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_FDC)); |
| 288 | } |
| 289 | |
Rabin Vincent | 1b3ed36 | 2015-06-12 10:01:56 +0200 | [diff] [blame] | 290 | static void gic_handle_shared_int(bool chained) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 291 | { |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 292 | unsigned int i, intr, virq, gic_reg_step = mips_cm_is64 ? 8 : 4; |
Andrew Bresticker | 8f5ee79 | 2014-10-20 12:03:56 -0700 | [diff] [blame] | 293 | unsigned long *pcpu_mask; |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 294 | unsigned long pending_reg, intrmask_reg; |
Andrew Bresticker | 8f5ee79 | 2014-10-20 12:03:56 -0700 | [diff] [blame] | 295 | DECLARE_BITMAP(pending, GIC_MAX_INTRS); |
| 296 | DECLARE_BITMAP(intrmask, GIC_MAX_INTRS); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 297 | |
| 298 | /* Get per-cpu bitmaps */ |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 299 | pcpu_mask = pcpu_masks[smp_processor_id()].pcpu_mask; |
| 300 | |
Andrew Bresticker | 824f3f7 | 2014-10-20 12:03:54 -0700 | [diff] [blame] | 301 | pending_reg = GIC_REG(SHARED, GIC_SH_PEND); |
| 302 | intrmask_reg = GIC_REG(SHARED, GIC_SH_MASK); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 303 | |
Andrew Bresticker | fbd5524 | 2014-09-18 14:47:25 -0700 | [diff] [blame] | 304 | for (i = 0; i < BITS_TO_LONGS(gic_shared_intrs); i++) { |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 305 | pending[i] = gic_read(pending_reg); |
| 306 | intrmask[i] = gic_read(intrmask_reg); |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 307 | pending_reg += gic_reg_step; |
| 308 | intrmask_reg += gic_reg_step; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 309 | } |
| 310 | |
Andrew Bresticker | fbd5524 | 2014-09-18 14:47:25 -0700 | [diff] [blame] | 311 | bitmap_and(pending, pending, intrmask, gic_shared_intrs); |
| 312 | bitmap_and(pending, pending, pcpu_mask, gic_shared_intrs); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 313 | |
Qais Yousef | d7eb4f2 | 2015-01-19 11:51:29 +0000 | [diff] [blame] | 314 | intr = find_first_bit(pending, gic_shared_intrs); |
| 315 | while (intr != gic_shared_intrs) { |
| 316 | virq = irq_linear_revmap(gic_irq_domain, |
| 317 | GIC_SHARED_TO_HWIRQ(intr)); |
Rabin Vincent | 1b3ed36 | 2015-06-12 10:01:56 +0200 | [diff] [blame] | 318 | if (chained) |
| 319 | generic_handle_irq(virq); |
| 320 | else |
| 321 | do_IRQ(virq); |
Qais Yousef | d7eb4f2 | 2015-01-19 11:51:29 +0000 | [diff] [blame] | 322 | |
| 323 | /* go to next pending bit */ |
| 324 | bitmap_clear(pending, intr, 1); |
| 325 | intr = find_first_bit(pending, gic_shared_intrs); |
| 326 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 327 | } |
| 328 | |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 329 | static void gic_mask_irq(struct irq_data *d) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 330 | { |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 331 | gic_reset_mask(GIC_HWIRQ_TO_SHARED(d->hwirq)); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 332 | } |
| 333 | |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 334 | static void gic_unmask_irq(struct irq_data *d) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 335 | { |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 336 | gic_set_mask(GIC_HWIRQ_TO_SHARED(d->hwirq)); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 337 | } |
| 338 | |
Andrew Bresticker | 5561c9e | 2014-09-18 14:47:20 -0700 | [diff] [blame] | 339 | static void gic_ack_irq(struct irq_data *d) |
| 340 | { |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 341 | unsigned int irq = GIC_HWIRQ_TO_SHARED(d->hwirq); |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 342 | |
Andrew Bresticker | 53a7bc8 | 2014-10-20 12:03:57 -0700 | [diff] [blame] | 343 | gic_write(GIC_REG(SHARED, GIC_SH_WEDGE), GIC_SH_WEDGE_CLR(irq)); |
Andrew Bresticker | 5561c9e | 2014-09-18 14:47:20 -0700 | [diff] [blame] | 344 | } |
| 345 | |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 346 | static int gic_set_type(struct irq_data *d, unsigned int type) |
| 347 | { |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 348 | unsigned int irq = GIC_HWIRQ_TO_SHARED(d->hwirq); |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 349 | unsigned long flags; |
| 350 | bool is_edge; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 351 | |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 352 | spin_lock_irqsave(&gic_lock, flags); |
| 353 | switch (type & IRQ_TYPE_SENSE_MASK) { |
| 354 | case IRQ_TYPE_EDGE_FALLING: |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 355 | gic_set_polarity(irq, GIC_POL_NEG); |
| 356 | gic_set_trigger(irq, GIC_TRIG_EDGE); |
| 357 | gic_set_dual_edge(irq, GIC_TRIG_DUAL_DISABLE); |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 358 | is_edge = true; |
| 359 | break; |
| 360 | case IRQ_TYPE_EDGE_RISING: |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 361 | gic_set_polarity(irq, GIC_POL_POS); |
| 362 | gic_set_trigger(irq, GIC_TRIG_EDGE); |
| 363 | gic_set_dual_edge(irq, GIC_TRIG_DUAL_DISABLE); |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 364 | is_edge = true; |
| 365 | break; |
| 366 | case IRQ_TYPE_EDGE_BOTH: |
| 367 | /* polarity is irrelevant in this case */ |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 368 | gic_set_trigger(irq, GIC_TRIG_EDGE); |
| 369 | gic_set_dual_edge(irq, GIC_TRIG_DUAL_ENABLE); |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 370 | is_edge = true; |
| 371 | break; |
| 372 | case IRQ_TYPE_LEVEL_LOW: |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 373 | gic_set_polarity(irq, GIC_POL_NEG); |
| 374 | gic_set_trigger(irq, GIC_TRIG_LEVEL); |
| 375 | gic_set_dual_edge(irq, GIC_TRIG_DUAL_DISABLE); |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 376 | is_edge = false; |
| 377 | break; |
| 378 | case IRQ_TYPE_LEVEL_HIGH: |
| 379 | default: |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 380 | gic_set_polarity(irq, GIC_POL_POS); |
| 381 | gic_set_trigger(irq, GIC_TRIG_LEVEL); |
| 382 | gic_set_dual_edge(irq, GIC_TRIG_DUAL_DISABLE); |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 383 | is_edge = false; |
| 384 | break; |
| 385 | } |
| 386 | |
| 387 | if (is_edge) { |
Andrew Bresticker | 4a6a3ea3 | 2014-09-18 14:47:26 -0700 | [diff] [blame] | 388 | __irq_set_chip_handler_name_locked(d->irq, |
| 389 | &gic_edge_irq_controller, |
| 390 | handle_edge_irq, NULL); |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 391 | } else { |
Andrew Bresticker | 4a6a3ea3 | 2014-09-18 14:47:26 -0700 | [diff] [blame] | 392 | __irq_set_chip_handler_name_locked(d->irq, |
| 393 | &gic_level_irq_controller, |
| 394 | handle_level_irq, NULL); |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 395 | } |
| 396 | spin_unlock_irqrestore(&gic_lock, flags); |
| 397 | |
| 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | #ifdef CONFIG_SMP |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 402 | static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, |
| 403 | bool force) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 404 | { |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 405 | unsigned int irq = GIC_HWIRQ_TO_SHARED(d->hwirq); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 406 | cpumask_t tmp = CPU_MASK_NONE; |
| 407 | unsigned long flags; |
| 408 | int i; |
| 409 | |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 410 | cpumask_and(&tmp, cpumask, cpu_online_mask); |
Rusty Russell | f9b531f | 2015-03-05 10:49:16 +1030 | [diff] [blame] | 411 | if (cpumask_empty(&tmp)) |
Andrew Bresticker | 14d160a | 2014-09-18 14:47:22 -0700 | [diff] [blame] | 412 | return -EINVAL; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 413 | |
| 414 | /* Assumption : cpumask refers to a single CPU */ |
| 415 | spin_lock_irqsave(&gic_lock, flags); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 416 | |
Tony Wu | c214c03 | 2013-06-21 10:13:08 +0000 | [diff] [blame] | 417 | /* Re-route this IRQ */ |
Rusty Russell | f9b531f | 2015-03-05 10:49:16 +1030 | [diff] [blame] | 418 | gic_map_to_vpe(irq, cpumask_first(&tmp)); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 419 | |
Tony Wu | c214c03 | 2013-06-21 10:13:08 +0000 | [diff] [blame] | 420 | /* Update the pcpu_masks */ |
| 421 | for (i = 0; i < NR_CPUS; i++) |
| 422 | clear_bit(irq, pcpu_masks[i].pcpu_mask); |
Rusty Russell | f9b531f | 2015-03-05 10:49:16 +1030 | [diff] [blame] | 423 | set_bit(irq, pcpu_masks[cpumask_first(&tmp)].pcpu_mask); |
Tony Wu | c214c03 | 2013-06-21 10:13:08 +0000 | [diff] [blame] | 424 | |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 425 | cpumask_copy(d->affinity, cpumask); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 426 | spin_unlock_irqrestore(&gic_lock, flags); |
| 427 | |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 428 | return IRQ_SET_MASK_OK_NOCOPY; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 429 | } |
| 430 | #endif |
| 431 | |
Andrew Bresticker | 4a6a3ea3 | 2014-09-18 14:47:26 -0700 | [diff] [blame] | 432 | static struct irq_chip gic_level_irq_controller = { |
| 433 | .name = "MIPS GIC", |
| 434 | .irq_mask = gic_mask_irq, |
| 435 | .irq_unmask = gic_unmask_irq, |
| 436 | .irq_set_type = gic_set_type, |
| 437 | #ifdef CONFIG_SMP |
| 438 | .irq_set_affinity = gic_set_affinity, |
| 439 | #endif |
| 440 | }; |
| 441 | |
| 442 | static struct irq_chip gic_edge_irq_controller = { |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 443 | .name = "MIPS GIC", |
Andrew Bresticker | 5561c9e | 2014-09-18 14:47:20 -0700 | [diff] [blame] | 444 | .irq_ack = gic_ack_irq, |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 445 | .irq_mask = gic_mask_irq, |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 446 | .irq_unmask = gic_unmask_irq, |
Andrew Bresticker | 95150ae | 2014-09-18 14:47:21 -0700 | [diff] [blame] | 447 | .irq_set_type = gic_set_type, |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 448 | #ifdef CONFIG_SMP |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 449 | .irq_set_affinity = gic_set_affinity, |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 450 | #endif |
| 451 | }; |
| 452 | |
Rabin Vincent | 1b3ed36 | 2015-06-12 10:01:56 +0200 | [diff] [blame] | 453 | static void gic_handle_local_int(bool chained) |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 454 | { |
| 455 | unsigned long pending, masked; |
Qais Yousef | d7eb4f2 | 2015-01-19 11:51:29 +0000 | [diff] [blame] | 456 | unsigned int intr, virq; |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 457 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 458 | pending = gic_read32(GIC_REG(VPE_LOCAL, GIC_VPE_PEND)); |
| 459 | masked = gic_read32(GIC_REG(VPE_LOCAL, GIC_VPE_MASK)); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 460 | |
| 461 | bitmap_and(&pending, &pending, &masked, GIC_NUM_LOCAL_INTRS); |
| 462 | |
Qais Yousef | d7eb4f2 | 2015-01-19 11:51:29 +0000 | [diff] [blame] | 463 | intr = find_first_bit(&pending, GIC_NUM_LOCAL_INTRS); |
| 464 | while (intr != GIC_NUM_LOCAL_INTRS) { |
| 465 | virq = irq_linear_revmap(gic_irq_domain, |
| 466 | GIC_LOCAL_TO_HWIRQ(intr)); |
Rabin Vincent | 1b3ed36 | 2015-06-12 10:01:56 +0200 | [diff] [blame] | 467 | if (chained) |
| 468 | generic_handle_irq(virq); |
| 469 | else |
| 470 | do_IRQ(virq); |
Qais Yousef | d7eb4f2 | 2015-01-19 11:51:29 +0000 | [diff] [blame] | 471 | |
| 472 | /* go to next pending bit */ |
| 473 | bitmap_clear(&pending, intr, 1); |
| 474 | intr = find_first_bit(&pending, GIC_NUM_LOCAL_INTRS); |
| 475 | } |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | static void gic_mask_local_irq(struct irq_data *d) |
| 479 | { |
| 480 | int intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); |
| 481 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 482 | gic_write32(GIC_REG(VPE_LOCAL, GIC_VPE_RMASK), 1 << intr); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | static void gic_unmask_local_irq(struct irq_data *d) |
| 486 | { |
| 487 | int intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); |
| 488 | |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 489 | gic_write32(GIC_REG(VPE_LOCAL, GIC_VPE_SMASK), 1 << intr); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | static struct irq_chip gic_local_irq_controller = { |
| 493 | .name = "MIPS GIC Local", |
| 494 | .irq_mask = gic_mask_local_irq, |
| 495 | .irq_unmask = gic_unmask_local_irq, |
| 496 | }; |
| 497 | |
| 498 | static void gic_mask_local_irq_all_vpes(struct irq_data *d) |
| 499 | { |
| 500 | int intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); |
| 501 | int i; |
| 502 | unsigned long flags; |
| 503 | |
| 504 | spin_lock_irqsave(&gic_lock, flags); |
| 505 | for (i = 0; i < gic_vpes; i++) { |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 506 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 507 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_RMASK), 1 << intr); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 508 | } |
| 509 | spin_unlock_irqrestore(&gic_lock, flags); |
| 510 | } |
| 511 | |
| 512 | static void gic_unmask_local_irq_all_vpes(struct irq_data *d) |
| 513 | { |
| 514 | int intr = GIC_HWIRQ_TO_LOCAL(d->hwirq); |
| 515 | int i; |
| 516 | unsigned long flags; |
| 517 | |
| 518 | spin_lock_irqsave(&gic_lock, flags); |
| 519 | for (i = 0; i < gic_vpes; i++) { |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 520 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 521 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_SMASK), 1 << intr); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 522 | } |
| 523 | spin_unlock_irqrestore(&gic_lock, flags); |
| 524 | } |
| 525 | |
| 526 | static struct irq_chip gic_all_vpes_local_irq_controller = { |
| 527 | .name = "MIPS GIC Local", |
| 528 | .irq_mask = gic_mask_local_irq_all_vpes, |
| 529 | .irq_unmask = gic_unmask_local_irq_all_vpes, |
| 530 | }; |
| 531 | |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 532 | static void __gic_irq_dispatch(void) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 533 | { |
Rabin Vincent | 1b3ed36 | 2015-06-12 10:01:56 +0200 | [diff] [blame] | 534 | gic_handle_local_int(false); |
| 535 | gic_handle_shared_int(false); |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | static void gic_irq_dispatch(unsigned int irq, struct irq_desc *desc) |
| 539 | { |
Rabin Vincent | 1b3ed36 | 2015-06-12 10:01:56 +0200 | [diff] [blame] | 540 | gic_handle_local_int(true); |
| 541 | gic_handle_shared_int(true); |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | #ifdef CONFIG_MIPS_GIC_IPI |
| 545 | static int gic_resched_int_base; |
| 546 | static int gic_call_int_base; |
| 547 | |
| 548 | unsigned int plat_ipi_resched_int_xlate(unsigned int cpu) |
| 549 | { |
| 550 | return gic_resched_int_base + cpu; |
| 551 | } |
| 552 | |
| 553 | unsigned int plat_ipi_call_int_xlate(unsigned int cpu) |
| 554 | { |
| 555 | return gic_call_int_base + cpu; |
| 556 | } |
| 557 | |
| 558 | static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) |
| 559 | { |
| 560 | scheduler_ipi(); |
| 561 | |
| 562 | return IRQ_HANDLED; |
| 563 | } |
| 564 | |
| 565 | static irqreturn_t ipi_call_interrupt(int irq, void *dev_id) |
| 566 | { |
Alex Smith | 4ace613 | 2015-07-24 16:57:49 +0100 | [diff] [blame] | 567 | generic_smp_call_function_interrupt(); |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 568 | |
| 569 | return IRQ_HANDLED; |
| 570 | } |
| 571 | |
| 572 | static struct irqaction irq_resched = { |
| 573 | .handler = ipi_resched_interrupt, |
| 574 | .flags = IRQF_PERCPU, |
| 575 | .name = "IPI resched" |
| 576 | }; |
| 577 | |
| 578 | static struct irqaction irq_call = { |
| 579 | .handler = ipi_call_interrupt, |
| 580 | .flags = IRQF_PERCPU, |
| 581 | .name = "IPI call" |
| 582 | }; |
| 583 | |
| 584 | static __init void gic_ipi_init_one(unsigned int intr, int cpu, |
| 585 | struct irqaction *action) |
| 586 | { |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 587 | int virq = irq_create_mapping(gic_irq_domain, |
| 588 | GIC_SHARED_TO_HWIRQ(intr)); |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 589 | int i; |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 590 | |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 591 | gic_map_to_vpe(intr, cpu); |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 592 | for (i = 0; i < NR_CPUS; i++) |
| 593 | clear_bit(intr, pcpu_masks[i].pcpu_mask); |
Jeffrey Deans | b0a88ae | 2014-07-17 09:20:55 +0100 | [diff] [blame] | 594 | set_bit(intr, pcpu_masks[cpu].pcpu_mask); |
| 595 | |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 596 | irq_set_irq_type(virq, IRQ_TYPE_EDGE_RISING); |
| 597 | |
| 598 | irq_set_handler(virq, handle_percpu_irq); |
| 599 | setup_irq(virq, action); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 600 | } |
| 601 | |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 602 | static __init void gic_ipi_init(void) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 603 | { |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 604 | int i; |
| 605 | |
| 606 | /* Use last 2 * NR_CPUS interrupts as IPIs */ |
Andrew Bresticker | fbd5524 | 2014-09-18 14:47:25 -0700 | [diff] [blame] | 607 | gic_resched_int_base = gic_shared_intrs - nr_cpu_ids; |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 608 | gic_call_int_base = gic_resched_int_base - nr_cpu_ids; |
| 609 | |
| 610 | for (i = 0; i < nr_cpu_ids; i++) { |
| 611 | gic_ipi_init_one(gic_call_int_base + i, i, &irq_call); |
| 612 | gic_ipi_init_one(gic_resched_int_base + i, i, &irq_resched); |
| 613 | } |
| 614 | } |
| 615 | #else |
| 616 | static inline void gic_ipi_init(void) |
| 617 | { |
| 618 | } |
| 619 | #endif |
| 620 | |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 621 | static void __init gic_basic_init(void) |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 622 | { |
| 623 | unsigned int i; |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 624 | |
| 625 | board_bind_eic_interrupt = &gic_bind_eic_interrupt; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 626 | |
| 627 | /* Setup defaults */ |
Andrew Bresticker | fbd5524 | 2014-09-18 14:47:25 -0700 | [diff] [blame] | 628 | for (i = 0; i < gic_shared_intrs; i++) { |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 629 | gic_set_polarity(i, GIC_POL_POS); |
| 630 | gic_set_trigger(i, GIC_TRIG_LEVEL); |
| 631 | gic_reset_mask(i); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 632 | } |
| 633 | |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 634 | for (i = 0; i < gic_vpes; i++) { |
| 635 | unsigned int j; |
| 636 | |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 637 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 638 | for (j = 0; j < GIC_NUM_LOCAL_INTRS; j++) { |
| 639 | if (!gic_local_irq_is_routable(j)) |
| 640 | continue; |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 641 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_RMASK), 1 << j); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 642 | } |
| 643 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 644 | } |
| 645 | |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 646 | static int gic_local_irq_domain_map(struct irq_domain *d, unsigned int virq, |
| 647 | irq_hw_number_t hw) |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 648 | { |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 649 | int intr = GIC_HWIRQ_TO_LOCAL(hw); |
| 650 | int ret = 0; |
| 651 | int i; |
| 652 | unsigned long flags; |
| 653 | |
| 654 | if (!gic_local_irq_is_routable(intr)) |
| 655 | return -EPERM; |
| 656 | |
| 657 | /* |
| 658 | * HACK: These are all really percpu interrupts, but the rest |
| 659 | * of the MIPS kernel code does not use the percpu IRQ API for |
| 660 | * the CP0 timer and performance counter interrupts. |
| 661 | */ |
James Hogan | b720fd8 | 2015-01-29 11:14:08 +0000 | [diff] [blame] | 662 | switch (intr) { |
| 663 | case GIC_LOCAL_INT_TIMER: |
| 664 | case GIC_LOCAL_INT_PERFCTR: |
| 665 | case GIC_LOCAL_INT_FDC: |
| 666 | irq_set_chip_and_handler(virq, |
| 667 | &gic_all_vpes_local_irq_controller, |
| 668 | handle_percpu_irq); |
| 669 | break; |
| 670 | default: |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 671 | irq_set_chip_and_handler(virq, |
| 672 | &gic_local_irq_controller, |
| 673 | handle_percpu_devid_irq); |
| 674 | irq_set_percpu_devid(virq); |
James Hogan | b720fd8 | 2015-01-29 11:14:08 +0000 | [diff] [blame] | 675 | break; |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | spin_lock_irqsave(&gic_lock, flags); |
| 679 | for (i = 0; i < gic_vpes; i++) { |
| 680 | u32 val = GIC_MAP_TO_PIN_MSK | gic_cpu_pin; |
| 681 | |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 682 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 683 | |
| 684 | switch (intr) { |
| 685 | case GIC_LOCAL_INT_WD: |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 686 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_WD_MAP), val); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 687 | break; |
| 688 | case GIC_LOCAL_INT_COMPARE: |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 689 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE_MAP), |
| 690 | val); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 691 | break; |
| 692 | case GIC_LOCAL_INT_TIMER: |
James Hogan | 1b6af71 | 2015-01-19 15:38:24 +0000 | [diff] [blame] | 693 | /* CONFIG_MIPS_CMP workaround (see __gic_init) */ |
| 694 | val = GIC_MAP_TO_PIN_MSK | timer_cpu_pin; |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 695 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_TIMER_MAP), |
| 696 | val); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 697 | break; |
| 698 | case GIC_LOCAL_INT_PERFCTR: |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 699 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_PERFCTR_MAP), |
| 700 | val); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 701 | break; |
| 702 | case GIC_LOCAL_INT_SWINT0: |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 703 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_SWINT0_MAP), |
| 704 | val); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 705 | break; |
| 706 | case GIC_LOCAL_INT_SWINT1: |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 707 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_SWINT1_MAP), |
| 708 | val); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 709 | break; |
| 710 | case GIC_LOCAL_INT_FDC: |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 711 | gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_FDC_MAP), val); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 712 | break; |
| 713 | default: |
| 714 | pr_err("Invalid local IRQ %d\n", intr); |
| 715 | ret = -EINVAL; |
| 716 | break; |
| 717 | } |
| 718 | } |
| 719 | spin_unlock_irqrestore(&gic_lock, flags); |
| 720 | |
| 721 | return ret; |
| 722 | } |
| 723 | |
| 724 | static int gic_shared_irq_domain_map(struct irq_domain *d, unsigned int virq, |
| 725 | irq_hw_number_t hw) |
| 726 | { |
| 727 | int intr = GIC_HWIRQ_TO_SHARED(hw); |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 728 | unsigned long flags; |
| 729 | |
Andrew Bresticker | 4a6a3ea3 | 2014-09-18 14:47:26 -0700 | [diff] [blame] | 730 | irq_set_chip_and_handler(virq, &gic_level_irq_controller, |
| 731 | handle_level_irq); |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 732 | |
| 733 | spin_lock_irqsave(&gic_lock, flags); |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 734 | gic_map_to_pin(intr, gic_cpu_pin); |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 735 | /* Map to VPE 0 by default */ |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 736 | gic_map_to_vpe(intr, 0); |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 737 | set_bit(intr, pcpu_masks[0].pcpu_mask); |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 738 | spin_unlock_irqrestore(&gic_lock, flags); |
| 739 | |
| 740 | return 0; |
| 741 | } |
| 742 | |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 743 | static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq, |
| 744 | irq_hw_number_t hw) |
| 745 | { |
| 746 | if (GIC_HWIRQ_TO_LOCAL(hw) < GIC_NUM_LOCAL_INTRS) |
| 747 | return gic_local_irq_domain_map(d, virq, hw); |
| 748 | return gic_shared_irq_domain_map(d, virq, hw); |
| 749 | } |
| 750 | |
Andrew Bresticker | a705727 | 2014-11-12 11:43:38 -0800 | [diff] [blame] | 751 | static int gic_irq_domain_xlate(struct irq_domain *d, struct device_node *ctrlr, |
| 752 | const u32 *intspec, unsigned int intsize, |
| 753 | irq_hw_number_t *out_hwirq, |
| 754 | unsigned int *out_type) |
| 755 | { |
| 756 | if (intsize != 3) |
| 757 | return -EINVAL; |
| 758 | |
| 759 | if (intspec[0] == GIC_SHARED) |
| 760 | *out_hwirq = GIC_SHARED_TO_HWIRQ(intspec[1]); |
| 761 | else if (intspec[0] == GIC_LOCAL) |
| 762 | *out_hwirq = GIC_LOCAL_TO_HWIRQ(intspec[1]); |
| 763 | else |
| 764 | return -EINVAL; |
| 765 | *out_type = intspec[2] & IRQ_TYPE_SENSE_MASK; |
| 766 | |
| 767 | return 0; |
| 768 | } |
| 769 | |
Krzysztof Kozlowski | 9600973 | 2015-04-27 21:54:24 +0900 | [diff] [blame] | 770 | static const struct irq_domain_ops gic_irq_domain_ops = { |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 771 | .map = gic_irq_domain_map, |
Andrew Bresticker | a705727 | 2014-11-12 11:43:38 -0800 | [diff] [blame] | 772 | .xlate = gic_irq_domain_xlate, |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 773 | }; |
| 774 | |
Andrew Bresticker | a705727 | 2014-11-12 11:43:38 -0800 | [diff] [blame] | 775 | static void __init __gic_init(unsigned long gic_base_addr, |
| 776 | unsigned long gic_addrspace_size, |
| 777 | unsigned int cpu_vec, unsigned int irqbase, |
| 778 | struct device_node *node) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 779 | { |
| 780 | unsigned int gicconfig; |
| 781 | |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 782 | gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 783 | |
Andrew Bresticker | 5f68fea | 2014-10-20 12:03:52 -0700 | [diff] [blame] | 784 | gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG)); |
Andrew Bresticker | fbd5524 | 2014-09-18 14:47:25 -0700 | [diff] [blame] | 785 | gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 786 | GIC_SH_CONFIG_NUMINTRS_SHF; |
Andrew Bresticker | fbd5524 | 2014-09-18 14:47:25 -0700 | [diff] [blame] | 787 | gic_shared_intrs = ((gic_shared_intrs + 1) * 8); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 788 | |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 789 | gic_vpes = (gicconfig & GIC_SH_CONFIG_NUMVPES_MSK) >> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 790 | GIC_SH_CONFIG_NUMVPES_SHF; |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 791 | gic_vpes = gic_vpes + 1; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 792 | |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 793 | if (cpu_has_veic) { |
| 794 | /* Always use vector 1 in EIC mode */ |
| 795 | gic_cpu_pin = 0; |
James Hogan | 1b6af71 | 2015-01-19 15:38:24 +0000 | [diff] [blame] | 796 | timer_cpu_pin = gic_cpu_pin; |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 797 | set_vi_handler(gic_cpu_pin + GIC_PIN_TO_VEC_OFFSET, |
| 798 | __gic_irq_dispatch); |
| 799 | } else { |
| 800 | gic_cpu_pin = cpu_vec - GIC_CPU_PIN_OFFSET; |
| 801 | irq_set_chained_handler(MIPS_CPU_IRQ_BASE + cpu_vec, |
| 802 | gic_irq_dispatch); |
James Hogan | 1b6af71 | 2015-01-19 15:38:24 +0000 | [diff] [blame] | 803 | /* |
| 804 | * With the CMP implementation of SMP (deprecated), other CPUs |
| 805 | * are started by the bootloader and put into a timer based |
| 806 | * waiting poll loop. We must not re-route those CPU's local |
| 807 | * timer interrupts as the wait instruction will never finish, |
| 808 | * so just handle whatever CPU interrupt it is routed to by |
| 809 | * default. |
| 810 | * |
| 811 | * This workaround should be removed when CMP support is |
| 812 | * dropped. |
| 813 | */ |
| 814 | if (IS_ENABLED(CONFIG_MIPS_CMP) && |
| 815 | gic_local_irq_is_routable(GIC_LOCAL_INT_TIMER)) { |
Markos Chandras | c3f57f0 | 2015-07-14 10:26:09 +0100 | [diff] [blame^] | 816 | timer_cpu_pin = gic_read32(GIC_REG(VPE_LOCAL, |
James Hogan | 1b6af71 | 2015-01-19 15:38:24 +0000 | [diff] [blame] | 817 | GIC_VPE_TIMER_MAP)) & |
| 818 | GIC_MAP_MSK; |
| 819 | irq_set_chained_handler(MIPS_CPU_IRQ_BASE + |
| 820 | GIC_CPU_PIN_OFFSET + |
| 821 | timer_cpu_pin, |
| 822 | gic_irq_dispatch); |
| 823 | } else { |
| 824 | timer_cpu_pin = gic_cpu_pin; |
| 825 | } |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 826 | } |
| 827 | |
Andrew Bresticker | a705727 | 2014-11-12 11:43:38 -0800 | [diff] [blame] | 828 | gic_irq_domain = irq_domain_add_simple(node, GIC_NUM_LOCAL_INTRS + |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 829 | gic_shared_intrs, irqbase, |
Andrew Bresticker | c49581a | 2014-09-18 14:47:23 -0700 | [diff] [blame] | 830 | &gic_irq_domain_ops, NULL); |
| 831 | if (!gic_irq_domain) |
| 832 | panic("Failed to add GIC IRQ domain"); |
Steven J. Hill | 0b271f5 | 2012-08-31 16:05:37 -0500 | [diff] [blame] | 833 | |
Andrew Bresticker | e9de688 | 2014-09-18 14:47:27 -0700 | [diff] [blame] | 834 | gic_basic_init(); |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 835 | |
| 836 | gic_ipi_init(); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 837 | } |
Andrew Bresticker | a705727 | 2014-11-12 11:43:38 -0800 | [diff] [blame] | 838 | |
| 839 | void __init gic_init(unsigned long gic_base_addr, |
| 840 | unsigned long gic_addrspace_size, |
| 841 | unsigned int cpu_vec, unsigned int irqbase) |
| 842 | { |
| 843 | __gic_init(gic_base_addr, gic_addrspace_size, cpu_vec, irqbase, NULL); |
| 844 | } |
| 845 | |
| 846 | static int __init gic_of_init(struct device_node *node, |
| 847 | struct device_node *parent) |
| 848 | { |
| 849 | struct resource res; |
| 850 | unsigned int cpu_vec, i = 0, reserved = 0; |
| 851 | phys_addr_t gic_base; |
| 852 | size_t gic_len; |
| 853 | |
| 854 | /* Find the first available CPU vector. */ |
| 855 | while (!of_property_read_u32_index(node, "mti,reserved-cpu-vectors", |
| 856 | i++, &cpu_vec)) |
| 857 | reserved |= BIT(cpu_vec); |
| 858 | for (cpu_vec = 2; cpu_vec < 8; cpu_vec++) { |
| 859 | if (!(reserved & BIT(cpu_vec))) |
| 860 | break; |
| 861 | } |
| 862 | if (cpu_vec == 8) { |
| 863 | pr_err("No CPU vectors available for GIC\n"); |
| 864 | return -ENODEV; |
| 865 | } |
| 866 | |
| 867 | if (of_address_to_resource(node, 0, &res)) { |
| 868 | /* |
| 869 | * Probe the CM for the GIC base address if not specified |
| 870 | * in the device-tree. |
| 871 | */ |
| 872 | if (mips_cm_present()) { |
| 873 | gic_base = read_gcr_gic_base() & |
| 874 | ~CM_GCR_GIC_BASE_GICEN_MSK; |
| 875 | gic_len = 0x20000; |
| 876 | } else { |
| 877 | pr_err("Failed to get GIC memory range\n"); |
| 878 | return -ENODEV; |
| 879 | } |
| 880 | } else { |
| 881 | gic_base = res.start; |
| 882 | gic_len = resource_size(&res); |
| 883 | } |
| 884 | |
| 885 | if (mips_cm_present()) |
| 886 | write_gcr_gic_base(gic_base | CM_GCR_GIC_BASE_GICEN_MSK); |
| 887 | gic_present = true; |
| 888 | |
| 889 | __gic_init(gic_base, gic_len, cpu_vec, 0, node); |
| 890 | |
| 891 | return 0; |
| 892 | } |
| 893 | IRQCHIP_DECLARE(mips_gic, "mti,gic", gic_of_init); |