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>
16 #include <asm/addrspace.h>
18 #include <asm/ddb5xxx/ddb5xxx.h>
22 * Interrupt Programming
24 void nile4_map_irq(int nile4_irq
, int cpu_irq
)
34 t
&= ~(7 << (nile4_irq
* 4));
35 t
|= cpu_irq
<< (nile4_irq
* 4);
39 void nile4_map_irq_all(int cpu_irq
)
47 t
= ddb_in32(DDB_INTCTRL
);
50 ddb_out32(DDB_INTCTRL
, t
);
51 t
= ddb_in32(DDB_INTCTRL
+ 4);
54 ddb_out32(DDB_INTCTRL
+ 4, t
);
57 void nile4_enable_irq(int nile4_irq
)
67 t
|= 8 << (nile4_irq
* 4);
71 void nile4_disable_irq(int nile4_irq
)
81 t
&= ~(8 << (nile4_irq
* 4));
85 void nile4_disable_irq_all(void)
87 ddb_out32(DDB_INTCTRL
, 0);
88 ddb_out32(DDB_INTCTRL
+ 4, 0);
91 u16
nile4_get_irq_stat(int cpu_irq
)
93 return ddb_in16(DDB_INTSTAT0
+ cpu_irq
* 2);
96 void nile4_enable_irq_output(int cpu_irq
)
100 t
= ddb_in32(DDB_INTSTAT1
+ 4);
101 t
|= 1 << (16 + cpu_irq
);
102 ddb_out32(DDB_INTSTAT1
, t
);
105 void nile4_disable_irq_output(int cpu_irq
)
109 t
= ddb_in32(DDB_INTSTAT1
+ 4);
110 t
&= ~(1 << (16 + cpu_irq
));
111 ddb_out32(DDB_INTSTAT1
, t
);
114 void nile4_set_pci_irq_polarity(int pci_irq
, int high
)
118 t
= ddb_in32(DDB_INTPPES
);
120 t
&= ~(1 << (pci_irq
* 2));
122 t
|= 1 << (pci_irq
* 2);
123 ddb_out32(DDB_INTPPES
, t
);
126 void nile4_set_pci_irq_level_or_edge(int pci_irq
, int level
)
130 t
= ddb_in32(DDB_INTPPES
);
132 t
|= 2 << (pci_irq
* 2);
134 t
&= ~(2 << (pci_irq
* 2));
135 ddb_out32(DDB_INTPPES
, t
);
138 void nile4_clear_irq(int nile4_irq
)
140 ddb_out32(DDB_INTCLR
, 1 << nile4_irq
);
143 void nile4_clear_irq_mask(u32 mask
)
145 ddb_out32(DDB_INTCLR
, mask
);
148 u8
nile4_i8259_iack(void)
153 /* Set window 0 for interrupt acknowledge */
154 reg
= ddb_in32(DDB_PCIINIT0
);
156 ddb_set_pmr(DDB_PCIINIT0
, DDB_PCICMD_IACK
, 0, DDB_PCI_ACCESS_32
);
157 irq
= *(volatile u8
*) KSEG1ADDR(DDB_PCI_IACK_BASE
);
158 /* restore window 0 for PCI I/O space */
159 // ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, DDB_PCI_ACCESS_32);
160 ddb_out32(DDB_PCIINIT0
, reg
);
162 /* i8269.c set the base vector to be 0x0 */
163 return irq
+ I8259_IRQ_BASE
;
166 #if defined(CONFIG_RUNTIME_DEBUG)
167 void nile4_dump_irq_status(void)
170 CPUSTAT = %p:%p\n", (void *) ddb_in32(DDB_CPUSTAT
+ 4),
171 (void *) ddb_in32(DDB_CPUSTAT
));
173 INTCTRL = %p:%p\n", (void *) ddb_in32(DDB_INTCTRL
+ 4),
174 (void *) ddb_in32(DDB_INTCTRL
));
176 "INTSTAT0 = %p:%p\n",
177 (void *) ddb_in32(DDB_INTSTAT0
+ 4),
178 (void *) ddb_in32(DDB_INTSTAT0
));
180 "INTSTAT1 = %p:%p\n",
181 (void *) ddb_in32(DDB_INTSTAT1
+ 4),
182 (void *) ddb_in32(DDB_INTSTAT1
));
184 "INTCLR = %p:%p\n", (void *) ddb_in32(DDB_INTCLR
+ 4),
185 (void *) ddb_in32(DDB_INTCLR
));
187 "INTPPES = %p:%p\n", (void *) ddb_in32(DDB_INTPPES
+ 4),
188 (void *) ddb_in32(DDB_INTPPES
));