aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh64/mach-cayman/irq.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh64/mach-cayman/irq.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/sh64/mach-cayman/irq.c')
-rw-r--r--arch/sh64/mach-cayman/irq.c196
1 files changed, 196 insertions, 0 deletions
diff --git a/arch/sh64/mach-cayman/irq.c b/arch/sh64/mach-cayman/irq.c
new file mode 100644
index 000000000000..f797c84bfdd1
--- /dev/null
+++ b/arch/sh64/mach-cayman/irq.c
@@ -0,0 +1,196 @@
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.
5 *
6 * arch/sh64/kernel/irq_cayman.c
7 *
8 * SH-5 Cayman Interrupt Support
9 *
10 * This file handles the board specific parts of the Cayman interrupt system
11 *
12 * Copyright (C) 2002 Stuart Menefy
13 */
14
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>
23
24unsigned long epld_virt;
25
26#define EPLD_BASE 0x04002000
27#define EPLD_STATUS_BASE (epld_virt + 0x10)
28#define EPLD_MASK_BASE (epld_virt + 0x20)
29
30/* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
31 the same SH-5 interrupt */
32
33static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id, struct pt_regs *regs)
34{
35 printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
36 return IRQ_NONE;
37}
38
39static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id, struct pt_regs *regs)
40{
41 printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
42 return IRQ_NONE;
43}
44
45static struct irqaction cayman_action_smsc = {
46 .name = "Cayman SMSC Mux",
47 .handler = cayman_interrupt_smsc,
48 .flags = SA_INTERRUPT,
49};
50
51static struct irqaction cayman_action_pci2 = {
52 .name = "Cayman PCI2 Mux",
53 .handler = cayman_interrupt_pci2,
54 .flags = SA_INTERRUPT,
55};
56
57static void enable_cayman_irq(unsigned int irq)
58{
59 unsigned long flags;
60 unsigned long mask;
61 unsigned int reg;
62 unsigned char bit;
63
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);
72}
73
74void disable_cayman_irq(unsigned int irq)
75{
76 unsigned long flags;
77 unsigned long mask;
78 unsigned int reg;
79 unsigned char bit;
80
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);
89}
90
91static void ack_cayman_irq(unsigned int irq)
92{
93 disable_cayman_irq(irq);
94}
95
96static void end_cayman_irq(unsigned int irq)
97{
98 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
99 enable_cayman_irq(irq);
100}
101
102static unsigned int startup_cayman_irq(unsigned int irq)
103{
104 enable_cayman_irq(irq);
105 return 0; /* never anything pending */
106}
107
108static void shutdown_cayman_irq(unsigned int irq)
109{
110 disable_cayman_irq(irq);
111}
112
113struct 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,
121};
122
123int cayman_irq_demux(int evt)
124{
125 int irq = intc_evt_to_irq[evt];
126
127 if (irq == SMSC_IRQ) {
128 unsigned long status;
129 int i;
130
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;
139 }
140 irq = START_EXT_IRQS + i;
141 }
142 }
143
144 if (irq == PCI2_IRQ) {
145 unsigned long status;
146 int i;
147
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;
156 }
157 irq = START_EXT_IRQS + (3 * 8) + i;
158 }
159 }
160
161 return irq;
162}
163
164#if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
165int cayman_irq_describe(char* p, int irq)
166{
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));
173 }
174
175 return 0;
176}
177#endif
178
179void init_cayman_irq(void)
180{
181 int i;
182
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;
187 }
188
189 for (i=0; i<NR_EXT_IRQS; i++) {
190 irq_desc[START_EXT_IRQS + i].handler = &cayman_irq_type;
191 }
192
193 /* Setup the SMSC interrupt */
194 setup_irq(SMSC_IRQ, &cayman_action_smsc);
195 setup_irq(PCI2_IRQ, &cayman_action_pci2);
196}