2 * Interrupt handling for INTC2-based IRQ.
4 * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
5 * Copyright (C) 2005, 2006 Paul Mundt (lethal@linux-sh.org)
7 * May be copied or modified under the terms of the GNU General Public
8 * License. See linux/COPYING for more information.
10 * These are the "new Hitachi style" interrupts, as present on the
11 * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780.
13 #include <linux/kernel.h>
14 #include <linux/interrupt.h>
17 #if defined(CONFIG_CPU_SUBTYPE_SH7760)
18 #define INTC2_BASE 0xfe080000
19 #define INTC2_INTMSK (INTC2_BASE + 0x40)
20 #define INTC2_INTMSKCLR (INTC2_BASE + 0x60)
21 #elif defined(CONFIG_CPU_SUBTYPE_SH7780)
22 #define INTC2_BASE 0xffd40000
23 #define INTC2_INTMSK (INTC2_BASE + 0x38)
24 #define INTC2_INTMSKCLR (INTC2_BASE + 0x3c)
27 static void disable_intc2_irq(unsigned int irq)
29 struct intc2_data *p = get_irq_chip_data(irq);
30 ctrl_outl(1 << p->msk_shift, INTC2_INTMSK + p->msk_offset);
33 static void enable_intc2_irq(unsigned int irq)
35 struct intc2_data *p = get_irq_chip_data(irq);
36 ctrl_outl(1 << p->msk_shift, INTC2_INTMSKCLR + p->msk_offset);
39 static struct irq_chip intc2_irq_chip = {
41 .mask = disable_intc2_irq,
42 .unmask = enable_intc2_irq,
43 .mask_ack = disable_intc2_irq,
47 * Setup an INTC2 style interrupt.
48 * NOTE: Unlike IPR interrupts, parameters are not shifted by this code,
49 * allowing the use of the numbers straight out of the datasheet.
51 * PIO1 which is INTPRI00[19,16] and INTMSK00[13]
54 * { 84, 0, 16, 0, 13 },
56 * in the intc2_data table.
58 void make_intc2_irq(struct intc2_data *table, unsigned int nr_irqs)
62 for (i = 0; i < nr_irqs; i++) {
63 unsigned long ipr, flags;
64 struct intc2_data *p = table + i;
66 disable_irq_nosync(p->irq);
68 /* Set the priority level */
69 local_irq_save(flags);
71 ipr = ctrl_inl(INTC2_BASE + p->ipr_offset);
72 ipr &= ~(0xf << p->ipr_shift);
73 ipr |= p->priority << p->ipr_shift;
74 ctrl_outl(ipr, INTC2_BASE + p->ipr_offset);
76 local_irq_restore(flags);
78 set_irq_chip_and_handler_name(p->irq, &intc2_irq_chip,
79 handle_level_irq, "level");
80 set_irq_chip_data(p->irq, p);
82 enable_intc2_irq(p->irq);