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 void enable_cayman_irq(struct irq_data *data)
45 unsigned int irq = data->irq;
51 irq -= START_EXT_IRQS;
52 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
54 local_irq_save(flags);
55 mask = __raw_readl(reg);
57 __raw_writel(mask, reg);
58 local_irq_restore(flags);
61 static void disable_cayman_irq(struct irq_data *data)
63 unsigned int irq = data->irq;
69 irq -= START_EXT_IRQS;
70 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
72 local_irq_save(flags);
73 mask = __raw_readl(reg);
75 __raw_writel(mask, reg);
76 local_irq_restore(flags);
79 struct irq_chip cayman_irq_type = {
81 .irq_unmask = enable_cayman_irq,
82 .irq_mask = disable_cayman_irq,
85 int cayman_irq_demux(int evt)
87 int irq = intc_evt_to_irq[evt];
89 if (irq == SMSC_IRQ) {
93 status = __raw_readl(EPLD_STATUS_BASE) &
94 __raw_readl(EPLD_MASK_BASE) & 0xff;
102 irq = START_EXT_IRQS + i;
106 if (irq == PCI2_IRQ) {
107 unsigned long status;
110 status = __raw_readl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
111 __raw_readl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
115 for (i=0; i<8; i++) {
119 irq = START_EXT_IRQS + (3 * 8) + i;
126 void init_cayman_irq(void)
130 epld_virt = (unsigned long)ioremap(EPLD_BASE, 1024);
132 printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
136 for (i = 0; i < NR_EXT_IRQS; i++) {
137 irq_set_chip_and_handler(START_EXT_IRQS + i,
138 &cayman_irq_type, handle_level_irq);
141 /* Setup the SMSC interrupt */
142 if (request_irq(SMSC_IRQ, cayman_interrupt_smsc, 0, "Cayman SMSC Mux",
144 pr_err("Failed to register Cayman SMSC Mux interrupt\n");
145 if (request_irq(PCI2_IRQ, cayman_interrupt_pci2, 0, "Cayman PCI2 Mux",
147 pr_err("Failed to register Cayman PCI2 Mux interrupt\n");