2 * Copyright (C) 2013 Altera Corporation
3 * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
4 * Copyright (C) 2008 Thomas Chou <thomas@wytron.com.tw>
6 * based on irq.c from m68k which is:
8 * Copyright (C) 2007 Greg Ungerer <gerg@snapgear.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <linux/init.h>
26 #include <linux/interrupt.h>
31 asmlinkage
void do_IRQ(int hwirq
, struct pt_regs
*regs
)
33 struct pt_regs
*oldregs
= set_irq_regs(regs
);
37 irq
= irq_find_mapping(NULL
, hwirq
);
38 generic_handle_irq(irq
);
41 set_irq_regs(oldregs
);
44 static void chip_unmask(struct irq_data
*d
)
46 ienable
|= (1 << d
->hwirq
);
47 WRCTL(CTL_IENABLE
, ienable
);
50 static void chip_mask(struct irq_data
*d
)
52 ienable
&= ~(1 << d
->hwirq
);
53 WRCTL(CTL_IENABLE
, ienable
);
56 static struct irq_chip m_irq_chip
= {
58 .irq_unmask
= chip_unmask
,
59 .irq_mask
= chip_mask
,
62 static int irq_map(struct irq_domain
*h
, unsigned int virq
,
63 irq_hw_number_t hw_irq_num
)
65 irq_set_chip_and_handler(virq
, &m_irq_chip
, handle_level_irq
);
70 static struct irq_domain_ops irq_ops
= {
72 .xlate
= irq_domain_xlate_onecell
,
75 void __init
init_IRQ(void)
77 struct irq_domain
*domain
;
78 struct device_node
*node
;
80 node
= of_find_compatible_node(NULL
, NULL
, "altr,nios2-1.0");
82 node
= of_find_compatible_node(NULL
, NULL
, "altr,nios2-1.1");
86 domain
= irq_domain_add_linear(node
, NIOS2_CPU_NR_IRQS
, &irq_ops
, NULL
);
89 irq_set_default_host(domain
);
91 /* Load the initial ienable value */
92 ienable
= RDCTL(CTL_IENABLE
);