arch: sh: smc37c93x: fix spelling mistake
[linux-2.6-microblaze.git] / arch / sh / boards / mach-cayman / irq.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * arch/sh/mach-cayman/irq.c - SH-5 Cayman Interrupt Support
4  *
5  * This file handles the board specific parts of the Cayman interrupt system
6  *
7  * Copyright (C) 2002 Stuart Menefy
8  */
9 #include <linux/io.h>
10 #include <linux/irq.h>
11 #include <linux/interrupt.h>
12 #include <linux/signal.h>
13 #include <cpu/irq.h>
14 #include <asm/page.h>
15
16 /* Setup for the SMSC FDC37C935 / LAN91C100FD */
17 #define SMSC_IRQ         IRQ_IRL1
18
19 /* Setup for PCI Bus 2, which transmits interrupts via the EPLD */
20 #define PCI2_IRQ         IRQ_IRL3
21
22 unsigned long epld_virt;
23
24 #define EPLD_BASE        0x04002000
25 #define EPLD_STATUS_BASE (epld_virt + 0x10)
26 #define EPLD_MASK_BASE   (epld_virt + 0x20)
27
28 /* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
29    the same SH-5 interrupt */
30
31 static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id)
32 {
33         printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
34         return IRQ_NONE;
35 }
36
37 static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id)
38 {
39         printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
40         return IRQ_NONE;
41 }
42
43 static void enable_cayman_irq(struct irq_data *data)
44 {
45         unsigned int irq = data->irq;
46         unsigned long flags;
47         unsigned long mask;
48         unsigned int reg;
49         unsigned char bit;
50
51         irq -= START_EXT_IRQS;
52         reg = EPLD_MASK_BASE + ((irq / 8) << 2);
53         bit = 1<<(irq % 8);
54         local_irq_save(flags);
55         mask = __raw_readl(reg);
56         mask |= bit;
57         __raw_writel(mask, reg);
58         local_irq_restore(flags);
59 }
60
61 static void disable_cayman_irq(struct irq_data *data)
62 {
63         unsigned int irq = data->irq;
64         unsigned long flags;
65         unsigned long mask;
66         unsigned int reg;
67         unsigned char bit;
68
69         irq -= START_EXT_IRQS;
70         reg = EPLD_MASK_BASE + ((irq / 8) << 2);
71         bit = 1<<(irq % 8);
72         local_irq_save(flags);
73         mask = __raw_readl(reg);
74         mask &= ~bit;
75         __raw_writel(mask, reg);
76         local_irq_restore(flags);
77 }
78
79 struct irq_chip cayman_irq_type = {
80         .name           = "Cayman-IRQ",
81         .irq_unmask     = enable_cayman_irq,
82         .irq_mask       = disable_cayman_irq,
83 };
84
85 int cayman_irq_demux(int evt)
86 {
87         int irq = intc_evt_to_irq[evt];
88
89         if (irq == SMSC_IRQ) {
90                 unsigned long status;
91                 int i;
92
93                 status = __raw_readl(EPLD_STATUS_BASE) &
94                          __raw_readl(EPLD_MASK_BASE) & 0xff;
95                 if (status == 0) {
96                         irq = -1;
97                 } else {
98                         for (i=0; i<8; i++) {
99                                 if (status & (1<<i))
100                                         break;
101                         }
102                         irq = START_EXT_IRQS + i;
103                 }
104         }
105
106         if (irq == PCI2_IRQ) {
107                 unsigned long status;
108                 int i;
109
110                 status = __raw_readl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
111                          __raw_readl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
112                 if (status == 0) {
113                         irq = -1;
114                 } else {
115                         for (i=0; i<8; i++) {
116                                 if (status & (1<<i))
117                                         break;
118                         }
119                         irq = START_EXT_IRQS + (3 * 8) + i;
120                 }
121         }
122
123         return irq;
124 }
125
126 void init_cayman_irq(void)
127 {
128         int i;
129
130         epld_virt = (unsigned long)ioremap(EPLD_BASE, 1024);
131         if (!epld_virt) {
132                 printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
133                 return;
134         }
135
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);
139         }
140
141         /* Setup the SMSC interrupt */
142         if (request_irq(SMSC_IRQ, cayman_interrupt_smsc, 0, "Cayman SMSC Mux",
143                         NULL))
144                 pr_err("Failed to register Cayman SMSC Mux interrupt\n");
145         if (request_irq(PCI2_IRQ, cayman_interrupt_pci2, 0, "Cayman PCI2 Mux",
146                         NULL))
147                 pr_err("Failed to register Cayman PCI2 Mux interrupt\n");
148 }