linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hs@denx.de (Heiko Schocher)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/7] ARM: davinci, intc: Add OF support for TI interrupt controller
Date: Mon, 23 Jan 2012 09:56:01 +0100	[thread overview]
Message-ID: <1327308967-8092-2-git-send-email-hs@denx.de> (raw)
In-Reply-To: <1327308967-8092-1-git-send-email-hs@denx.de>

Add a function to initialize the davinci interrupt controller (INTC)
using a device tree node.

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: davinci-linux-open-source at linux.davincidsp.com
Cc: linux-arm-kernel at lists.infradead.org
Cc: devicetree-discuss at lists.ozlabs.org
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
---
 .../devicetree/bindings/arm/davinci/intc.txt       |   26 ++++++++++
 arch/arm/mach-davinci/cp_intc.c                    |   51 ++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/cp_intc.h       |    1 +
 3 files changed, 78 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/davinci/intc.txt

diff --git a/Documentation/devicetree/bindings/arm/davinci/intc.txt b/Documentation/devicetree/bindings/arm/davinci/intc.txt
new file mode 100644
index 0000000..dac2f69
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/davinci/intc.txt
@@ -0,0 +1,26 @@
+* TI Davinci Interrupt Controller
+
+davinci are using a TI interrupt controller that can support several
+configurable number of interrupts.
+
+Main node required properties:
+
+- compatible : should be:
+	"ti,davinci-intc"
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells : Specifies the number of cells needed to encode an
+  interrupt source. The type shall be a <u32> and the value shall be 1.
+
+  The cell contains the interrupt number in the range [0-128].
+- ti,intc-size: Number of interrupts handled by the interrupt controller.
+- reg: physical base address and size of the intc registers map.
+
+Example:
+
+	intc: interrupt-controller at 1 {
+		compatible = "ti,davinci-intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		ti,intc-size = <101>;
+		reg = <0xfffee000 0x2000>;
+	};
diff --git a/arch/arm/mach-davinci/cp_intc.c b/arch/arm/mach-davinci/cp_intc.c
index f83152d..2c6e2e4 100644
--- a/arch/arm/mach-davinci/cp_intc.c
+++ b/arch/arm/mach-davinci/cp_intc.c
@@ -11,7 +11,11 @@
 
 #include <linux/init.h>
 #include <linux/irq.h>
+#include <linux/irqdomain.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 
 #include <mach/common.h>
 #include <mach/cp_intc.h>
@@ -175,3 +179,50 @@ void __init cp_intc_init(void)
 	/* Enable global interrupt */
 	cp_intc_write(1, CP_INTC_GLOBAL_ENABLE);
 }
+
+#ifdef CONFIG_OF
+int __init dv_intc_of_init(struct device_node *node, struct device_node *parent)
+{
+	struct resource res;
+	u32 nr_irqs;
+
+	if (WARN_ON(!node))
+		return -ENODEV;
+
+	if (of_address_to_resource(node, 0, &res)) {
+		WARN(1, "unable to get intc registers\n");
+		return -EINVAL;
+	}
+
+	davinci_soc_info.intc_base = res.start;
+	if (WARN_ON(!davinci_soc_info.intc_base))
+		return -EINVAL;
+
+	if (of_property_read_u32(node, "ti,intc-size", &nr_irqs)) {
+		WARN(1, "unable to get intc-size\n");
+		return -EINVAL;
+	}
+	davinci_soc_info.intc_irq_num = nr_irqs;
+	davinci_soc_info.intc_type = DAVINCI_INTC_TYPE_CP_INTC;
+
+	cp_intc_init();
+	irq_domain_add_simple(node, 0);
+
+	return 0;
+}
+
+static struct of_device_id irq_match[] __initdata = {
+	{ .compatible = "ti,davinci-intc", .data = dv_intc_of_init, },
+	{ }
+};
+
+void __init davinci_init_irq(void)
+{
+	of_irq_init(irq_match);
+}
+#else
+void __init davinci_init_irq(void)
+{
+	cp_intc_init();
+}
+#endif
diff --git a/arch/arm/mach-davinci/include/mach/cp_intc.h b/arch/arm/mach-davinci/include/mach/cp_intc.h
index 4e8190e..d674b95 100644
--- a/arch/arm/mach-davinci/include/mach/cp_intc.h
+++ b/arch/arm/mach-davinci/include/mach/cp_intc.h
@@ -52,5 +52,6 @@
 #define CP_INTC_VECTOR_ADDR(n)		(0x2000 + (n << 2))
 
 void __init cp_intc_init(void);
+void __init davinci_init_irq(void);
 
 #endif	/* __ASM_HARDWARE_CP_INTC_H */
-- 
1.7.7.5

  reply	other threads:[~2012-01-23  8:56 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-23  8:56 [RFC PATCH 0/7] ARM: davinci: add support for the am1808 based enbw_cmc board Heiko Schocher
2012-01-23  8:56 ` Heiko Schocher [this message]
2012-02-02  4:54   ` [RFC PATCH 1/7] ARM: davinci, intc: Add OF support for TI interrupt controller Grant Likely
2012-02-06  6:36     ` Heiko Schocher
2012-02-14  7:15       ` Heiko Schocher
2012-01-23  8:56 ` [RFC PATCH 2/7 v2] ARM: davinci: configure davinci aemif chipselects through OF Heiko Schocher
2012-01-23  8:56 ` [RFC PATCH 3/7] ARM: davinci: mux: add OF support Heiko Schocher
2012-01-23  8:56 ` [RFC PATCH 4/7] ARM: davinci: net: davinci_emac: " Heiko Schocher
2012-01-23 19:20   ` Anatoly Sivov
2012-01-24  6:14     ` Heiko Schocher
2012-01-30 20:22   ` Grant Likely
2012-01-31 11:27     ` Heiko Schocher
2012-02-02  0:19       ` Grant Likely
2012-01-23  8:56 ` [RFC PATCH 5/7] ARM: davinci: i2c: " Heiko Schocher
2012-01-23 20:35   ` Sylwester Nawrocki
2012-01-24  7:18     ` Heiko Schocher
2012-01-24  9:51       ` Sylwester Nawrocki
2012-01-30 20:13         ` Grant Likely
2012-01-31  7:31           ` Heiko Schocher
2012-02-05 20:44           ` Sylwester Nawrocki
2012-01-30 20:04   ` Grant Likely
2012-01-31  7:14     ` Heiko Schocher
2012-02-13 23:37   ` Ben Dooks
2012-02-14  7:16     ` Heiko Schocher
2012-01-23  8:56 ` [RFC PATCH 6/7] ARM: mtd: nand: davinci: add OF support for davinci nand controller Heiko Schocher
2012-01-23 23:59   ` Scott Wood
2012-01-24  7:23     ` Heiko Schocher
2012-01-24 19:45       ` Scott Wood
2012-01-25  7:09         ` Heiko Schocher
2012-01-26 20:33           ` Scott Wood
2012-01-27  6:40             ` Heiko Schocher
2012-01-27 17:02               ` Scott Wood
2012-01-23  8:56 ` [RFC PATCH 7/7] ARM: davinci: add support for the am1808 based enbw_cmc board Heiko Schocher
2012-01-30 20:32   ` Grant Likely
2012-01-31 13:04     ` Heiko Schocher
2012-02-01 10:20       ` Sergei Shtylyov
2012-02-02  0:17         ` Grant Likely

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=1327308967-8092-2-git-send-email-hs@denx.de \
    --to=hs@denx.de \
    --cc=linux-arm-kernel@lists.infradead.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).