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> |
| 10 | #include <linux/init.h> |
Ralf Baechle | 631330f | 2009-06-19 14:05:26 +0100 | [diff] [blame] | 11 | #include <linux/smp.h> |
David Howells | ca4d3e67 | 2010-10-07 14:08:54 +0100 | [diff] [blame] | 12 | #include <linux/irq.h> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 13 | |
| 14 | #include <asm/io.h> |
| 15 | #include <asm/gic.h> |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 16 | #include <asm/setup.h> |
| 17 | #include <asm/traps.h> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 18 | #include <asm/gcmpregs.h> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 19 | #include <linux/hardirq.h> |
| 20 | #include <asm-generic/bitops/find.h> |
| 21 | |
Steven J. Hill | 0b271f5 | 2012-08-31 16:05:37 -0500 | [diff] [blame] | 22 | unsigned long _gic_base; |
| 23 | unsigned int gic_irq_base; |
| 24 | unsigned int gic_irq_flags[GIC_NUM_INTRS]; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 25 | |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 26 | /* The index into this array is the vector # of the interrupt. */ |
| 27 | struct gic_shared_intr_map gic_shared_intr_map[GIC_NUM_INTRS]; |
| 28 | |
Steven J. Hill | 0b271f5 | 2012-08-31 16:05:37 -0500 | [diff] [blame] | 29 | static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 30 | static struct gic_pending_regs pending_regs[NR_CPUS]; |
| 31 | static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; |
| 32 | |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 33 | unsigned int gic_get_timer_pending(void) |
| 34 | { |
| 35 | unsigned int vpe_pending; |
| 36 | |
| 37 | GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), 0); |
| 38 | GICREAD(GIC_REG(VPE_OTHER, GIC_VPE_PEND), vpe_pending); |
| 39 | return (vpe_pending & GIC_VPE_PEND_TIMER_MSK); |
| 40 | } |
| 41 | |
| 42 | void gic_bind_eic_interrupt(int irq, int set) |
| 43 | { |
| 44 | /* Convert irq vector # to hw int # */ |
| 45 | irq -= GIC_PIN_TO_VEC_OFFSET; |
| 46 | |
| 47 | /* Set irq to use shadow set */ |
| 48 | GICWRITE(GIC_REG_ADDR(VPE_LOCAL, GIC_VPE_EIC_SS(irq)), set); |
| 49 | } |
| 50 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 51 | void gic_send_ipi(unsigned int intr) |
| 52 | { |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 53 | GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), 0x80000000 | intr); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 54 | } |
| 55 | |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 56 | static void gic_eic_irq_dispatch(void) |
| 57 | { |
| 58 | unsigned int cause = read_c0_cause(); |
| 59 | int irq; |
| 60 | |
| 61 | irq = (cause & ST0_IM) >> STATUSB_IP2; |
| 62 | if (irq == 0) |
| 63 | irq = -1; |
| 64 | |
| 65 | if (irq >= 0) |
| 66 | do_IRQ(gic_irq_base + irq); |
| 67 | else |
| 68 | spurious_interrupt(); |
| 69 | } |
| 70 | |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 71 | static void __init vpe_local_setup(unsigned int numvpes) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 72 | { |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 73 | unsigned long timer_intr = GIC_INT_TMR; |
| 74 | unsigned long perf_intr = GIC_INT_PERFCTR; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 75 | unsigned int vpe_ctl; |
Steven J. Hill | 2299c49 | 2012-08-31 16:13:07 -0500 | [diff] [blame] | 76 | int i; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 77 | |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 78 | if (cpu_has_veic) { |
| 79 | /* |
| 80 | * GIC timer interrupt -> CPU HW Int X (vector X+2) -> |
| 81 | * map to pin X+2-1 (since GIC adds 1) |
| 82 | */ |
| 83 | timer_intr += (GIC_CPU_TO_VEC_OFFSET - GIC_PIN_TO_VEC_OFFSET); |
| 84 | /* |
| 85 | * GIC perfcnt interrupt -> CPU HW Int X (vector X+2) -> |
| 86 | * map to pin X+2-1 (since GIC adds 1) |
| 87 | */ |
| 88 | perf_intr += (GIC_CPU_TO_VEC_OFFSET - GIC_PIN_TO_VEC_OFFSET); |
| 89 | } |
| 90 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 91 | /* |
| 92 | * Setup the default performance counter timer interrupts |
| 93 | * for all VPEs |
| 94 | */ |
| 95 | for (i = 0; i < numvpes; i++) { |
| 96 | GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i); |
| 97 | |
| 98 | /* Are Interrupts locally routable? */ |
| 99 | GICREAD(GIC_REG(VPE_OTHER, GIC_VPE_CTL), vpe_ctl); |
| 100 | if (vpe_ctl & GIC_VPE_CTL_TIMER_RTBL_MSK) |
| 101 | GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_TIMER_MAP), |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 102 | GIC_MAP_TO_PIN_MSK | timer_intr); |
| 103 | if (cpu_has_veic) { |
| 104 | set_vi_handler(timer_intr + GIC_PIN_TO_VEC_OFFSET, |
| 105 | gic_eic_irq_dispatch); |
| 106 | gic_shared_intr_map[timer_intr + GIC_PIN_TO_VEC_OFFSET].local_intr_mask |= GIC_VPE_RMASK_TIMER_MSK; |
| 107 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 108 | |
| 109 | if (vpe_ctl & GIC_VPE_CTL_PERFCNT_RTBL_MSK) |
| 110 | GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_PERFCTR_MAP), |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 111 | GIC_MAP_TO_PIN_MSK | perf_intr); |
| 112 | if (cpu_has_veic) { |
| 113 | set_vi_handler(perf_intr + GIC_PIN_TO_VEC_OFFSET, gic_eic_irq_dispatch); |
| 114 | gic_shared_intr_map[perf_intr + GIC_PIN_TO_VEC_OFFSET].local_intr_mask |= GIC_VPE_RMASK_PERFCNT_MSK; |
| 115 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 116 | } |
| 117 | } |
| 118 | |
| 119 | unsigned int gic_get_int(void) |
| 120 | { |
| 121 | unsigned int i; |
| 122 | unsigned long *pending, *intrmask, *pcpu_mask; |
| 123 | unsigned long *pending_abs, *intrmask_abs; |
| 124 | |
| 125 | /* Get per-cpu bitmaps */ |
| 126 | pending = pending_regs[smp_processor_id()].pending; |
| 127 | intrmask = intrmask_regs[smp_processor_id()].intrmask; |
| 128 | pcpu_mask = pcpu_masks[smp_processor_id()].pcpu_mask; |
| 129 | |
| 130 | pending_abs = (unsigned long *) GIC_REG_ABS_ADDR(SHARED, |
| 131 | GIC_SH_PEND_31_0_OFS); |
| 132 | intrmask_abs = (unsigned long *) GIC_REG_ABS_ADDR(SHARED, |
| 133 | GIC_SH_MASK_31_0_OFS); |
| 134 | |
| 135 | for (i = 0; i < BITS_TO_LONGS(GIC_NUM_INTRS); i++) { |
| 136 | GICREAD(*pending_abs, pending[i]); |
| 137 | GICREAD(*intrmask_abs, intrmask[i]); |
| 138 | pending_abs++; |
| 139 | intrmask_abs++; |
| 140 | } |
| 141 | |
| 142 | bitmap_and(pending, pending, intrmask, GIC_NUM_INTRS); |
| 143 | bitmap_and(pending, pending, pcpu_mask, GIC_NUM_INTRS); |
| 144 | |
Steven J. Hill | 2299c49 | 2012-08-31 16:13:07 -0500 | [diff] [blame] | 145 | return find_first_bit(pending, GIC_NUM_INTRS); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 146 | } |
| 147 | |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 148 | static void gic_mask_irq(struct irq_data *d) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 149 | { |
Steven J. Hill | 2299c49 | 2012-08-31 16:13:07 -0500 | [diff] [blame] | 150 | GIC_CLR_INTR_MASK(d->irq - gic_irq_base); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 151 | } |
| 152 | |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 153 | static void gic_unmask_irq(struct irq_data *d) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 154 | { |
Steven J. Hill | 2299c49 | 2012-08-31 16:13:07 -0500 | [diff] [blame] | 155 | GIC_SET_INTR_MASK(d->irq - gic_irq_base); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | #ifdef CONFIG_SMP |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 159 | static DEFINE_SPINLOCK(gic_lock); |
| 160 | |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 161 | static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, |
| 162 | bool force) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 163 | { |
Steven J. Hill | 2299c49 | 2012-08-31 16:13:07 -0500 | [diff] [blame] | 164 | unsigned int irq = (d->irq - gic_irq_base); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 165 | cpumask_t tmp = CPU_MASK_NONE; |
| 166 | unsigned long flags; |
| 167 | int i; |
| 168 | |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 169 | cpumask_and(&tmp, cpumask, cpu_online_mask); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 170 | if (cpus_empty(tmp)) |
Yinghai Lu | d5dedd4 | 2009-04-27 17:59:21 -0700 | [diff] [blame] | 171 | return -1; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 172 | |
| 173 | /* Assumption : cpumask refers to a single CPU */ |
| 174 | spin_lock_irqsave(&gic_lock, flags); |
| 175 | for (;;) { |
| 176 | /* Re-route this IRQ */ |
| 177 | GIC_SH_MAP_TO_VPE_SMASK(irq, first_cpu(tmp)); |
| 178 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 179 | /* Update the pcpu_masks */ |
| 180 | for (i = 0; i < NR_CPUS; i++) |
| 181 | clear_bit(irq, pcpu_masks[i].pcpu_mask); |
| 182 | set_bit(irq, pcpu_masks[first_cpu(tmp)].pcpu_mask); |
| 183 | |
| 184 | } |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 185 | cpumask_copy(d->affinity, cpumask); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 186 | spin_unlock_irqrestore(&gic_lock, flags); |
| 187 | |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 188 | return IRQ_SET_MASK_OK_NOCOPY; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 189 | } |
| 190 | #endif |
| 191 | |
| 192 | static struct irq_chip gic_irq_controller = { |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 193 | .name = "MIPS GIC", |
| 194 | .irq_ack = gic_irq_ack, |
| 195 | .irq_mask = gic_mask_irq, |
| 196 | .irq_mask_ack = gic_mask_irq, |
| 197 | .irq_unmask = gic_unmask_irq, |
Steven J. Hill | ec167f2 | 2012-08-31 16:20:08 -0500 | [diff] [blame^] | 198 | .irq_eoi = gic_finish_irq, |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 199 | #ifdef CONFIG_SMP |
Thomas Gleixner | 161d049 | 2011-03-23 21:08:58 +0000 | [diff] [blame] | 200 | .irq_set_affinity = gic_set_affinity, |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 201 | #endif |
| 202 | }; |
| 203 | |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 204 | static void __init gic_setup_intr(unsigned int intr, unsigned int cpu, |
| 205 | unsigned int pin, unsigned int polarity, unsigned int trigtype, |
| 206 | unsigned int flags) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 207 | { |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 208 | struct gic_shared_intr_map *map_ptr; |
| 209 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 210 | /* Setup Intr to Pin mapping */ |
| 211 | if (pin & GIC_MAP_TO_NMI_MSK) { |
| 212 | GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_PIN(intr)), pin); |
| 213 | /* FIXME: hack to route NMI to all cpu's */ |
| 214 | for (cpu = 0; cpu < NR_CPUS; cpu += 32) { |
| 215 | GICWRITE(GIC_REG_ADDR(SHARED, |
| 216 | GIC_SH_MAP_TO_VPE_REG_OFF(intr, cpu)), |
| 217 | 0xffffffff); |
| 218 | } |
| 219 | } else { |
| 220 | GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_PIN(intr)), |
| 221 | GIC_MAP_TO_PIN_MSK | pin); |
| 222 | /* Setup Intr to CPU mapping */ |
| 223 | GIC_SH_MAP_TO_VPE_SMASK(intr, cpu); |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 224 | if (cpu_has_veic) { |
| 225 | set_vi_handler(pin + GIC_PIN_TO_VEC_OFFSET, |
| 226 | gic_eic_irq_dispatch); |
| 227 | map_ptr = &gic_shared_intr_map[pin + GIC_PIN_TO_VEC_OFFSET]; |
| 228 | if (map_ptr->num_shared_intr >= GIC_MAX_SHARED_INTR) |
| 229 | BUG(); |
| 230 | map_ptr->intr_list[map_ptr->num_shared_intr++] = intr; |
| 231 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | /* Setup Intr Polarity */ |
| 235 | GIC_SET_POLARITY(intr, polarity); |
| 236 | |
| 237 | /* Setup Intr Trigger Type */ |
| 238 | GIC_SET_TRIGGER(intr, trigtype); |
| 239 | |
| 240 | /* Init Intr Masks */ |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 241 | GIC_CLR_INTR_MASK(intr); |
| 242 | /* Initialise per-cpu Interrupt software masks */ |
| 243 | if (flags & GIC_FLAG_IPI) |
| 244 | set_bit(intr, pcpu_masks[cpu].pcpu_mask); |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 245 | if ((flags & GIC_FLAG_TRANSPARENT) && (cpu_has_veic == 0)) |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 246 | GIC_SET_INTR_MASK(intr); |
| 247 | if (trigtype == GIC_TRIG_EDGE) |
Steven J. Hill | 0b271f5 | 2012-08-31 16:05:37 -0500 | [diff] [blame] | 248 | gic_irq_flags[intr] |= GIC_TRIG_EDGE; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 249 | } |
| 250 | |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 251 | static void __init gic_basic_init(int numintrs, int numvpes, |
| 252 | struct gic_intr_map *intrmap, int mapsize) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 253 | { |
| 254 | unsigned int i, cpu; |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 255 | unsigned int pin_offset = 0; |
| 256 | |
| 257 | board_bind_eic_interrupt = &gic_bind_eic_interrupt; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 258 | |
| 259 | /* Setup defaults */ |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 260 | for (i = 0; i < numintrs; i++) { |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 261 | GIC_SET_POLARITY(i, GIC_POL_POS); |
| 262 | GIC_SET_TRIGGER(i, GIC_TRIG_LEVEL); |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 263 | GIC_CLR_INTR_MASK(i); |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 264 | if (i < GIC_NUM_INTRS) { |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 265 | gic_irq_flags[i] = 0; |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 266 | gic_shared_intr_map[i].num_shared_intr = 0; |
| 267 | gic_shared_intr_map[i].local_intr_mask = 0; |
| 268 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 269 | } |
| 270 | |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 271 | /* |
| 272 | * In EIC mode, the HW_INT# is offset by (2-1). Need to subtract |
| 273 | * one because the GIC will add one (since 0=no intr). |
| 274 | */ |
| 275 | if (cpu_has_veic) |
| 276 | pin_offset = (GIC_CPU_TO_VEC_OFFSET - GIC_PIN_TO_VEC_OFFSET); |
| 277 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 278 | /* Setup specifics */ |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 279 | for (i = 0; i < mapsize; i++) { |
| 280 | cpu = intrmap[i].cpunum; |
Ralf Baechle | 863cb9b | 2010-09-17 17:07:48 +0100 | [diff] [blame] | 281 | if (cpu == GIC_UNUSED) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 282 | continue; |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 283 | if (cpu == 0 && i != 0 && intrmap[i].flags == 0) |
Tim Anderson | a214cef | 2009-06-17 16:22:25 -0700 | [diff] [blame] | 284 | continue; |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 285 | gic_setup_intr(i, |
| 286 | intrmap[i].cpunum, |
Steven J. Hill | 98b67c3 | 2012-08-31 16:18:49 -0500 | [diff] [blame] | 287 | intrmap[i].pin + pin_offset, |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 288 | intrmap[i].polarity, |
| 289 | intrmap[i].trigtype, |
| 290 | intrmap[i].flags); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | vpe_local_setup(numvpes); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | void __init gic_init(unsigned long gic_base_addr, |
| 297 | unsigned long gic_addrspace_size, |
| 298 | struct gic_intr_map *intr_map, unsigned int intr_map_size, |
| 299 | unsigned int irqbase) |
| 300 | { |
| 301 | unsigned int gicconfig; |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 302 | int numvpes, numintrs; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 303 | |
| 304 | _gic_base = (unsigned long) ioremap_nocache(gic_base_addr, |
| 305 | gic_addrspace_size); |
Steven J. Hill | 0b271f5 | 2012-08-31 16:05:37 -0500 | [diff] [blame] | 306 | gic_irq_base = irqbase; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 307 | |
| 308 | GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig); |
| 309 | numintrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> |
| 310 | GIC_SH_CONFIG_NUMINTRS_SHF; |
| 311 | numintrs = ((numintrs + 1) * 8); |
| 312 | |
| 313 | numvpes = (gicconfig & GIC_SH_CONFIG_NUMVPES_MSK) >> |
| 314 | GIC_SH_CONFIG_NUMVPES_SHF; |
| 315 | |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 316 | gic_basic_init(numintrs, numvpes, intr_map, intr_map_size); |
Steven J. Hill | 0b271f5 | 2012-08-31 16:05:37 -0500 | [diff] [blame] | 317 | |
| 318 | gic_platform_init(numintrs, &gic_irq_controller); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 319 | } |