Skip to content

Commit 981b58f

Browse files
Rich FelkerJason Cooper
authored andcommitted
irqchip/jcore-aic: Add J-Core AIC driver
There are two versions of the J-Core interrupt controller in use, aic1 which generates interrupts with programmable priorities, but only supports 8 irq lines and maps them to cpu traps in the range 17 to 24, and aic2 which uses traps in the range 64-127 and supports up to 128 irqs, with priorities dependent on the interrupt number. The Linux driver does not make use of priorities anyway. For simplicity, there is no aic1-specific logic in the driver beyond setting the priority register, which is necessary for interrupts to work at all. Eventually aic1 will likely be phased out, but it's currently in use in deployments and all released bitstream binaries. Signed-off-by: Rich Felker <[email protected]> Link: https://lkml.kernel.org/r/c3b89ef74aaa6477575dbe2d410eb1d182503243.147018b6529.git.dalias@libc.org Signed-off-by: Jason Cooper <[email protected]>
1 parent a9da291 commit 981b58f

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

drivers/irqchip/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ config PIC32_EVIC
156156
select GENERIC_IRQ_CHIP
157157
select IRQ_DOMAIN
158158

159+
config JCORE_AIC
160+
bool "J-Core integrated AIC"
161+
depends on OF && (SUPERH || COMPILE_TEST)
162+
select IRQ_DOMAIN
163+
help
164+
Support for the J-Core integrated AIC.
165+
159166
config RENESAS_INTC_IRQPIN
160167
bool
161168
select IRQ_DOMAIN

drivers/irqchip/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ obj-$(CONFIG_I8259) += irq-i8259.o
4040
obj-$(CONFIG_IMGPDC_IRQ) += irq-imgpdc.o
4141
obj-$(CONFIG_IRQ_MIPS_CPU) += irq-mips-cpu.o
4242
obj-$(CONFIG_SIRF_IRQ) += irq-sirfsoc.o
43+
obj-$(CONFIG_JCORE_AIC) += irq-jcore-aic.o
4344
obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o
4445
obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o
4546
obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o

drivers/irqchip/irq-jcore-aic.c

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* J-Core SoC AIC driver
3+
*
4+
* Copyright (C) 2015-2016 Smart Energy Instruments, Inc.
5+
*
6+
* This file is subject to the terms and conditions of the GNU General Public
7+
* License. See the file "COPYING" in the main directory of this archive
8+
* for more details.
9+
*/
10+
11+
#include <linux/irq.h>
12+
#include <linux/io.h>
13+
#include <linux/irqchip.h>
14+
#include <linux/irqdomain.h>
15+
#include <linux/cpu.h>
16+
#include <linux/of.h>
17+
#include <linux/of_address.h>
18+
#include <linux/of_irq.h>
19+
20+
#define JCORE_AIC_MAX_HWIRQ 127
21+
#define JCORE_AIC1_MIN_HWIRQ 16
22+
#define JCORE_AIC2_MIN_HWIRQ 64
23+
24+
#define JCORE_AIC1_INTPRI_REG 8
25+
26+
static struct irq_chip jcore_aic;
27+
28+
static int jcore_aic_irqdomain_map(struct irq_domain *d, unsigned int irq,
29+
irq_hw_number_t hwirq)
30+
{
31+
struct irq_chip *aic = d->host_data;
32+
33+
irq_set_chip_and_handler(irq, aic, handle_simple_irq);
34+
35+
return 0;
36+
}
37+
38+
static const struct irq_domain_ops jcore_aic_irqdomain_ops = {
39+
.map = jcore_aic_irqdomain_map,
40+
.xlate = irq_domain_xlate_onecell,
41+
};
42+
43+
static void noop(struct irq_data *data)
44+
{
45+
}
46+
47+
int __init aic_irq_of_init(struct device_node *node, struct device_node *parent)
48+
{
49+
unsigned min_irq = JCORE_AIC2_MIN_HWIRQ;
50+
unsigned dom_sz = JCORE_AIC_MAX_HWIRQ+1;
51+
struct irq_domain *domain;
52+
53+
pr_info("Initializing J-Core AIC\n");
54+
55+
/* AIC1 needs priority initialization to receive interrupts. */
56+
if (of_device_is_compatible(node, "jcore,aic1")) {
57+
unsigned cpu;
58+
59+
for_each_present_cpu(cpu) {
60+
void __iomem *base = of_iomap(node, cpu);
61+
62+
if (!base) {
63+
pr_err("Unable to map AIC for cpu %u\n", cpu);
64+
return -ENOMEM;
65+
}
66+
__raw_writel(0xffffffff, base + JCORE_AIC1_INTPRI_REG);
67+
iounmap(base);
68+
}
69+
min_irq = JCORE_AIC1_MIN_HWIRQ;
70+
}
71+
72+
/*
73+
* The irq chip framework requires either mask/unmask or enable/disable
74+
* function pointers to be provided, but the hardware does not have any
75+
* such mechanism; the only interrupt masking is at the cpu level and
76+
* it affects all interrupts. We provide dummy mask/unmask. The hardware
77+
* handles all interrupt control and clears pending status when the cpu
78+
* accepts the interrupt.
79+
*/
80+
jcore_aic.irq_mask = noop;
81+
jcore_aic.irq_unmask = noop;
82+
jcore_aic.name = "AIC";
83+
84+
domain = irq_domain_add_linear(node, dom_sz, &jcore_aic_irqdomain_ops,
85+
&jcore_aic);
86+
if (!domain)
87+
return -ENOMEM;
88+
irq_create_strict_mappings(domain, min_irq, min_irq, dom_sz - min_irq);
89+
90+
return 0;
91+
}
92+
93+
IRQCHIP_DECLARE(jcore_aic2, "jcore,aic2", aic_irq_of_init);
94+
IRQCHIP_DECLARE(jcore_aic1, "jcore,aic1", aic_irq_of_init);

0 commit comments

Comments
 (0)