Merge branch 'for-linus' of git://git.kernel.dk/linux-block
[pandora-kernel.git] / arch / powerpc / platforms / 85xx / corenet_ds.c
1 /*
2  * Corenet based SoC DS Setup
3  *
4  * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5  *
6  * Copyright 2009-2011 Freescale Semiconductor Inc.
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  */
13
14 #include <linux/kernel.h>
15 #include <linux/pci.h>
16 #include <linux/kdev_t.h>
17 #include <linux/delay.h>
18 #include <linux/interrupt.h>
19 #include <linux/memblock.h>
20
21 #include <asm/system.h>
22 #include <asm/time.h>
23 #include <asm/machdep.h>
24 #include <asm/pci-bridge.h>
25 #include <asm/ppc-pci.h>
26 #include <mm/mmu_decl.h>
27 #include <asm/prom.h>
28 #include <asm/udbg.h>
29 #include <asm/mpic.h>
30
31 #include <linux/of_platform.h>
32 #include <sysdev/fsl_soc.h>
33 #include <sysdev/fsl_pci.h>
34
35 void __init corenet_ds_pic_init(void)
36 {
37         struct mpic *mpic;
38         struct resource r;
39         struct device_node *np = NULL;
40         unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
41                                 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
42
43         np = of_find_node_by_type(np, "open-pic");
44
45         if (np == NULL) {
46                 printk(KERN_ERR "Could not find open-pic node\n");
47                 return;
48         }
49
50         if (of_address_to_resource(np, 0, &r)) {
51                 printk(KERN_ERR "Failed to map mpic register space\n");
52                 of_node_put(np);
53                 return;
54         }
55
56         if (ppc_md.get_irq == mpic_get_coreint_irq)
57                 flags |= MPIC_ENABLE_COREINT;
58
59         mpic = mpic_alloc(np, r.start, flags, 0, 256, " OpenPIC  ");
60         BUG_ON(mpic == NULL);
61
62         mpic_init(mpic);
63 }
64
65 /*
66  * Setup the architecture
67  */
68 #ifdef CONFIG_SMP
69 void __init mpc85xx_smp_init(void);
70 #endif
71
72 void __init corenet_ds_setup_arch(void)
73 {
74 #ifdef CONFIG_PCI
75         struct device_node *np;
76         struct pci_controller *hose;
77 #endif
78         dma_addr_t max = 0xffffffff;
79
80 #ifdef CONFIG_SMP
81         mpc85xx_smp_init();
82 #endif
83
84 #ifdef CONFIG_PCI
85         for_each_node_by_type(np, "pci") {
86                 if (of_device_is_compatible(np, "fsl,p4080-pcie") ||
87                     of_device_is_compatible(np, "fsl,qoriq-pcie-v2.2")) {
88                         fsl_add_bridge(np, 0);
89                         hose = pci_find_hose_for_OF_device(np);
90                         max = min(max, hose->dma_window_base_cur +
91                                         hose->dma_window_size);
92                 }
93         }
94
95 #ifdef CONFIG_PPC64
96         pci_devs_phb_init();
97 #endif
98 #endif
99
100 #ifdef CONFIG_SWIOTLB
101         if (memblock_end_of_DRAM() > max) {
102                 ppc_swiotlb_enable = 1;
103                 set_pci_dma_ops(&swiotlb_dma_ops);
104                 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
105         }
106 #endif
107         pr_info("%s board from Freescale Semiconductor\n", ppc_md.name);
108 }
109
110 static const struct of_device_id of_device_ids[] __devinitconst = {
111         {
112                 .compatible     = "simple-bus"
113         },
114         {
115                 .compatible     = "fsl,rapidio-delta",
116         },
117         {
118                 .compatible     = "fsl,p4080-pcie",
119         },
120         {
121                 .compatible     = "fsl,qoriq-pcie-v2.2",
122         },
123         /* The following two are for the Freescale hypervisor */
124         {
125                 .name           = "hypervisor",
126         },
127         {
128                 .name           = "handles",
129         },
130         {}
131 };
132
133 int __init corenet_ds_publish_devices(void)
134 {
135         return of_platform_bus_probe(NULL, of_device_ids, NULL);
136 }