blob: 14632a971225c7b497f51e13c61c9bf2ce49db20 [file] [log] [blame]
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -05001/*
2 * Wind River SBC8548 setup and early boot code.
3 *
4 * Copyright 2007 Wind River Systems Inc.
5 *
6 * By Paul Gortmaker (see MAINTAINERS for contact information)
7 *
8 * Based largely on the MPC8548CDS support - Copyright 2005 Freescale Inc.
9 *
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
16
17#include <linux/stddef.h>
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/errno.h>
21#include <linux/reboot.h>
22#include <linux/pci.h>
23#include <linux/kdev_t.h>
24#include <linux/major.h>
25#include <linux/console.h>
26#include <linux/delay.h>
27#include <linux/seq_file.h>
28#include <linux/initrd.h>
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -050029#include <linux/interrupt.h>
30#include <linux/fsl_devices.h>
31#include <linux/of_platform.h>
32
33#include <asm/system.h>
34#include <asm/pgtable.h>
35#include <asm/page.h>
Arun Sharma600634972011-07-26 16:09:06 -070036#include <linux/atomic.h>
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -050037#include <asm/time.h>
38#include <asm/io.h>
39#include <asm/machdep.h>
40#include <asm/ipic.h>
41#include <asm/pci-bridge.h>
42#include <asm/irq.h>
43#include <mm/mmu_decl.h>
44#include <asm/prom.h>
45#include <asm/udbg.h>
46#include <asm/mpic.h>
47
48#include <sysdev/fsl_soc.h>
49#include <sysdev/fsl_pci.h>
50
Jeremy McNicollbfd123b2008-05-05 18:17:24 -040051static int sbc_rev;
52
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -050053static void __init sbc8548_pic_init(void)
54{
55 struct mpic *mpic;
56 struct resource r;
57 struct device_node *np = NULL;
58
59 np = of_find_node_by_type(np, "open-pic");
60
61 if (np == NULL) {
62 printk(KERN_ERR "Could not find open-pic node\n");
63 return;
64 }
65
66 if (of_address_to_resource(np, 0, &r)) {
67 printk(KERN_ERR "Failed to map mpic register space\n");
68 of_node_put(np);
69 return;
70 }
71
72 mpic = mpic_alloc(np, r.start,
73 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
74 0, 256, " OpenPIC ");
75 BUG_ON(mpic == NULL);
76
77 /* Return the mpic node */
78 of_node_put(np);
79
80 mpic_init(mpic);
81}
82
Jeremy McNicollbfd123b2008-05-05 18:17:24 -040083/* Extract the HW Rev from the EPLD on the board */
84static int __init sbc8548_hw_rev(void)
85{
86 struct device_node *np;
87 struct resource res;
88 unsigned int *rev;
89 int board_rev = 0;
90
91 np = of_find_compatible_node(NULL, NULL, "hw-rev");
92 if (np == NULL) {
93 printk("No HW-REV found in DTB.\n");
94 return -ENODEV;
95 }
96
97 of_address_to_resource(np, 0, &res);
98 of_node_put(np);
99
100 rev = ioremap(res.start,sizeof(unsigned int));
101 board_rev = (*rev) >> 28;
102 iounmap(rev);
103
104 return board_rev;
105}
106
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500107/*
108 * Setup the architecture
109 */
110static void __init sbc8548_setup_arch(void)
111{
112#ifdef CONFIG_PCI
113 struct device_node *np;
114#endif
115
116 if (ppc_md.progress)
117 ppc_md.progress("sbc8548_setup_arch()", 0);
118
119#ifdef CONFIG_PCI
120 for_each_node_by_type(np, "pci") {
121 if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
122 of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
123 struct resource rsrc;
124 of_address_to_resource(np, 0, &rsrc);
125 if ((rsrc.start & 0xfffff) == 0x8000)
126 fsl_add_bridge(np, 1);
127 else
128 fsl_add_bridge(np, 0);
129 }
130 }
131#endif
Jeremy McNicollbfd123b2008-05-05 18:17:24 -0400132 sbc_rev = sbc8548_hw_rev();
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500133}
134
135static void sbc8548_show_cpuinfo(struct seq_file *m)
136{
137 uint pvid, svid, phid1;
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500138
139 pvid = mfspr(SPRN_PVR);
140 svid = mfspr(SPRN_SVR);
141
142 seq_printf(m, "Vendor\t\t: Wind River\n");
Jeremy McNicollbfd123b2008-05-05 18:17:24 -0400143 seq_printf(m, "Machine\t\t: SBC8548 v%d\n", sbc_rev);
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500144 seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
145 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
146
147 /* Display cpu Pll setting */
148 phid1 = mfspr(SPRN_HID1);
149 seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500150}
151
152static struct of_device_id __initdata of_bus_ids[] = {
153 { .name = "soc", },
154 { .type = "soc", },
Jeremy McNicollbfd123b2008-05-05 18:17:24 -0400155 { .compatible = "simple-bus", },
Anton Vorontsov84ba4a52009-03-19 21:01:48 +0300156 { .compatible = "gianfar", },
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500157 {},
158};
159
160static int __init declare_of_platform_devices(void)
161{
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500162 of_platform_bus_probe(NULL, of_bus_ids, NULL);
Kumar Gala77b41592008-01-28 10:55:42 -0600163
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500164 return 0;
165}
Kumar Gala77b41592008-01-28 10:55:42 -0600166machine_device_initcall(sbc8548, declare_of_platform_devices);
Paul Gortmaker0e0fffe2008-01-24 18:41:27 -0500167
168/*
169 * Called very early, device-tree isn't unflattened
170 */
171static int __init sbc8548_probe(void)
172{
173 unsigned long root = of_get_flat_dt_root();
174
175 return of_flat_dt_is_compatible(root, "SBC8548");
176}
177
178define_machine(sbc8548) {
179 .name = "SBC8548",
180 .probe = sbc8548_probe,
181 .setup_arch = sbc8548_setup_arch,
182 .init_IRQ = sbc8548_pic_init,
183 .show_cpuinfo = sbc8548_show_cpuinfo,
184 .get_irq = mpic_get_irq,
185 .restart = fsl_rstcr_restart,
186#ifdef CONFIG_PCI
187 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
188#endif
189 .calibrate_decr = generic_calibrate_decr,
190 .progress = udbg_progress,
191};