irq.c 2.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * 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>
17
#include <mach-se/mach/se7722.h>
18

19 20
unsigned int se7722_fpga_irq[SE7722_FPGA_IRQ_NR] = { 0, };

P
Paul Mundt 已提交
21
static void disable_se7722_irq(struct irq_data *data)
22
{
P
Paul Mundt 已提交
23
	unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
24
	__raw_writew(__raw_readw(IRQ01_MASK) | 1 << bit, IRQ01_MASK);
25 26
}

P
Paul Mundt 已提交
27
static void enable_se7722_irq(struct irq_data *data)
28
{
P
Paul Mundt 已提交
29
	unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
30
	__raw_writew(__raw_readw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK);
31 32 33
}

static struct irq_chip se7722_irq_chip __read_mostly = {
P
Paul Mundt 已提交
34 35 36
	.name		= "SE7722-FPGA",
	.irq_mask	= disable_se7722_irq,
	.irq_unmask	= enable_se7722_irq,
37 38
};

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

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

46 47 48 49 50
	for (; intv; intv >>= 1, ext_irq++) {
		if (!(intv & 1))
			continue;

		generic_handle_irq(se7722_fpga_irq[ext_irq]);
51 52
	}
}
53

54 55 56 57 58
/*
 * Initialize IRQ setting
 */
void __init init_se7722_IRQ(void)
{
59
	int i, irq;
60

61 62
	__raw_writew(0, IRQ01_MASK);       /* disable all irqs */
	__raw_writew(0x2000, 0xb03fffec);  /* mrshpc irq enable */
63

64
	for (i = 0; i < SE7722_FPGA_IRQ_NR; i++) {
65 66
		irq = create_irq();
		if (irq < 0)
67
			return;
68
		se7722_fpga_irq[i] = irq;
69 70

		set_irq_chip_and_handler_name(se7722_fpga_irq[i],
71 72 73
					      &se7722_irq_chip,
					      handle_level_irq, "level");

74 75 76
		set_irq_chip_data(se7722_fpga_irq[i], (void *)i);
	}

77 78 79 80 81
	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);
82
}