irq.c 1.7 KB
Newer Older
1
/*
2
 * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology
3 4
 * Author: Fuxin Zhang, zhangfx@lemote.com
 *
R
Ralf Baechle 已提交
5 6 7
 *  This program is free software; you can redistribute	 it and/or modify it
 *  under  the terms of	 the GNU General  Public License as published by the
 *  Free Software Foundation;  either version 2 of the	License, or (at your
8 9 10 11 12 13 14
 *  option) any later version.
 */
#include <linux/interrupt.h>

#include <asm/irq_cpu.h>
#include <asm/i8259.h>

15
#include <loongson.h>
16 17 18 19 20 21

static void i8259_irqdispatch(void)
{
	int irq;

	irq = i8259_irq();
22
	if (irq >= 0)
23
		do_IRQ(irq);
24
	else
25 26 27
		spurious_interrupt();
}

28
asmlinkage void mach_irq_dispatch(unsigned int pending)
29
{
30
	if (pending & CAUSEF_IP7)
31
		do_IRQ(MIPS_CPU_IRQ_BASE + 7);
32
	else if (pending & CAUSEF_IP6) /* perf counter loverflow */
33
		do_perfcnt_IRQ();
34
	else if (pending & CAUSEF_IP5)
35
		i8259_irqdispatch();
36
	else if (pending & CAUSEF_IP2)
37
		bonito_irqdispatch();
38
	else
39 40 41 42 43 44
		spurious_interrupt();
}

static struct irqaction cascade_irqaction = {
	.handler = no_action,
	.name = "cascade",
45
	.flags = IRQF_NO_THREAD,
46 47
};

48 49
void __init mach_init_irq(void)
{
50
	/* init all controller
R
Ralf Baechle 已提交
51 52 53
	 *   0-15	  ------> i8259 interrupt
	 *   16-23	  ------> mips cpu interrupt
	 *   32-63	  ------> bonito irq
54 55
	 */

56 57 58 59
	/* most bonito irq should be level triggered */
	LOONGSON_INTEDGE = LOONGSON_ICU_SYSTEMERR | LOONGSON_ICU_MASTERERR |
	    LOONGSON_ICU_RETRYERR | LOONGSON_ICU_MBOXES;

60 61 62 63 64 65 66 67 68 69
	/* Sets the first-level interrupt dispatcher. */
	mips_cpu_irq_init();
	init_i8259_irqs();
	bonito_irq_init();

	/* bonito irq at IP2 */
	setup_irq(MIPS_CPU_IRQ_BASE + 2, &cascade_irqaction);
	/* 8259 irq at IP5 */
	setup_irq(MIPS_CPU_IRQ_BASE + 5, &cascade_irqaction);
}