aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2007-08-02 10:36:02 -0400
committerRalf Baechle <ralf@linux-mips.org>2007-08-26 21:16:53 -0400
commitc87abd75b35e8f991ff8ff1510d6fb62612c61fa (patch)
treede68c4446c35337c47c17253d769bfeee92f80b3 /arch/mips
parent8420fd00e88ef4f6082866aa151bc753b006b3b6 (diff)
[MIPS] Cleanup TX39/TX49 irq code
Cleanup jmr3927, tx4927 and tx4938 irq codes, using common IRQ_CPU, I8259 and IRQ_TXX9 irq routines. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/Kconfig8
-rw-r--r--arch/mips/jmr3927/rbhma3100/irq.c48
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c13
-rw-r--r--arch/mips/tx4927/common/tx4927_irq.c395
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c171
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c11
-rw-r--r--arch/mips/tx4938/common/irq.c279
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/irq.c2
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/setup.c9
9 files changed, 41 insertions, 895 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index cec0d8411269..4b02d8acc15b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -528,6 +528,7 @@ config TOSHIBA_JMR3927
528 select DMA_NONCOHERENT 528 select DMA_NONCOHERENT
529 select HW_HAS_PCI 529 select HW_HAS_PCI
530 select MIPS_TX3927 530 select MIPS_TX3927
531 select IRQ_TXX9
531 select SWAP_IO_SPACE 532 select SWAP_IO_SPACE
532 select SYS_HAS_CPU_TX39XX 533 select SYS_HAS_CPU_TX39XX
533 select SYS_SUPPORTS_32BIT_KERNEL 534 select SYS_SUPPORTS_32BIT_KERNEL
@@ -540,7 +541,9 @@ config TOSHIBA_RBTX4927
540 select DMA_NONCOHERENT 541 select DMA_NONCOHERENT
541 select HAS_TXX9_SERIAL 542 select HAS_TXX9_SERIAL
542 select HW_HAS_PCI 543 select HW_HAS_PCI
543 select I8259 544 select IRQ_CPU
545 select IRQ_TXX9
546 select I8259 if TOSHIBA_FPCIB0
544 select SWAP_IO_SPACE 547 select SWAP_IO_SPACE
545 select SYS_HAS_CPU_TX49XX 548 select SYS_HAS_CPU_TX49XX
546 select SYS_SUPPORTS_32BIT_KERNEL 549 select SYS_SUPPORTS_32BIT_KERNEL
@@ -560,7 +563,8 @@ config TOSHIBA_RBTX4938
560 select GENERIC_ISA_DMA 563 select GENERIC_ISA_DMA
561 select HAS_TXX9_SERIAL 564 select HAS_TXX9_SERIAL
562 select HW_HAS_PCI 565 select HW_HAS_PCI
563 select I8259 566 select IRQ_CPU
567 select IRQ_TXX9
564 select SWAP_IO_SPACE 568 select SWAP_IO_SPACE
565 select SYS_HAS_CPU_TX49XX 569 select SYS_HAS_CPU_TX49XX
566 select SYS_SUPPORTS_32BIT_KERNEL 570 select SYS_SUPPORTS_32BIT_KERNEL
diff --git a/arch/mips/jmr3927/rbhma3100/irq.c b/arch/mips/jmr3927/rbhma3100/irq.c
index 1187b44a3dd4..d9efe692e551 100644
--- a/arch/mips/jmr3927/rbhma3100/irq.c
+++ b/arch/mips/jmr3927/rbhma3100/irq.c
@@ -45,9 +45,6 @@
45#error JMR3927_IRQ_END > NR_IRQS 45#error JMR3927_IRQ_END > NR_IRQS
46#endif 46#endif
47 47
48#define irc_dlevel 0
49#define irc_elevel 1
50
51static unsigned char irc_level[TX3927_NUM_IR] = { 48static unsigned char irc_level[TX3927_NUM_IR] = {
52 5, 5, 5, 5, 5, 5, /* INT[5:0] */ 49 5, 5, 5, 5, 5, 5, /* INT[5:0] */
53 7, 7, /* SIO */ 50 7, 7, /* SIO */
@@ -80,34 +77,6 @@ static void unmask_irq_ioc(unsigned int irq)
80 (void)jmr3927_ioc_reg_in(JMR3927_IOC_REV_ADDR); 77 (void)jmr3927_ioc_reg_in(JMR3927_IOC_REV_ADDR);
81} 78}
82 79
83static void mask_irq_irc(unsigned int irq)
84{
85 unsigned int irq_nr = irq - JMR3927_IRQ_IRC;
86 volatile unsigned long *ilrp = &tx3927_ircptr->ilr[irq_nr / 2];
87 if (irq_nr & 1)
88 *ilrp = (*ilrp & 0x00ff) | (irc_dlevel << 8);
89 else
90 *ilrp = (*ilrp & 0xff00) | irc_dlevel;
91 /* update IRCSR */
92 tx3927_ircptr->imr = 0;
93 tx3927_ircptr->imr = irc_elevel;
94 /* flush write buffer */
95 (void)tx3927_ircptr->ssr;
96}
97
98static void unmask_irq_irc(unsigned int irq)
99{
100 unsigned int irq_nr = irq - JMR3927_IRQ_IRC;
101 volatile unsigned long *ilrp = &tx3927_ircptr->ilr[irq_nr / 2];
102 if (irq_nr & 1)
103 *ilrp = (*ilrp & 0x00ff) | (irc_level[irq_nr] << 8);
104 else
105 *ilrp = (*ilrp & 0xff00) | irc_level[irq_nr];
106 /* update IRCSR */
107 tx3927_ircptr->imr = 0;
108 tx3927_ircptr->imr = irc_elevel;
109}
110
111asmlinkage void plat_irq_dispatch(void) 80asmlinkage void plat_irq_dispatch(void)
112{ 81{
113 unsigned long cp0_cause = read_c0_cause(); 82 unsigned long cp0_cause = read_c0_cause();
@@ -168,10 +137,6 @@ void __init arch_init_irq(void)
168 /* clear PCI Reset interrupts */ 137 /* clear PCI Reset interrupts */
169 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR); 138 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
170 139
171 /* enable interrupt control */
172 tx3927_ircptr->cer = TX3927_IRCER_ICE;
173 tx3927_ircptr->imr = irc_elevel;
174
175 jmr3927_irq_init(); 140 jmr3927_irq_init();
176 141
177 /* setup IOC interrupt 1 (PCI, MODEM) */ 142 /* setup IOC interrupt 1 (PCI, MODEM) */
@@ -193,20 +158,13 @@ static struct irq_chip jmr3927_irq_ioc = {
193 .unmask = unmask_irq_ioc, 158 .unmask = unmask_irq_ioc,
194}; 159};
195 160
196static struct irq_chip jmr3927_irq_irc = {
197 .name = "jmr3927_irc",
198 .ack = mask_irq_irc,
199 .mask = mask_irq_irc,
200 .mask_ack = mask_irq_irc,
201 .unmask = unmask_irq_irc,
202};
203
204static void __init jmr3927_irq_init(void) 161static void __init jmr3927_irq_init(void)
205{ 162{
206 u32 i; 163 u32 i;
207 164
208 for (i = JMR3927_IRQ_IRC; i < JMR3927_IRQ_IRC + JMR3927_NR_IRQ_IRC; i++) 165 txx9_irq_init(TX3927_IRC_REG);
209 set_irq_chip_and_handler(i, &jmr3927_irq_irc, handle_level_irq); 166 for (i = 0; i < TXx9_MAX_IR; i++)
167 txx9_irq_set_pri(i, irc_level[i]);
210 for (i = JMR3927_IRQ_IOC; i < JMR3927_IRQ_IOC + JMR3927_NR_IRQ_IOC; i++) 168 for (i = JMR3927_IRQ_IOC; i < JMR3927_IRQ_IOC + JMR3927_NR_IRQ_IOC; i++)
211 set_irq_chip_and_handler(i, &jmr3927_irq_ioc, handle_level_irq); 169 set_irq_chip_and_handler(i, &jmr3927_irq_ioc, handle_level_irq);
212} 170}
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
index 8303001516d2..fde56e86c2ab 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -290,19 +290,6 @@ static void __init tx3927_setup(void)
290 tx3927_ccfgptr->crir, 290 tx3927_ccfgptr->crir,
291 tx3927_ccfgptr->ccfg, tx3927_ccfgptr->pcfg); 291 tx3927_ccfgptr->ccfg, tx3927_ccfgptr->pcfg);
292 292
293 /* IRC */
294 /* disable interrupt control */
295 tx3927_ircptr->cer = 0;
296 /* mask all IRC interrupts */
297 tx3927_ircptr->imr = 0;
298 for (i = 0; i < TX3927_NUM_IR / 2; i++) {
299 tx3927_ircptr->ilr[i] = 0;
300 }
301 /* setup IRC interrupt mode (Low Active) */
302 for (i = 0; i < TX3927_NUM_IR / 8; i++) {
303 tx3927_ircptr->cr[i] = 0;
304 }
305
306 /* TMR */ 293 /* TMR */
307 /* disable all timers */ 294 /* disable all timers */
308 for (i = 0; i < TX3927_NR_TMR; i++) { 295 for (i = 0; i < TX3927_NR_TMR; i++) {
diff --git a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
index 00b0b975f349..0aabd57fdad2 100644
--- a/arch/mips/tx4927/common/tx4927_irq.c
+++ b/arch/mips/tx4927/common/tx4927_irq.c
@@ -23,398 +23,20 @@
23 * with this program; if not, write to the Free Software Foundation, Inc., 23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26#include <linux/errno.h>
27#include <linux/init.h> 26#include <linux/init.h>
28#include <linux/kernel_stat.h>
29#include <linux/module.h>
30#include <linux/signal.h>
31#include <linux/sched.h>
32#include <linux/types.h>
33#include <linux/interrupt.h> 27#include <linux/interrupt.h>
34#include <linux/ioport.h> 28#include <asm/irq_cpu.h>
35#include <linux/timex.h>
36#include <linux/slab.h>
37#include <linux/random.h>
38#include <linux/irq.h>
39#include <linux/bitops.h>
40#include <asm/bootinfo.h>
41#include <asm/io.h>
42#include <asm/irq.h>
43#include <asm/mipsregs.h> 29#include <asm/mipsregs.h>
44#include <asm/system.h>
45#include <asm/tx4927/tx4927.h> 30#include <asm/tx4927/tx4927.h>
46#ifdef CONFIG_TOSHIBA_RBTX4927 31#ifdef CONFIG_TOSHIBA_RBTX4927
47#include <asm/tx4927/toshiba_rbtx4927.h> 32#include <asm/tx4927/toshiba_rbtx4927.h>
48#endif 33#endif
49 34
50/*
51 * DEBUG
52 */
53
54#undef TX4927_IRQ_DEBUG
55
56#ifdef TX4927_IRQ_DEBUG
57#define TX4927_IRQ_NONE 0x00000000
58
59#define TX4927_IRQ_INFO ( 1 << 0 )
60#define TX4927_IRQ_WARN ( 1 << 1 )
61#define TX4927_IRQ_EROR ( 1 << 2 )
62
63#define TX4927_IRQ_INIT ( 1 << 5 )
64#define TX4927_IRQ_NEST1 ( 1 << 6 )
65#define TX4927_IRQ_NEST2 ( 1 << 7 )
66#define TX4927_IRQ_NEST3 ( 1 << 8 )
67#define TX4927_IRQ_NEST4 ( 1 << 9 )
68
69#define TX4927_IRQ_CP0_INIT ( 1 << 10 )
70#define TX4927_IRQ_CP0_ENABLE ( 1 << 13 )
71#define TX4927_IRQ_CP0_DISABLE ( 1 << 14 )
72
73#define TX4927_IRQ_PIC_INIT ( 1 << 20 )
74#define TX4927_IRQ_PIC_ENABLE ( 1 << 23 )
75#define TX4927_IRQ_PIC_DISABLE ( 1 << 24 )
76
77#define TX4927_IRQ_ALL 0xffffffff
78#endif
79
80#ifdef TX4927_IRQ_DEBUG
81static const u32 tx4927_irq_debug_flag = (TX4927_IRQ_NONE
82 | TX4927_IRQ_INFO
83 | TX4927_IRQ_WARN | TX4927_IRQ_EROR
84// | TX4927_IRQ_CP0_INIT
85// | TX4927_IRQ_CP0_ENABLE
86// | TX4927_IRQ_CP0_ENDIRQ
87// | TX4927_IRQ_PIC_INIT
88// | TX4927_IRQ_PIC_ENABLE
89// | TX4927_IRQ_PIC_DISABLE
90// | TX4927_IRQ_INIT
91// | TX4927_IRQ_NEST1
92// | TX4927_IRQ_NEST2
93// | TX4927_IRQ_NEST3
94// | TX4927_IRQ_NEST4
95 );
96#endif
97
98#ifdef TX4927_IRQ_DEBUG
99#define TX4927_IRQ_DPRINTK(flag,str...) \
100 if ( (tx4927_irq_debug_flag) & (flag) ) \
101 { \
102 char tmp[100]; \
103 sprintf( tmp, str ); \
104 printk( "%s(%s:%u)::%s", __FUNCTION__, __FILE__, __LINE__, tmp ); \
105 }
106#else
107#define TX4927_IRQ_DPRINTK(flag,str...)
108#endif
109
110/*
111 * Forwad definitions for all pic's
112 */
113
114static void tx4927_irq_cp0_enable(unsigned int irq);
115static void tx4927_irq_cp0_disable(unsigned int irq);
116
117static void tx4927_irq_pic_enable(unsigned int irq);
118static void tx4927_irq_pic_disable(unsigned int irq);
119
120/*
121 * Kernel structs for all pic's
122 */
123
124#define TX4927_CP0_NAME "TX4927-CP0"
125static struct irq_chip tx4927_irq_cp0_type = {
126 .name = TX4927_CP0_NAME,
127 .ack = tx4927_irq_cp0_disable,
128 .mask = tx4927_irq_cp0_disable,
129 .mask_ack = tx4927_irq_cp0_disable,
130 .unmask = tx4927_irq_cp0_enable,
131};
132
133#define TX4927_PIC_NAME "TX4927-PIC"
134static struct irq_chip tx4927_irq_pic_type = {
135 .name = TX4927_PIC_NAME,
136 .ack = tx4927_irq_pic_disable,
137 .mask = tx4927_irq_pic_disable,
138 .mask_ack = tx4927_irq_pic_disable,
139 .unmask = tx4927_irq_pic_enable,
140};
141
142#define TX4927_PIC_ACTION(s) { no_action, 0, CPU_MASK_NONE, s, NULL, NULL }
143static struct irqaction tx4927_irq_pic_action =
144TX4927_PIC_ACTION(TX4927_PIC_NAME);
145
146#define CCP0_STATUS 12
147#define CCP0_CAUSE 13
148
149/*
150 * Functions for cp0
151 */
152
153#define tx4927_irq_cp0_mask(irq) ( 1 << ( irq-TX4927_IRQ_CP0_BEG+8 ) )
154
155static void
156tx4927_irq_cp0_modify(unsigned cp0_reg, unsigned clr_bits, unsigned set_bits)
157{
158 unsigned long val = 0;
159
160 switch (cp0_reg) {
161 case CCP0_STATUS:
162 val = read_c0_status();
163 break;
164
165 case CCP0_CAUSE:
166 val = read_c0_cause();
167 break;
168
169 }
170
171 val &= (~clr_bits);
172 val |= (set_bits);
173
174 switch (cp0_reg) {
175 case CCP0_STATUS:{
176 write_c0_status(val);
177 break;
178 }
179 case CCP0_CAUSE:{
180 write_c0_cause(val);
181 break;
182 }
183 }
184}
185
186static void __init tx4927_irq_cp0_init(void)
187{
188 int i;
189
190 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_INIT, "beg=%d end=%d\n",
191 TX4927_IRQ_CP0_BEG, TX4927_IRQ_CP0_END);
192
193 for (i = TX4927_IRQ_CP0_BEG; i <= TX4927_IRQ_CP0_END; i++)
194 set_irq_chip_and_handler(i, &tx4927_irq_cp0_type,
195 handle_level_irq);
196}
197
198static void tx4927_irq_cp0_enable(unsigned int irq)
199{
200 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_ENABLE, "irq=%d \n", irq);
201
202 tx4927_irq_cp0_modify(CCP0_STATUS, 0, tx4927_irq_cp0_mask(irq));
203}
204
205static void tx4927_irq_cp0_disable(unsigned int irq)
206{
207 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_DISABLE, "irq=%d \n", irq);
208
209 tx4927_irq_cp0_modify(CCP0_STATUS, tx4927_irq_cp0_mask(irq), 0);
210}
211
212/*
213 * Functions for pic
214 */
215u32 tx4927_irq_pic_addr(int irq)
216{
217 /* MVMCP -- need to formulize this */
218 irq -= TX4927_IRQ_PIC_BEG;
219 switch (irq) {
220 case 17:
221 case 16:
222 case 1:
223 case 0:
224 return (0xff1ff610);
225
226 case 19:
227 case 18:
228 case 3:
229 case 2:
230 return (0xff1ff614);
231
232 case 21:
233 case 20:
234 case 5:
235 case 4:
236 return (0xff1ff618);
237
238 case 23:
239 case 22:
240 case 7:
241 case 6:
242 return (0xff1ff61c);
243
244 case 25:
245 case 24:
246 case 9:
247 case 8:
248 return (0xff1ff620);
249
250 case 27:
251 case 26:
252 case 11:
253 case 10:
254 return (0xff1ff624);
255
256 case 29:
257 case 28:
258 case 13:
259 case 12:
260 return (0xff1ff628);
261
262 case 31:
263 case 30:
264 case 15:
265 case 14:
266 return (0xff1ff62c);
267
268 }
269 return (0);
270}
271
272u32 tx4927_irq_pic_mask(int irq)
273{
274 /* MVMCP -- need to formulize this */
275 irq -= TX4927_IRQ_PIC_BEG;
276 switch (irq) {
277 case 31:
278 case 29:
279 case 27:
280 case 25:
281 case 23:
282 case 21:
283 case 19:
284 case 17:{
285 return (0x07000000);
286 }
287 case 30:
288 case 28:
289 case 26:
290 case 24:
291 case 22:
292 case 20:
293 case 18:
294 case 16:{
295 return (0x00070000);
296 }
297 case 15:
298 case 13:
299 case 11:
300 case 9:
301 case 7:
302 case 5:
303 case 3:
304 case 1:{
305 return (0x00000700);
306 }
307 case 14:
308 case 12:
309 case 10:
310 case 8:
311 case 6:
312 case 4:
313 case 2:
314 case 0:{
315 return (0x00000007);
316 }
317 }
318 return (0x00000000);
319}
320
321static void tx4927_irq_pic_modify(unsigned pic_reg, unsigned clr_bits,
322 unsigned set_bits)
323{
324 unsigned long val = 0;
325
326 val = TX4927_RD(pic_reg);
327 val &= (~clr_bits);
328 val |= (set_bits);
329 TX4927_WR(pic_reg, val);
330}
331
332static void __init tx4927_irq_pic_init(void)
333{
334 int i;
335
336 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_INIT, "beg=%d end=%d\n",
337 TX4927_IRQ_PIC_BEG, TX4927_IRQ_PIC_END);
338
339 for (i = TX4927_IRQ_PIC_BEG; i <= TX4927_IRQ_PIC_END; i++)
340 set_irq_chip_and_handler(i, &tx4927_irq_pic_type,
341 handle_level_irq);
342
343 setup_irq(TX4927_IRQ_NEST_PIC_ON_CP0, &tx4927_irq_pic_action);
344
345 TX4927_WR(0xff1ff640, 0x6); /* irq level mask -- only accept hightest */
346 TX4927_WR(0xff1ff600, TX4927_RD(0xff1ff600) | 0x1); /* irq enable */
347}
348
349static void tx4927_irq_pic_enable(unsigned int irq)
350{
351 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_ENABLE, "irq=%d\n", irq);
352
353 tx4927_irq_pic_modify(tx4927_irq_pic_addr(irq), 0,
354 tx4927_irq_pic_mask(irq));
355}
356
357static void tx4927_irq_pic_disable(unsigned int irq)
358{
359 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_DISABLE, "irq=%d\n", irq);
360
361 tx4927_irq_pic_modify(tx4927_irq_pic_addr(irq),
362 tx4927_irq_pic_mask(irq), 0);
363}
364
365/*
366 * Main init functions
367 */
368void __init tx4927_irq_init(void) 35void __init tx4927_irq_init(void)
369{ 36{
370 TX4927_IRQ_DPRINTK(TX4927_IRQ_INIT, "-\n"); 37 mips_cpu_irq_init();
371 38 txx9_irq_init(TX4927_IRC_REG);
372 TX4927_IRQ_DPRINTK(TX4927_IRQ_INIT, "=Calling tx4927_irq_cp0_init()\n"); 39 set_irq_chained_handler(TX4927_IRQ_NEST_PIC_ON_CP0, handle_simple_irq);
373 tx4927_irq_cp0_init();
374
375 TX4927_IRQ_DPRINTK(TX4927_IRQ_INIT, "=Calling tx4927_irq_pic_init()\n");
376 tx4927_irq_pic_init();
377
378 TX4927_IRQ_DPRINTK(TX4927_IRQ_INIT, "+\n");
379}
380
381static int tx4927_irq_nested(void)
382{
383 int sw_irq = 0;
384 u32 level2;
385
386 TX4927_IRQ_DPRINTK(TX4927_IRQ_NEST1, "-\n");
387
388 level2 = TX4927_RD(0xff1ff6a0);
389 TX4927_IRQ_DPRINTK(TX4927_IRQ_NEST2, "=level2a=0x%x\n", level2);
390
391 if ((level2 & 0x10000) == 0) {
392 level2 &= 0x1f;
393 TX4927_IRQ_DPRINTK(TX4927_IRQ_NEST3, "=level2b=0x%x\n", level2);
394
395 sw_irq = TX4927_IRQ_PIC_BEG + level2;
396 TX4927_IRQ_DPRINTK(TX4927_IRQ_NEST3, "=sw_irq=%d\n", sw_irq);
397
398 if (sw_irq == 27) {
399 TX4927_IRQ_DPRINTK(TX4927_IRQ_NEST4, "=irq-%d\n",
400 sw_irq);
401
402#ifdef CONFIG_TOSHIBA_RBTX4927
403 {
404 sw_irq = toshiba_rbtx4927_irq_nested(sw_irq);
405 }
406#endif
407
408 TX4927_IRQ_DPRINTK(TX4927_IRQ_NEST4, "=irq+%d\n",
409 sw_irq);
410 }
411 }
412
413 TX4927_IRQ_DPRINTK(TX4927_IRQ_NEST2, "=sw_irq=%d\n", sw_irq);
414
415 TX4927_IRQ_DPRINTK(TX4927_IRQ_NEST1, "+\n");
416
417 return (sw_irq);
418} 40}
419 41
420asmlinkage void plat_irq_dispatch(void) 42asmlinkage void plat_irq_dispatch(void)
@@ -424,9 +46,12 @@ asmlinkage void plat_irq_dispatch(void)
424 if (pending & STATUSF_IP7) /* cpu timer */ 46 if (pending & STATUSF_IP7) /* cpu timer */
425 do_IRQ(TX4927_IRQ_CPU_TIMER); 47 do_IRQ(TX4927_IRQ_CPU_TIMER);
426 else if (pending & STATUSF_IP2) { /* tx4927 pic */ 48 else if (pending & STATUSF_IP2) { /* tx4927 pic */
427 unsigned int irq = tx4927_irq_nested(); 49 int irq = txx9_irq();
428 50#ifdef CONFIG_TOSHIBA_RBTX4927
429 if (unlikely(irq == 0)) { 51 if (irq == TX4927_IRQ_NEST_EXT_ON_PIC)
52 irq = toshiba_rbtx4927_irq_nested(irq);
53#endif
54 if (unlikely(irq < 0)) {
430 spurious_interrupt(); 55 spurious_interrupt();
431 return; 56 return;
432 } 57 }
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
index e265fcd31b60..9607ad5e734a 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
@@ -133,6 +133,7 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
133#include <linux/bootmem.h> 133#include <linux/bootmem.h>
134#include <linux/blkdev.h> 134#include <linux/blkdev.h>
135#ifdef CONFIG_TOSHIBA_FPCIB0 135#ifdef CONFIG_TOSHIBA_FPCIB0
136#include <asm/i8259.h>
136#include <asm/tx4927/smsc_fdc37m81x.h> 137#include <asm/tx4927/smsc_fdc37m81x.h>
137#endif 138#endif
138#include <asm/tx4927/toshiba_rbtx4927.h> 139#include <asm/tx4927/toshiba_rbtx4927.h>
@@ -151,11 +152,6 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
151#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 ) 152#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 )
152#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 ) 153#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 )
153 154
154#define TOSHIBA_RBTX4927_IRQ_ISA_INIT ( 1 << 20 )
155#define TOSHIBA_RBTX4927_IRQ_ISA_ENABLE ( 1 << 23 )
156#define TOSHIBA_RBTX4927_IRQ_ISA_DISABLE ( 1 << 24 )
157#define TOSHIBA_RBTX4927_IRQ_ISA_MASK ( 1 << 25 )
158
159#define TOSHIBA_RBTX4927_SETUP_ALL 0xffffffff 155#define TOSHIBA_RBTX4927_SETUP_ALL 0xffffffff
160#endif 156#endif
161 157
@@ -167,10 +163,6 @@ static const u32 toshiba_rbtx4927_irq_debug_flag =
167// | TOSHIBA_RBTX4927_IRQ_IOC_INIT 163// | TOSHIBA_RBTX4927_IRQ_IOC_INIT
168// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE 164// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE
169// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE 165// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE
170// | TOSHIBA_RBTX4927_IRQ_ISA_INIT
171// | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE
172// | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE
173// | TOSHIBA_RBTX4927_IRQ_ISA_MASK
174 ); 166 );
175#endif 167#endif
176 168
@@ -196,33 +188,14 @@ static const u32 toshiba_rbtx4927_irq_debug_flag =
196#define TOSHIBA_RBTX4927_IRQ_IOC_BEG ((TX4927_IRQ_PIC_END+1)+TOSHIBA_RBTX4927_IRQ_IOC_RAW_BEG) /* 56 */ 188#define TOSHIBA_RBTX4927_IRQ_IOC_BEG ((TX4927_IRQ_PIC_END+1)+TOSHIBA_RBTX4927_IRQ_IOC_RAW_BEG) /* 56 */
197#define TOSHIBA_RBTX4927_IRQ_IOC_END ((TX4927_IRQ_PIC_END+1)+TOSHIBA_RBTX4927_IRQ_IOC_RAW_END) /* 63 */ 189#define TOSHIBA_RBTX4927_IRQ_IOC_END ((TX4927_IRQ_PIC_END+1)+TOSHIBA_RBTX4927_IRQ_IOC_RAW_END) /* 63 */
198 190
199
200#define TOSHIBA_RBTX4927_IRQ_ISA_BEG MI8259_IRQ_ISA_BEG
201#define TOSHIBA_RBTX4927_IRQ_ISA_END MI8259_IRQ_ISA_END
202#define TOSHIBA_RBTX4927_IRQ_ISA_MID ((TOSHIBA_RBTX4927_IRQ_ISA_BEG+TOSHIBA_RBTX4927_IRQ_ISA_END+1)/2)
203
204
205#define TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC TX4927_IRQ_NEST_EXT_ON_PIC 191#define TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC TX4927_IRQ_NEST_EXT_ON_PIC
206#define TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC (TOSHIBA_RBTX4927_IRQ_IOC_BEG+2) 192#define TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC (TOSHIBA_RBTX4927_IRQ_IOC_BEG+2)
207#define TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_ISA (TOSHIBA_RBTX4927_IRQ_ISA_BEG+2)
208 193
209extern int tx4927_using_backplane; 194extern int tx4927_using_backplane;
210 195
211#ifdef CONFIG_TOSHIBA_FPCIB0
212extern void enable_8259A_irq(unsigned int irq);
213extern void disable_8259A_irq(unsigned int irq);
214extern void mask_and_ack_8259A(unsigned int irq);
215#endif
216
217static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq); 196static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq);
218static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq); 197static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq);
219 198
220#ifdef CONFIG_TOSHIBA_FPCIB0
221static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq);
222static void toshiba_rbtx4927_irq_isa_disable(unsigned int irq);
223static void toshiba_rbtx4927_irq_isa_mask_and_ack(unsigned int irq);
224#endif
225
226#define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC" 199#define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC"
227static struct irq_chip toshiba_rbtx4927_irq_ioc_type = { 200static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
228 .name = TOSHIBA_RBTX4927_IOC_NAME, 201 .name = TOSHIBA_RBTX4927_IOC_NAME,
@@ -235,18 +208,6 @@ static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
235#define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006 208#define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006
236 209
237 210
238#ifdef CONFIG_TOSHIBA_FPCIB0
239#define TOSHIBA_RBTX4927_ISA_NAME "RBTX4927-ISA"
240static struct irq_chip toshiba_rbtx4927_irq_isa_type = {
241 .name = TOSHIBA_RBTX4927_ISA_NAME,
242 .ack = toshiba_rbtx4927_irq_isa_mask_and_ack,
243 .mask = toshiba_rbtx4927_irq_isa_disable,
244 .mask_ack = toshiba_rbtx4927_irq_isa_mask_and_ack,
245 .unmask = toshiba_rbtx4927_irq_isa_enable,
246};
247#endif
248
249
250u32 bit2num(u32 num) 211u32 bit2num(u32 num)
251{ 212{
252 u32 i; 213 u32 i;
@@ -271,31 +232,10 @@ int toshiba_rbtx4927_irq_nested(int sw_irq)
271 } 232 }
272 } 233 }
273#ifdef CONFIG_TOSHIBA_FPCIB0 234#ifdef CONFIG_TOSHIBA_FPCIB0
274 { 235 if (tx4927_using_backplane) {
275 if (tx4927_using_backplane) { 236 int irq = i8259_irq();
276 u32 level4; 237 if (irq >= 0)
277 u32 level5; 238 sw_irq = irq;
278 outb(0x0A, 0x20);
279 level4 = inb(0x20) & 0xff;
280 if (level4) {
281 sw_irq =
282 TOSHIBA_RBTX4927_IRQ_ISA_BEG +
283 bit2num(level4);
284 if (sw_irq !=
285 TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_ISA) {
286 goto RETURN;
287 }
288 }
289
290 outb(0x0A, 0xA0);
291 level5 = inb(0xA0) & 0xff;
292 if (level5) {
293 sw_irq =
294 TOSHIBA_RBTX4927_IRQ_ISA_MID +
295 bit2num(level5);
296 goto RETURN;
297 }
298 }
299 } 239 }
300#endif 240#endif
301 241
@@ -307,12 +247,6 @@ int toshiba_rbtx4927_irq_nested(int sw_irq)
307#define TOSHIBA_RBTX4927_PIC_ACTION(s) { no_action, IRQF_SHARED, CPU_MASK_NONE, s, NULL, NULL } 247#define TOSHIBA_RBTX4927_PIC_ACTION(s) { no_action, IRQF_SHARED, CPU_MASK_NONE, s, NULL, NULL }
308static struct irqaction toshiba_rbtx4927_irq_ioc_action = 248static struct irqaction toshiba_rbtx4927_irq_ioc_action =
309TOSHIBA_RBTX4927_PIC_ACTION(TOSHIBA_RBTX4927_IOC_NAME); 249TOSHIBA_RBTX4927_PIC_ACTION(TOSHIBA_RBTX4927_IOC_NAME);
310#ifdef CONFIG_TOSHIBA_FPCIB0
311static struct irqaction toshiba_rbtx4927_irq_isa_master =
312TOSHIBA_RBTX4927_PIC_ACTION(TOSHIBA_RBTX4927_ISA_NAME "/M");
313static struct irqaction toshiba_rbtx4927_irq_isa_slave =
314TOSHIBA_RBTX4927_PIC_ACTION(TOSHIBA_RBTX4927_ISA_NAME "/S");
315#endif
316 250
317 251
318/**********************************************************************************/ 252/**********************************************************************************/
@@ -378,92 +312,6 @@ static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
378} 312}
379 313
380 314
381/**********************************************************************************/
382/* Functions for isa */
383/**********************************************************************************/
384
385
386#ifdef CONFIG_TOSHIBA_FPCIB0
387static void __init toshiba_rbtx4927_irq_isa_init(void)
388{
389 int i;
390
391 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_ISA_INIT,
392 "beg=%d end=%d\n",
393 TOSHIBA_RBTX4927_IRQ_ISA_BEG,
394 TOSHIBA_RBTX4927_IRQ_ISA_END);
395
396 for (i = TOSHIBA_RBTX4927_IRQ_ISA_BEG;
397 i <= TOSHIBA_RBTX4927_IRQ_ISA_END; i++)
398 set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_isa_type,
399 handle_level_irq);
400
401 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC,
402 &toshiba_rbtx4927_irq_isa_master);
403 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_ISA,
404 &toshiba_rbtx4927_irq_isa_slave);
405
406 /* make sure we are looking at IRR (not ISR) */
407 outb(0x0A, 0x20);
408 outb(0x0A, 0xA0);
409}
410#endif
411
412
413#ifdef CONFIG_TOSHIBA_FPCIB0
414static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq)
415{
416 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_ISA_ENABLE,
417 "irq=%d\n", irq);
418
419 if (irq < TOSHIBA_RBTX4927_IRQ_ISA_BEG
420 || irq > TOSHIBA_RBTX4927_IRQ_ISA_END) {
421 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
422 "bad irq=%d\n", irq);
423 panic("\n");
424 }
425
426 enable_8259A_irq(irq);
427}
428#endif
429
430
431#ifdef CONFIG_TOSHIBA_FPCIB0
432static void toshiba_rbtx4927_irq_isa_disable(unsigned int irq)
433{
434 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_ISA_DISABLE,
435 "irq=%d\n", irq);
436
437 if (irq < TOSHIBA_RBTX4927_IRQ_ISA_BEG
438 || irq > TOSHIBA_RBTX4927_IRQ_ISA_END) {
439 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
440 "bad irq=%d\n", irq);
441 panic("\n");
442 }
443
444 disable_8259A_irq(irq);
445}
446#endif
447
448
449#ifdef CONFIG_TOSHIBA_FPCIB0
450static void toshiba_rbtx4927_irq_isa_mask_and_ack(unsigned int irq)
451{
452 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_ISA_MASK,
453 "irq=%d\n", irq);
454
455 if (irq < TOSHIBA_RBTX4927_IRQ_ISA_BEG
456 || irq > TOSHIBA_RBTX4927_IRQ_ISA_END) {
457 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
458 "bad irq=%d\n", irq);
459 panic("\n");
460 }
461
462 mask_and_ack_8259A(irq);
463}
464#endif
465
466
467void __init arch_init_irq(void) 315void __init arch_init_irq(void)
468{ 316{
469 extern void tx4927_irq_init(void); 317 extern void tx4927_irq_init(void);
@@ -471,12 +319,11 @@ void __init arch_init_irq(void)
471 tx4927_irq_init(); 319 tx4927_irq_init();
472 toshiba_rbtx4927_irq_ioc_init(); 320 toshiba_rbtx4927_irq_ioc_init();
473#ifdef CONFIG_TOSHIBA_FPCIB0 321#ifdef CONFIG_TOSHIBA_FPCIB0
474 { 322 if (tx4927_using_backplane)
475 if (tx4927_using_backplane) { 323 init_i8259_irqs();
476 toshiba_rbtx4927_irq_isa_init();
477 }
478 }
479#endif 324#endif
325 /* Onboard 10M Ether: High Active */
326 set_irq_type(RBTX4927_RTL_8019_IRQ, IRQF_TRIGGER_HIGH);
480 327
481 wbflush(); 328 wbflush();
482} 329}
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
index ea5a70b252a0..3e84237abe63 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
@@ -151,7 +151,6 @@ unsigned long mips_memory_upper;
151static int tx4927_ccfg_toeon = 1; 151static int tx4927_ccfg_toeon = 1;
152static int tx4927_pcic_trdyto = 0; /* default: disabled */ 152static int tx4927_pcic_trdyto = 0; /* default: disabled */
153unsigned long tx4927_ce_base[8]; 153unsigned long tx4927_ce_base[8];
154void tx4927_pci_setup(void);
155void tx4927_reset_pci_pcic(void); 154void tx4927_reset_pci_pcic(void);
156int tx4927_pci66 = 0; /* 0:auto */ 155int tx4927_pci66 = 0; /* 0:auto */
157#endif 156#endif
@@ -442,7 +441,7 @@ arch_initcall(tx4927_pcibios_init);
442extern struct resource pci_io_resource; 441extern struct resource pci_io_resource;
443extern struct resource pci_mem_resource; 442extern struct resource pci_mem_resource;
444 443
445void tx4927_pci_setup(void) 444void __init tx4927_pci_setup(void)
446{ 445{
447 static int called = 0; 446 static int called = 0;
448 extern unsigned int tx4927_get_mem_size(void); 447 extern unsigned int tx4927_get_mem_size(void);
@@ -748,12 +747,6 @@ void __init toshiba_rbtx4927_setup(void)
748 } 747 }
749#endif 748#endif
750 749
751 /* setup irq stuff */
752 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
753 ":Setting up tx4927 pic.\n");
754 TX4927_WR(0xff1ff604, 0x00000400); /* irq trigger */
755 TX4927_WR(0xff1ff608, 0x00000000); /* irq trigger */
756
757 /* setup serial stuff */ 750 /* setup serial stuff */
758 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP, 751 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
759 ":Setting up tx4927 sio.\n"); 752 ":Setting up tx4927 sio.\n");
@@ -915,7 +908,7 @@ void __init toshiba_rbtx4927_setup(void)
915 req.iotype = UPIO_MEM; 908 req.iotype = UPIO_MEM;
916 req.membase = (char *)(0xff1ff300 + i * 0x100); 909 req.membase = (char *)(0xff1ff300 + i * 0x100);
917 req.mapbase = 0xff1ff300 + i * 0x100; 910 req.mapbase = 0xff1ff300 + i * 0x100;
918 req.irq = 32 + i; 911 req.irq = TX4927_IRQ_PIC_BEG + 8 + i;
919 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/; 912 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
920 req.uartclk = 50000000; 913 req.uartclk = 50000000;
921 early_serial_txx9_setup(&req); 914 early_serial_txx9_setup(&req);
diff --git a/arch/mips/tx4938/common/irq.c b/arch/mips/tx4938/common/irq.c
index 3a2dbfc25014..c059b899d120 100644
--- a/arch/mips/tx4938/common/irq.c
+++ b/arch/mips/tx4938/common/irq.c
@@ -11,284 +11,21 @@
11 * 11 *
12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) 12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
13 */ 13 */
14#include <linux/errno.h>
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/kernel_stat.h>
17#include <linux/module.h>
18#include <linux/signal.h>
19#include <linux/sched.h>
20#include <linux/types.h>
21#include <linux/interrupt.h> 15#include <linux/interrupt.h>
22#include <linux/ioport.h> 16#include <asm/irq_cpu.h>
23#include <linux/timex.h>
24#include <linux/slab.h>
25#include <linux/random.h>
26#include <linux/irq.h>
27#include <asm/bitops.h>
28#include <asm/bootinfo.h>
29#include <asm/io.h>
30#include <asm/irq.h>
31#include <asm/mipsregs.h> 17#include <asm/mipsregs.h>
32#include <asm/system.h>
33#include <asm/wbflush.h>
34#include <asm/tx4938/rbtx4938.h> 18#include <asm/tx4938/rbtx4938.h>
35 19
36/**********************************************************************************/
37/* Forwad definitions for all pic's */
38/**********************************************************************************/
39
40static void tx4938_irq_cp0_enable(unsigned int irq);
41static void tx4938_irq_cp0_disable(unsigned int irq);
42
43static void tx4938_irq_pic_enable(unsigned int irq);
44static void tx4938_irq_pic_disable(unsigned int irq);
45
46/**********************************************************************************/
47/* Kernel structs for all pic's */
48/**********************************************************************************/
49
50#define TX4938_CP0_NAME "TX4938-CP0"
51static struct irq_chip tx4938_irq_cp0_type = {
52 .name = TX4938_CP0_NAME,
53 .ack = tx4938_irq_cp0_disable,
54 .mask = tx4938_irq_cp0_disable,
55 .mask_ack = tx4938_irq_cp0_disable,
56 .unmask = tx4938_irq_cp0_enable,
57};
58
59#define TX4938_PIC_NAME "TX4938-PIC"
60static struct irq_chip tx4938_irq_pic_type = {
61 .name = TX4938_PIC_NAME,
62 .ack = tx4938_irq_pic_disable,
63 .mask = tx4938_irq_pic_disable,
64 .mask_ack = tx4938_irq_pic_disable,
65 .unmask = tx4938_irq_pic_enable,
66};
67
68static struct irqaction tx4938_irq_pic_action = {
69 .handler = no_action,
70 .flags = 0,
71 .mask = CPU_MASK_NONE,
72 .name = TX4938_PIC_NAME
73};
74
75/**********************************************************************************/
76/* Functions for cp0 */
77/**********************************************************************************/
78
79#define tx4938_irq_cp0_mask(irq) ( 1 << ( irq-TX4938_IRQ_CP0_BEG+8 ) )
80
81static void __init
82tx4938_irq_cp0_init(void)
83{
84 int i;
85
86 for (i = TX4938_IRQ_CP0_BEG; i <= TX4938_IRQ_CP0_END; i++)
87 set_irq_chip_and_handler(i, &tx4938_irq_cp0_type,
88 handle_level_irq);
89}
90
91static void
92tx4938_irq_cp0_enable(unsigned int irq)
93{
94 set_c0_status(tx4938_irq_cp0_mask(irq));
95}
96
97static void
98tx4938_irq_cp0_disable(unsigned int irq)
99{
100 clear_c0_status(tx4938_irq_cp0_mask(irq));
101}
102
103/**********************************************************************************/
104/* Functions for pic */
105/**********************************************************************************/
106
107u32
108tx4938_irq_pic_addr(int irq)
109{
110 /* MVMCP -- need to formulize this */
111 irq -= TX4938_IRQ_PIC_BEG;
112
113 switch (irq) {
114 case 17:
115 case 16:
116 case 1:
117 case 0:{
118 return (TX4938_MKA(TX4938_IRC_IRLVL0));
119 }
120 case 19:
121 case 18:
122 case 3:
123 case 2:{
124 return (TX4938_MKA(TX4938_IRC_IRLVL1));
125 }
126 case 21:
127 case 20:
128 case 5:
129 case 4:{
130 return (TX4938_MKA(TX4938_IRC_IRLVL2));
131 }
132 case 23:
133 case 22:
134 case 7:
135 case 6:{
136 return (TX4938_MKA(TX4938_IRC_IRLVL3));
137 }
138 case 25:
139 case 24:
140 case 9:
141 case 8:{
142 return (TX4938_MKA(TX4938_IRC_IRLVL4));
143 }
144 case 27:
145 case 26:
146 case 11:
147 case 10:{
148 return (TX4938_MKA(TX4938_IRC_IRLVL5));
149 }
150 case 29:
151 case 28:
152 case 13:
153 case 12:{
154 return (TX4938_MKA(TX4938_IRC_IRLVL6));
155 }
156 case 31:
157 case 30:
158 case 15:
159 case 14:{
160 return (TX4938_MKA(TX4938_IRC_IRLVL7));
161 }
162 }
163
164 return 0;
165}
166
167u32
168tx4938_irq_pic_mask(int irq)
169{
170 /* MVMCP -- need to formulize this */
171 irq -= TX4938_IRQ_PIC_BEG;
172
173 switch (irq) {
174 case 31:
175 case 29:
176 case 27:
177 case 25:
178 case 23:
179 case 21:
180 case 19:
181 case 17:{
182 return (0x07000000);
183 }
184 case 30:
185 case 28:
186 case 26:
187 case 24:
188 case 22:
189 case 20:
190 case 18:
191 case 16:{
192 return (0x00070000);
193 }
194 case 15:
195 case 13:
196 case 11:
197 case 9:
198 case 7:
199 case 5:
200 case 3:
201 case 1:{
202 return (0x00000700);
203 }
204 case 14:
205 case 12:
206 case 10:
207 case 8:
208 case 6:
209 case 4:
210 case 2:
211 case 0:{
212 return (0x00000007);
213 }
214 }
215 return 0x00000000;
216}
217
218static void
219tx4938_irq_pic_modify(unsigned pic_reg, unsigned clr_bits, unsigned set_bits)
220{
221 unsigned long val = 0;
222
223 val = TX4938_RD(pic_reg);
224 val &= (~clr_bits);
225 val |= (set_bits);
226 TX4938_WR(pic_reg, val);
227 mmiowb();
228 TX4938_RD(pic_reg);
229}
230
231static void __init
232tx4938_irq_pic_init(void)
233{
234 int i;
235
236 for (i = TX4938_IRQ_PIC_BEG; i <= TX4938_IRQ_PIC_END; i++)
237 set_irq_chip_and_handler(i, &tx4938_irq_pic_type,
238 handle_level_irq);
239
240 setup_irq(TX4938_IRQ_NEST_PIC_ON_CP0, &tx4938_irq_pic_action);
241
242 TX4938_WR(0xff1ff640, 0x6); /* irq level mask -- only accept hightest */
243 TX4938_WR(0xff1ff600, TX4938_RD(0xff1ff600) | 0x1); /* irq enable */
244}
245
246static void
247tx4938_irq_pic_enable(unsigned int irq)
248{
249 tx4938_irq_pic_modify(tx4938_irq_pic_addr(irq), 0,
250 tx4938_irq_pic_mask(irq));
251}
252
253static void
254tx4938_irq_pic_disable(unsigned int irq)
255{
256 tx4938_irq_pic_modify(tx4938_irq_pic_addr(irq),
257 tx4938_irq_pic_mask(irq), 0);
258}
259
260/**********************************************************************************/
261/* Main init functions */
262/**********************************************************************************/
263
264void __init 20void __init
265tx4938_irq_init(void) 21tx4938_irq_init(void)
266{ 22{
267 tx4938_irq_cp0_init(); 23 mips_cpu_irq_init();
268 tx4938_irq_pic_init(); 24 txx9_irq_init(TX4938_IRC_REG);
25 set_irq_chained_handler(TX4938_IRQ_NEST_PIC_ON_CP0, handle_simple_irq);
269} 26}
270 27
271int 28int toshiba_rbtx4938_irq_nested(int irq);
272tx4938_irq_nested(void)
273{
274 int sw_irq = 0;
275 u32 level2;
276
277 level2 = TX4938_RD(0xff1ff6a0);
278 if ((level2 & 0x10000) == 0) {
279 level2 &= 0x1f;
280 sw_irq = TX4938_IRQ_PIC_BEG + level2;
281 if (sw_irq == 26) {
282 {
283 extern int toshiba_rbtx4938_irq_nested(int sw_irq);
284 sw_irq = toshiba_rbtx4938_irq_nested(sw_irq);
285 }
286 }
287 }
288
289 wbflush();
290 return sw_irq;
291}
292 29
293asmlinkage void plat_irq_dispatch(void) 30asmlinkage void plat_irq_dispatch(void)
294{ 31{
@@ -297,8 +34,10 @@ asmlinkage void plat_irq_dispatch(void)
297 if (pending & STATUSF_IP7) 34 if (pending & STATUSF_IP7)
298 do_IRQ(TX4938_IRQ_CPU_TIMER); 35 do_IRQ(TX4938_IRQ_CPU_TIMER);
299 else if (pending & STATUSF_IP2) { 36 else if (pending & STATUSF_IP2) {
300 int irq = tx4938_irq_nested(); 37 int irq = txx9_irq();
301 if (irq) 38 if (irq == TX4938_IRQ_PIC_BEG + TX4938_IR_INT(0))
39 irq = toshiba_rbtx4938_irq_nested(irq);
40 if (irq >= 0)
302 do_IRQ(irq); 41 do_IRQ(irq);
303 else 42 else
304 spurious_interrupt(); 43 spurious_interrupt();
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/irq.c b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
index 91aea7aff515..f00185017e80 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/irq.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
@@ -181,7 +181,7 @@ void __init arch_init_irq(void)
181 tx4938_irq_init(); 181 tx4938_irq_init();
182 toshiba_rbtx4938_irq_ioc_init(); 182 toshiba_rbtx4938_irq_ioc_init();
183 /* Onboard 10M Ether: High Active */ 183 /* Onboard 10M Ether: High Active */
184 TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM0), 0x00000040); 184 set_irq_type(RBTX4938_IRQ_ETHER, IRQF_TRIGGER_HIGH);
185 185
186 wbflush(); 186 wbflush();
187} 187}
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/setup.c b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
index f9ad482749e4..57f3c705d082 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/setup.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
@@ -773,10 +773,6 @@ void __init tx4938_board_setup(void)
773 txboard_add_phys_region(base, size); 773 txboard_add_phys_region(base, size);
774 } 774 }
775 775
776 /* IRC */
777 /* disable interrupt control */
778 tx4938_ircptr->cer = 0;
779
780 /* TMR */ 776 /* TMR */
781 /* disable all timers */ 777 /* disable all timers */
782 for (i = 0; i < TX4938_NR_TMR; i++) { 778 for (i = 0; i < TX4938_NR_TMR; i++) {
@@ -875,9 +871,6 @@ void __init toshiba_rbtx4938_setup(void)
875 if (txx9_master_clock == 0) 871 if (txx9_master_clock == 0)
876 txx9_master_clock = 25000000; /* 25MHz */ 872 txx9_master_clock = 25000000; /* 25MHz */
877 tx4938_board_setup(); 873 tx4938_board_setup();
878 /* setup irq stuff */
879 TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM0), 0x00000000); /* irq trigger */
880 TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM1), 0x00000000); /* irq trigger */
881 /* setup serial stuff */ 874 /* setup serial stuff */
882 TX4938_WR(0xff1ff314, 0x00000000); /* h/w flow control off */ 875 TX4938_WR(0xff1ff314, 0x00000000); /* h/w flow control off */
883 TX4938_WR(0xff1ff414, 0x00000000); /* h/w flow control off */ 876 TX4938_WR(0xff1ff414, 0x00000000); /* h/w flow control off */
@@ -897,7 +890,7 @@ void __init toshiba_rbtx4938_setup(void)
897 req.iotype = UPIO_MEM; 890 req.iotype = UPIO_MEM;
898 req.membase = (char *)(0xff1ff300 + i * 0x100); 891 req.membase = (char *)(0xff1ff300 + i * 0x100);
899 req.mapbase = 0xff1ff300 + i * 0x100; 892 req.mapbase = 0xff1ff300 + i * 0x100;
900 req.irq = 32 + i; 893 req.irq = RBTX4938_IRQ_IRC_SIO(i);
901 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/; 894 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
902 req.uartclk = 50000000; 895 req.uartclk = 50000000;
903 early_serial_txx9_setup(&req); 896 early_serial_txx9_setup(&req);