[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / sh64 / mach-cayman / irq.c
blobf797c84bfdd1e9dae8c26211d9ca2024e9297861
1 /*
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.
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
15 #include <linux/config.h>
16 #include <asm/irq.h>
17 #include <asm/page.h>
18 #include <asm/io.h>
19 #include <linux/irq.h>
20 #include <linux/interrupt.h>
21 #include <linux/signal.h>
22 #include <asm/cayman.h>
24 unsigned long epld_virt;
26 #define EPLD_BASE 0x04002000
27 #define EPLD_STATUS_BASE (epld_virt + 0x10)
28 #define EPLD_MASK_BASE (epld_virt + 0x20)
30 /* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
31 the same SH-5 interrupt */
33 static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id, struct pt_regs *regs)
35 printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
36 return IRQ_NONE;
39 static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id, struct pt_regs *regs)
41 printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
42 return IRQ_NONE;
45 static struct irqaction cayman_action_smsc = {
46 .name = "Cayman SMSC Mux",
47 .handler = cayman_interrupt_smsc,
48 .flags = SA_INTERRUPT,
51 static struct irqaction cayman_action_pci2 = {
52 .name = "Cayman PCI2 Mux",
53 .handler = cayman_interrupt_pci2,
54 .flags = SA_INTERRUPT,
57 static void enable_cayman_irq(unsigned int irq)
59 unsigned long flags;
60 unsigned long mask;
61 unsigned int reg;
62 unsigned char bit;
64 irq -= START_EXT_IRQS;
65 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
66 bit = 1<<(irq % 8);
67 local_irq_save(flags);
68 mask = ctrl_inl(reg);
69 mask |= bit;
70 ctrl_outl(mask, reg);
71 local_irq_restore(flags);
74 void disable_cayman_irq(unsigned int irq)
76 unsigned long flags;
77 unsigned long mask;
78 unsigned int reg;
79 unsigned char bit;
81 irq -= START_EXT_IRQS;
82 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
83 bit = 1<<(irq % 8);
84 local_irq_save(flags);
85 mask = ctrl_inl(reg);
86 mask &= ~bit;
87 ctrl_outl(mask, reg);
88 local_irq_restore(flags);
91 static void ack_cayman_irq(unsigned int irq)
93 disable_cayman_irq(irq);
96 static void end_cayman_irq(unsigned int irq)
98 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
99 enable_cayman_irq(irq);
102 static unsigned int startup_cayman_irq(unsigned int irq)
104 enable_cayman_irq(irq);
105 return 0; /* never anything pending */
108 static void shutdown_cayman_irq(unsigned int irq)
110 disable_cayman_irq(irq);
113 struct hw_interrupt_type cayman_irq_type = {
114 .typename = "Cayman-IRQ",
115 .startup = startup_cayman_irq,
116 .shutdown = shutdown_cayman_irq,
117 .enable = enable_cayman_irq,
118 .disable = disable_cayman_irq,
119 .ack = ack_cayman_irq,
120 .end = end_cayman_irq,
123 int cayman_irq_demux(int evt)
125 int irq = intc_evt_to_irq[evt];
127 if (irq == SMSC_IRQ) {
128 unsigned long status;
129 int i;
131 status = ctrl_inl(EPLD_STATUS_BASE) &
132 ctrl_inl(EPLD_MASK_BASE) & 0xff;
133 if (status == 0) {
134 irq = -1;
135 } else {
136 for (i=0; i<8; i++) {
137 if (status & (1<<i))
138 break;
140 irq = START_EXT_IRQS + i;
144 if (irq == PCI2_IRQ) {
145 unsigned long status;
146 int i;
148 status = ctrl_inl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
149 ctrl_inl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
150 if (status == 0) {
151 irq = -1;
152 } else {
153 for (i=0; i<8; i++) {
154 if (status & (1<<i))
155 break;
157 irq = START_EXT_IRQS + (3 * 8) + i;
161 return irq;
164 #if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
165 int cayman_irq_describe(char* p, int irq)
167 if (irq < NR_INTC_IRQS) {
168 return intc_irq_describe(p, irq);
169 } else if (irq < NR_INTC_IRQS + 8) {
170 return sprintf(p, "(SMSC %d)", irq - NR_INTC_IRQS);
171 } else if ((irq >= NR_INTC_IRQS + 24) && (irq < NR_INTC_IRQS + 32)) {
172 return sprintf(p, "(PCI2 %d)", irq - (NR_INTC_IRQS + 24));
175 return 0;
177 #endif
179 void init_cayman_irq(void)
181 int i;
183 epld_virt = onchip_remap(EPLD_BASE, 1024, "EPLD");
184 if (!epld_virt) {
185 printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
186 return;
189 for (i=0; i<NR_EXT_IRQS; i++) {
190 irq_desc[START_EXT_IRQS + i].handler = &cayman_irq_type;
193 /* Setup the SMSC interrupt */
194 setup_irq(SMSC_IRQ, &cayman_action_smsc);
195 setup_irq(PCI2_IRQ, &cayman_action_pci2);