linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: john.linn@xilinx.com, linuxppc-dev@ozlabs.org,
	jwboyer@linux.vnet.ibm.com, benh@kernel.crashing.org
Subject: [PATCH] powerpc: add cascade support to xilinx intc controller
Date: Tue, 25 Aug 2009 00:08:51 -0600	[thread overview]
Message-ID: <20090825060848.3913.60710.stgit@localhost.localdomain> (raw)

From: Grant Likely <grant.likely@secretlab.ca>

This patch allows the Xilinx intc interrupt controller to be cascaded
instead of being the master irqhost.  Useful when attaching an FPGA
to an SoC that has its own interrupt controller.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

 arch/powerpc/include/asm/xilinx_intc.h |    1 +
 arch/powerpc/sysdev/Kconfig            |    4 ++
 arch/powerpc/sysdev/Makefile           |    2 +
 arch/powerpc/sysdev/xilinx_intc.c      |   61 ++++++++++++++++++++++++++++++--
 4 files changed, 64 insertions(+), 4 deletions(-)


diff --git a/arch/powerpc/include/asm/xilinx_intc.h b/arch/powerpc/include/asm/xilinx_intc.h
index 343612f..47ef6bd 100644
--- a/arch/powerpc/include/asm/xilinx_intc.h
+++ b/arch/powerpc/include/asm/xilinx_intc.h
@@ -13,6 +13,7 @@
 
 #ifdef __KERNEL__
 
+extern int xilinx_intc_cascade_setup(struct device_node *cascade_node);
 extern void __init xilinx_intc_init_tree(void);
 extern unsigned int xilinx_intc_get_irq(void);
 
diff --git a/arch/powerpc/sysdev/Kconfig b/arch/powerpc/sysdev/Kconfig
index 3965828..d78f2da 100644
--- a/arch/powerpc/sysdev/Kconfig
+++ b/arch/powerpc/sysdev/Kconfig
@@ -12,3 +12,7 @@ config PPC_MSI_BITMAP
 	depends on PCI_MSI
 	default y if MPIC
 	default y if FSL_PCI
+
+config XILINX_INTC
+	bool
+	default y if XILINX_VIRTEX
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 9d4b174..1cf11b6 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -35,7 +35,7 @@ obj-$(CONFIG_PPC_I8259)		+= i8259.o
 obj-$(CONFIG_IPIC)		+= ipic.o
 obj-$(CONFIG_4xx)		+= uic.o
 obj-$(CONFIG_4xx_SOC)		+= ppc4xx_soc.o
-obj-$(CONFIG_XILINX_VIRTEX)	+= xilinx_intc.o
+obj-$(CONFIG_XILINX_INTC)	+= xilinx_intc.o
 obj-$(CONFIG_XILINX_PCI)	+= xilinx_pci.o
 obj-$(CONFIG_OF_RTC)		+= of_rtc.o
 ifeq ($(CONFIG_PCI),y)
diff --git a/arch/powerpc/sysdev/xilinx_intc.c b/arch/powerpc/sysdev/xilinx_intc.c
index 3ee1fd3..14ef172 100644
--- a/arch/powerpc/sysdev/xilinx_intc.c
+++ b/arch/powerpc/sysdev/xilinx_intc.c
@@ -188,8 +188,7 @@ static struct irq_host_ops xilinx_intc_ops = {
 	.xlate = xilinx_intc_xlate,
 };
 
-struct irq_host * __init
-xilinx_intc_init(struct device_node *np)
+struct irq_host *xilinx_intc_init(struct device_node *np)
 {
 	struct irq_host * irq;
 	void * regs;
@@ -269,13 +268,69 @@ static void __init xilinx_i8259_setup_cascade(void)
 static inline void xilinx_i8259_setup_cascade(void) { return; }
 #endif /* defined(CONFIG_PPC_I8259) */
 
-static struct of_device_id xilinx_intc_match[] __initconst = {
+static struct of_device_id xilinx_intc_match[] = {
 	{ .compatible = "xlnx,opb-intc-1.00.c", },
 	{ .compatible = "xlnx,xps-intc-1.00.a", },
 	{}
 };
 
 /*
+ * Cascaded Xilinx interrupt controller
+ */
+static void xilinx_intc_cascade(unsigned int virq, struct irq_desc *desc)
+{
+	struct irq_host *cascade_irqhost = get_irq_data(virq);
+	void *regs = cascade_irqhost->host_data;
+	unsigned int cascade_virq;
+
+	pr_debug("%s(virq=%i) irq_host=%p\n", __func__, virq, cascade_irqhost);
+	cascade_virq = irq_linear_revmap(cascade_irqhost,
+					 in_be32(regs + XINTC_IVR));
+	if (cascade_virq)
+		generic_handle_irq(cascade_virq);
+}
+
+/**
+ * xilinx_intc_cascade_setup - Add a xilinx intc device as a cascaded controller
+ * @cascade_node: device node for xilinx intc controller.
+ */
+int xilinx_intc_cascade_setup(struct device_node *cascade_node)
+{
+	struct irq_host *cascade_irqhost;
+	int cascade_virq;
+
+	if (!cascade_node) {
+		pr_err("%s(): cannot find xilinx intc node\n", __func__);
+		return -ENODEV;
+	}
+
+	/* Make sure this is a xilinx intc device */
+	if (!of_match_node(xilinx_intc_match, cascade_node)) {
+		pr_err("%s(): %s is not compatible\n",
+			__func__, cascade_node->name);
+		return -EINVAL;
+	}
+
+	/* Map a VIRQ for the cascaded handler */
+	cascade_virq = irq_of_parse_and_map(cascade_node, 0);
+	if (!cascade_virq) {
+		pr_err("%s(): error mapping cascade interrupt\n", __func__);
+		return -ENODEV;
+	}
+
+	/* Set up the irqhost and register it */
+	cascade_irqhost = xilinx_intc_init(cascade_node);
+	set_irq_data(cascade_virq, cascade_irqhost);
+	set_irq_chained_handler(cascade_virq, xilinx_intc_cascade);
+
+	pr_debug("%s(): cascading virq %i to irq_host %p\n",
+		 __func__, cascade_virq, cascade_irqhost);
+
+	return 0;
+}
+EXPORT_SYMBOL(xilinx_intc_cascade_setup);
+
+/*
  * Initialize master Xilinx interrupt controller
  */
 void __init xilinx_intc_init_tree(void)

             reply	other threads:[~2009-08-25  6:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-25  6:08 Grant Likely [this message]
2009-08-27  4:15 ` [PATCH] powerpc: add cascade support to xilinx intc controller Benjamin Herrenschmidt

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=20090825060848.3913.60710.stgit@localhost.localdomain \
    --to=grant.likely@secretlab.ca \
    --cc=benh@kernel.crashing.org \
    --cc=john.linn@xilinx.com \
    --cc=jwboyer@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    /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).