Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Make GIC code platform independent.

The GIC interrupt code is used by multiple platforms and the
current code was half Malta dependent code. These changes
abstract away the platform specific differences.

Signed-off-by: Steven J. Hill <sjhill@mips.com>

+81 -72
+29
arch/mips/include/asm/gic.h
··· 341 341 unsigned int local_intr_mask; 342 342 }; 343 343 344 + /* GIC nomenclature for Core Interrupt Pins. */ 345 + #define GIC_CPU_INT0 0 /* Core Interrupt 2 */ 346 + #define GIC_CPU_INT1 1 /* . */ 347 + #define GIC_CPU_INT2 2 /* . */ 348 + #define GIC_CPU_INT3 3 /* . */ 349 + #define GIC_CPU_INT4 4 /* . */ 350 + #define GIC_CPU_INT5 5 /* Core Interrupt 5 */ 351 + 352 + /* Local GIC interrupts. */ 353 + #define GIC_INT_TMR (GIC_CPU_INT5) 354 + #define GIC_INT_PERFCTR (GIC_CPU_INT5) 355 + 356 + /* Add 2 to convert non-EIC hardware interrupt to EIC vector number. */ 357 + #define GIC_CPU_TO_VEC_OFFSET (2) 358 + 359 + /* Mapped interrupt to pin X, then GIC will generate the vector (X+1). */ 360 + #define GIC_PIN_TO_VEC_OFFSET (1) 361 + 362 + extern unsigned long _gic_base; 363 + extern unsigned int gic_irq_base; 364 + extern unsigned int gic_irq_flags[]; 365 + extern struct gic_shared_intr_map gic_shared_intr_map[]; 366 + 344 367 extern void gic_init(unsigned long gic_base_addr, 345 368 unsigned long gic_addrspace_size, struct gic_intr_map *intrmap, 346 369 unsigned int intrmap_size, unsigned int irqbase); 347 370 371 + extern void gic_clocksource_init(unsigned int); 348 372 extern unsigned int gic_get_int(void); 349 373 extern void gic_send_ipi(unsigned int intr); 350 374 extern unsigned int plat_ipi_call_int_xlate(unsigned int); 351 375 extern unsigned int plat_ipi_resched_int_xlate(unsigned int); 352 376 extern void gic_bind_eic_interrupt(int irq, int set); 353 377 extern unsigned int gic_get_timer_pending(void); 378 + extern void gic_enable_interrupt(int irq_vec); 379 + extern void gic_disable_interrupt(int irq_vec); 380 + extern void gic_irq_ack(struct irq_data *d); 381 + extern void gic_finish_irq(struct irq_data *d); 382 + extern void gic_platform_init(int irqs, struct irq_chip *irq_controller); 354 383 355 384 #endif /* _ASM_GICREGS_H */
+7 -48
arch/mips/include/asm/mips-boards/maltaint.h
··· 1 1 /* 2 - * Carsten Langgaard, carstenl@mips.com 3 - * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. 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. 4 5 * 5 - * ######################################################################## 6 - * 7 - * This program is free software; you can distribute it and/or modify it 8 - * under the terms of the GNU General Public License (Version 2) as 9 - * published by the Free Software Foundation. 10 - * 11 - * This program is distributed in the hope it will be useful, but WITHOUT 12 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 - * for more details. 15 - * 16 - * You should have received a copy of the GNU General Public License along 17 - * with this program; if not, write to the Free Software Foundation, Inc., 18 - * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 19 - * 20 - * ######################################################################## 21 - * 22 - * Defines for the Malta interrupt controller. 23 - * 6 + * Copyright (C) 2000,2012 MIPS Technologies, Inc. All rights reserved. 7 + * Carsten Langgaard <carstenl@mips.com> 8 + * Steven J. Hill <sjhill@mips.com> 24 9 */ 25 10 #ifndef _MIPS_MALTAINT_H 26 11 #define _MIPS_MALTAINT_H 27 12 28 - #include <irq.h> 13 + #define MIPS_GIC_IRQ_BASE (MIPS_CPU_IRQ_BASE + 8) 29 14 30 15 /* 31 16 * Interrupts 0..15 are used for Malta ISA compatible interrupts ··· 63 78 #define MSC01E_INT_PERFCTR 10 64 79 #define MSC01E_INT_CPUCTR 11 65 80 66 - /* GIC's Nomenclature for Core Interrupt Pins on the Malta */ 67 - #define GIC_CPU_INT0 0 /* Core Interrupt 2 */ 68 - #define GIC_CPU_INT1 1 /* . */ 69 - #define GIC_CPU_INT2 2 /* . */ 70 - #define GIC_CPU_INT3 3 /* . */ 71 - #define GIC_CPU_INT4 4 /* . */ 72 - #define GIC_CPU_INT5 5 /* Core Interrupt 5 */ 73 - 74 - /* MALTA GIC local interrupts */ 75 - #define GIC_INT_TMR (GIC_CPU_INT5) 76 - #define GIC_INT_PERFCTR (GIC_CPU_INT5) 77 - 78 - /* GIC constants */ 79 - /* Add 2 to convert non-eic hw int # to eic vector # */ 80 - #define GIC_CPU_TO_VEC_OFFSET (2) 81 - /* If we map an intr to pin X, GIC will actually generate vector X+1 */ 82 - #define GIC_PIN_TO_VEC_OFFSET (1) 83 - 84 - #define GIC_EXT_INTR(x) x 85 - 86 81 /* External Interrupts used for IPI */ 87 82 #define GIC_IPI_EXT_INTR_RESCHED_VPE0 16 88 83 #define GIC_IPI_EXT_INTR_CALLFNC_VPE0 17 ··· 72 107 #define GIC_IPI_EXT_INTR_CALLFNC_VPE2 21 73 108 #define GIC_IPI_EXT_INTR_RESCHED_VPE3 22 74 109 #define GIC_IPI_EXT_INTR_CALLFNC_VPE3 23 75 - 76 - #define MIPS_GIC_IRQ_BASE (MIPS_CPU_IRQ_BASE + 8) 77 - 78 - #ifndef __ASSEMBLY__ 79 - extern void maltaint_init(void); 80 - #endif 81 110 82 111 #endif /* !(_MIPS_MALTAINT_H) */
+11 -24
arch/mips/kernel/irq-gic.c
··· 12 12 #include <asm-generic/bitops/find.h> 13 13 14 14 15 - static unsigned long _gic_base; 16 - static unsigned int _irqbase; 17 - static unsigned int gic_irq_flags[GIC_NUM_INTRS]; 18 - #define GIC_IRQ_FLAG_EDGE 0x0001 15 + unsigned long _gic_base; 16 + unsigned int gic_irq_base; 17 + unsigned int gic_irq_flags[GIC_NUM_INTRS]; 19 18 20 - struct gic_pcpu_mask pcpu_masks[NR_CPUS]; 19 + static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; 21 20 static struct gic_pending_regs pending_regs[NR_CPUS]; 22 21 static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; 23 22 ··· 86 87 return i; 87 88 } 88 89 89 - static void gic_irq_ack(struct irq_data *d) 90 - { 91 - unsigned int irq = d->irq - _irqbase; 92 - 93 - pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 94 - GIC_CLR_INTR_MASK(irq); 95 - 96 - if (gic_irq_flags[irq] & GIC_IRQ_FLAG_EDGE) 97 - GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq); 98 - } 99 - 100 90 static void gic_mask_irq(struct irq_data *d) 101 91 { 102 - unsigned int irq = d->irq - _irqbase; 92 + unsigned int irq = d->irq - gic_irq_base; 103 93 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 104 94 GIC_CLR_INTR_MASK(irq); 105 95 } 106 96 107 97 static void gic_unmask_irq(struct irq_data *d) 108 98 { 109 - unsigned int irq = d->irq - _irqbase; 99 + unsigned int irq = d->irq - gic_irq_base; 110 100 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 111 101 GIC_SET_INTR_MASK(irq); 112 102 } ··· 107 119 static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, 108 120 bool force) 109 121 { 110 - unsigned int irq = d->irq - _irqbase; 122 + unsigned int irq = d->irq - gic_irq_base; 111 123 cpumask_t tmp = CPU_MASK_NONE; 112 124 unsigned long flags; 113 125 int i; ··· 182 194 if (flags & GIC_FLAG_TRANSPARENT) 183 195 GIC_SET_INTR_MASK(intr); 184 196 if (trigtype == GIC_TRIG_EDGE) 185 - gic_irq_flags[intr] |= GIC_IRQ_FLAG_EDGE; 197 + gic_irq_flags[intr] |= GIC_TRIG_EDGE; 186 198 } 187 199 188 200 static void __init gic_basic_init(int numintrs, int numvpes, ··· 215 227 } 216 228 217 229 vpe_local_setup(numvpes); 218 - 219 - for (i = _irqbase; i < (_irqbase + numintrs); i++) 220 - irq_set_chip(i, &gic_irq_controller); 221 230 } 222 231 223 232 void __init gic_init(unsigned long gic_base_addr, ··· 227 242 228 243 _gic_base = (unsigned long) ioremap_nocache(gic_base_addr, 229 244 gic_addrspace_size); 230 - _irqbase = irqbase; 245 + gic_irq_base = irqbase; 231 246 232 247 GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig); 233 248 numintrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> ··· 240 255 pr_debug("%s called\n", __func__); 241 256 242 257 gic_basic_init(numintrs, numvpes, intr_map, intr_map_size); 258 + 259 + gic_platform_init(numintrs, &gic_irq_controller); 243 260 }
+34
arch/mips/mti-malta/malta-int.c
··· 747 747 748 748 return retval; 749 749 } 750 + 751 + void gic_enable_interrupt(int irq_vec) 752 + { 753 + GIC_SET_INTR_MASK(irq_vec); 754 + } 755 + 756 + void gic_disable_interrupt(int irq_vec) 757 + { 758 + GIC_CLR_INTR_MASK(irq_vec); 759 + } 760 + 761 + void gic_irq_ack(struct irq_data *d) 762 + { 763 + int irq = (d->irq - gic_irq_base); 764 + 765 + GIC_CLR_INTR_MASK(irq); 766 + 767 + if (gic_irq_flags[irq] & GIC_TRIG_EDGE) 768 + GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq); 769 + } 770 + 771 + void gic_finish_irq(struct irq_data *d) 772 + { 773 + /* Enable interrupts. */ 774 + GIC_SET_INTR_MASK(d->irq - gic_irq_base); 775 + } 776 + 777 + void __init gic_platform_init(int irqs, struct irq_chip *irq_controller) 778 + { 779 + int i; 780 + 781 + for (i = gic_irq_base; i < (gic_irq_base + irqs); i++) 782 + irq_set_chip(i, irq_controller); 783 + }