1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2013 Altera Corporation
7 * based on irq.c from m68k which is:
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/irqdomain.h>
19 asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs)
21 struct pt_regs *oldregs = set_irq_regs(regs);
24 generic_handle_domain_irq(NULL, hwirq);
27 set_irq_regs(oldregs);
30 static void chip_unmask(struct irq_data *d)
32 ienable |= (1 << d->hwirq);
33 WRCTL(CTL_IENABLE, ienable);
36 static void chip_mask(struct irq_data *d)
38 ienable &= ~(1 << d->hwirq);
39 WRCTL(CTL_IENABLE, ienable);
42 static struct irq_chip m_irq_chip = {
44 .irq_unmask = chip_unmask,
45 .irq_mask = chip_mask,
48 static int irq_map(struct irq_domain *h, unsigned int virq,
49 irq_hw_number_t hw_irq_num)
51 irq_set_chip_and_handler(virq, &m_irq_chip, handle_level_irq);
56 static const struct irq_domain_ops irq_ops = {
58 .xlate = irq_domain_xlate_onecell,
61 void __init init_IRQ(void)
63 struct irq_domain *domain;
64 struct device_node *node;
66 node = of_find_compatible_node(NULL, NULL, "altr,nios2-1.0");
68 node = of_find_compatible_node(NULL, NULL, "altr,nios2-1.1");
72 domain = irq_domain_add_linear(node, NIOS2_CPU_NR_IRQS, &irq_ops, NULL);
75 irq_set_default_host(domain);
77 /* Load the initial ienable value */
78 ienable = RDCTL(CTL_IENABLE);