blob: f79f2f1021416c5a4e1f6a97ebe4cab9ff02d57b [file] [log] [blame]
Kumar Gala2f3804e2008-07-02 01:36:15 -05001/*
2 * MPC8536 DS Board Setup
3 *
4 * Copyright 2008 Freescale Semiconductor, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/pci.h>
15#include <linux/kdev_t.h>
16#include <linux/delay.h>
17#include <linux/seq_file.h>
18#include <linux/interrupt.h>
19#include <linux/of_platform.h>
Yinghai Lu95f72d12010-07-12 14:36:09 +100020#include <linux/memblock.h>
Kumar Gala2f3804e2008-07-02 01:36:15 -050021
22#include <asm/system.h>
23#include <asm/time.h>
24#include <asm/machdep.h>
25#include <asm/pci-bridge.h>
26#include <mm/mmu_decl.h>
27#include <asm/prom.h>
28#include <asm/udbg.h>
29#include <asm/mpic.h>
Kumar Gala152d0182009-05-15 00:37:35 -050030#include <asm/swiotlb.h>
Kumar Gala2f3804e2008-07-02 01:36:15 -050031
32#include <sysdev/fsl_soc.h>
33#include <sysdev/fsl_pci.h>
34
35void __init mpc8536_ds_pic_init(void)
36{
37 struct mpic *mpic;
38 struct resource r;
39 struct device_node *np;
40
Jason Jinb93eeba2008-07-08 09:21:08 +080041 np = of_find_node_by_type(NULL, "open-pic");
Kumar Gala2f3804e2008-07-02 01:36:15 -050042 if (np == NULL) {
43 printk(KERN_ERR "Could not find open-pic node\n");
44 return;
45 }
46
47 if (of_address_to_resource(np, 0, &r)) {
48 printk(KERN_ERR "Failed to map mpic register space\n");
49 of_node_put(np);
50 return;
51 }
52
53 mpic = mpic_alloc(np, r.start,
54 MPIC_PRIMARY | MPIC_WANTS_RESET |
55 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
56 0, 256, " OpenPIC ");
57 BUG_ON(mpic == NULL);
58 of_node_put(np);
59
60 mpic_init(mpic);
61}
62
63/*
64 * Setup the architecture
65 */
66static void __init mpc8536_ds_setup_arch(void)
67{
68#ifdef CONFIG_PCI
69 struct device_node *np;
Kumar Gala152d0182009-05-15 00:37:35 -050070 struct pci_controller *hose;
Kumar Gala2f3804e2008-07-02 01:36:15 -050071#endif
Kumar Gala152d0182009-05-15 00:37:35 -050072 dma_addr_t max = 0xffffffff;
Kumar Gala2f3804e2008-07-02 01:36:15 -050073
74 if (ppc_md.progress)
75 ppc_md.progress("mpc8536_ds_setup_arch()", 0);
76
77#ifdef CONFIG_PCI
78 for_each_node_by_type(np, "pci") {
79 if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
80 of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
81 struct resource rsrc;
82 of_address_to_resource(np, 0, &rsrc);
83 if ((rsrc.start & 0xfffff) == 0x8000)
84 fsl_add_bridge(np, 1);
85 else
86 fsl_add_bridge(np, 0);
Kumar Gala152d0182009-05-15 00:37:35 -050087
88 hose = pci_find_hose_for_OF_device(np);
89 max = min(max, hose->dma_window_base_cur +
90 hose->dma_window_size);
Kumar Gala2f3804e2008-07-02 01:36:15 -050091 }
92 }
93
94#endif
95
Kumar Gala152d0182009-05-15 00:37:35 -050096#ifdef CONFIG_SWIOTLB
Yinghai Lu95f72d12010-07-12 14:36:09 +100097 if (memblock_end_of_DRAM() > max) {
Kumar Gala152d0182009-05-15 00:37:35 -050098 ppc_swiotlb_enable = 1;
FUJITA Tomonori37029772009-08-04 19:08:23 +000099 set_pci_dma_ops(&swiotlb_dma_ops);
FUJITA Tomonori762afb72009-08-04 19:08:22 +0000100 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
Kumar Gala152d0182009-05-15 00:37:35 -0500101 }
102#endif
103
Kumar Gala2f3804e2008-07-02 01:36:15 -0500104 printk("MPC8536 DS board from Freescale Semiconductor\n");
105}
106
107static struct of_device_id __initdata mpc8536_ds_ids[] = {
108 { .type = "soc", },
109 { .compatible = "soc", },
Kim Phillipscf0d19f2008-07-29 15:29:24 -0500110 { .compatible = "simple-bus", },
Anton Vorontsov84ba4a52009-03-19 21:01:48 +0300111 { .compatible = "gianfar", },
Kumar Gala2f3804e2008-07-02 01:36:15 -0500112 {},
113};
114
115static int __init mpc8536_ds_publish_devices(void)
116{
117 return of_platform_bus_probe(NULL, mpc8536_ds_ids, NULL);
118}
119machine_device_initcall(mpc8536_ds, mpc8536_ds_publish_devices);
120
Kumar Gala152d0182009-05-15 00:37:35 -0500121machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
122
Kumar Gala2f3804e2008-07-02 01:36:15 -0500123/*
124 * Called very early, device-tree isn't unflattened
125 */
126static int __init mpc8536_ds_probe(void)
127{
128 unsigned long root = of_get_flat_dt_root();
129
130 return of_flat_dt_is_compatible(root, "fsl,mpc8536ds");
131}
132
133define_machine(mpc8536_ds) {
134 .name = "MPC8536 DS",
135 .probe = mpc8536_ds_probe,
136 .setup_arch = mpc8536_ds_setup_arch,
137 .init_IRQ = mpc8536_ds_pic_init,
138#ifdef CONFIG_PCI
139 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
140#endif
141 .get_irq = mpic_get_irq,
142 .restart = fsl_rstcr_restart,
143 .calibrate_decr = generic_calibrate_decr,
144 .progress = udbg_progress,
145};