diff options
Diffstat (limited to 'arch/arm/common/gic.c')
-rw-r--r-- | arch/arm/common/gic.c | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c index e6388dcd8cfa..0b89ef001330 100644 --- a/arch/arm/common/gic.c +++ b/arch/arm/common/gic.c | |||
@@ -35,6 +35,9 @@ | |||
35 | 35 | ||
36 | static DEFINE_SPINLOCK(irq_controller_lock); | 36 | static DEFINE_SPINLOCK(irq_controller_lock); |
37 | 37 | ||
38 | /* Address of GIC 0 CPU interface */ | ||
39 | void __iomem *gic_cpu_base_addr __read_mostly; | ||
40 | |||
38 | struct gic_chip_data { | 41 | struct gic_chip_data { |
39 | unsigned int irq_offset; | 42 | unsigned int irq_offset; |
40 | void __iomem *dist_base; | 43 | void __iomem *dist_base; |
@@ -45,7 +48,7 @@ struct gic_chip_data { | |||
45 | #define MAX_GIC_NR 1 | 48 | #define MAX_GIC_NR 1 |
46 | #endif | 49 | #endif |
47 | 50 | ||
48 | static struct gic_chip_data gic_data[MAX_GIC_NR]; | 51 | static struct gic_chip_data gic_data[MAX_GIC_NR] __read_mostly; |
49 | 52 | ||
50 | static inline void __iomem *gic_dist_base(unsigned int irq) | 53 | static inline void __iomem *gic_dist_base(unsigned int irq) |
51 | { | 54 | { |
@@ -213,21 +216,16 @@ void __init gic_cascade_irq(unsigned int gic_nr, unsigned int irq) | |||
213 | set_irq_chained_handler(irq, gic_handle_cascade_irq); | 216 | set_irq_chained_handler(irq, gic_handle_cascade_irq); |
214 | } | 217 | } |
215 | 218 | ||
216 | void __init gic_dist_init(unsigned int gic_nr, void __iomem *base, | 219 | static void __init gic_dist_init(struct gic_chip_data *gic, |
217 | unsigned int irq_start) | 220 | unsigned int irq_start) |
218 | { | 221 | { |
219 | unsigned int gic_irqs, irq_limit, i; | 222 | unsigned int gic_irqs, irq_limit, i; |
223 | void __iomem *base = gic->dist_base; | ||
220 | u32 cpumask = 1 << smp_processor_id(); | 224 | u32 cpumask = 1 << smp_processor_id(); |
221 | 225 | ||
222 | if (gic_nr >= MAX_GIC_NR) | ||
223 | BUG(); | ||
224 | |||
225 | cpumask |= cpumask << 8; | 226 | cpumask |= cpumask << 8; |
226 | cpumask |= cpumask << 16; | 227 | cpumask |= cpumask << 16; |
227 | 228 | ||
228 | gic_data[gic_nr].dist_base = base; | ||
229 | gic_data[gic_nr].irq_offset = (irq_start - 1) & ~31; | ||
230 | |||
231 | writel(0, base + GIC_DIST_CTRL); | 229 | writel(0, base + GIC_DIST_CTRL); |
232 | 230 | ||
233 | /* | 231 | /* |
@@ -267,7 +265,7 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base, | |||
267 | /* | 265 | /* |
268 | * Limit number of interrupts registered to the platform maximum | 266 | * Limit number of interrupts registered to the platform maximum |
269 | */ | 267 | */ |
270 | irq_limit = gic_data[gic_nr].irq_offset + gic_irqs; | 268 | irq_limit = gic->irq_offset + gic_irqs; |
271 | if (WARN_ON(irq_limit > NR_IRQS)) | 269 | if (WARN_ON(irq_limit > NR_IRQS)) |
272 | irq_limit = NR_IRQS; | 270 | irq_limit = NR_IRQS; |
273 | 271 | ||
@@ -276,7 +274,7 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base, | |||
276 | */ | 274 | */ |
277 | for (i = irq_start; i < irq_limit; i++) { | 275 | for (i = irq_start; i < irq_limit; i++) { |
278 | set_irq_chip(i, &gic_chip); | 276 | set_irq_chip(i, &gic_chip); |
279 | set_irq_chip_data(i, &gic_data[gic_nr]); | 277 | set_irq_chip_data(i, gic); |
280 | set_irq_handler(i, handle_level_irq); | 278 | set_irq_handler(i, handle_level_irq); |
281 | set_irq_flags(i, IRQF_VALID | IRQF_PROBE); | 279 | set_irq_flags(i, IRQF_VALID | IRQF_PROBE); |
282 | } | 280 | } |
@@ -284,19 +282,12 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base, | |||
284 | writel(1, base + GIC_DIST_CTRL); | 282 | writel(1, base + GIC_DIST_CTRL); |
285 | } | 283 | } |
286 | 284 | ||
287 | void __cpuinit gic_cpu_init(unsigned int gic_nr, void __iomem *base) | 285 | static void __cpuinit gic_cpu_init(struct gic_chip_data *gic) |
288 | { | 286 | { |
289 | void __iomem *dist_base; | 287 | void __iomem *dist_base = gic->dist_base; |
288 | void __iomem *base = gic->cpu_base; | ||
290 | int i; | 289 | int i; |
291 | 290 | ||
292 | if (gic_nr >= MAX_GIC_NR) | ||
293 | BUG(); | ||
294 | |||
295 | dist_base = gic_data[gic_nr].dist_base; | ||
296 | BUG_ON(!dist_base); | ||
297 | |||
298 | gic_data[gic_nr].cpu_base = base; | ||
299 | |||
300 | /* | 291 | /* |
301 | * Deal with the banked PPI and SGI interrupts - disable all | 292 | * Deal with the banked PPI and SGI interrupts - disable all |
302 | * PPI interrupts, ensure all SGI interrupts are enabled. | 293 | * PPI interrupts, ensure all SGI interrupts are enabled. |
@@ -314,6 +305,42 @@ void __cpuinit gic_cpu_init(unsigned int gic_nr, void __iomem *base) | |||
314 | writel(1, base + GIC_CPU_CTRL); | 305 | writel(1, base + GIC_CPU_CTRL); |
315 | } | 306 | } |
316 | 307 | ||
308 | void __init gic_init(unsigned int gic_nr, unsigned int irq_start, | ||
309 | void __iomem *dist_base, void __iomem *cpu_base) | ||
310 | { | ||
311 | struct gic_chip_data *gic; | ||
312 | |||
313 | BUG_ON(gic_nr >= MAX_GIC_NR); | ||
314 | |||
315 | gic = &gic_data[gic_nr]; | ||
316 | gic->dist_base = dist_base; | ||
317 | gic->cpu_base = cpu_base; | ||
318 | gic->irq_offset = (irq_start - 1) & ~31; | ||
319 | |||
320 | if (gic_nr == 0) | ||
321 | gic_cpu_base_addr = cpu_base; | ||
322 | |||
323 | gic_dist_init(gic, irq_start); | ||
324 | gic_cpu_init(gic); | ||
325 | } | ||
326 | |||
327 | void __cpuinit gic_secondary_init(unsigned int gic_nr) | ||
328 | { | ||
329 | BUG_ON(gic_nr >= MAX_GIC_NR); | ||
330 | |||
331 | gic_cpu_init(&gic_data[gic_nr]); | ||
332 | } | ||
333 | |||
334 | void __cpuinit gic_enable_ppi(unsigned int irq) | ||
335 | { | ||
336 | unsigned long flags; | ||
337 | |||
338 | local_irq_save(flags); | ||
339 | irq_to_desc(irq)->status |= IRQ_NOPROBE; | ||
340 | gic_unmask_irq(irq); | ||
341 | local_irq_restore(flags); | ||
342 | } | ||
343 | |||
317 | #ifdef CONFIG_SMP | 344 | #ifdef CONFIG_SMP |
318 | void gic_raise_softirq(const struct cpumask *mask, unsigned int irq) | 345 | void gic_raise_softirq(const struct cpumask *mask, unsigned int irq) |
319 | { | 346 | { |