1 /*
2  * Routines common to most mpc85xx-based boards.
3  *
4  * This is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8 
9 #include <linux/of_irq.h>
10 #include <linux/of_platform.h>
11 
12 #include <sysdev/cpm2_pic.h>
13 
14 #include "mpc85xx.h"
15 
16 static struct of_device_id __initdata mpc85xx_common_ids[] = {
17 	{ .type = "soc", },
18 	{ .compatible = "soc", },
19 	{ .compatible = "simple-bus", },
20 	{ .name = "cpm", },
21 	{ .name = "localbus", },
22 	{ .compatible = "gianfar", },
23 	{ .compatible = "fsl,qe", },
24 	{ .compatible = "fsl,cpm2", },
25 	{ .compatible = "fsl,srio", },
26 	/* So that the DMA channel nodes can be probed individually: */
27 	{ .compatible = "fsl,eloplus-dma", },
28 	/* For the PMC driver */
29 	{ .compatible = "fsl,mpc8548-guts", },
30 	/* Probably unnecessary? */
31 	{ .compatible = "gpio-leds", },
32 	/* For all PCI controllers */
33 	{ .compatible = "fsl,mpc8540-pci", },
34 	{ .compatible = "fsl,mpc8548-pcie", },
35 	{ .compatible = "fsl,p1022-pcie", },
36 	{ .compatible = "fsl,p1010-pcie", },
37 	{ .compatible = "fsl,p1023-pcie", },
38 	{ .compatible = "fsl,p4080-pcie", },
39 	{ .compatible = "fsl,qoriq-pcie-v2.4", },
40 	{ .compatible = "fsl,qoriq-pcie-v2.3", },
41 	{ .compatible = "fsl,qoriq-pcie-v2.2", },
42 	{},
43 };
44 
45 int __init mpc85xx_common_publish_devices(void)
46 {
47 	return of_platform_bus_probe(NULL, mpc85xx_common_ids, NULL);
48 }
49 #ifdef CONFIG_CPM2
50 static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
51 {
52 	struct irq_chip *chip = irq_desc_get_chip(desc);
53 	int cascade_irq;
54 
55 	while ((cascade_irq = cpm2_get_irq()) >= 0)
56 		generic_handle_irq(cascade_irq);
57 
58 	chip->irq_eoi(&desc->irq_data);
59 }
60 
61 
62 void __init mpc85xx_cpm2_pic_init(void)
63 {
64 	struct device_node *np;
65 	int irq;
66 
67 	/* Setup CPM2 PIC */
68 	np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
69 	if (np == NULL) {
70 		printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
71 		return;
72 	}
73 	irq = irq_of_parse_and_map(np, 0);
74 	if (irq == NO_IRQ) {
75 		of_node_put(np);
76 		printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
77 		return;
78 	}
79 
80 	cpm2_pic_init(np);
81 	of_node_put(np);
82 	irq_set_chained_handler(irq, cpm2_cascade);
83 }
84 #endif
85