treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / nios2 / kernel / irq.c
blob5f3555ce48656b3498ae01c02347cce84dca8561
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2013 Altera Corporation
4 * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
5 * Copyright (C) 2008 Thomas Chou <thomas@wytron.com.tw>
7 * based on irq.c from m68k which is:
9 * Copyright (C) 2007 Greg Ungerer <gerg@snapgear.com>
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/of.h>
16 static u32 ienable;
18 asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs)
20 struct pt_regs *oldregs = set_irq_regs(regs);
21 int irq;
23 irq_enter();
24 irq = irq_find_mapping(NULL, hwirq);
25 generic_handle_irq(irq);
26 irq_exit();
28 set_irq_regs(oldregs);
31 static void chip_unmask(struct irq_data *d)
33 ienable |= (1 << d->hwirq);
34 WRCTL(CTL_IENABLE, ienable);
37 static void chip_mask(struct irq_data *d)
39 ienable &= ~(1 << d->hwirq);
40 WRCTL(CTL_IENABLE, ienable);
43 static struct irq_chip m_irq_chip = {
44 .name = "NIOS2-INTC",
45 .irq_unmask = chip_unmask,
46 .irq_mask = chip_mask,
49 static int irq_map(struct irq_domain *h, unsigned int virq,
50 irq_hw_number_t hw_irq_num)
52 irq_set_chip_and_handler(virq, &m_irq_chip, handle_level_irq);
54 return 0;
57 static const struct irq_domain_ops irq_ops = {
58 .map = irq_map,
59 .xlate = irq_domain_xlate_onecell,
62 void __init init_IRQ(void)
64 struct irq_domain *domain;
65 struct device_node *node;
67 node = of_find_compatible_node(NULL, NULL, "altr,nios2-1.0");
68 if (!node)
69 node = of_find_compatible_node(NULL, NULL, "altr,nios2-1.1");
71 BUG_ON(!node);
73 domain = irq_domain_add_linear(node, NIOS2_CPU_NR_IRQS, &irq_ops, NULL);
74 BUG_ON(!domain);
76 irq_set_default_host(domain);
77 of_node_put(node);
78 /* Load the initial ienable value */
79 ienable = RDCTL(CTL_IENABLE);