1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/init.h>
3 #include <linux/list.h>
6 #include <asm/mach/irq.h>
7 #include <asm/hardware/iomd.h>
11 // These are offsets from the stat register for each IRQ bank
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);
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++) {
89 if (irq <= 6 || (irq >= 9 && irq <= 15))
92 if (irq == 21 || (irq >= 16 && irq <= 19) ||
93 irq == IRQ_KEYBOARDTX)
98 irq_set_chip_and_handler(irq, &iomd_chip_clr,
100 irq_modify_status(irq, clr, set);
101 iomd_set_base_mask(irq, IOMD_BASE + IOMD_IRQSTATA,
106 irq_set_chip_and_handler(irq, &iomd_chip_noclr,
108 irq_modify_status(irq, clr, set);
109 iomd_set_base_mask(irq, IOMD_BASE + IOMD_IRQSTATB,
114 irq_set_chip_and_handler(irq, &iomd_chip_noclr,
116 irq_modify_status(irq, clr, set);
117 iomd_set_base_mask(irq, IOMD_BASE + IOMD_DMASTAT,
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,