Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology |
| 3 | * Author: Fuxin Zhang, zhangfx@lemote.com |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License as published by the |
| 7 | * Free Software Foundation; either version 2 of the License, or (at your |
| 8 | * option) any later version. |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 9 | */ |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 10 | #include <linux/interrupt.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 11 | |
| 12 | #include <asm/irq_cpu.h> |
| 13 | #include <asm/i8259.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 14 | |
Wu Zhangjin | 5e983ff | 2009-07-02 23:23:03 +0800 | [diff] [blame] | 15 | #include <loongson.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 16 | |
| 17 | static void i8259_irqdispatch(void) |
| 18 | { |
| 19 | int irq; |
| 20 | |
| 21 | irq = i8259_irq(); |
Wu Zhangjin | 5e983ff | 2009-07-02 23:23:03 +0800 | [diff] [blame] | 22 | if (irq >= 0) |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 23 | do_IRQ(irq); |
Wu Zhangjin | 5e983ff | 2009-07-02 23:23:03 +0800 | [diff] [blame] | 24 | else |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 25 | spurious_interrupt(); |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 26 | } |
| 27 | |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 28 | asmlinkage void mach_irq_dispatch(unsigned int pending) |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 29 | { |
Wu Zhangjin | 5e983ff | 2009-07-02 23:23:03 +0800 | [diff] [blame] | 30 | if (pending & CAUSEF_IP7) |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 31 | do_IRQ(MIPS_CPU_IRQ_BASE + 7); |
Wu Zhangjin | 67b35e5 | 2009-07-02 23:25:46 +0800 | [diff] [blame] | 32 | else if (pending & CAUSEF_IP6) /* perf counter loverflow */ |
Wu Zhangjin | de3bc0e | 2010-07-24 09:22:14 +0800 | [diff] [blame] | 33 | do_perfcnt_IRQ(); |
Wu Zhangjin | 5e983ff | 2009-07-02 23:23:03 +0800 | [diff] [blame] | 34 | else if (pending & CAUSEF_IP5) |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 35 | i8259_irqdispatch(); |
Wu Zhangjin | 5e983ff | 2009-07-02 23:23:03 +0800 | [diff] [blame] | 36 | else if (pending & CAUSEF_IP2) |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 37 | bonito_irqdispatch(); |
Wu Zhangjin | 5e983ff | 2009-07-02 23:23:03 +0800 | [diff] [blame] | 38 | else |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 39 | spurious_interrupt(); |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static struct irqaction cascade_irqaction = { |
| 43 | .handler = no_action, |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 44 | .name = "cascade", |
Wu Zhangjin | 77cbece | 2011-07-23 12:41:24 +0000 | [diff] [blame] | 45 | .flags = IRQF_NO_THREAD, |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 46 | }; |
| 47 | |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 48 | void __init mach_init_irq(void) |
| 49 | { |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 50 | /* init all controller |
| 51 | * 0-15 ------> i8259 interrupt |
| 52 | * 16-23 ------> mips cpu interrupt |
| 53 | * 32-63 ------> bonito irq |
| 54 | */ |
| 55 | |
Wu Zhangjin | b8c7428 | 2010-07-24 09:22:13 +0800 | [diff] [blame] | 56 | /* most bonito irq should be level triggered */ |
| 57 | LOONGSON_INTEDGE = LOONGSON_ICU_SYSTEMERR | LOONGSON_ICU_MASTERERR | |
| 58 | LOONGSON_ICU_RETRYERR | LOONGSON_ICU_MBOXES; |
| 59 | |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 60 | /* Sets the first-level interrupt dispatcher. */ |
| 61 | mips_cpu_irq_init(); |
| 62 | init_i8259_irqs(); |
| 63 | bonito_irq_init(); |
| 64 | |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 65 | /* bonito irq at IP2 */ |
| 66 | setup_irq(MIPS_CPU_IRQ_BASE + 2, &cascade_irqaction); |
| 67 | /* 8259 irq at IP5 */ |
| 68 | setup_irq(MIPS_CPU_IRQ_BASE + 5, &cascade_irqaction); |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 69 | } |