2 * intc.c -- support for the old ColdFire interrupt controller
4 * (C) Copyright 2009, Greg Ungerer <gerg@snapgear.com>
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
11 #include <linux/types.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/interrupt.h>
15 #include <linux/irq.h>
17 #include <asm/traps.h>
18 #include <asm/coldfire.h>
19 #include <asm/mcfsim.h>
22 * Define the vector numbers for the basic 7 interrupt sources.
23 * These are often referred to as the "external" interrupts in
24 * the ColdFire documentation (for the early ColdFire cores at least).
30 * In the early version 2 core ColdFire parts the IMR register was 16 bits
31 * in size. Version 3 (and later version 2) core parts have a 32 bit
32 * sized IMR register. Provide some size independant methods to access the
35 #ifdef MCFSIM_IMR_IS_16BITS
37 void mcf_setimr(int index)
40 imr = __raw_readw(MCF_MBAR + MCFSIM_IMR);
41 __raw_writew(imr | (0x1 << index), MCF_MBAR + MCFSIM_IMR);
44 void mcf_clrimr(int index)
47 imr = __raw_readw(MCF_MBAR + MCFSIM_IMR);
48 __raw_writew(imr & ~(0x1 << index), MCF_MBAR + MCFSIM_IMR);
51 void mcf_maskimr(unsigned int mask)
54 imr = __raw_readw(MCF_MBAR + MCFSIM_IMR);
56 __raw_writew(imr, MCF_MBAR + MCFSIM_IMR);
61 void mcf_setimr(int index)
64 imr = __raw_readl(MCF_MBAR + MCFSIM_IMR);
65 __raw_writel(imr | (0x1 << index), MCF_MBAR + MCFSIM_IMR);
68 void mcf_clrimr(int index)
71 imr = __raw_readl(MCF_MBAR + MCFSIM_IMR);
72 __raw_writel(imr & ~(0x1 << index), MCF_MBAR + MCFSIM_IMR);
75 void mcf_maskimr(unsigned int mask)
78 imr = __raw_readl(MCF_MBAR + MCFSIM_IMR);
80 __raw_writel(imr, MCF_MBAR + MCFSIM_IMR);
86 * Interrupts can be "vectored" on the ColdFire cores that support this old
87 * interrupt controller. That is, the device raising the interrupt can also
88 * supply the vector number to interrupt through. The AVR register of the
89 * interrupt controller enables or disables this for each external interrupt,
90 * so provide generic support for this. Setting this up is out-of-band for
91 * the interrupt system API's, and needs to be done by the driver that
92 * supports this device. Very few devices actually use this.
94 void mcf_autovector(int irq)
96 if ((irq >= EIRQ1) && (irq <= EIRQ7)) {
98 avec = __raw_readb(MCF_MBAR + MCFSIM_AVR);
99 avec |= (0x1 << (irq - EIRQ1 + 1));
100 __raw_writeb(avec, MCF_MBAR + MCFSIM_AVR);
104 static void intc_irq_mask(unsigned int irq)
108 static void intc_irq_unmask(unsigned int irq)
112 static int intc_irq_set_type(unsigned int irq, unsigned int type)
117 static struct irq_chip intc_irq_chip = {
119 .mask = intc_irq_mask,
120 .unmask = intc_irq_unmask,
121 .set_type = intc_irq_set_type,
124 void __init init_IRQ(void)
129 mcf_maskimr(0xffffffff);
131 for (irq = 0; (irq < NR_IRQS); irq++) {
132 irq_desc[irq].status = IRQ_DISABLED;
133 irq_desc[irq].action = NULL;
134 irq_desc[irq].depth = 1;
135 irq_desc[irq].chip = &intc_irq_chip;
136 intc_irq_set_type(irq, 0);