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
15 #include <linux/config.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");
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
);
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
)
64 irq
-= START_EXT_IRQS
;
65 reg
= EPLD_MASK_BASE
+ ((irq
/ 8) << 2);
67 local_irq_save(flags
);
71 local_irq_restore(flags
);
74 void disable_cayman_irq(unsigned int irq
)
81 irq
-= START_EXT_IRQS
;
82 reg
= EPLD_MASK_BASE
+ ((irq
/ 8) << 2);
84 local_irq_save(flags
);
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
;
131 status
= ctrl_inl(EPLD_STATUS_BASE
) &
132 ctrl_inl(EPLD_MASK_BASE
) & 0xff;
136 for (i
=0; i
<8; i
++) {
140 irq
= START_EXT_IRQS
+ i
;
144 if (irq
== PCI2_IRQ
) {
145 unsigned long status
;
148 status
= ctrl_inl(EPLD_STATUS_BASE
+ 3 * sizeof(u32
)) &
149 ctrl_inl(EPLD_MASK_BASE
+ 3 * sizeof(u32
)) & 0xff;
153 for (i
=0; i
<8; i
++) {
157 irq
= START_EXT_IRQS
+ (3 * 8) + i
;
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));
179 void init_cayman_irq(void)
183 epld_virt
= onchip_remap(EPLD_BASE
, 1024, "EPLD");
185 printk(KERN_ERR
"Cayman IRQ: Unable to remap EPLD\n");
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
);