2 * arch/mips/ddb5476/nile4.c --
3 * low-level PIC code for NEC Vrc-5476 (Nile 4)
5 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
6 * Sony Software Development Center Europe (SDCE), Brussels
8 * Copyright 2001 MontaVista Software Inc.
9 * Author: jsun@mvista.com or jsun@junsun.net
12 #include <linux/config.h>
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/interrupt.h>
16 #include <linux/ioport.h>
18 #include <asm/addrspace.h>
20 #include <asm/ddb5xxx/ddb5xxx.h>
25 * Interrupt Programming
27 void nile4_map_irq(int nile4_irq
, int cpu_irq
)
37 t
&= ~(7 << (nile4_irq
* 4));
38 t
|= cpu_irq
<< (nile4_irq
* 4);
42 void nile4_map_irq_all(int cpu_irq
)
50 t
= ddb_in32(DDB_INTCTRL
);
53 ddb_out32(DDB_INTCTRL
, t
);
54 t
= ddb_in32(DDB_INTCTRL
+ 4);
57 ddb_out32(DDB_INTCTRL
+ 4, t
);
60 void nile4_enable_irq(unsigned int nile4_irq
)
76 t
|= 8 << (nile4_irq
* 4);
81 void nile4_disable_irq(unsigned int nile4_irq
)
93 t
&= ~(8 << (nile4_irq
* 4));
97 void nile4_disable_irq_all(void)
99 ddb_out32(DDB_INTCTRL
, 0);
100 ddb_out32(DDB_INTCTRL
+ 4, 0);
103 u16
nile4_get_irq_stat(int cpu_irq
)
105 return ddb_in16(DDB_INTSTAT0
+ cpu_irq
* 2);
108 void nile4_enable_irq_output(int cpu_irq
)
112 t
= ddb_in32(DDB_INTSTAT1
+ 4);
113 t
|= 1 << (16 + cpu_irq
);
114 ddb_out32(DDB_INTSTAT1
, t
);
117 void nile4_disable_irq_output(int cpu_irq
)
121 t
= ddb_in32(DDB_INTSTAT1
+ 4);
122 t
&= ~(1 << (16 + cpu_irq
));
123 ddb_out32(DDB_INTSTAT1
, t
);
126 void nile4_set_pci_irq_polarity(int pci_irq
, int high
)
130 t
= ddb_in32(DDB_INTPPES
);
132 t
&= ~(1 << (pci_irq
* 2));
134 t
|= 1 << (pci_irq
* 2);
135 ddb_out32(DDB_INTPPES
, t
);
138 void nile4_set_pci_irq_level_or_edge(int pci_irq
, int level
)
142 t
= ddb_in32(DDB_INTPPES
);
144 t
|= 2 << (pci_irq
* 2);
146 t
&= ~(2 << (pci_irq
* 2));
147 ddb_out32(DDB_INTPPES
, t
);
150 void nile4_clear_irq(int nile4_irq
)
153 ddb_out32(DDB_INTCLR
, 1 << nile4_irq
);
156 void nile4_clear_irq_mask(u32 mask
)
158 ddb_out32(DDB_INTCLR
, mask
);
161 u8
nile4_i8259_iack(void)
166 /* Set window 0 for interrupt acknowledge */
167 reg
= ddb_in32(DDB_PCIINIT0
);
169 ddb_set_pmr(DDB_PCIINIT0
, DDB_PCICMD_IACK
, 0, DDB_PCI_ACCESS_32
);
170 irq
= *(volatile u8
*) KSEG1ADDR(DDB_PCI_IACK_BASE
);
171 /* restore window 0 for PCI I/O space */
172 // ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, DDB_PCI_ACCESS_32);
173 ddb_out32(DDB_PCIINIT0
, reg
);
175 /* i8269.c set the base vector to be 0x0 */
179 static unsigned int nile4_irq_startup(unsigned int irq
) {
181 nile4_enable_irq(irq
);
186 static void nile4_ack_irq(unsigned int irq
) {
190 nile4_clear_irq(irq
);
192 nile4_disable_irq(irq
);
197 static void nile4_irq_end(unsigned int irq
) {
200 if(!(irq_desc
[irq
].status
& (IRQ_DISABLED
| IRQ_INPROGRESS
))) {
202 nile4_enable_irq(irq
);
209 #define nile4_irq_shutdown nile4_disable_irq
211 static hw_irq_controller nile4_irq_controller
= {
213 .startup
= nile4_irq_startup
,
214 .shutdown
= nile4_irq_shutdown
,
215 .enable
= nile4_enable_irq
,
216 .disable
= nile4_disable_irq
,
217 .ack
= nile4_ack_irq
,
218 .end
= nile4_irq_end
,
221 void nile4_irq_setup(u32 base
) {
227 /* Map all interrupts to CPU int #0 */
228 nile4_map_irq_all(0);
230 /* PCI INTA#-E# must be level triggered */
231 nile4_set_pci_irq_level_or_edge(0, 1);
232 nile4_set_pci_irq_level_or_edge(1, 1);
233 nile4_set_pci_irq_level_or_edge(2, 1);
234 nile4_set_pci_irq_level_or_edge(3, 1);
235 nile4_set_pci_irq_level_or_edge(4, 1);
237 /* PCI INTA#-D# must be active low, INTE# must be active high */
238 nile4_set_pci_irq_polarity(0, 0);
239 nile4_set_pci_irq_polarity(1, 0);
240 nile4_set_pci_irq_polarity(2, 0);
241 nile4_set_pci_irq_polarity(3, 0);
242 nile4_set_pci_irq_polarity(4, 1);
245 for (i
= 0; i
< 16; i
++) {
247 nile4_disable_irq(i
);
250 /* Enable CPU int #0 */
251 nile4_enable_irq_output(0);
253 for (i
= base
; i
< base
+ NUM_NILE4_INTERRUPTS
; i
++) {
254 irq_desc
[i
].status
= IRQ_DISABLED
;
255 irq_desc
[i
].action
= NULL
;
256 irq_desc
[i
].depth
= 1;
257 irq_desc
[i
].handler
= &nile4_irq_controller
;
261 #if defined(CONFIG_RUNTIME_DEBUG)
262 void nile4_dump_irq_status(void)
265 CPUSTAT = %p:%p\n", (void *) ddb_in32(DDB_CPUSTAT
+ 4),
266 (void *) ddb_in32(DDB_CPUSTAT
));
268 INTCTRL = %p:%p\n", (void *) ddb_in32(DDB_INTCTRL
+ 4),
269 (void *) ddb_in32(DDB_INTCTRL
));
271 "INTSTAT0 = %p:%p\n",
272 (void *) ddb_in32(DDB_INTSTAT0
+ 4),
273 (void *) ddb_in32(DDB_INTSTAT0
));
275 "INTSTAT1 = %p:%p\n",
276 (void *) ddb_in32(DDB_INTSTAT1
+ 4),
277 (void *) ddb_in32(DDB_INTSTAT1
));
279 "INTCLR = %p:%p\n", (void *) ddb_in32(DDB_INTCLR
+ 4),
280 (void *) ddb_in32(DDB_INTCLR
));
282 "INTPPES = %p:%p\n", (void *) ddb_in32(DDB_INTPPES
+ 4),
283 (void *) ddb_in32(DDB_INTPPES
));