irq.c 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * linux/arch/sh/boards/se/7722/irq.c
 *
 * Copyright (C) 2007  Nobuhiro Iwamatsu
 *
 * Hitachi UL SolutionEngine 7722 Support.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 */
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/se7722.h>

static void disable_se7722_irq(unsigned int irq)
{
21 22
	unsigned int bit = irq - SE7722_FPGA_IRQ_BASE;
	ctrl_outw(ctrl_inw(IRQ01_MASK) | 1 << bit, IRQ01_MASK);
23 24 25 26
}

static void enable_se7722_irq(unsigned int irq)
{
27 28
	unsigned int bit = irq - SE7722_FPGA_IRQ_BASE;
	ctrl_outw(ctrl_inw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK);
29 30 31
}

static struct irq_chip se7722_irq_chip __read_mostly = {
32
	.name           = "SE7722-FPGA",
33 34 35 36 37
	.mask           = disable_se7722_irq,
	.unmask         = enable_se7722_irq,
	.mask_ack       = disable_se7722_irq,
};

38
static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc)
39
{
40 41 42 43 44
	unsigned short intv = ctrl_inw(IRQ01_STS);
	struct irq_desc *ext_desc;
	unsigned int ext_irq = SE7722_FPGA_IRQ_BASE;

	intv &= (1 << SE7722_FPGA_IRQ_NR) - 1;
45

46 47 48 49
	while (intv) {
		if (intv & 1) {
			ext_desc = irq_desc + ext_irq;
			handle_level_irq(ext_irq, ext_desc);
50
		}
51 52
		intv >>= 1;
		ext_irq++;
53 54
	}
}
55

56 57 58 59 60
/*
 * Initialize IRQ setting
 */
void __init init_se7722_IRQ(void)
{
61 62 63
	int i;

	ctrl_outw(0, IRQ01_MASK);       /* disable all irqs */
64 65
	ctrl_outw(0x2000, 0xb03fffec);  /* mrshpc irq enable */

66 67 68 69 70 71 72 73 74 75
	for (i = 0; i < SE7722_FPGA_IRQ_NR; i++)
		set_irq_chip_and_handler_name(SE7722_FPGA_IRQ_BASE + i,
					      &se7722_irq_chip,
					      handle_level_irq, "level");

	set_irq_chained_handler(IRQ0_IRQ, se7722_irq_demux);
	set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);

	set_irq_chained_handler(IRQ1_IRQ, se7722_irq_demux);
	set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW);
76
}