[PATCH] ocfs2: zero_user_page conversion
[wrt350n-kernel.git] / arch / sh64 / mach-cayman / irq.c
blobaaad36d37d1f600bfd573814111e216894a762dc
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 <asm/irq.h>
16 #include <asm/page.h>
17 #include <asm/io.h>
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)
34 printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
35 return IRQ_NONE;
38 static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id)
40 printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
41 return IRQ_NONE;
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)
58 unsigned long flags;
59 unsigned long mask;
60 unsigned int reg;
61 unsigned char bit;
63 irq -= START_EXT_IRQS;
64 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
65 bit = 1<<(irq % 8);
66 local_irq_save(flags);
67 mask = ctrl_inl(reg);
68 mask |= bit;
69 ctrl_outl(mask, reg);
70 local_irq_restore(flags);
73 void disable_cayman_irq(unsigned int irq)
75 unsigned long flags;
76 unsigned long mask;
77 unsigned int reg;
78 unsigned char bit;
80 irq -= START_EXT_IRQS;
81 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
82 bit = 1<<(irq % 8);
83 local_irq_save(flags);
84 mask = ctrl_inl(reg);
85 mask &= ~bit;
86 ctrl_outl(mask, reg);
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;
128 int i;
130 status = ctrl_inl(EPLD_STATUS_BASE) &
131 ctrl_inl(EPLD_MASK_BASE) & 0xff;
132 if (status == 0) {
133 irq = -1;
134 } else {
135 for (i=0; i<8; i++) {
136 if (status & (1<<i))
137 break;
139 irq = START_EXT_IRQS + i;
143 if (irq == PCI2_IRQ) {
144 unsigned long status;
145 int i;
147 status = ctrl_inl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
148 ctrl_inl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
149 if (status == 0) {
150 irq = -1;
151 } else {
152 for (i=0; i<8; i++) {
153 if (status & (1<<i))
154 break;
156 irq = START_EXT_IRQS + (3 * 8) + i;
160 return irq;
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));
174 return 0;
176 #endif
178 void init_cayman_irq(void)
180 int i;
182 epld_virt = onchip_remap(EPLD_BASE, 1024, "EPLD");
183 if (!epld_virt) {
184 printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
185 return;
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);