base-files: define yes/no as valid boolean options
[openwrt/openwrt.git] / target / linux / mvebu / patches-3.10 / 0189-of-irq-create-interrupts-extended-property.patch
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
5
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.
13
14 This patch does exactly that by creating a new interrupts-extended
15 property which reuses the phandle+arguments pattern used by GPIOs and
16 other core bindings.
17
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>
23
24 Conflicts:
25 arch/arm/boot/dts/testcases/tests-interrupts.dtsi
26 drivers/of/selftest.c
27 ---
28 drivers/of/selftest.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++-
29 1 file changed, 145 insertions(+), 1 deletion(-)
30
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);
35 }
36
37 +static void __init of_selftest_parse_interrupts(void)
38 +{
39 + struct device_node *np;
40 + struct of_phandle_args args;
41 + int i, rc;
42 +
43 + np = of_find_node_by_path("/testcase-data/interrupts/interrupts0");
44 + if (!np) {
45 + pr_err("missing testcase data\n");
46 + return;
47 + }
48 +
49 + for (i = 0; i < 4; i++) {
50 + bool passed = true;
51 + args.args_count = 0;
52 + rc = of_irq_parse_one(np, i, &args);
53 +
54 + passed &= !rc;
55 + passed &= (args.args_count == 1);
56 + passed &= (args.args[0] == (i + 1));
57 +
58 + selftest(passed, "index %i - data error on node %s rc=%i\n",
59 + i, args.np->full_name, rc);
60 + }
61 + of_node_put(np);
62 +
63 + np = of_find_node_by_path("/testcase-data/interrupts/interrupts1");
64 + if (!np) {
65 + pr_err("missing testcase data\n");
66 + return;
67 + }
68 +
69 + for (i = 0; i < 4; i++) {
70 + bool passed = true;
71 + args.args_count = 0;
72 + rc = of_irq_parse_one(np, i, &args);
73 +
74 + /* Test the values from tests-phandle.dtsi */
75 + switch (i) {
76 + case 0:
77 + passed &= !rc;
78 + passed &= (args.args_count == 1);
79 + passed &= (args.args[0] == 9);
80 + break;
81 + case 1:
82 + passed &= !rc;
83 + passed &= (args.args_count == 3);
84 + passed &= (args.args[0] == 10);
85 + passed &= (args.args[1] == 11);
86 + passed &= (args.args[2] == 12);
87 + break;
88 + case 2:
89 + passed &= !rc;
90 + passed &= (args.args_count == 2);
91 + passed &= (args.args[0] == 13);
92 + passed &= (args.args[1] == 14);
93 + break;
94 + case 3:
95 + passed &= !rc;
96 + passed &= (args.args_count == 2);
97 + passed &= (args.args[0] == 15);
98 + passed &= (args.args[1] == 16);
99 + break;
100 + default:
101 + passed = false;
102 + }
103 + selftest(passed, "index %i - data error on node %s rc=%i\n",
104 + i, args.np->full_name, rc);
105 + }
106 + of_node_put(np);
107 +}
108 +
109 +static void __init of_selftest_parse_interrupts_extended(void)
110 +{
111 + struct device_node *np;
112 + struct of_phandle_args args;
113 + int i, rc;
114 +
115 + np = of_find_node_by_path("/testcase-data/interrupts/interrupts-extended0");
116 + if (!np) {
117 + pr_err("missing testcase data\n");
118 + return;
119 + }
120 +
121 + for (i = 0; i < 7; i++) {
122 + bool passed = true;
123 + rc = of_irq_parse_one(np, i, &args);
124 +
125 + /* Test the values from tests-phandle.dtsi */
126 + switch (i) {
127 + case 0:
128 + passed &= !rc;
129 + passed &= (args.args_count == 1);
130 + passed &= (args.args[0] == 1);
131 + break;
132 + case 1:
133 + passed &= !rc;
134 + passed &= (args.args_count == 3);
135 + passed &= (args.args[0] == 2);
136 + passed &= (args.args[1] == 3);
137 + passed &= (args.args[2] == 4);
138 + break;
139 + case 2:
140 + passed &= !rc;
141 + passed &= (args.args_count == 2);
142 + passed &= (args.args[0] == 5);
143 + passed &= (args.args[1] == 6);
144 + break;
145 + case 3:
146 + passed &= !rc;
147 + passed &= (args.args_count == 1);
148 + passed &= (args.args[0] == 9);
149 + break;
150 + case 4:
151 + passed &= !rc;
152 + passed &= (args.args_count == 3);
153 + passed &= (args.args[0] == 10);
154 + passed &= (args.args[1] == 11);
155 + passed &= (args.args[2] == 12);
156 + break;
157 + case 5:
158 + passed &= !rc;
159 + passed &= (args.args_count == 2);
160 + passed &= (args.args[0] == 13);
161 + passed &= (args.args[1] == 14);
162 + break;
163 + case 6:
164 + passed &= !rc;
165 + passed &= (args.args_count == 1);
166 + passed &= (args.args[0] == 15);
167 + break;
168 + default:
169 + passed = false;
170 + }
171 +
172 + selftest(passed, "index %i - data error on node %s rc=%i\n",
173 + i, args.np->full_name, rc);
174 + }
175 + of_node_put(np);
176 +}
177 +
178 static int __init of_selftest(void)
179 {
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);
190 return 0;
191 }
192 late_initcall(of_selftest);