2 * arch/sh/mach-cayman/irq.c - SH-5 Cayman Interrupt Support
4 * This file handles the board specific parts of the Cayman interrupt system
6 * Copyright (C) 2002 Stuart Menefy
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/irq.h>
14 #include <linux/interrupt.h>
15 #include <linux/signal.h>
19 /* Setup for the SMSC FDC37C935 / LAN91C100FD */
20 #define SMSC_IRQ IRQ_IRL1
22 /* Setup for PCI Bus 2, which transmits interrupts via the EPLD */
23 #define PCI2_IRQ IRQ_IRL3
25 unsigned long epld_virt
;
27 #define EPLD_BASE 0x04002000
28 #define EPLD_STATUS_BASE (epld_virt + 0x10)
29 #define EPLD_MASK_BASE (epld_virt + 0x20)
31 /* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
32 the same SH-5 interrupt */
34 static irqreturn_t
cayman_interrupt_smsc(int irq
, void *dev_id
)
36 printk(KERN_INFO
"CAYMAN: spurious SMSC interrupt\n");
40 static irqreturn_t
cayman_interrupt_pci2(int irq
, void *dev_id
)
42 printk(KERN_INFO
"CAYMAN: spurious PCI interrupt, IRQ %d\n", irq
);
46 static struct irqaction cayman_action_smsc
= {
47 .name
= "Cayman SMSC Mux",
48 .handler
= cayman_interrupt_smsc
,
51 static struct irqaction cayman_action_pci2
= {
52 .name
= "Cayman PCI2 Mux",
53 .handler
= cayman_interrupt_pci2
,
56 static void enable_cayman_irq(struct irq_data
*data
)
58 unsigned int irq
= data
->irq
;
64 irq
-= START_EXT_IRQS
;
65 reg
= EPLD_MASK_BASE
+ ((irq
/ 8) << 2);
67 local_irq_save(flags
);
68 mask
= __raw_readl(reg
);
70 __raw_writel(mask
, reg
);
71 local_irq_restore(flags
);
74 static void disable_cayman_irq(struct irq_data
*data
)
76 unsigned int irq
= data
->irq
;
82 irq
-= START_EXT_IRQS
;
83 reg
= EPLD_MASK_BASE
+ ((irq
/ 8) << 2);
85 local_irq_save(flags
);
86 mask
= __raw_readl(reg
);
88 __raw_writel(mask
, reg
);
89 local_irq_restore(flags
);
92 struct irq_chip cayman_irq_type
= {
94 .irq_unmask
= enable_cayman_irq
,
95 .irq_mask
= disable_cayman_irq
,
98 int cayman_irq_demux(int evt
)
100 int irq
= intc_evt_to_irq
[evt
];
102 if (irq
== SMSC_IRQ
) {
103 unsigned long status
;
106 status
= __raw_readl(EPLD_STATUS_BASE
) &
107 __raw_readl(EPLD_MASK_BASE
) & 0xff;
111 for (i
=0; i
<8; i
++) {
115 irq
= START_EXT_IRQS
+ i
;
119 if (irq
== PCI2_IRQ
) {
120 unsigned long status
;
123 status
= __raw_readl(EPLD_STATUS_BASE
+ 3 * sizeof(u32
)) &
124 __raw_readl(EPLD_MASK_BASE
+ 3 * sizeof(u32
)) & 0xff;
128 for (i
=0; i
<8; i
++) {
132 irq
= START_EXT_IRQS
+ (3 * 8) + i
;
139 void init_cayman_irq(void)
143 epld_virt
= (unsigned long)ioremap_nocache(EPLD_BASE
, 1024);
145 printk(KERN_ERR
"Cayman IRQ: Unable to remap EPLD\n");
149 for (i
= 0; i
< NR_EXT_IRQS
; i
++) {
150 irq_set_chip_and_handler(START_EXT_IRQS
+ i
,
151 &cayman_irq_type
, handle_level_irq
);
154 /* Setup the SMSC interrupt */
155 setup_irq(SMSC_IRQ
, &cayman_action_smsc
);
156 setup_irq(PCI2_IRQ
, &cayman_action_pci2
);