2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2015-03-06 16:38:20 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Synopsys, Inc. (www.synopsys.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/irqdomain.h>
|
|
|
|
#include <linux/irqchip.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
|
2017-02-02 01:44:33 +08:00
|
|
|
#define NR_EXCEPTIONS 16
|
|
|
|
|
|
|
|
struct bcr_irq_arcv2 {
|
|
|
|
#ifdef CONFIG_CPU_BIG_ENDIAN
|
|
|
|
unsigned int pad:3, firq:1, prio:4, exts:8, irqs:8, ver:8;
|
|
|
|
#else
|
|
|
|
unsigned int ver:8, irqs:8, exts:8, prio:4, firq:1, pad:3;
|
|
|
|
#endif
|
|
|
|
};
|
2017-02-02 02:14:11 +08:00
|
|
|
|
2015-03-06 16:38:20 +08:00
|
|
|
/*
|
|
|
|
* Early Hardware specific Interrupt setup
|
|
|
|
* -Called very early (start_kernel -> setup_arch -> setup_processor)
|
|
|
|
* -Platform Independent (must for any ARC Core)
|
|
|
|
* -Needed for each CPU (hence not foldable into init_IRQ)
|
|
|
|
*/
|
|
|
|
void arc_init_IRQ(void)
|
|
|
|
{
|
2017-01-31 19:45:24 +08:00
|
|
|
unsigned int tmp, irq_prio, i;
|
2017-02-02 01:44:33 +08:00
|
|
|
struct bcr_irq_arcv2 irq_bcr;
|
2016-02-07 15:24:35 +08:00
|
|
|
|
2015-03-06 16:38:20 +08:00
|
|
|
struct aux_irq_ctrl {
|
|
|
|
#ifdef CONFIG_CPU_BIG_ENDIAN
|
|
|
|
unsigned int res3:18, save_idx_regs:1, res2:1,
|
|
|
|
save_u_to_u:1, save_lp_regs:1, save_blink:1,
|
|
|
|
res:4, save_nr_gpr_pairs:5;
|
|
|
|
#else
|
|
|
|
unsigned int save_nr_gpr_pairs:5, res:4,
|
|
|
|
save_blink:1, save_lp_regs:1, save_u_to_u:1,
|
|
|
|
res2:1, save_idx_regs:1, res3:18;
|
|
|
|
#endif
|
|
|
|
} ictrl;
|
|
|
|
|
|
|
|
*(unsigned int *)&ictrl = 0;
|
|
|
|
|
2018-06-07 01:20:37 +08:00
|
|
|
#ifndef CONFIG_ARC_IRQ_NO_AUTOSAVE
|
2015-03-06 16:38:20 +08:00
|
|
|
ictrl.save_nr_gpr_pairs = 6; /* r0 to r11 (r12 saved manually) */
|
|
|
|
ictrl.save_blink = 1;
|
|
|
|
ictrl.save_lp_regs = 1; /* LP_COUNT, LP_START, LP_END */
|
|
|
|
ictrl.save_u_to_u = 0; /* user ctxt saved on kernel stack */
|
|
|
|
ictrl.save_idx_regs = 1; /* JLI, LDI, EI */
|
2018-06-07 01:20:37 +08:00
|
|
|
#endif
|
2015-03-06 16:38:20 +08:00
|
|
|
|
|
|
|
WRITE_AUX(AUX_IRQ_CTRL, ictrl);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ARCv2 core intc provides multiple interrupt priorities (upto 16).
|
|
|
|
* Typical builds though have only two levels (0-high, 1-low)
|
|
|
|
* Linux by default uses lower prio 1 for most irqs, reserving 0 for
|
|
|
|
* NMI style interrupts in future (say perf)
|
|
|
|
*/
|
2016-02-07 15:24:35 +08:00
|
|
|
|
|
|
|
READ_BCR(ARC_REG_IRQ_BCR, irq_bcr);
|
|
|
|
|
|
|
|
irq_prio = irq_bcr.prio; /* Encoded as N-1 for N levels */
|
|
|
|
pr_info("archs-intc\t: %d priority levels (default %d)%s\n",
|
2016-10-01 07:13:28 +08:00
|
|
|
irq_prio + 1, ARCV2_IRQ_DEF_PRIO,
|
2016-02-07 15:24:35 +08:00
|
|
|
irq_bcr.firq ? " FIRQ (not used)":"");
|
|
|
|
|
2017-01-31 19:45:24 +08:00
|
|
|
/*
|
|
|
|
* Set a default priority for all available interrupts to prevent
|
|
|
|
* switching of register banks if Fast IRQ and multiple register banks
|
|
|
|
* are supported by CPU.
|
ARCv2: SMP: Mask only private-per-core IRQ lines on boot at core intc
Recent commit a8ec3ee861b6 "arc: Mask individual IRQ lines during core
INTC init" breaks interrupt handling on ARCv2 SMP systems.
That commit masked all interrupts at onset, as some controllers on some
boards (customer as well as internal), would assert interrutps early
before any handlers were installed. For SMP systems, the masking was
done at each cpu's core-intc. Later, when the IRQ was actually
requested, it was unmasked, but only on the requesting cpu.
For "common" interrupts, which were wired up from the 2nd level IDU
intc, this was as issue as they needed to be enabled on ALL the cpus
(given that IDU IRQs are by default served Round Robin across cpus)
So fix that by NOT masking "common" interrupts at core-intc, but instead
at the 2nd level IDU intc (latter already being done in idu_of_init())
Fixes: a8ec3ee861b6 ("arc: Mask individual IRQ lines during core INTC init")
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
[vgupta: reworked changelog, removed the extraneous idu_irq_mask_raw()]
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-08-29 06:03:58 +08:00
|
|
|
* Also disable private-per-core IRQ lines so faulty external HW won't
|
2017-08-10 23:07:36 +08:00
|
|
|
* trigger interrupt that kernel is not ready to handle.
|
2017-01-31 19:45:24 +08:00
|
|
|
*/
|
|
|
|
for (i = NR_EXCEPTIONS; i < irq_bcr.irqs + NR_EXCEPTIONS; i++) {
|
|
|
|
write_aux_reg(AUX_IRQ_SELECT, i);
|
|
|
|
write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO);
|
ARCv2: SMP: Mask only private-per-core IRQ lines on boot at core intc
Recent commit a8ec3ee861b6 "arc: Mask individual IRQ lines during core
INTC init" breaks interrupt handling on ARCv2 SMP systems.
That commit masked all interrupts at onset, as some controllers on some
boards (customer as well as internal), would assert interrutps early
before any handlers were installed. For SMP systems, the masking was
done at each cpu's core-intc. Later, when the IRQ was actually
requested, it was unmasked, but only on the requesting cpu.
For "common" interrupts, which were wired up from the 2nd level IDU
intc, this was as issue as they needed to be enabled on ALL the cpus
(given that IDU IRQs are by default served Round Robin across cpus)
So fix that by NOT masking "common" interrupts at core-intc, but instead
at the 2nd level IDU intc (latter already being done in idu_of_init())
Fixes: a8ec3ee861b6 ("arc: Mask individual IRQ lines during core INTC init")
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
[vgupta: reworked changelog, removed the extraneous idu_irq_mask_raw()]
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-08-29 06:03:58 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Only mask cpu private IRQs here.
|
|
|
|
* "common" interrupts are masked at IDU, otherwise it would
|
|
|
|
* need to be unmasked at each cpu, with IPIs
|
|
|
|
*/
|
|
|
|
if (i < FIRST_EXT_IRQ)
|
|
|
|
write_aux_reg(AUX_IRQ_ENABLE, 0);
|
2017-01-31 19:45:24 +08:00
|
|
|
}
|
|
|
|
|
2016-02-07 15:24:35 +08:00
|
|
|
/* setup status32, don't enable intr yet as kernel doesn't want */
|
2017-01-31 19:45:21 +08:00
|
|
|
tmp = read_aux_reg(ARC_REG_STATUS32);
|
2019-01-31 00:32:41 +08:00
|
|
|
tmp |= ARCV2_IRQ_DEF_PRIO << 1;
|
2016-02-07 15:24:35 +08:00
|
|
|
tmp &= ~STATUS_IE_MASK;
|
2016-09-12 23:55:03 +08:00
|
|
|
asm volatile("kflag %0 \n"::"r"(tmp));
|
2015-03-06 16:38:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void arcv2_irq_mask(struct irq_data *data)
|
|
|
|
{
|
2016-12-28 16:46:24 +08:00
|
|
|
write_aux_reg(AUX_IRQ_SELECT, data->hwirq);
|
2015-03-06 16:38:20 +08:00
|
|
|
write_aux_reg(AUX_IRQ_ENABLE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void arcv2_irq_unmask(struct irq_data *data)
|
|
|
|
{
|
2016-12-28 16:46:24 +08:00
|
|
|
write_aux_reg(AUX_IRQ_SELECT, data->hwirq);
|
2015-03-06 16:38:20 +08:00
|
|
|
write_aux_reg(AUX_IRQ_ENABLE, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void arcv2_irq_enable(struct irq_data *data)
|
|
|
|
{
|
|
|
|
/* set default priority */
|
2016-12-28 16:46:24 +08:00
|
|
|
write_aux_reg(AUX_IRQ_SELECT, data->hwirq);
|
2016-10-01 07:13:28 +08:00
|
|
|
write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO);
|
2015-03-06 16:38:20 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* hw auto enables (linux unmask) all by default
|
|
|
|
* So no need to do IRQ_ENABLE here
|
|
|
|
* XXX: However OSCI LAN need it
|
|
|
|
*/
|
|
|
|
write_aux_reg(AUX_IRQ_ENABLE, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct irq_chip arcv2_irq_chip = {
|
|
|
|
.name = "ARCv2 core Intc",
|
|
|
|
.irq_mask = arcv2_irq_mask,
|
|
|
|
.irq_unmask = arcv2_irq_unmask,
|
|
|
|
.irq_enable = arcv2_irq_enable
|
|
|
|
};
|
|
|
|
|
|
|
|
static int arcv2_irq_map(struct irq_domain *d, unsigned int irq,
|
|
|
|
irq_hw_number_t hw)
|
|
|
|
{
|
2015-12-11 18:24:03 +08:00
|
|
|
/*
|
|
|
|
* core intc IRQs [16, 23]:
|
|
|
|
* Statically assigned always private-per-core (Timers, WDT, IPI, PCT)
|
|
|
|
*/
|
2017-02-02 01:44:33 +08:00
|
|
|
if (hw < FIRST_EXT_IRQ) {
|
2015-12-11 18:24:03 +08:00
|
|
|
/*
|
|
|
|
* A subsequent request_percpu_irq() fails if percpu_devid is
|
|
|
|
* not set. That in turns sets NOAUTOEN, meaning each core needs
|
|
|
|
* to call enable_percpu_irq()
|
|
|
|
*/
|
|
|
|
irq_set_percpu_devid(irq);
|
2015-03-06 16:38:20 +08:00
|
|
|
irq_set_chip_and_handler(irq, &arcv2_irq_chip, handle_percpu_irq);
|
2015-12-11 18:24:03 +08:00
|
|
|
} else {
|
2015-03-06 16:38:20 +08:00
|
|
|
irq_set_chip_and_handler(irq, &arcv2_irq_chip, handle_level_irq);
|
2015-12-11 18:24:03 +08:00
|
|
|
}
|
2015-03-06 16:38:20 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct irq_domain_ops arcv2_irq_ops = {
|
|
|
|
.xlate = irq_domain_xlate_onecell,
|
|
|
|
.map = arcv2_irq_map,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
init_onchip_IRQ(struct device_node *intc, struct device_node *parent)
|
|
|
|
{
|
2016-01-01 17:42:54 +08:00
|
|
|
struct irq_domain *root_domain;
|
2017-02-02 01:44:33 +08:00
|
|
|
struct bcr_irq_arcv2 irq_bcr;
|
|
|
|
unsigned int nr_cpu_irqs;
|
|
|
|
|
|
|
|
READ_BCR(ARC_REG_IRQ_BCR, irq_bcr);
|
|
|
|
nr_cpu_irqs = irq_bcr.irqs + NR_EXCEPTIONS;
|
2016-01-01 17:42:54 +08:00
|
|
|
|
2015-03-06 16:38:20 +08:00
|
|
|
if (parent)
|
|
|
|
panic("DeviceTree incore intc not a root irq controller\n");
|
|
|
|
|
2017-02-02 01:44:33 +08:00
|
|
|
root_domain = irq_domain_add_linear(intc, nr_cpu_irqs, &arcv2_irq_ops, NULL);
|
2015-03-06 16:38:20 +08:00
|
|
|
if (!root_domain)
|
|
|
|
panic("root irq domain not avail\n");
|
|
|
|
|
2016-01-01 17:42:54 +08:00
|
|
|
/*
|
|
|
|
* Needed for primary domain lookup to succeed
|
|
|
|
* This is a primary irqchip, and can never have a parent
|
|
|
|
*/
|
2015-03-06 16:38:20 +08:00
|
|
|
irq_set_default_host(root_domain);
|
|
|
|
|
2016-01-28 12:10:10 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
irq_create_mapping(root_domain, IPI_IRQ);
|
|
|
|
#endif
|
|
|
|
irq_create_mapping(root_domain, SOFTIRQ_IRQ);
|
|
|
|
|
2015-03-06 16:38:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IRQCHIP_DECLARE(arc_intc, "snps,archs-intc", init_onchip_IRQ);
|