Merge tag 'locking-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / arm / mach-rpc / irq.c
blob803aeb126f0e9f9d6eaa061e26d7b21df6cc51b6
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 // These are offsets from the stat register for each IRQ bank
12 #define STAT 0x00
13 #define REQ 0x04
14 #define CLR 0x04
15 #define MASK 0x08
17 static void __iomem *iomd_get_base(struct irq_data *d)
19 void *cd = irq_data_get_irq_chip_data(d);
21 return (void __iomem *)(unsigned long)cd;
24 static void iomd_set_base_mask(unsigned int irq, void __iomem *base, u32 mask)
26 struct irq_data *d = irq_get_irq_data(irq);
28 d->mask = mask;
29 irq_set_chip_data(irq, (void *)(unsigned long)base);
32 static void iomd_irq_mask_ack(struct irq_data *d)
34 void __iomem *base = iomd_get_base(d);
35 unsigned int val, mask = d->mask;
37 val = readb(base + MASK);
38 writeb(val & ~mask, base + MASK);
39 writeb(mask, base + CLR);
42 static void iomd_irq_mask(struct irq_data *d)
44 void __iomem *base = iomd_get_base(d);
45 unsigned int val, mask = d->mask;
47 val = readb(base + MASK);
48 writeb(val & ~mask, base + MASK);
51 static void iomd_irq_unmask(struct irq_data *d)
53 void __iomem *base = iomd_get_base(d);
54 unsigned int val, mask = d->mask;
56 val = readb(base + MASK);
57 writeb(val | mask, base + MASK);
60 static struct irq_chip iomd_chip_clr = {
61 .irq_mask_ack = iomd_irq_mask_ack,
62 .irq_mask = iomd_irq_mask,
63 .irq_unmask = iomd_irq_unmask,
66 static struct irq_chip iomd_chip_noclr = {
67 .irq_mask = iomd_irq_mask,
68 .irq_unmask = iomd_irq_unmask,
71 extern unsigned char rpc_default_fiq_start, rpc_default_fiq_end;
73 void __init rpc_init_irq(void)
75 unsigned int irq, clr, set;
77 iomd_writeb(0, IOMD_IRQMASKA);
78 iomd_writeb(0, IOMD_IRQMASKB);
79 iomd_writeb(0, IOMD_FIQMASK);
80 iomd_writeb(0, IOMD_DMAMASK);
82 set_fiq_handler(&rpc_default_fiq_start,
83 &rpc_default_fiq_end - &rpc_default_fiq_start);
85 for (irq = 0; irq < NR_IRQS; irq++) {
86 clr = IRQ_NOREQUEST;
87 set = 0;
89 if (irq <= 6 || (irq >= 9 && irq <= 15))
90 clr |= IRQ_NOPROBE;
92 if (irq == 21 || (irq >= 16 && irq <= 19) ||
93 irq == IRQ_KEYBOARDTX)
94 set |= IRQ_NOAUTOEN;
96 switch (irq) {
97 case 0 ... 7:
98 irq_set_chip_and_handler(irq, &iomd_chip_clr,
99 handle_level_irq);
100 irq_modify_status(irq, clr, set);
101 iomd_set_base_mask(irq, IOMD_BASE + IOMD_IRQSTATA,
102 BIT(irq));
103 break;
105 case 8 ... 15:
106 irq_set_chip_and_handler(irq, &iomd_chip_noclr,
107 handle_level_irq);
108 irq_modify_status(irq, clr, set);
109 iomd_set_base_mask(irq, IOMD_BASE + IOMD_IRQSTATB,
110 BIT(irq - 8));
111 break;
113 case 16 ... 21:
114 irq_set_chip_and_handler(irq, &iomd_chip_noclr,
115 handle_level_irq);
116 irq_modify_status(irq, clr, set);
117 iomd_set_base_mask(irq, IOMD_BASE + IOMD_DMASTAT,
118 BIT(irq - 16));
119 break;
121 case 64 ... 71:
122 irq_set_chip(irq, &iomd_chip_noclr);
123 irq_modify_status(irq, clr, set);
124 iomd_set_base_mask(irq, IOMD_BASE + IOMD_FIQSTAT,
125 BIT(irq - 64));
126 break;
130 init_FIQ(FIQ_START);