From: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Subject: [RFC 9/9] of/irq: create interrupts-extended property
Date: Tue, 15 Oct 2013 21:39:23 +0100 [thread overview]
Message-ID: <1381869563-16083-10-git-send-email-grant.likely@linaro.org> (raw)
In-Reply-To: <1381869563-16083-1-git-send-email-grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
The standard interrupts property in device tree can only handle
interrupts coming from a single interrupt parent. If a device is wired
to multiple interrupt controllers, then it needs to be attached to a
node with an interrupt-map property to demux the interrupt specifiers
which is confusing. It would be a lot easier if there was a form of the
interrupts property that allows for a separate interrupt phandle for
each interrupt specifier.
This patch does exactly that by creating a new interrupts-extended
property which reuses the phandle+arguments pattern used by GPIOs and
other core bindings.
Signed-off-by: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
---
.../bindings/interrupt-controller/interrupts.txt | 29 +++++++--
arch/arm/boot/dts/testcases/tests-interrupts.dtsi | 16 +++++
arch/arm/boot/dts/versatile-ab.dts | 2 +-
arch/arm/boot/dts/versatile-pb.dts | 2 +-
drivers/of/irq.c | 16 +++--
drivers/of/selftest.c | 70 ++++++++++++++++++++++
6 files changed, 122 insertions(+), 13 deletions(-)
diff --git a/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt b/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
index 72a06c0..1486497 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
@@ -4,16 +4,33 @@ Specifying interrupt information for devices
1) Interrupt client nodes
-------------------------
-Nodes that describe devices which generate interrupts must contain an
-"interrupts" property. This property must contain a list of interrupt
-specifiers, one per output interrupt. The format of the interrupt specifier is
-determined by the interrupt controller to which the interrupts are routed; see
-section 2 below for details.
+Nodes that describe devices which generate interrupts must contain an either an
+"interrupts" property or an "interrupts-extended" property. These properties
+contain a list of interrupt specifiers, one per output interrupt. The format of
+the interrupt specifier is determined by the interrupt controller to which the
+interrupts are routed; see section 2 below for details.
+
+ Example:
+ interrupt-parent = <&intc1>;
+ interrupts = <5 0>, <6 0>;
The "interrupt-parent" property is used to specify the controller to which
interrupts are routed and contains a single phandle referring to the interrupt
controller node. This property is inherited, so it may be specified in an
-interrupt client node or in any of its parent nodes.
+interrupt client node or in any of its parent nodes. Interrupts listed in the
+"interrupts" property are always in reference to the node's interrupt parent.
+
+The "interrupts-extended" property is a special form for use when a node needs
+to reference multiple interrupt parents. Each entry in this property contains
+both the parent phandle and the interrupt specifier. "interrupts-extended"
+should only be used when a device has multiple interrupt parents.
+
+ Example:
+ interrupts-extended = <&intc1 5 1>, <&intc2 1 0>;
+
+A device node may contain either "interrupts" or "interrupts-extended", but not
+both. If both properties are present, then the operating system should log an
+error and use only the data in "interrupts".
2) Interrupt controller nodes
-----------------------------
diff --git a/arch/arm/boot/dts/testcases/tests-interrupts.dtsi b/arch/arm/boot/dts/testcases/tests-interrupts.dtsi
index 6ecda71..560d6bf 100644
--- a/arch/arm/boot/dts/testcases/tests-interrupts.dtsi
+++ b/arch/arm/boot/dts/testcases/tests-interrupts.dtsi
@@ -27,6 +27,12 @@
<4 &test_intc2 15 16>;
};
+ test_intmap1: intmap1 {
+ #interrupt-cells = <2>;
+ #address-cells = <0>;
+ interrupt-map = <1 2 &test_intc0 15>;
+ };
+
interrupts0 {
interrupt-parent = <&test_intc0>;
interrupts = <1>, <2>, <3>, <4>;
@@ -36,6 +42,16 @@
interrupt-parent = <&test_intmap0>;
interrupts = <1>, <2>, <3>, <4>;
};
+
+ interrupts-extended0 {
+ interrupts-extended = <&test_intc0 1>,
+ <&test_intc1 2 3 4>,
+ <&test_intc2 5 6>,
+ <&test_intmap0 1>,
+ <&test_intmap0 2>,
+ <&test_intmap0 3>,
+ <&test_intmap1 1 2>;
+ };
};
};
};
diff --git a/arch/arm/boot/dts/versatile-ab.dts b/arch/arm/boot/dts/versatile-ab.dts
index dde75ae..e01e5a0 100644
--- a/arch/arm/boot/dts/versatile-ab.dts
+++ b/arch/arm/boot/dts/versatile-ab.dts
@@ -185,7 +185,7 @@
mmc@5000 {
compatible = "arm,primecell";
reg = < 0x5000 0x1000>;
- interrupts = <22 34>;
+ interrupts-extended = <&vic 22 &sic 2>;
};
kmi@6000 {
compatible = "arm,pl050", "arm,primecell";
diff --git a/arch/arm/boot/dts/versatile-pb.dts b/arch/arm/boot/dts/versatile-pb.dts
index 7e81752..f43907c 100644
--- a/arch/arm/boot/dts/versatile-pb.dts
+++ b/arch/arm/boot/dts/versatile-pb.dts
@@ -41,7 +41,7 @@
mmc@b000 {
compatible = "arm,primecell";
reg = <0xb000 0x1000>;
- interrupts = <23 34>;
+ interrupts-extended = <&vic 23 &sic 2>;
};
};
};
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index ddea945..c01f60e 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -292,17 +292,23 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
return of_irq_parse_oldworld(device, index, out_irq);
+ /* Get the reg property (if any) */
+ addr = of_get_property(device, "reg", NULL);
+
/* Get the interrupts property */
intspec = of_get_property(device, "interrupts", &intlen);
- if (intspec == NULL)
- return -EINVAL;
+ if (intspec == NULL) {
+ /* Try the new-style interrupts-extended */
+ res = of_parse_phandle_with_args(device, "interrupts-extended",
+ "#interrupt-cells", index, out_irq);
+ if (res)
+ return -EINVAL;
+ return of_irq_parse_raw(addr, out_irq);
+ }
intlen /= sizeof(*intspec);
pr_debug(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
- /* Get the reg property (if any) */
- addr = of_get_property(device, "reg", NULL);
-
/* Look for the interrupt parent. */
p = of_irq_find_parent(device);
if (p == NULL)
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index 9c80f0b..e21012b 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -231,6 +231,75 @@ static void __init of_selftest_parse_interrupts(void)
of_node_put(np);
}
+static void __init of_selftest_parse_interrupts_extended(void)
+{
+ struct device_node *np;
+ struct of_phandle_args args;
+ int i, rc;
+
+ np = of_find_node_by_path("/testcase-data/interrupts/interrupts-extended0");
+ if (!np) {
+ pr_err("missing testcase data\n");
+ return;
+ }
+
+ for (i = 0; i < 7; i++) {
+ bool passed = true;
+ rc = of_irq_parse_one(np, i, &args);
+
+ /* Test the values from tests-phandle.dtsi */
+ switch (i) {
+ case 0:
+ passed &= !rc;
+ passed &= (args.args_count == 1);
+ passed &= (args.args[0] == 1);
+ break;
+ case 1:
+ passed &= !rc;
+ passed &= (args.args_count == 3);
+ passed &= (args.args[0] == 2);
+ passed &= (args.args[1] == 3);
+ passed &= (args.args[2] == 4);
+ break;
+ case 2:
+ passed &= !rc;
+ passed &= (args.args_count == 2);
+ passed &= (args.args[0] == 5);
+ passed &= (args.args[1] == 6);
+ break;
+ case 3:
+ passed &= !rc;
+ passed &= (args.args_count == 1);
+ passed &= (args.args[0] == 9);
+ break;
+ case 4:
+ passed &= !rc;
+ passed &= (args.args_count == 3);
+ passed &= (args.args[0] == 10);
+ passed &= (args.args[1] == 11);
+ passed &= (args.args[2] == 12);
+ break;
+ case 5:
+ passed &= !rc;
+ passed &= (args.args_count == 2);
+ passed &= (args.args[0] == 13);
+ passed &= (args.args[1] == 14);
+ break;
+ case 6:
+ passed &= !rc;
+ passed &= (args.args_count == 1);
+ passed &= (args.args[0] == 15);
+ break;
+ default:
+ passed = false;
+ }
+
+ selftest(passed, "index %i - data error on node %s rc=%i\n",
+ i, args.np->full_name, rc);
+ }
+ of_node_put(np);
+}
+
static int __init of_selftest(void)
{
struct device_node *np;
@@ -246,6 +315,7 @@ static int __init of_selftest(void)
of_selftest_parse_phandle_with_args();
of_selftest_property_match_string();
of_selftest_parse_interrupts();
+ of_selftest_parse_interrupts_extended();
pr_info("end of selftest - %i passed, %i failed\n",
selftest_results.passed, selftest_results.failed);
return 0;
--
1.8.1.2
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-10-15 20:39 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-15 20:39 [RFC 0/9] of: refactor IRQ parsing and add interrupts-extended implementation Grant Likely
2013-10-15 20:39 ` [RFC 1/9] of/irq: Rename of_irq_map_* functions to of_irq_parse_* Grant Likely
2013-10-16 10:47 ` Michal Simek
2013-10-15 20:39 ` [RFC 2/9] of/irq: Replace of_irq with of_phandle_args Grant Likely
2013-10-15 20:39 ` [RFC 4/9] of/irq: Refactor interrupt-map parsing Grant Likely
2013-10-29 16:23 ` Olof Johansson
2013-10-31 1:19 ` Ming Lei
[not found] ` <CACxGe6uE+KvycQq3XBavRcvprff6PhBaxX54W_Cb1cfuVpMXvQ@mail.gmail.com>
2013-10-31 18:57 ` Olof Johansson
2013-11-01 14:48 ` Grant Likely
2013-11-01 17:53 ` Grant Likely
[not found] ` <20131101175317.A812AC40868-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-01 18:54 ` Grant Likely
2013-11-02 4:16 ` Ming Lei
[not found] ` <20131101185401.B298FC40868-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-04 5:04 ` Olof Johansson
2013-11-05 15:18 ` Tomasz Figa
2013-11-05 15:21 ` [PATCH 1/2] of: irq: Fix interrupt-map entry matching Tomasz Figa
2013-11-07 11:32 ` Tomasz Figa
2013-11-07 16:40 ` Rob Herring
[not found] ` <CAL_JsqKUaioiz2dw3Sr8f7UfqzjagWH_je2-u_QGYXRK5g1=yg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-07 22:11 ` Tomasz Figa
2013-11-08 9:37 ` Grant Likely
2013-11-07 11:50 ` Sachin Kamat
2013-11-05 15:21 ` [PATCH 2/2] of: irq: Check for reg property presence only when parsing interrupt-map Tomasz Figa
2013-11-07 11:33 ` Tomasz Figa
2013-11-01 19:07 ` [RFC 4/9] of/irq: Refactor interrupt-map parsing Stephen Warren
2013-10-31 20:45 ` [RFC 4/9] of/irq: Refactor interrupt-map parsing [CPU hotplug clockevents issue] Stephen Warren
2013-10-15 20:39 ` [RFC 5/9] of: Add helper for printing an of_phandle_args structure Grant Likely
[not found] ` <1381869563-16083-1-git-send-email-grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-10-15 20:39 ` [RFC 3/9] of/irq: simplify args to irq_create_of_mapping Grant Likely
2013-10-15 20:39 ` [RFC 6/9] of: Add testcases for interrupt parsing Grant Likely
2013-10-15 20:39 ` Grant Likely [this message]
2013-10-17 17:33 ` [RFC 9/9] of/irq: create interrupts-extended property Tony Lindgren
2013-10-27 13:46 ` Grant Likely
2013-10-27 20:24 ` Rob Herring
2013-10-28 3:16 ` Mark Rutland
2013-10-28 6:54 ` Kumar Gala
[not found] ` <20131027134607.E1782C4039D-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-10-28 21:47 ` Stephen Warren
2013-10-28 22:49 ` Mark Rutland
2013-10-28 23:16 ` Benjamin Herrenschmidt
[not found] ` <1381869563-16083-10-git-send-email-grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-10-28 6:54 ` Kumar Gala
[not found] ` <31D756E7-A7CD-42ED-8D1D-D1B38B85E3A0-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2013-10-28 23:41 ` Grant Likely
2013-11-11 22:58 ` Peter Crosthwaite
[not found] ` <CAEgOgz6=HhBkb2KtxcmHpNdE_0sNngw0NaL2SnLWj1opZkO3SA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-12 6:54 ` Grant Likely
[not found] ` <20131112065405.C75E8C42024-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-12 7:49 ` Peter Crosthwaite
[not found] ` <CAEgOgz6j8YsvFgq8ZbE20ocHPA0C-eUGBb7F1gNiVBvJXLa8_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-12 8:50 ` Grant Likely
[not found] ` <20131112085038.B6A75C421BB-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-12 23:17 ` Peter Crosthwaite
2013-11-13 6:14 ` Grant Likely
2013-11-24 7:04 ` Peter Crosthwaite
2013-10-17 17:30 ` [RFC 0/9] of: refactor IRQ parsing and add interrupts-extended implementation Tony Lindgren
2013-10-15 20:39 ` [RFC 7/9] of/irq: Create of_irq_parse_and_map_pci() to consolidate arch code Grant Likely
2013-10-15 20:39 ` [RFC 8/9] microblaze/pci: Drop PowerPC-ism from irq parsing Grant Likely
[not found] ` < 1381869563-16083-10-git-send-email-grant.likely@linaro.org>
[not found] ` < CAEgOgz6=HhBkb2KtxcmHpNdE_0sNngw0NaL2SnLWj1opZkO3SA@mail.gmail.com>
[not found] ` < 20131112065405.C75E8C42024@trevor.secretlab.ca>
[not found] ` < CAEgOgz6j8YsvFgq8ZbE20ocHPA0C-eUGBb7F1gNiVBvJXLa8_g@mail.gmail.com>
[not found] ` < 20131112085038.B6A75C421BB@trevor.secretlab.ca>
[not found] ` < CAEgOgz4dM1zQdFpOkUwZqAUMUBe2eh3j1Ah0KgomVAOGgrPsVw@mail.gmail.com>
[not found] ` < 20131113061425.667F9C41807@trevor.secretlab.ca>
[not found] ` < CAEgOgz5BWzo-LGddjG6ZUtKt6GHxLmDUEndFOdVrn+1HTPvpGQ@mail.gmail.com>
[not found] ` <CAEgOgz5BWzo-LGddjG6ZUtKt6GHxLmDUEndFOdVrn+1HTPvpGQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-24 21:32 ` [RFC 9/9] of/irq: create interrupts-extended property Grant Likely
[not found] ` <20131124213212.226B8C402C3-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-11-27 9:06 ` Peter Crosthwaite
[not found] ` < 20131124213212.226B8C402C3@trevor.secretlab.ca>
[not found] ` < CAEgOgz4yhDzy_BFiotK5Qi48sczR3PL1oPjPhNYC9O94P6AnzQ@mail.gmail.com>
[not found] ` <CAEgOgz4yhDzy_BFiotK5Qi48sczR3PL1oPjPhNYC9O94P6AnzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-27 14:17 ` Grant Likely
2013-11-28 7:28 ` Peter Crosthwaite
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=1381869563-16083-10-git-send-email-grant.likely@linaro.org \
--to=grant.likely-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.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).