]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/m68knommu/platform/coldfire/intc-2.c
m68knommu: rename PT_OFF_VECTOR to PT_OFF_FORMATVEC.
[mirror_ubuntu-artful-kernel.git] / arch / m68knommu / platform / coldfire / intc-2.c
CommitLineData
2fba4f0b 1/*
03cbc385
PDM
2 * intc-2.c
3 *
8851338d
PDM
4 * General interrupt controller code for the many ColdFire cores that use
5 * interrupt controllers with 63 interrupt sources, organized as 56 fully-
6 * programmable + 7 fixed-level interrupt sources. This includes the 523x
7 * family, the 5270, 5271, 5274, 5275, and the 528x family which have two such
8 * controllers, and the 547x and 548x families which have only one of them.
2fba4f0b
GU
9 *
10 * (C) Copyright 2009, Greg Ungerer <gerg@snapgear.com>
11 *
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file COPYING in the main directory of this archive
14 * for more details.
15 */
16
17#include <linux/types.h>
18#include <linux/init.h>
19#include <linux/kernel.h>
20#include <linux/interrupt.h>
21#include <linux/irq.h>
22#include <linux/io.h>
23#include <asm/coldfire.h>
24#include <asm/mcfsim.h>
25#include <asm/traps.h>
26
27/*
8851338d
PDM
28 * Bit definitions for the ICR family of registers.
29 */
30#define MCFSIM_ICR_LEVEL(l) ((l)<<3) /* Level l intr */
31#define MCFSIM_ICR_PRI(p) (p) /* Priority p intr */
32
33/*
34 * Each vector needs a unique priority and level associated with it.
2fba4f0b 35 * We don't really care so much what they are, we don't rely on the
8851338d 36 * traditional priority interrupt scheme of the m68k/ColdFire.
2fba4f0b 37 */
8851338d
PDM
38static u8 intc_intpri = MCFSIM_ICR_LEVEL(6) | MCFSIM_ICR_PRI(6);
39
40#ifdef MCFICM_INTC1
41#define NR_VECS 128
42#else
43#define NR_VECS 64
44#endif
2fba4f0b
GU
45
46static void intc_irq_mask(unsigned int irq)
47{
8851338d 48 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECBASE + NR_VECS)) {
2fba4f0b
GU
49 unsigned long imraddr;
50 u32 val, imrbit;
51
52 irq -= MCFINT_VECBASE;
53 imraddr = MCF_IPSBAR;
8851338d 54#ifdef MCFICM_INTC1
2fba4f0b 55 imraddr += (irq & 0x40) ? MCFICM_INTC1 : MCFICM_INTC0;
8851338d
PDM
56#else
57 imraddr += MCFICM_INTC0;
58#endif
2fba4f0b
GU
59 imraddr += (irq & 0x20) ? MCFINTC_IMRH : MCFINTC_IMRL;
60 imrbit = 0x1 << (irq & 0x1f);
61
62 val = __raw_readl(imraddr);
63 __raw_writel(val | imrbit, imraddr);
64 }
65}
66
67static void intc_irq_unmask(unsigned int irq)
68{
8851338d 69 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECBASE + NR_VECS)) {
2fba4f0b
GU
70 unsigned long intaddr, imraddr, icraddr;
71 u32 val, imrbit;
72
73 irq -= MCFINT_VECBASE;
74 intaddr = MCF_IPSBAR;
8851338d 75#ifdef MCFICM_INTC1
2fba4f0b 76 intaddr += (irq & 0x40) ? MCFICM_INTC1 : MCFICM_INTC0;
8851338d
PDM
77#else
78 intaddr += MCFICM_INTC0;
79#endif
2fba4f0b
GU
80 imraddr = intaddr + ((irq & 0x20) ? MCFINTC_IMRH : MCFINTC_IMRL);
81 icraddr = intaddr + MCFINTC_ICR0 + (irq & 0x3f);
82 imrbit = 0x1 << (irq & 0x1f);
83
84 /* Don't set the "maskall" bit! */
85 if ((irq & 0x20) == 0)
86 imrbit |= 0x1;
87
88 if (__raw_readb(icraddr) == 0)
89 __raw_writeb(intc_intpri--, icraddr);
90
91 val = __raw_readl(imraddr);
92 __raw_writel(val & ~imrbit, imraddr);
93 }
94}
95
96static struct irq_chip intc_irq_chip = {
97 .name = "CF-INTC",
98 .mask = intc_irq_mask,
99 .unmask = intc_irq_unmask,
100};
101
102void __init init_IRQ(void)
103{
104 int irq;
105
106 init_vectors();
107
108 /* Mask all interrupt sources */
109 __raw_writel(0x1, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
8851338d 110#ifdef MCFICM_INTC1
2fba4f0b 111 __raw_writel(0x1, MCF_IPSBAR + MCFICM_INTC1 + MCFINTC_IMRL);
8851338d 112#endif
2fba4f0b
GU
113
114 for (irq = 0; (irq < NR_IRQS); irq++) {
115 irq_desc[irq].status = IRQ_DISABLED;
116 irq_desc[irq].action = NULL;
117 irq_desc[irq].depth = 1;
118 irq_desc[irq].chip = &intc_irq_chip;
119 }
120}
121