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 static void iomd_ack_irq_a(struct irq_data
*d
)
13 unsigned int val
, mask
;
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
;
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
;
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
++) {
134 if (irq
<= 6 || (irq
>= 9 && irq
<= 15))
137 if (irq
== 21 || (irq
>= 16 && irq
<= 19) ||
138 irq
== IRQ_KEYBOARDTX
)
143 irq_set_chip_and_handler(irq
, &iomd_a_chip
,
145 irq_modify_status(irq
, clr
, set
);
149 irq_set_chip_and_handler(irq
, &iomd_b_chip
,
151 irq_modify_status(irq
, clr
, set
);
155 irq_set_chip_and_handler(irq
, &iomd_dma_chip
,
157 irq_modify_status(irq
, clr
, set
);
161 irq_set_chip(irq
, &iomd_fiq_chip
);
162 irq_modify_status(irq
, clr
, set
);