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
6 * arch/sh64/kernel/irq_cayman.c
8 * SH-5 Cayman Interrupt Support
10 * This file handles the board specific parts of the Cayman interrupt system
12 * Copyright (C) 2002 Stuart Menefy
18 #include <linux/irq.h>
19 #include <linux/interrupt.h>
20 #include <linux/signal.h>
21 #include <asm/cayman.h>
23 unsigned long epld_virt;
25 #define EPLD_BASE 0x04002000
26 #define EPLD_STATUS_BASE (epld_virt + 0x10)
27 #define EPLD_MASK_BASE (epld_virt + 0x20)
29 /* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
30 the same SH-5 interrupt */
32 static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id, struct pt_regs *regs)
34 printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
38 static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id, struct pt_regs *regs)
40 printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
44 static struct irqaction cayman_action_smsc = {
45 .name = "Cayman SMSC Mux",
46 .handler = cayman_interrupt_smsc,
47 .flags = IRQF_DISABLED,
50 static struct irqaction cayman_action_pci2 = {
51 .name = "Cayman PCI2 Mux",
52 .handler = cayman_interrupt_pci2,
53 .flags = IRQF_DISABLED,
56 static void enable_cayman_irq(unsigned int irq)
63 irq -= START_EXT_IRQS;
64 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
66 local_irq_save(flags);
70 local_irq_restore(flags);
73 void disable_cayman_irq(unsigned int irq)
80 irq -= START_EXT_IRQS;
81 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
83 local_irq_save(flags);
87 local_irq_restore(flags);
90 static void ack_cayman_irq(unsigned int irq)
92 disable_cayman_irq(irq);
95 static void end_cayman_irq(unsigned int irq)
97 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
98 enable_cayman_irq(irq);
101 static unsigned int startup_cayman_irq(unsigned int irq)
103 enable_cayman_irq(irq);
104 return 0; /* never anything pending */
107 static void shutdown_cayman_irq(unsigned int irq)
109 disable_cayman_irq(irq);
112 struct hw_interrupt_type cayman_irq_type = {
113 .typename = "Cayman-IRQ",
114 .startup = startup_cayman_irq,
115 .shutdown = shutdown_cayman_irq,
116 .enable = enable_cayman_irq,
117 .disable = disable_cayman_irq,
118 .ack = ack_cayman_irq,
119 .end = end_cayman_irq,
122 int cayman_irq_demux(int evt)
124 int irq = intc_evt_to_irq[evt];
126 if (irq == SMSC_IRQ) {
127 unsigned long status;
130 status = ctrl_inl(EPLD_STATUS_BASE) &
131 ctrl_inl(EPLD_MASK_BASE) & 0xff;
135 for (i=0; i<8; i++) {
139 irq = START_EXT_IRQS + i;
143 if (irq == PCI2_IRQ) {
144 unsigned long status;
147 status = ctrl_inl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
148 ctrl_inl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
152 for (i=0; i<8; i++) {
156 irq = START_EXT_IRQS + (3 * 8) + i;
163 #if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
164 int cayman_irq_describe(char* p, int irq)
166 if (irq < NR_INTC_IRQS) {
167 return intc_irq_describe(p, irq);
168 } else if (irq < NR_INTC_IRQS + 8) {
169 return sprintf(p, "(SMSC %d)", irq - NR_INTC_IRQS);
170 } else if ((irq >= NR_INTC_IRQS + 24) && (irq < NR_INTC_IRQS + 32)) {
171 return sprintf(p, "(PCI2 %d)", irq - (NR_INTC_IRQS + 24));
178 void init_cayman_irq(void)
182 epld_virt = onchip_remap(EPLD_BASE, 1024, "EPLD");
184 printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
188 for (i=0; i<NR_EXT_IRQS; i++) {
189 irq_desc[START_EXT_IRQS + i].chip = &cayman_irq_type;
192 /* Setup the SMSC interrupt */
193 setup_irq(SMSC_IRQ, &cayman_action_smsc);
194 setup_irq(PCI2_IRQ, &cayman_action_pci2);