RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / sh / kernel / cpu / irq / ipr.c
blob210280b6fddfdb5484ef472a2307cf54d7363a23
1 /*
2 * Interrupt handling for IPR-based IRQ.
4 * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
5 * Copyright (C) 2000 Kazumoto Kojima
6 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
7 * Copyright (C) 2006 Paul Mundt
9 * Supported system:
10 * On-chip supporting modules (TMU, RTC, etc.).
11 * On-chip supporting modules for SH7709/SH7709A/SH7729/SH7300.
12 * Hitachi SolutionEngine external I/O:
13 * MS7709SE01, MS7709ASE01, and MS7750SE01
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
19 #include <linux/init.h>
20 #include <linux/irq.h>
21 #include <linux/module.h>
22 #include <linux/io.h>
23 #include <linux/interrupt.h>
25 static void disable_ipr_irq(unsigned int irq)
27 struct ipr_data *p = get_irq_chip_data(irq);
28 /* Set the priority in IPR to 0 */
29 ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << p->shift)), p->addr);
32 static void enable_ipr_irq(unsigned int irq)
34 struct ipr_data *p = get_irq_chip_data(irq);
35 /* Set priority in IPR back to original value */
36 ctrl_outw(ctrl_inw(p->addr) | (p->priority << p->shift), p->addr);
39 static struct irq_chip ipr_irq_chip = {
40 .name = "IPR",
41 .mask = disable_ipr_irq,
42 .unmask = enable_ipr_irq,
43 .mask_ack = disable_ipr_irq,
46 unsigned int map_ipridx_to_addr(int idx) __attribute__ ((weak));
47 unsigned int map_ipridx_to_addr(int idx)
49 return 0;
52 void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
54 int i;
56 for (i = 0; i < nr_irqs; i++) {
57 unsigned int irq = table[i].irq;
59 if (!irq)
60 irq = table[i].irq = i;
62 /* could the IPR index be mapped, if not we ignore this */
63 if (!table[i].addr) {
64 table[i].addr = map_ipridx_to_addr(table[i].ipr_idx);
65 if (!table[i].addr)
66 continue;
69 disable_irq_nosync(irq);
70 set_irq_chip_and_handler_name(irq, &ipr_irq_chip,
71 handle_level_irq, "level");
72 set_irq_chip_data(irq, &table[i]);
73 enable_ipr_irq(irq);
76 EXPORT_SYMBOL(make_ipr_irq);
78 #if !defined(CONFIG_CPU_HAS_PINT_IRQ)
79 int ipr_irq_demux(int irq)
81 return irq;
83 #endif