ipr.c 2.1 KB
Newer Older
P
Paul Mundt 已提交
1
/*
P
Paul Mundt 已提交
2
 * Interrupt handling for IPR-based IRQ.
L
Linus Torvalds 已提交
3 4 5
 *
 * Copyright (C) 1999  Niibe Yutaka & Takeshi Yaegashi
 * Copyright (C) 2000  Kazumoto Kojima
P
Paul Mundt 已提交
6 7
 * Copyright (C) 2003  Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
 * Copyright (C) 2006  Paul Mundt
L
Linus Torvalds 已提交
8 9 10 11 12 13 14
 *
 * Supported system:
 *	On-chip supporting modules (TMU, RTC, etc.).
 *	On-chip supporting modules for SH7709/SH7709A/SH7729/SH7300.
 *	Hitachi SolutionEngine external I/O:
 *		MS7709SE01, MS7709ASE01, and MS7750SE01
 *
P
Paul Mundt 已提交
15 16 17
 * 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.
L
Linus Torvalds 已提交
18 19 20 21
 */
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/module.h>
P
Paul Mundt 已提交
22 23
#include <linux/io.h>
#include <linux/interrupt.h>
L
Linus Torvalds 已提交
24 25 26

static void disable_ipr_irq(unsigned int irq)
{
P
Paul Mundt 已提交
27
	struct ipr_data *p = get_irq_chip_data(irq);
L
Linus Torvalds 已提交
28
	/* Set the priority in IPR to 0 */
29
	ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << p->shift)), p->addr);
L
Linus Torvalds 已提交
30 31 32 33
}

static void enable_ipr_irq(unsigned int irq)
{
P
Paul Mundt 已提交
34
	struct ipr_data *p = get_irq_chip_data(irq);
L
Linus Torvalds 已提交
35
	/* Set priority in IPR back to original value */
36
	ctrl_outw(ctrl_inw(p->addr) | (p->priority << p->shift), p->addr);
L
Linus Torvalds 已提交
37 38
}

P
Paul Mundt 已提交
39
static struct irq_chip ipr_irq_chip = {
40
	.name		= "IPR",
P
Paul Mundt 已提交
41 42 43 44
	.mask		= disable_ipr_irq,
	.unmask		= enable_ipr_irq,
	.mask_ack	= disable_ipr_irq,
};
L
Linus Torvalds 已提交
45

T
Takashi YOSHII 已提交
46 47 48 49 50 51
unsigned int map_ipridx_to_addr(int idx) __attribute__ ((weak));
unsigned int map_ipridx_to_addr(int idx)
{
	return 0;
}

52
void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
L
Linus Torvalds 已提交
53
{
54
	int i;
P
Paul Mundt 已提交
55

56 57
	for (i = 0; i < nr_irqs; i++) {
		unsigned int irq = table[i].irq;
T
Takashi YOSHII 已提交
58 59 60 61

		if (!irq)
			irq = table[i].irq = i;

62
		/* could the IPR index be mapped, if not we ignore this */
T
Takashi YOSHII 已提交
63 64 65 66 67 68
		if (!table[i].addr) {
			table[i].addr = map_ipridx_to_addr(table[i].ipr_idx);
			if (!table[i].addr)
				continue;
		}

69 70
		disable_irq_nosync(irq);
		set_irq_chip_and_handler_name(irq, &ipr_irq_chip,
71
				      handle_level_irq, "level");
72 73 74
		set_irq_chip_data(irq, &table[i]);
		enable_ipr_irq(irq);
	}
L
Linus Torvalds 已提交
75
}
76
EXPORT_SYMBOL(make_ipr_irq);
L
Linus Torvalds 已提交
77

P
Paul Mundt 已提交
78
#if !defined(CONFIG_CPU_HAS_PINT_IRQ)
L
Linus Torvalds 已提交
79 80 81 82 83
int ipr_irq_demux(int irq)
{
	return irq;
}
#endif