Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / arm / mach-rpc / irq.c
blobb8a61cb112073643256dbb693a8351e07c1f4335
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/init.h>
3 #include <linux/list.h>
4 #include <linux/io.h>
6 #include <asm/mach/irq.h>
7 #include <asm/hardware/iomd.h>
8 #include <asm/irq.h>
9 #include <asm/fiq.h>
11 static void iomd_ack_irq_a(struct irq_data *d)
13 unsigned int val, mask;
15 mask = 1 << d->irq;
16 val = iomd_readb(IOMD_IRQMASKA);
17 iomd_writeb(val & ~mask, IOMD_IRQMASKA);
18 iomd_writeb(mask, IOMD_IRQCLRA);
21 static void iomd_mask_irq_a(struct irq_data *d)
23 unsigned int val, mask;
25 mask = 1 << d->irq;
26 val = iomd_readb(IOMD_IRQMASKA);
27 iomd_writeb(val & ~mask, IOMD_IRQMASKA);
30 static void iomd_unmask_irq_a(struct irq_data *d)
32 unsigned int val, mask;
34 mask = 1 << d->irq;
35 val = iomd_readb(IOMD_IRQMASKA);
36 iomd_writeb(val | mask, IOMD_IRQMASKA);
39 static struct irq_chip iomd_a_chip = {
40 .irq_ack = iomd_ack_irq_a,
41 .irq_mask = iomd_mask_irq_a,
42 .irq_unmask = iomd_unmask_irq_a,
45 static void iomd_mask_irq_b(struct irq_data *d)
47 unsigned int val, mask;
49 mask = 1 << (d->irq & 7);
50 val = iomd_readb(IOMD_IRQMASKB);
51 iomd_writeb(val & ~mask, IOMD_IRQMASKB);
54 static void iomd_unmask_irq_b(struct irq_data *d)
56 unsigned int val, mask;
58 mask = 1 << (d->irq & 7);
59 val = iomd_readb(IOMD_IRQMASKB);
60 iomd_writeb(val | mask, IOMD_IRQMASKB);
63 static struct irq_chip iomd_b_chip = {
64 .irq_ack = iomd_mask_irq_b,
65 .irq_mask = iomd_mask_irq_b,
66 .irq_unmask = iomd_unmask_irq_b,
69 static void iomd_mask_irq_dma(struct irq_data *d)
71 unsigned int val, mask;
73 mask = 1 << (d->irq & 7);
74 val = iomd_readb(IOMD_DMAMASK);
75 iomd_writeb(val & ~mask, IOMD_DMAMASK);
78 static void iomd_unmask_irq_dma(struct irq_data *d)
80 unsigned int val, mask;
82 mask = 1 << (d->irq & 7);
83 val = iomd_readb(IOMD_DMAMASK);
84 iomd_writeb(val | mask, IOMD_DMAMASK);
87 static struct irq_chip iomd_dma_chip = {
88 .irq_ack = iomd_mask_irq_dma,
89 .irq_mask = iomd_mask_irq_dma,
90 .irq_unmask = iomd_unmask_irq_dma,
93 static void iomd_mask_irq_fiq(struct irq_data *d)
95 unsigned int val, mask;
97 mask = 1 << (d->irq & 7);
98 val = iomd_readb(IOMD_FIQMASK);
99 iomd_writeb(val & ~mask, IOMD_FIQMASK);
102 static void iomd_unmask_irq_fiq(struct irq_data *d)
104 unsigned int val, mask;
106 mask = 1 << (d->irq & 7);
107 val = iomd_readb(IOMD_FIQMASK);
108 iomd_writeb(val | mask, IOMD_FIQMASK);
111 static struct irq_chip iomd_fiq_chip = {
112 .irq_ack = iomd_mask_irq_fiq,
113 .irq_mask = iomd_mask_irq_fiq,
114 .irq_unmask = iomd_unmask_irq_fiq,
117 extern unsigned char rpc_default_fiq_start, rpc_default_fiq_end;
119 void __init rpc_init_irq(void)
121 unsigned int irq, clr, set = 0;
123 iomd_writeb(0, IOMD_IRQMASKA);
124 iomd_writeb(0, IOMD_IRQMASKB);
125 iomd_writeb(0, IOMD_FIQMASK);
126 iomd_writeb(0, IOMD_DMAMASK);
128 set_fiq_handler(&rpc_default_fiq_start,
129 &rpc_default_fiq_end - &rpc_default_fiq_start);
131 for (irq = 0; irq < NR_IRQS; irq++) {
132 clr = IRQ_NOREQUEST;
134 if (irq <= 6 || (irq >= 9 && irq <= 15))
135 clr |= IRQ_NOPROBE;
137 if (irq == 21 || (irq >= 16 && irq <= 19) ||
138 irq == IRQ_KEYBOARDTX)
139 set |= IRQ_NOAUTOEN;
141 switch (irq) {
142 case 0 ... 7:
143 irq_set_chip_and_handler(irq, &iomd_a_chip,
144 handle_level_irq);
145 irq_modify_status(irq, clr, set);
146 break;
148 case 8 ... 15:
149 irq_set_chip_and_handler(irq, &iomd_b_chip,
150 handle_level_irq);
151 irq_modify_status(irq, clr, set);
152 break;
154 case 16 ... 21:
155 irq_set_chip_and_handler(irq, &iomd_dma_chip,
156 handle_level_irq);
157 irq_modify_status(irq, clr, set);
158 break;
160 case 64 ... 71:
161 irq_set_chip(irq, &iomd_fiq_chip);
162 irq_modify_status(irq, clr, set);
163 break;
167 init_FIQ(FIQ_START);