mvebu: backport mainline patches from kernel 3.13
[openwrt/staging/lynxis/omap.git] / target / linux / mvebu / patches-3.10 / 0184-of-irq-Replace-of_irq-with-of_phandle_args.patch
1 From 1baf727ee1d863a0eacd249cff6afc99022593c2 Mon Sep 17 00:00:00 2001
2 From: Grant Likely <grant.likely@linaro.org>
3 Date: Thu, 19 Dec 2013 09:30:55 -0300
4 Subject: [PATCH 184/203] of/irq: Replace of_irq with of_phandle_args
5
6 struct of_irq and struct of_phandle_args are exactly the same structure.
7 This patch makes the kernel use of_phandle_args everywhere. This in
8 itself isn't a big deal, but it makes some follow-on patches simpler.
9
10 Signed-off-by: Grant Likely <grant.likely@linaro.org>
11 Acked-by: Michal Simek <monstr@monstr.eu>
12 Acked-by: Tony Lindgren <tony@atomide.com>
13 Cc: Russell King <linux@arm.linux.org.uk>
14 Cc: Ralf Baechle <ralf@linux-mips.org>
15 Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
16
17 Conflicts:
18 arch/mips/pci/pci-rt3883.c
19 ---
20 arch/arm/mach-integrator/pci_v3.c | 5 ++---
21 arch/microblaze/pci/pci-common.c | 9 ++++-----
22 arch/mips/pci/fixup-lantiq.c | 5 ++---
23 arch/powerpc/kernel/pci-common.c | 9 ++++-----
24 arch/powerpc/platforms/cell/celleb_scc_pciex.c | 5 ++---
25 arch/powerpc/platforms/cell/celleb_scc_sio.c | 5 ++---
26 arch/powerpc/platforms/cell/spider-pic.c | 6 +++---
27 arch/powerpc/platforms/cell/spu_manage.c | 12 ++++++------
28 arch/powerpc/platforms/fsl_uli1575.c | 8 +++-----
29 arch/powerpc/platforms/powermac/pic.c | 8 ++++----
30 arch/powerpc/platforms/pseries/event_sources.c | 7 +++----
31 arch/powerpc/sysdev/mpic_msi.c | 6 +++---
32 arch/x86/kernel/devicetree.c | 5 ++---
33 drivers/of/irq.c | 15 +++++++--------
34 drivers/of/of_pci_irq.c | 2 +-
35 drivers/pci/host/pci-mvebu.c | 5 ++---
36 include/linux/of_irq.h | 24 ++++--------------------
37 include/linux/of_pci.h | 4 ++--
38 18 files changed, 56 insertions(+), 84 deletions(-)
39
40 --- a/arch/arm/mach-integrator/pci_v3.c
41 +++ b/arch/arm/mach-integrator/pci_v3.c
42 @@ -684,7 +684,7 @@ static struct hw_pci pci_v3 __initdata =
43
44 static int __init pci_v3_map_irq_dt(const struct pci_dev *dev, u8 slot, u8 pin)
45 {
46 - struct of_irq oirq;
47 + struct of_phandle_args oirq;
48 int ret;
49
50 ret = of_irq_parse_pci(dev, &oirq);
51 @@ -694,8 +694,7 @@ static int __init pci_v3_map_irq_dt(cons
52 return 0;
53 }
54
55 - return irq_create_of_mapping(oirq.controller, oirq.specifier,
56 - oirq.size);
57 + return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count);
58 }
59
60 static int __init pci_v3_dtprobe(struct platform_device *pdev,
61 --- a/arch/microblaze/pci/pci-common.c
62 +++ b/arch/microblaze/pci/pci-common.c
63 @@ -199,7 +199,7 @@ void pcibios_set_master(struct pci_dev *
64 */
65 int pci_read_irq_line(struct pci_dev *pci_dev)
66 {
67 - struct of_irq oirq;
68 + struct of_phandle_args oirq;
69 unsigned int virq;
70
71 /* The current device-tree that iSeries generates from the HV
72 @@ -243,11 +243,10 @@ int pci_read_irq_line(struct pci_dev *pc
73 irq_set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
74 } else {
75 pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
76 - oirq.size, oirq.specifier[0], oirq.specifier[1],
77 - of_node_full_name(oirq.controller));
78 + oirq.args_count, oirq.args[0], oirq.args[1],
79 + of_node_full_name(oirq.np));
80
81 - virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
82 - oirq.size);
83 + virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count);
84 }
85 if (!virq) {
86 pr_debug(" Failed to map !\n");
87 --- a/arch/mips/pci/fixup-lantiq.c
88 +++ b/arch/mips/pci/fixup-lantiq.c
89 @@ -25,7 +25,7 @@ int pcibios_plat_dev_init(struct pci_dev
90
91 int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
92 {
93 - struct of_irq dev_irq;
94 + struct of_phandle_args dev_irq;
95 int irq;
96
97 if (of_irq_parse_pci(dev, &dev_irq)) {
98 @@ -33,8 +33,7 @@ int __init pcibios_map_irq(const struct
99 slot, pin);
100 return 0;
101 }
102 - irq = irq_create_of_mapping(dev_irq.controller, dev_irq.specifier,
103 - dev_irq.size);
104 + irq = irq_create_of_mapping(dev_irq.np, dev_irq.args, dev_irq.args_count);
105 dev_info(&dev->dev, "SLOT:%d PIN:%d IRQ:%d\n", slot, pin, irq);
106 return irq;
107 }
108 --- a/arch/powerpc/kernel/pci-common.c
109 +++ b/arch/powerpc/kernel/pci-common.c
110 @@ -228,7 +228,7 @@ int pcibios_add_platform_entries(struct
111 */
112 static int pci_read_irq_line(struct pci_dev *pci_dev)
113 {
114 - struct of_irq oirq;
115 + struct of_phandle_args oirq;
116 unsigned int virq;
117
118 pr_debug("PCI: Try to map irq for %s...\n", pci_name(pci_dev));
119 @@ -263,11 +263,10 @@ static int pci_read_irq_line(struct pci_
120 irq_set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
121 } else {
122 pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
123 - oirq.size, oirq.specifier[0], oirq.specifier[1],
124 - of_node_full_name(oirq.controller));
125 + oirq.args_count, oirq.args[0], oirq.args[1],
126 + of_node_full_name(oirq.np));
127
128 - virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
129 - oirq.size);
130 + virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count);
131 }
132 if(virq == NO_IRQ) {
133 pr_debug(" Failed to map !\n");
134 --- a/arch/powerpc/platforms/cell/celleb_scc_pciex.c
135 +++ b/arch/powerpc/platforms/cell/celleb_scc_pciex.c
136 @@ -486,7 +486,7 @@ static __init int celleb_setup_pciex(str
137 struct pci_controller *phb)
138 {
139 struct resource r;
140 - struct of_irq oirq;
141 + struct of_phandle_args oirq;
142 int virq;
143
144 /* SMMIO registers; used inside this file */
145 @@ -511,8 +511,7 @@ static __init int celleb_setup_pciex(str
146 pr_err("PCIEXC:Failed to map irq\n");
147 goto error;
148 }
149 - virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
150 - oirq.size);
151 + virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count);
152 if (request_irq(virq, pciex_handle_internal_irq,
153 0, "pciex", (void *)phb)) {
154 pr_err("PCIEXC:Failed to request irq\n");
155 --- a/arch/powerpc/platforms/cell/celleb_scc_sio.c
156 +++ b/arch/powerpc/platforms/cell/celleb_scc_sio.c
157 @@ -45,7 +45,7 @@ static int __init txx9_serial_init(void)
158 struct device_node *node;
159 int i;
160 struct uart_port req;
161 - struct of_irq irq;
162 + struct of_phandle_args irq;
163 struct resource res;
164
165 for_each_compatible_node(node, "serial", "toshiba,sio-scc") {
166 @@ -66,8 +66,7 @@ static int __init txx9_serial_init(void)
167 #ifdef CONFIG_SERIAL_TXX9_CONSOLE
168 req.membase = ioremap(req.mapbase, 0x24);
169 #endif
170 - req.irq = irq_create_of_mapping(irq.controller,
171 - irq.specifier, irq.size);
172 + req.irq = irq_create_of_mapping(irq.np, irq.args, irq.args_count);
173 req.flags |= UPF_IOREMAP | UPF_BUGGY_UART
174 /*HAVE_CTS_LINE*/;
175 req.uartclk = 83300000;
176 --- a/arch/powerpc/platforms/cell/spider-pic.c
177 +++ b/arch/powerpc/platforms/cell/spider-pic.c
178 @@ -235,10 +235,10 @@ static unsigned int __init spider_find_c
179 /* First, we check whether we have a real "interrupts" in the device
180 * tree in case the device-tree is ever fixed
181 */
182 - struct of_irq oirq;
183 + struct of_phandle_args oirq;
184 if (of_irq_parse_one(pic->host->of_node, 0, &oirq) == 0) {
185 - virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
186 - oirq.size);
187 + virq = irq_create_of_mapping(oirq.np, oirq.args,
188 + oirq.args_count);
189 return virq;
190 }
191
192 --- a/arch/powerpc/platforms/cell/spu_manage.c
193 +++ b/arch/powerpc/platforms/cell/spu_manage.c
194 @@ -177,7 +177,7 @@ out:
195
196 static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
197 {
198 - struct of_irq oirq;
199 + struct of_phandle_args oirq;
200 int ret;
201 int i;
202
203 @@ -188,10 +188,10 @@ static int __init spu_map_interrupts(str
204 goto err;
205 }
206 ret = -EINVAL;
207 - pr_debug(" irq %d no 0x%x on %s\n", i, oirq.specifier[0],
208 - oirq.controller->full_name);
209 - spu->irqs[i] = irq_create_of_mapping(oirq.controller,
210 - oirq.specifier, oirq.size);
211 + pr_debug(" irq %d no 0x%x on %s\n", i, oirq.args[0],
212 + oirq.np->full_name);
213 + spu->irqs[i] = irq_create_of_mapping(oirq.np,
214 + oirq.args, oirq.args_count);
215 if (spu->irqs[i] == NO_IRQ) {
216 pr_debug("spu_new: failed to map it !\n");
217 goto err;
218 @@ -200,7 +200,7 @@ static int __init spu_map_interrupts(str
219 return 0;
220
221 err:
222 - pr_debug("failed to map irq %x for spu %s\n", *oirq.specifier,
223 + pr_debug("failed to map irq %x for spu %s\n", *oirq.args,
224 spu->name);
225 for (; i >= 0; i--) {
226 if (spu->irqs[i] != NO_IRQ)
227 --- a/arch/powerpc/platforms/fsl_uli1575.c
228 +++ b/arch/powerpc/platforms/fsl_uli1575.c
229 @@ -321,8 +321,8 @@ static void hpcd_final_uli5288(struct pc
230 {
231 struct pci_controller *hose = pci_bus_to_host(dev->bus);
232 struct device_node *hosenode = hose ? hose->dn : NULL;
233 - struct of_irq oirq;
234 - int virq, pin = 2;
235 + struct of_phandle_args oirq;
236 + int pin = 2;
237 u32 laddr[3];
238
239 if (!machine_is(mpc86xx_hpcd))
240 @@ -334,9 +334,7 @@ static void hpcd_final_uli5288(struct pc
241 laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8);
242 laddr[1] = laddr[2] = 0;
243 of_irq_parse_raw(hosenode, &pin, 1, laddr, &oirq);
244 - virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
245 - oirq.size);
246 - dev->irq = virq;
247 + dev->irq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count);
248 }
249
250 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, hpcd_quirk_uli1575);
251 --- a/arch/powerpc/platforms/powermac/pic.c
252 +++ b/arch/powerpc/platforms/powermac/pic.c
253 @@ -394,7 +394,7 @@ static void __init pmac_pic_probe_oldsty
254 }
255
256 int of_irq_parse_oldworld(struct device_node *device, int index,
257 - struct of_irq *out_irq)
258 + struct of_phandle_args *out_irq)
259 {
260 const u32 *ints = NULL;
261 int intlen;
262 @@ -422,9 +422,9 @@ int of_irq_parse_oldworld(struct device_
263 if (index >= intlen)
264 return -EINVAL;
265
266 - out_irq->controller = NULL;
267 - out_irq->specifier[0] = ints[index];
268 - out_irq->size = 1;
269 + out_irq->np = NULL;
270 + out_irq->args[0] = ints[index];
271 + out_irq->args_count = 1;
272
273 return 0;
274 }
275 --- a/arch/powerpc/platforms/pseries/event_sources.c
276 +++ b/arch/powerpc/platforms/pseries/event_sources.c
277 @@ -25,7 +25,7 @@ void request_event_sources_irqs(struct d
278 const char *name)
279 {
280 int i, index, count = 0;
281 - struct of_irq oirq;
282 + struct of_phandle_args oirq;
283 const u32 *opicprop;
284 unsigned int opicplen;
285 unsigned int virqs[16];
286 @@ -59,9 +59,8 @@ void request_event_sources_irqs(struct d
287 index++) {
288 if (count > 15)
289 break;
290 - virqs[count] = irq_create_of_mapping(oirq.controller,
291 - oirq.specifier,
292 - oirq.size);
293 + virqs[count] = irq_create_of_mapping(oirq.np, oirq.args,
294 + oirq.args_count);
295 if (virqs[count] == NO_IRQ) {
296 pr_err("event-sources: Unable to allocate "
297 "interrupt number for %s\n",
298 --- a/arch/powerpc/sysdev/mpic_msi.c
299 +++ b/arch/powerpc/sysdev/mpic_msi.c
300 @@ -35,7 +35,7 @@ static int mpic_msi_reserve_u3_hwirqs(st
301 const struct irq_domain_ops *ops = mpic->irqhost->ops;
302 struct device_node *np;
303 int flags, index, i;
304 - struct of_irq oirq;
305 + struct of_phandle_args oirq;
306
307 pr_debug("mpic: found U3, guessing msi allocator setup\n");
308
309 @@ -64,8 +64,8 @@ static int mpic_msi_reserve_u3_hwirqs(st
310
311 index = 0;
312 while (of_irq_parse_one(np, index++, &oirq) == 0) {
313 - ops->xlate(mpic->irqhost, NULL, oirq.specifier,
314 - oirq.size, &hwirq, &flags);
315 + ops->xlate(mpic->irqhost, NULL, oirq.args,
316 + oirq.args_count, &hwirq, &flags);
317 msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, hwirq);
318 }
319 }
320 --- a/arch/x86/kernel/devicetree.c
321 +++ b/arch/x86/kernel/devicetree.c
322 @@ -106,7 +106,7 @@ struct device_node *pcibios_get_phb_of_n
323
324 static int x86_of_pci_irq_enable(struct pci_dev *dev)
325 {
326 - struct of_irq oirq;
327 + struct of_phandle_args oirq;
328 u32 virq;
329 int ret;
330 u8 pin;
331 @@ -121,8 +121,7 @@ static int x86_of_pci_irq_enable(struct
332 if (ret)
333 return ret;
334
335 - virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
336 - oirq.size);
337 + virq = irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count);
338 if (virq == 0)
339 return -EINVAL;
340 dev->irq = virq;
341 --- a/drivers/of/irq.c
342 +++ b/drivers/of/irq.c
343 @@ -36,13 +36,12 @@
344 */
345 unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
346 {
347 - struct of_irq oirq;
348 + struct of_phandle_args oirq;
349
350 if (of_irq_parse_one(dev, index, &oirq))
351 return 0;
352
353 - return irq_create_of_mapping(oirq.controller, oirq.specifier,
354 - oirq.size);
355 + return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count);
356 }
357 EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
358
359 @@ -94,7 +93,7 @@ struct device_node *of_irq_find_parent(s
360 * node exist for the parent.
361 */
362 int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec,
363 - u32 ointsize, const __be32 *addr, struct of_irq *out_irq)
364 + u32 ointsize, const __be32 *addr, struct of_phandle_args *out_irq)
365 {
366 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
367 const __be32 *tmp, *imap, *imask;
368 @@ -156,10 +155,10 @@ int of_irq_parse_raw(struct device_node
369 NULL) {
370 pr_debug(" -> got it !\n");
371 for (i = 0; i < intsize; i++)
372 - out_irq->specifier[i] =
373 + out_irq->args[i] =
374 of_read_number(intspec +i, 1);
375 - out_irq->size = intsize;
376 - out_irq->controller = ipar;
377 + out_irq->args_count = intsize;
378 + out_irq->np = ipar;
379 of_node_put(old);
380 return 0;
381 }
382 @@ -280,7 +279,7 @@ EXPORT_SYMBOL_GPL(of_irq_parse_raw);
383 * This function resolves an interrupt, walking the tree, for a given
384 * device-tree node. It's the high level pendant to of_irq_parse_raw().
385 */
386 -int of_irq_parse_one(struct device_node *device, int index, struct of_irq *out_irq)
387 +int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq)
388 {
389 struct device_node *p;
390 const __be32 *intspec, *tmp, *addr;
391 --- a/drivers/of/of_pci_irq.c
392 +++ b/drivers/of/of_pci_irq.c
393 @@ -15,7 +15,7 @@
394 * PCI tree until an device-node is found, at which point it will finish
395 * resolving using the OF tree walking.
396 */
397 -int of_irq_parse_pci(const struct pci_dev *pdev, struct of_irq *out_irq)
398 +int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
399 {
400 struct device_node *dn, *ppnode;
401 struct pci_dev *ppdev;
402 --- a/drivers/pci/host/pci-mvebu.c
403 +++ b/drivers/pci/host/pci-mvebu.c
404 @@ -649,15 +649,14 @@ static int __init mvebu_pcie_setup(int n
405
406 static int __init mvebu_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
407 {
408 - struct of_irq oirq;
409 + struct of_phandle_args oirq;
410 int ret;
411
412 ret = of_irq_parse_pci(dev, &oirq);
413 if (ret)
414 return ret;
415
416 - return irq_create_of_mapping(oirq.controller, oirq.specifier,
417 - oirq.size);
418 + return irq_create_of_mapping(oirq.np, oirq.args, oirq.args_count);
419 }
420
421 static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
422 --- a/include/linux/of_irq.h
423 +++ b/include/linux/of_irq.h
424 @@ -8,22 +8,6 @@
425 #include <linux/ioport.h>
426 #include <linux/of.h>
427
428 -/**
429 - * of_irq - container for device_node/irq_specifier pair for an irq controller
430 - * @controller: pointer to interrupt controller device tree node
431 - * @size: size of interrupt specifier
432 - * @specifier: array of cells @size long specifing the specific interrupt
433 - *
434 - * This structure is returned when an interrupt is mapped. The controller
435 - * field needs to be put() after use
436 - */
437 -#define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
438 -struct of_irq {
439 - struct device_node *controller; /* Interrupt controller node */
440 - u32 size; /* Specifier size */
441 - u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
442 -};
443 -
444 typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
445
446 /*
447 @@ -36,12 +20,12 @@ typedef int (*of_irq_init_cb_t)(struct d
448 extern unsigned int of_irq_workarounds;
449 extern struct device_node *of_irq_dflt_pic;
450 extern int of_irq_parse_oldworld(struct device_node *device, int index,
451 - struct of_irq *out_irq);
452 + struct of_phandle_args *out_irq);
453 #else /* CONFIG_PPC32 && CONFIG_PPC_PMAC */
454 #define of_irq_workarounds (0)
455 #define of_irq_dflt_pic (NULL)
456 static inline int of_irq_parse_oldworld(struct device_node *device, int index,
457 - struct of_irq *out_irq)
458 + struct of_phandle_args *out_irq)
459 {
460 return -EINVAL;
461 }
462 @@ -50,9 +34,9 @@ static inline int of_irq_parse_oldworld(
463
464 extern int of_irq_parse_raw(struct device_node *parent, const __be32 *intspec,
465 u32 ointsize, const __be32 *addr,
466 - struct of_irq *out_irq);
467 + struct of_phandle_args *out_irq);
468 extern int of_irq_parse_one(struct device_node *device, int index,
469 - struct of_irq *out_irq);
470 + struct of_phandle_args *out_irq);
471 extern unsigned int irq_create_of_mapping(struct device_node *controller,
472 const u32 *intspec,
473 unsigned int intsize);
474 --- a/include/linux/of_pci.h
475 +++ b/include/linux/of_pci.h
476 @@ -5,8 +5,8 @@
477 #include <linux/msi.h>
478
479 struct pci_dev;
480 -struct of_irq;
481 -int of_irq_parse_pci(const struct pci_dev *pdev, struct of_irq *out_irq);
482 +struct of_phandle_args;
483 +int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq);
484
485 struct device_node;
486 struct device_node *of_pci_find_child_device(struct device_node *parent,