1 From efd4032754a57bc258eafe30fde684ec47dc36e1 Mon Sep 17 00:00:00 2001
2 From: Grant Likely <grant.likely@linaro.org>
3 Date: Thu, 19 Dec 2013 09:31:00 -0300
4 Subject: [PATCH 189/203] of/irq: create interrupts-extended property
6 The standard interrupts property in device tree can only handle
7 interrupts coming from a single interrupt parent. If a device is wired
8 to multiple interrupt controllers, then it needs to be attached to a
9 node with an interrupt-map property to demux the interrupt specifiers
10 which is confusing. It would be a lot easier if there was a form of the
11 interrupts property that allows for a separate interrupt phandle for
12 each interrupt specifier.
14 This patch does exactly that by creating a new interrupts-extended
15 property which reuses the phandle+arguments pattern used by GPIOs and
18 Signed-off-by: Grant Likely <grant.likely@linaro.org>
19 Acked-by: Tony Lindgren <tony@atomide.com>
20 Acked-by: Kumar Gala <galak@codeaurora.org>
21 [grant.likely: removed versatile platform hunks into separate patch]
22 Cc: Rob Herring <rob.herring@calxeda.com>
25 arch/arm/boot/dts/testcases/tests-interrupts.dtsi
28 drivers/of/selftest.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++-
29 1 file changed, 145 insertions(+), 1 deletion(-)
31 --- a/drivers/of/selftest.c
32 +++ b/drivers/of/selftest.c
33 @@ -154,6 +154,147 @@ static void __init of_selftest_property_
34 selftest(rc == -EILSEQ, "unterminated string; rc=%i", rc);
37 +static void __init of_selftest_parse_interrupts(void)
39 + struct device_node *np;
40 + struct of_phandle_args args;
43 + np = of_find_node_by_path("/testcase-data/interrupts/interrupts0");
45 + pr_err("missing testcase data\n");
49 + for (i = 0; i < 4; i++) {
51 + args.args_count = 0;
52 + rc = of_irq_parse_one(np, i, &args);
55 + passed &= (args.args_count == 1);
56 + passed &= (args.args[0] == (i + 1));
58 + selftest(passed, "index %i - data error on node %s rc=%i\n",
59 + i, args.np->full_name, rc);
63 + np = of_find_node_by_path("/testcase-data/interrupts/interrupts1");
65 + pr_err("missing testcase data\n");
69 + for (i = 0; i < 4; i++) {
71 + args.args_count = 0;
72 + rc = of_irq_parse_one(np, i, &args);
74 + /* Test the values from tests-phandle.dtsi */
78 + passed &= (args.args_count == 1);
79 + passed &= (args.args[0] == 9);
83 + passed &= (args.args_count == 3);
84 + passed &= (args.args[0] == 10);
85 + passed &= (args.args[1] == 11);
86 + passed &= (args.args[2] == 12);
90 + passed &= (args.args_count == 2);
91 + passed &= (args.args[0] == 13);
92 + passed &= (args.args[1] == 14);
96 + passed &= (args.args_count == 2);
97 + passed &= (args.args[0] == 15);
98 + passed &= (args.args[1] == 16);
103 + selftest(passed, "index %i - data error on node %s rc=%i\n",
104 + i, args.np->full_name, rc);
109 +static void __init of_selftest_parse_interrupts_extended(void)
111 + struct device_node *np;
112 + struct of_phandle_args args;
115 + np = of_find_node_by_path("/testcase-data/interrupts/interrupts-extended0");
117 + pr_err("missing testcase data\n");
121 + for (i = 0; i < 7; i++) {
122 + bool passed = true;
123 + rc = of_irq_parse_one(np, i, &args);
125 + /* Test the values from tests-phandle.dtsi */
129 + passed &= (args.args_count == 1);
130 + passed &= (args.args[0] == 1);
134 + passed &= (args.args_count == 3);
135 + passed &= (args.args[0] == 2);
136 + passed &= (args.args[1] == 3);
137 + passed &= (args.args[2] == 4);
141 + passed &= (args.args_count == 2);
142 + passed &= (args.args[0] == 5);
143 + passed &= (args.args[1] == 6);
147 + passed &= (args.args_count == 1);
148 + passed &= (args.args[0] == 9);
152 + passed &= (args.args_count == 3);
153 + passed &= (args.args[0] == 10);
154 + passed &= (args.args[1] == 11);
155 + passed &= (args.args[2] == 12);
159 + passed &= (args.args_count == 2);
160 + passed &= (args.args[0] == 13);
161 + passed &= (args.args[1] == 14);
165 + passed &= (args.args_count == 1);
166 + passed &= (args.args[0] == 15);
172 + selftest(passed, "index %i - data error on node %s rc=%i\n",
173 + i, args.np->full_name, rc);
178 static int __init of_selftest(void)
180 struct device_node *np;
181 @@ -168,7 +309,10 @@ static int __init of_selftest(void)
182 pr_info("start of selftest - you will see error messages\n");
183 of_selftest_parse_phandle_with_args();
184 of_selftest_property_match_string();
185 - pr_info("end of selftest - %s\n", selftest_passed ? "PASS" : "FAIL");
186 + of_selftest_parse_interrupts();
187 + of_selftest_parse_interrupts_extended();
188 + pr_info("end of selftest - %i passed, %i failed\n",
189 + selftest_results.passed, selftest_results.failed);
192 late_initcall(of_selftest);