122b1d707SAtsushi Nemoto /*
222b1d707SAtsushi Nemoto  * linux/arch/mips/tx4938/common/irq.c
322b1d707SAtsushi Nemoto  *
422b1d707SAtsushi Nemoto  * Common tx4938 irq handler
522b1d707SAtsushi Nemoto  * Copyright (C) 2000-2001 Toshiba Corporation
622b1d707SAtsushi Nemoto  *
722b1d707SAtsushi Nemoto  * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
822b1d707SAtsushi Nemoto  * terms of the GNU General Public License version 2. This program is
922b1d707SAtsushi Nemoto  * licensed "as is" without any warranty of any kind, whether express
1022b1d707SAtsushi Nemoto  * or implied.
1122b1d707SAtsushi Nemoto  *
1222b1d707SAtsushi Nemoto  * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
1322b1d707SAtsushi Nemoto  */
1422b1d707SAtsushi Nemoto #include <linux/init.h>
1522b1d707SAtsushi Nemoto #include <linux/interrupt.h>
1622b1d707SAtsushi Nemoto #include <asm/irq_cpu.h>
1722b1d707SAtsushi Nemoto #include <asm/mipsregs.h>
1822b1d707SAtsushi Nemoto #include <asm/txx9/rbtx4938.h>
1922b1d707SAtsushi Nemoto 
2022b1d707SAtsushi Nemoto void __init
2122b1d707SAtsushi Nemoto tx4938_irq_init(void)
2222b1d707SAtsushi Nemoto {
2322b1d707SAtsushi Nemoto 	mips_cpu_irq_init();
2422b1d707SAtsushi Nemoto 	txx9_irq_init(TX4938_IRC_REG);
2522b1d707SAtsushi Nemoto 	set_irq_chained_handler(TX4938_IRQ_NEST_PIC_ON_CP0, handle_simple_irq);
2622b1d707SAtsushi Nemoto }
2722b1d707SAtsushi Nemoto 
2822b1d707SAtsushi Nemoto int toshiba_rbtx4938_irq_nested(int irq);
2922b1d707SAtsushi Nemoto 
3022b1d707SAtsushi Nemoto asmlinkage void plat_irq_dispatch(void)
3122b1d707SAtsushi Nemoto {
3222b1d707SAtsushi Nemoto 	unsigned int pending = read_c0_cause() & read_c0_status();
3322b1d707SAtsushi Nemoto 
3422b1d707SAtsushi Nemoto 	if (pending & STATUSF_IP7)
3522b1d707SAtsushi Nemoto 		do_IRQ(TX4938_IRQ_CPU_TIMER);
3622b1d707SAtsushi Nemoto 	else if (pending & STATUSF_IP2) {
3722b1d707SAtsushi Nemoto 		int irq = txx9_irq();
3822b1d707SAtsushi Nemoto 		if (irq == TX4938_IRQ_PIC_BEG + TX4938_IR_INT(0))
3922b1d707SAtsushi Nemoto 			irq = toshiba_rbtx4938_irq_nested(irq);
4022b1d707SAtsushi Nemoto 		if (irq >= 0)
4122b1d707SAtsushi Nemoto 			do_IRQ(irq);
4222b1d707SAtsushi Nemoto 		else
4322b1d707SAtsushi Nemoto 			spurious_interrupt();
4422b1d707SAtsushi Nemoto 	} else if (pending & STATUSF_IP1)
4522b1d707SAtsushi Nemoto 		do_IRQ(TX4938_IRQ_USER1);
4622b1d707SAtsushi Nemoto 	else if (pending & STATUSF_IP0)
4722b1d707SAtsushi Nemoto 		do_IRQ(TX4938_IRQ_USER0);
4822b1d707SAtsushi Nemoto }
49