blob: 7888cf69424af197171d12941a0ab6f01d162472 [file] [log] [blame]
Songmao Tian42d226c2007-06-06 14:52:38 +08001/*
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 Tian42d226c2007-06-06 14:52:38 +08009 */
Songmao Tian42d226c2007-06-06 14:52:38 +080010#include <linux/interrupt.h>
Songmao Tian42d226c2007-06-06 14:52:38 +080011
12#include <asm/irq_cpu.h>
13#include <asm/i8259.h>
Songmao Tian42d226c2007-06-06 14:52:38 +080014
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080015#include <loongson.h>
Songmao Tian42d226c2007-06-06 14:52:38 +080016
17static void i8259_irqdispatch(void)
18{
19 int irq;
20
21 irq = i8259_irq();
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080022 if (irq >= 0)
Songmao Tian42d226c2007-06-06 14:52:38 +080023 do_IRQ(irq);
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080024 else
Songmao Tian42d226c2007-06-06 14:52:38 +080025 spurious_interrupt();
Songmao Tian42d226c2007-06-06 14:52:38 +080026}
27
Wu Zhangjin85749d22009-07-02 23:26:45 +080028asmlinkage void mach_irq_dispatch(unsigned int pending)
Songmao Tian42d226c2007-06-06 14:52:38 +080029{
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080030 if (pending & CAUSEF_IP7)
Songmao Tian42d226c2007-06-06 14:52:38 +080031 do_IRQ(MIPS_CPU_IRQ_BASE + 7);
Wu Zhangjin67b35e52009-07-02 23:25:46 +080032 else if (pending & CAUSEF_IP6) /* perf counter loverflow */
33 do_IRQ(LOONGSON2_PERFCNT_IRQ);
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080034 else if (pending & CAUSEF_IP5)
Songmao Tian42d226c2007-06-06 14:52:38 +080035 i8259_irqdispatch();
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080036 else if (pending & CAUSEF_IP2)
Songmao Tian42d226c2007-06-06 14:52:38 +080037 bonito_irqdispatch();
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080038 else
Songmao Tian42d226c2007-06-06 14:52:38 +080039 spurious_interrupt();
Songmao Tian42d226c2007-06-06 14:52:38 +080040}
41
42static struct irqaction cascade_irqaction = {
43 .handler = no_action,
Songmao Tian42d226c2007-06-06 14:52:38 +080044 .name = "cascade",
45};
46
Wu Zhangjin85749d22009-07-02 23:26:45 +080047void __init set_irq_trigger_mode(void)
Songmao Tian42d226c2007-06-06 14:52:38 +080048{
Songmao Tian42d226c2007-06-06 14:52:38 +080049 /* most bonito irq should be level triggered */
50 BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR |
Wu Zhangjin85749d22009-07-02 23:26:45 +080051 BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES;
52}
Songmao Tian42d226c2007-06-06 14:52:38 +080053
Wu Zhangjin85749d22009-07-02 23:26:45 +080054void __init mach_init_irq(void)
55{
Songmao Tian42d226c2007-06-06 14:52:38 +080056 /* init all controller
57 * 0-15 ------> i8259 interrupt
58 * 16-23 ------> mips cpu interrupt
59 * 32-63 ------> bonito irq
60 */
61
62 /* Sets the first-level interrupt dispatcher. */
63 mips_cpu_irq_init();
64 init_i8259_irqs();
65 bonito_irq_init();
66
Songmao Tian42d226c2007-06-06 14:52:38 +080067 /* bonito irq at IP2 */
68 setup_irq(MIPS_CPU_IRQ_BASE + 2, &cascade_irqaction);
69 /* 8259 irq at IP5 */
70 setup_irq(MIPS_CPU_IRQ_BASE + 5, &cascade_irqaction);
Songmao Tian42d226c2007-06-06 14:52:38 +080071}