blob: 892963f860b7a21e4b2f4cfa521a6a514d52f347 [file] [log] [blame]
Songmao Tian42d226c2007-06-06 14:52:38 +08001/*
Ralf Baechle0bb383a2015-07-07 20:56:04 +02002 * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology
Songmao Tian42d226c2007-06-06 14:52:38 +08003 * Author: Fuxin Zhang, zhangfx@lemote.com
4 *
Ralf Baechle70342282013-01-22 12:59:30 +01005 * 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
Songmao Tian42d226c2007-06-06 14:52:38 +08008 * 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 */
Wu Zhangjinde3bc0e2010-07-24 09:22:14 +080033 do_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",
Wu Zhangjin77cbece2011-07-23 12:41:24 +000045 .flags = IRQF_NO_THREAD,
Songmao Tian42d226c2007-06-06 14:52:38 +080046};
47
Wu Zhangjin85749d22009-07-02 23:26:45 +080048void __init mach_init_irq(void)
49{
Songmao Tian42d226c2007-06-06 14:52:38 +080050 /* init all controller
Ralf Baechle70342282013-01-22 12:59:30 +010051 * 0-15 ------> i8259 interrupt
52 * 16-23 ------> mips cpu interrupt
53 * 32-63 ------> bonito irq
Songmao Tian42d226c2007-06-06 14:52:38 +080054 */
55
Wu Zhangjinb8c74282010-07-24 09:22:13 +080056 /* 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 Tian42d226c2007-06-06 14:52:38 +080060 /* Sets the first-level interrupt dispatcher. */
61 mips_cpu_irq_init();
62 init_i8259_irqs();
63 bonito_irq_init();
64
Songmao Tian42d226c2007-06-06 14:52:38 +080065 /* 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 Tian42d226c2007-06-06 14:52:38 +080069}