linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Noam Camus <noamc@ezchip.com>
To: <linux-snps-arc@lists.infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <talz@ezchip.com>,
	<gilf@ezchip.com>, <cmetcalf@ezchip.com>,
	Noam Camus <noamc@ezchip.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jason Cooper <jason@lakedaemon.net>,
	Marc Zyngier <marc.zyngier@arm.com>
Subject: [PATCH v2 04/19] irqchip: add nps Internal and external irqchips
Date: Sat, 7 Nov 2015 12:52:22 +0200	[thread overview]
Message-ID: <1446893557-29748-5-git-send-email-noamc@ezchip.com> (raw)
In-Reply-To: <1446297327-16298-1-git-send-email-noamc@ezchip.com>

From: Noam Camus <noamc@ezchip.com>

Adding EZchip NPS400 support.
NPS internal interrupts are internally handled at
Multi Thread Manager (MTM) that is signaled for deactivating
an interrupt.
External interrupts is handled also at Global Interrupt
Controller (GIC) e.g. serial and network devices.

Signed-off-by: Noam Camus <noamc@ezchip.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Marc Zyngier <marc.zyngier@arm.com>
---
 .../interrupt-controller/ezchip,nps400-ic.txt      |   17 ++
 drivers/irqchip/Makefile                           |    1 +
 drivers/irqchip/irq-eznps.c                        |  222 ++++++++++++++++++++
 3 files changed, 240 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/ezchip,nps400-ic.txt
 create mode 100644 drivers/irqchip/irq-eznps.c

diff --git a/Documentation/devicetree/bindings/interrupt-controller/ezchip,nps400-ic.txt b/Documentation/devicetree/bindings/interrupt-controller/ezchip,nps400-ic.txt
new file mode 100644
index 0000000..888b2b9
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/ezchip,nps400-ic.txt
@@ -0,0 +1,17 @@
+EZchip NPS Interrupt Controller
+
+Required properties:
+
+- compatible : should be "ezchip,nps400-ic"
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells : Specifies the number of cells needed to encode an
+  interrupt source. The value shall be 1.
+
+
+Example:
+
+intc: interrupt-controller {
+	compatible = "ezchip,nps400-ic";
+	interrupt-controller;
+	#interrupt-cells = <1>;
+};
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index bb3048f..decfc87 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -55,3 +55,4 @@ obj-$(CONFIG_RENESAS_H8S_INTC)		+= irq-renesas-h8s.o
 obj-$(CONFIG_ARCH_SA1100)		+= irq-sa11x0.o
 obj-$(CONFIG_INGENIC_IRQ)		+= irq-ingenic.o
 obj-$(CONFIG_IMX_GPCV2)			+= irq-imx-gpcv2.o
+obj-$(CONFIG_ARC_PLAT_EZNPS)		+= irq-eznps.o
diff --git a/drivers/irqchip/irq-eznps.c b/drivers/irqchip/irq-eznps.c
new file mode 100644
index 0000000..78f3667
--- /dev/null
+++ b/drivers/irqchip/irq-eznps.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright(c) 2015 EZchip Technologies.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * The full GNU General Public License is included in this distribution in
+ * the file called "COPYING".
+ */
+
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/irqdomain.h>
+#include <linux/irqchip.h>
+#include <asm/irq.h>
+#include <plat/mtm.h>
+#include <plat/smp.h>
+
+#define NPS_MSU_EN_CFG	0x80
+
+/* Messaging and Scheduling Unit:
+ * Provides message management for a CPU cluster.
+ */
+static void __init eznps_configure_msu(void)
+{
+	int cpu;
+	struct nps_host_reg_msu_en_cfg {
+		union {
+			struct {
+				u32     __reserved1:11,
+				rtc_en:1, ipc_en:1, gim_1_en:1,
+				gim_0_en:1, ipi_en:1, buff_e_rls_bmuw:1,
+				buff_e_alc_bmuw:1, buff_i_rls_bmuw:1,
+				buff_i_alc_bmuw:1, buff_e_rls_bmue:1,
+				buff_e_alc_bmue:1, buff_i_rls_bmue:1,
+				buff_i_alc_bmue:1, __reserved2:1,
+				buff_e_pre_en:1, buff_i_pre_en:1,
+				pmuw_ja_en:1, pmue_ja_en:1,
+				pmuw_nj_en:1, pmue_nj_en:1, msu_en:1;
+			};
+			u32 value;
+		};
+	};
+	struct nps_host_reg_msu_en_cfg msu_en_cfg = {.value = 0};
+
+	msu_en_cfg.msu_en = 1;
+	msu_en_cfg.ipi_en = 1;
+	msu_en_cfg.gim_0_en = 1;
+	msu_en_cfg.gim_1_en = 1;
+
+	/* Enable IPI and GIM messages on all clusters */
+	for (cpu = 0 ; cpu < eznps_max_cpus; cpu += eznps_cpus_per_cluster)
+		iowrite32be(msu_en_cfg.value,
+			    nps_host_reg(cpu, NPS_MSU_BLKID, NPS_MSU_EN_CFG));
+}
+
+/* Global Interrupt Manager:
+ * Configures and manages up to 64 interrupts from peripherals,
+ * 16 interrupts from CPUs (virtual interrupts) and ECC interrupts.
+ * Receives the interrupts and transmits them to relevant CPU.
+ */
+static void __init eznps_configure_gim(void)
+{
+	u32 reg_value;
+	u32 gim_int_lines;
+	struct nps_host_reg_gim_p_int_dst gim_p_int_dst = {.value = 0};
+
+	gim_int_lines = NPS_GIM_UART_LINE;
+	gim_int_lines |= NPS_GIM_DBG_LAN_TX_DONE_LINE;
+	gim_int_lines |= NPS_GIM_DBG_LAN_RX_RDY_LINE;
+
+	/*
+	 * IRQ polarity
+	 * low or high level
+	 * negative or positive edge
+	 */
+	reg_value = ioread32be(REG_GIM_P_INT_POL_0);
+	reg_value &= ~gim_int_lines;
+	iowrite32be(reg_value, REG_GIM_P_INT_POL_0);
+
+	/* IRQ type level or edge */
+	reg_value = ioread32be(REG_GIM_P_INT_SENS_0);
+	reg_value |= NPS_GIM_DBG_LAN_TX_DONE_LINE;
+	iowrite32be(reg_value, REG_GIM_P_INT_SENS_0);
+
+	/*
+	 * GIM interrupt select type for
+	 * dbg_lan TX and RX interrupts
+	 * should be type 1
+	 * type 0 = IRQ line 6
+	 * type 1 = IRQ line 7
+	 */
+	gim_p_int_dst.is = 1;
+	iowrite32be(gim_p_int_dst.value, REG_GIM_P_INT_DST_10);
+	iowrite32be(gim_p_int_dst.value, REG_GIM_P_INT_DST_11);
+
+	/*
+	 * CTOP IRQ lines should be defined
+	 * as blocking in GIM
+	 */
+	iowrite32be(gim_int_lines, REG_GIM_P_INT_BLK_0);
+
+	/* Enable CTOP IRQ lines in GIM */
+	iowrite32be(gim_int_lines, REG_GIM_P_INT_EN_0);
+}
+
+/*
+ * NPS400 core includes a Interrupt Controller (IC) support.
+ * All cores can deactivate level irqs at first level control
+ * at cores mesh layer called MTM.
+ * For devices out side chip e.g. uart, network there is another
+ * level called Global Interrupt Manager (GIM).
+ * This second level can control level and edge interrupt.
+ */
+
+static void nps400_irq_mask(struct irq_data *data)
+{
+	unsigned int ienb;
+
+	ienb = read_aux_reg(AUX_IENABLE);
+	ienb &= ~(1 << data->irq);
+	write_aux_reg(AUX_IENABLE, ienb);
+}
+
+static void nps400_irq_unmask(struct irq_data *data)
+{
+	unsigned int ienb;
+
+	ienb = read_aux_reg(AUX_IENABLE);
+	ienb |= (1 << data->irq);
+	write_aux_reg(AUX_IENABLE, ienb);
+}
+
+static void nps400_irq_eoi_global(struct irq_data *data)
+{
+	write_aux_reg(CTOP_AUX_IACK, 1 << data->irq);
+
+	/* Don't ack before all device access is done */
+	mb();
+
+	__asm__ __volatile__ (
+	"       .word %0\n"
+	:
+	: "i"(CTOP_INST_RSPI_GIC_0_R12)
+	: "memory");
+}
+
+static void nps400_irq_eoi(struct irq_data *data)
+{
+	write_aux_reg(CTOP_AUX_IACK, 1 << data->irq);
+}
+
+
+static struct irq_chip nps400_irq_chip_fasteoi = {
+	.name		= "NPS400 IC Global",
+	.irq_mask	= nps400_irq_mask,
+	.irq_unmask	= nps400_irq_unmask,
+	.irq_eoi	= nps400_irq_eoi_global,
+};
+
+static struct irq_chip nps400_irq_chip_percpu = {
+	.name		= "NPS400 IC",
+	.irq_mask	= nps400_irq_mask,
+	.irq_unmask	= nps400_irq_unmask,
+	.irq_eoi	= nps400_irq_eoi,
+};
+
+static int nps400_irq_map(struct irq_domain *d, unsigned int irq,
+			  irq_hw_number_t hw)
+{
+	switch (irq) {
+	case TIMER0_IRQ:
+#if defined(CONFIG_SMP)
+	case IPI_IRQ:
+#endif
+		irq_set_chip_and_handler(irq, &nps400_irq_chip_percpu,
+					 handle_percpu_irq);
+	break;
+	default:
+		irq_set_chip_and_handler(irq, &nps400_irq_chip_fasteoi,
+					 handle_fasteoi_irq);
+	break;
+	}
+
+	return 0;
+}
+
+static const struct irq_domain_ops nps400_irq_ops = {
+	.xlate = irq_domain_xlate_onecell,
+	.map = nps400_irq_map,
+};
+
+static struct irq_domain *nps400_root_domain;
+
+static int __init nps400_of_init(struct device_node *node,
+				 struct device_node *parent)
+{
+	if (parent)
+		panic("DeviceTree incore ic not a root irq controller\n");
+
+	eznps_configure_msu();
+	eznps_configure_gim();
+
+	nps400_root_domain = irq_domain_add_legacy(node, NR_CPU_IRQS, 0, 0,
+						   &nps400_irq_ops, NULL);
+
+	if (!nps400_root_domain)
+		panic("nps400 root irq domain not avail\n");
+
+	/* with this we don't need to export nps400_root_domain */
+	irq_set_default_host(nps400_root_domain);
+
+	return 0;
+}
+IRQCHIP_DECLARE(ezchip_nps400_ic, "ezchip,nps400-ic", nps400_of_init);
-- 
1.7.1


  parent reply	other threads:[~2015-11-07 10:55 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-31 13:15 [PATCH v1 00/20] eznps a new ARC platform Noam Camus
2015-10-31 13:15 ` [PATCH v1 01/20] Documentation: Add EZchip vendor to binding list Noam Camus
2015-10-31 13:15 ` [PATCH v1 02/20] clocksource: Add NPS400 timers driver Noam Camus
2015-11-01 20:44   ` Daniel Lezcano
2015-11-02  7:57     ` Noam Camus
2015-11-02 11:03   ` Vineet Gupta
2015-11-03 15:18     ` Noam Camus
2015-10-31 13:15 ` [PATCH v1 03/20] irqchip: add nps Internal and external irqchips Noam Camus
2015-10-31 13:15 ` [PATCH v1 04/20] ARC: Set vmalloc size from configuration Noam Camus
2015-10-31 13:15 ` [PATCH v1 05/20] ARC: rwlock: disable interrupts in !LLSC variant Noam Camus
2015-11-02  9:16   ` Peter Zijlstra
2015-11-02  9:42   ` Vineet Gupta
2015-11-02 10:03     ` Peter Zijlstra
2015-10-31 13:15 ` [PATCH v1 06/20] ARC: Mark cpu online only after it has executed the per cpu init hook Noam Camus
2015-10-31 13:15 ` [PATCH v1 07/20] ARC: mm: use generic macros _BITUL() Noam Camus
2015-11-02  6:23   ` Vineet Gupta
2015-11-02  6:27     ` Noam Camus
2015-10-31 13:15 ` [PATCH v1 08/20] ARC: Use res_service as entry point for secondaries Noam Camus
2015-11-02  6:38   ` Vineet Gupta
2015-11-02  8:05     ` Noam Camus
2015-10-31 13:15 ` [PATCH v1 09/20] ARC: add CONFIG_CLKSRC_OF support to time_init() Noam Camus
2015-11-02  6:32   ` Vineet Gupta
2015-10-31 13:15 ` [PATCH v1 10/20] ARC: [plat-eznps] Add eznps board defconfig and dts Noam Camus
2015-10-31 13:15 ` [PATCH v1 11/20] ARC: [plat-eznps] Add eznps platform Noam Camus
2015-11-02 10:56   ` Vineet Gupta
2015-11-03 15:59     ` Noam Camus
2015-11-04 12:38     ` Noam Camus
2015-11-05  5:09   ` Vineet Gupta
2015-10-31 13:15 ` [PATCH v1 12/20] ARC: [plat-eznps] Use dedicated user stack top Noam Camus
2015-10-31 13:15 ` [PATCH v1 13/20] ARC: [plat-eznps] Use dedicated bitops/atomic/cmpxchg Noam Camus
2015-11-02 11:56   ` Vineet Gupta
2015-10-31 13:15 ` [PATCH v1 14/20] ARC: [plat-eznps] Use dedicated SMP barriers Noam Camus
2015-11-02  8:02   ` Vineet Gupta
2015-11-02 13:08     ` Noam Camus
2015-10-31 13:15 ` [PATCH v1 15/20] ARC: [plat-eznps] Use dedicated identity auxiliary register Noam Camus
2015-10-31 13:15 ` [PATCH v1 16/20] ARC: [plat-eznps] Use dedicated cpu_relax() Noam Camus
2015-11-02  7:54   ` Vineet Gupta
2015-11-02  9:21   ` Peter Zijlstra
2015-11-03 14:02     ` Noam Camus
2015-10-31 13:15 ` [PATCH v1 17/20] ARC: [plat-eznps] Use dedicated COMMAND_LINE_SIZE Noam Camus
2015-10-31 13:15 ` [PATCH v1 18/20] ARC: [plat-eznps] define IPI_IRQ Noam Camus
2015-11-02  7:52   ` Vineet Gupta
2015-11-02 12:16     ` Noam Camus
2015-10-31 13:15 ` [PATCH v1 19/20] ARC: [plat-eznps] replace sync with proper cpu barrier Noam Camus
2015-11-02  7:48   ` Vineet Gupta
2015-11-02  9:26     ` Peter Zijlstra
2015-11-17 13:48       ` [PATCH] ARC: remove SYNC from __switch_to() Vineet Gupta
2015-10-31 13:15 ` [PATCH v1 20/20] ARC: Add eznps platform to Kconfig and Makefile Noam Camus
2015-11-02 11:06   ` Vineet Gupta
2015-11-03 15:32     ` Noam Camus
2015-11-04 15:35 ` [PATCH v1 00/20] eznps a new ARC platform Vineet Gupta
2015-11-04 15:53   ` Noam Camus
2015-11-04 17:42     ` Vineet Gupta
2015-11-07 10:52 ` [PATCH v2 00/19] " Noam Camus
2015-11-07 10:52 ` [PATCH v2 01/19] Documentation: Add EZchip vendor to binding list Noam Camus
2015-11-07 10:52 ` [PATCH v2 02/19] ARC: [plat-eznps] define IPI_IRQ Noam Camus
2015-11-07 10:52 ` [PATCH v2 03/19] clocksource: Add NPS400 timers driver Noam Camus
2015-11-07 11:26   ` Thomas Gleixner
2015-11-20 11:59     ` Noam Camus
2015-11-07 10:52 ` Noam Camus [this message]
2015-11-07 11:38   ` [PATCH v2 04/19] irqchip: add nps Internal and external irqchips Thomas Gleixner
2015-11-07 20:52     ` Noam Camus
2015-11-07 23:52       ` Thomas Gleixner
2015-11-07 10:52 ` [PATCH v2 05/19] ARC: Set vmalloc size from configuration Noam Camus
2015-11-07 10:52 ` [PATCH v2 06/19] ARC: rwlock: disable interrupts in !LLSC variant Noam Camus
2015-11-07 10:52 ` [PATCH v2 07/19] ARC: rename smp operation init_irq_cpu() to init_per_cpu() Noam Camus
2015-11-17 11:15   ` Vineet Gupta
2015-11-17 11:38     ` Noam Camus
2015-11-17 11:42       ` Vineet Gupta
2015-11-07 10:52 ` [PATCH v2 08/19] ARC: Mark secondary cpu online only after all HW setup is done Noam Camus
2015-11-17 11:17   ` Vineet Gupta
2015-11-07 10:52 ` [PATCH v2 09/19] ARC: add CONFIG_CLKSRC_OF support to time_init() Noam Camus
2015-11-07 10:52 ` [PATCH v2 10/19] ARC: [plat-eznps] Add eznps board defconfig and dts Noam Camus
2015-11-07 10:52 ` [PATCH v2 11/19] ARC: [plat-eznps] Add eznps platform Noam Camus
2015-11-07 10:52 ` [PATCH v2 12/19] ARC: [plat-eznps] Use dedicated user stack top Noam Camus
2015-11-07 10:52 ` [PATCH v2 13/19] ARC: [plat-eznps] Use dedicated atomic/bitops/cmpxchg Noam Camus
2015-11-07 10:52 ` [PATCH v2 14/19] ARC: [plat-eznps] Use dedicated SMP barriers Noam Camus
2015-11-07 10:52 ` [PATCH v2 15/19] ARC: [plat-eznps] Use dedicated identity auxiliary register Noam Camus
2015-11-07 10:52 ` [PATCH v2 16/19] ARC: [plat-eznps] Use dedicated cpu_relax() Noam Camus
2015-11-09 10:05   ` Peter Zijlstra
2015-11-09 10:22     ` Vineet Gupta
2015-11-09 10:45       ` Peter Zijlstra
2015-11-09 12:27         ` Vineet Gupta
2015-11-09 12:51           ` Peter Zijlstra
2015-11-07 10:52 ` [PATCH v2 17/19] ARC: [plat-eznps] Use dedicated COMMAND_LINE_SIZE Noam Camus
2015-11-07 10:52 ` [PATCH v2 18/19] ARC: [plat-eznps] replace sync with proper cpu barrier Noam Camus
2015-11-17 11:12   ` Vineet Gupta
2015-11-17 11:23     ` Peter Zijlstra
2015-11-17 11:37       ` Vineet Gupta
2015-11-17 12:22         ` Peter Zijlstra
2015-11-17 12:37           ` Vineet Gupta
2015-11-17 12:44             ` Peter Zijlstra
2015-11-17 13:32               ` Vineet Gupta
2015-11-17 13:59                 ` Peter Zijlstra
2015-11-07 10:52 ` [PATCH v2 19/19] ARC: Add eznps platform to Kconfig and Makefile Noam Camus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446893557-29748-5-git-send-email-noamc@ezchip.com \
    --to=noamc@ezchip.com \
    --cc=cmetcalf@ezchip.com \
    --cc=gilf@ezchip.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    --cc=talz@ezchip.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).