blob: d29cd9b737fc0aaca7522cfed688c85f16ecebbe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/init.h>
2#include <linux/list.h>
Russell Kingfced80c2008-09-06 12:10:45 +01003#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
5#include <asm/mach/irq.h>
6#include <asm/hardware/iomd.h>
7#include <asm/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Lennert Buytenhek9a364da2010-11-29 11:07:20 +01009static void iomd_ack_irq_a(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070010{
11 unsigned int val, mask;
12
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010013 mask = 1 << d->irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 val = iomd_readb(IOMD_IRQMASKA);
15 iomd_writeb(val & ~mask, IOMD_IRQMASKA);
16 iomd_writeb(mask, IOMD_IRQCLRA);
17}
18
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010019static void iomd_mask_irq_a(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020{
21 unsigned int val, mask;
22
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010023 mask = 1 << d->irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 val = iomd_readb(IOMD_IRQMASKA);
25 iomd_writeb(val & ~mask, IOMD_IRQMASKA);
26}
27
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010028static void iomd_unmask_irq_a(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029{
30 unsigned int val, mask;
31
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010032 mask = 1 << d->irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 val = iomd_readb(IOMD_IRQMASKA);
34 iomd_writeb(val | mask, IOMD_IRQMASKA);
35}
36
Russell King10dd5ce2006-11-23 11:41:32 +000037static struct irq_chip iomd_a_chip = {
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010038 .irq_ack = iomd_ack_irq_a,
39 .irq_mask = iomd_mask_irq_a,
40 .irq_unmask = iomd_unmask_irq_a,
Linus Torvalds1da177e2005-04-16 15:20:36 -070041};
42
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010043static void iomd_mask_irq_b(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
45 unsigned int val, mask;
46
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010047 mask = 1 << (d->irq & 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 val = iomd_readb(IOMD_IRQMASKB);
49 iomd_writeb(val & ~mask, IOMD_IRQMASKB);
50}
51
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010052static void iomd_unmask_irq_b(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
54 unsigned int val, mask;
55
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010056 mask = 1 << (d->irq & 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 val = iomd_readb(IOMD_IRQMASKB);
58 iomd_writeb(val | mask, IOMD_IRQMASKB);
59}
60
Russell King10dd5ce2006-11-23 11:41:32 +000061static struct irq_chip iomd_b_chip = {
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010062 .irq_ack = iomd_mask_irq_b,
63 .irq_mask = iomd_mask_irq_b,
64 .irq_unmask = iomd_unmask_irq_b,
Linus Torvalds1da177e2005-04-16 15:20:36 -070065};
66
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010067static void iomd_mask_irq_dma(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
69 unsigned int val, mask;
70
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010071 mask = 1 << (d->irq & 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 val = iomd_readb(IOMD_DMAMASK);
73 iomd_writeb(val & ~mask, IOMD_DMAMASK);
74}
75
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010076static void iomd_unmask_irq_dma(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077{
78 unsigned int val, mask;
79
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010080 mask = 1 << (d->irq & 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 val = iomd_readb(IOMD_DMAMASK);
82 iomd_writeb(val | mask, IOMD_DMAMASK);
83}
84
Russell King10dd5ce2006-11-23 11:41:32 +000085static struct irq_chip iomd_dma_chip = {
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010086 .irq_ack = iomd_mask_irq_dma,
87 .irq_mask = iomd_mask_irq_dma,
88 .irq_unmask = iomd_unmask_irq_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -070089};
90
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010091static void iomd_mask_irq_fiq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
93 unsigned int val, mask;
94
Lennert Buytenhek9a364da2010-11-29 11:07:20 +010095 mask = 1 << (d->irq & 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 val = iomd_readb(IOMD_FIQMASK);
97 iomd_writeb(val & ~mask, IOMD_FIQMASK);
98}
99
Lennert Buytenhek9a364da2010-11-29 11:07:20 +0100100static void iomd_unmask_irq_fiq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101{
102 unsigned int val, mask;
103
Lennert Buytenhek9a364da2010-11-29 11:07:20 +0100104 mask = 1 << (d->irq & 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 val = iomd_readb(IOMD_FIQMASK);
106 iomd_writeb(val | mask, IOMD_FIQMASK);
107}
108
Russell King10dd5ce2006-11-23 11:41:32 +0000109static struct irq_chip iomd_fiq_chip = {
Lennert Buytenhek9a364da2010-11-29 11:07:20 +0100110 .irq_ack = iomd_mask_irq_fiq,
111 .irq_mask = iomd_mask_irq_fiq,
112 .irq_unmask = iomd_unmask_irq_fiq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113};
114
115void __init rpc_init_irq(void)
116{
117 unsigned int irq, flags;
118
119 iomd_writeb(0, IOMD_IRQMASKA);
120 iomd_writeb(0, IOMD_IRQMASKB);
121 iomd_writeb(0, IOMD_FIQMASK);
122 iomd_writeb(0, IOMD_DMAMASK);
123
124 for (irq = 0; irq < NR_IRQS; irq++) {
125 flags = IRQF_VALID;
126
127 if (irq <= 6 || (irq >= 9 && irq <= 15))
128 flags |= IRQF_PROBE;
129
130 if (irq == 21 || (irq >= 16 && irq <= 19) ||
131 irq == IRQ_KEYBOARDTX)
132 flags |= IRQF_NOAUTOEN;
133
134 switch (irq) {
135 case 0 ... 7:
136 set_irq_chip(irq, &iomd_a_chip);
Russell King10dd5ce2006-11-23 11:41:32 +0000137 set_irq_handler(irq, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 set_irq_flags(irq, flags);
139 break;
140
141 case 8 ... 15:
142 set_irq_chip(irq, &iomd_b_chip);
Russell King10dd5ce2006-11-23 11:41:32 +0000143 set_irq_handler(irq, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 set_irq_flags(irq, flags);
145 break;
146
147 case 16 ... 21:
148 set_irq_chip(irq, &iomd_dma_chip);
Russell King10dd5ce2006-11-23 11:41:32 +0000149 set_irq_handler(irq, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 set_irq_flags(irq, flags);
151 break;
152
153 case 64 ... 71:
154 set_irq_chip(irq, &iomd_fiq_chip);
155 set_irq_flags(irq, IRQF_VALID);
156 break;
157 }
158 }
159
160 init_FIQ();
161}
162