1 // SPDX-License-Identifier: GPL-2.0
3 * arch/sh/mach-cayman/irq.c - SH-5 Cayman Interrupt Support
5 * This file handles the board specific parts of the Cayman interrupt system
7 * Copyright (C) 2002 Stuart Menefy
10 #include <linux/irq.h>
11 #include <linux/interrupt.h>
12 #include <linux/signal.h>
16 /* Setup for the SMSC FDC37C935 / LAN91C100FD */
17 #define SMSC_IRQ IRQ_IRL1
19 /* Setup for PCI Bus 2, which transmits interrupts via the EPLD */
20 #define PCI2_IRQ IRQ_IRL3
22 unsigned long epld_virt;
24 #define EPLD_BASE 0x04002000
25 #define EPLD_STATUS_BASE (epld_virt + 0x10)
26 #define EPLD_MASK_BASE (epld_virt + 0x20)
28 /* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
29 the same SH-5 interrupt */
31 static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id)
33 printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
37 static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id)
39 printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
43 static struct irqaction cayman_action_smsc = {
44 .name = "Cayman SMSC Mux",
45 .handler = cayman_interrupt_smsc,
48 static struct irqaction cayman_action_pci2 = {
49 .name = "Cayman PCI2 Mux",
50 .handler = cayman_interrupt_pci2,
53 static void enable_cayman_irq(struct irq_data *data)
55 unsigned int irq = data->irq;
61 irq -= START_EXT_IRQS;
62 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
64 local_irq_save(flags);
65 mask = __raw_readl(reg);
67 __raw_writel(mask, reg);
68 local_irq_restore(flags);
71 static void disable_cayman_irq(struct irq_data *data)
73 unsigned int irq = data->irq;
79 irq -= START_EXT_IRQS;
80 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
82 local_irq_save(flags);
83 mask = __raw_readl(reg);
85 __raw_writel(mask, reg);
86 local_irq_restore(flags);
89 struct irq_chip cayman_irq_type = {
91 .irq_unmask = enable_cayman_irq,
92 .irq_mask = disable_cayman_irq,
95 int cayman_irq_demux(int evt)
97 int irq = intc_evt_to_irq[evt];
99 if (irq == SMSC_IRQ) {
100 unsigned long status;
103 status = __raw_readl(EPLD_STATUS_BASE) &
104 __raw_readl(EPLD_MASK_BASE) & 0xff;
108 for (i=0; i<8; i++) {
112 irq = START_EXT_IRQS + i;
116 if (irq == PCI2_IRQ) {
117 unsigned long status;
120 status = __raw_readl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
121 __raw_readl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
125 for (i=0; i<8; i++) {
129 irq = START_EXT_IRQS + (3 * 8) + i;
136 void init_cayman_irq(void)
140 epld_virt = (unsigned long)ioremap(EPLD_BASE, 1024);
142 printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
146 for (i = 0; i < NR_EXT_IRQS; i++) {
147 irq_set_chip_and_handler(START_EXT_IRQS + i,
148 &cayman_irq_type, handle_level_irq);
151 /* Setup the SMSC interrupt */
152 setup_irq(SMSC_IRQ, &cayman_action_smsc);
153 setup_irq(PCI2_IRQ, &cayman_action_pci2);