blob: 2b299eba3670b408a73e18e2ac48402a03fa76ca [file] [log] [blame]
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +05301/*
2 * MPC85xx RDB Board Setup
3 *
4 * Copyright 2009 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>
20
21#include <asm/system.h>
22#include <asm/time.h>
23#include <asm/machdep.h>
24#include <asm/pci-bridge.h>
25#include <mm/mmu_decl.h>
26#include <asm/prom.h>
27#include <asm/udbg.h>
28#include <asm/mpic.h>
29
30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h>
Kyle Moffett582d3e02011-12-02 06:27:58 +000032#include "smp.h"
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053033
Dmitry Eremin-Solenikov543a07b2011-11-17 21:56:16 +040034#include "mpc85xx.h"
35
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053036#undef DEBUG
37
38#ifdef DEBUG
39#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
40#else
41#define DBG(fmt, args...)
42#endif
43
44
45void __init mpc85xx_rdb_pic_init(void)
46{
47 struct mpic *mpic;
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053048 struct device_node *np;
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053049 unsigned long root = of_get_flat_dt_root();
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053050
51 np = of_find_node_by_type(NULL, "open-pic");
52 if (np == NULL) {
53 printk(KERN_ERR "Could not find open-pic node\n");
54 return;
55 }
56
Fabio Baltieria63e23b2011-07-12 09:49:43 +020057 if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
Kyle Moffett8bf41562011-12-02 06:27:59 +000058 mpic = mpic_alloc(np, 0,
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053059 MPIC_PRIMARY |
Fabio Baltieria63e23b2011-07-12 09:49:43 +020060 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
61 MPIC_SINGLE_DEST_CPU,
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053062 0, 256, " OpenPIC ");
63 } else {
Kyle Moffett8bf41562011-12-02 06:27:59 +000064 mpic = mpic_alloc(np, 0,
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053065 MPIC_PRIMARY | MPIC_WANTS_RESET |
66 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
67 MPIC_SINGLE_DEST_CPU,
68 0, 256, " OpenPIC ");
Poonam Aggrwaldc2e6732009-09-19 22:43:56 +053069 }
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053070
71 BUG_ON(mpic == NULL);
72 of_node_put(np);
73
74 mpic_init(mpic);
75
76}
77
78/*
79 * Setup the architecture
80 */
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053081static void __init mpc85xx_rdb_setup_arch(void)
82{
83#ifdef CONFIG_PCI
84 struct device_node *np;
85#endif
86
87 if (ppc_md.progress)
88 ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
89
90#ifdef CONFIG_PCI
91 for_each_node_by_type(np, "pci") {
92 if (of_device_is_compatible(np, "fsl,mpc8548-pcie"))
93 fsl_add_bridge(np, 0);
94 }
95
96#endif
97
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053098 mpc85xx_smp_init();
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +053099 printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
100}
101
Dmitry Eremin-Solenikov46d026a2011-11-17 21:56:17 +0400102machine_device_initcall(p2020_rdb, mpc85xx_common_publish_devices);
103machine_device_initcall(p1020_rdb, mpc85xx_common_publish_devices);
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +0530104
105/*
106 * Called very early, device-tree isn't unflattened
107 */
108static int __init p2020_rdb_probe(void)
109{
110 unsigned long root = of_get_flat_dt_root();
111
112 if (of_flat_dt_is_compatible(root, "fsl,P2020RDB"))
113 return 1;
114 return 0;
115}
116
Poonam Aggrwal52dffd72009-09-25 09:50:28 +0530117static int __init p1020_rdb_probe(void)
118{
119 unsigned long root = of_get_flat_dt_root();
120
121 if (of_flat_dt_is_compatible(root, "fsl,P1020RDB"))
122 return 1;
123 return 0;
124}
125
Poonam Aggrwalfb8e3e12009-08-07 21:05:16 +0530126define_machine(p2020_rdb) {
127 .name = "P2020 RDB",
128 .probe = p2020_rdb_probe,
129 .setup_arch = mpc85xx_rdb_setup_arch,
130 .init_IRQ = mpc85xx_rdb_pic_init,
131#ifdef CONFIG_PCI
132 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
133#endif
134 .get_irq = mpic_get_irq,
135 .restart = fsl_rstcr_restart,
136 .calibrate_decr = generic_calibrate_decr,
137 .progress = udbg_progress,
138};
Poonam Aggrwal52dffd72009-09-25 09:50:28 +0530139
140define_machine(p1020_rdb) {
141 .name = "P1020 RDB",
142 .probe = p1020_rdb_probe,
143 .setup_arch = mpc85xx_rdb_setup_arch,
144 .init_IRQ = mpc85xx_rdb_pic_init,
145#ifdef CONFIG_PCI
146 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
147#endif
148 .get_irq = mpic_get_irq,
149 .restart = fsl_rstcr_restart,
150 .calibrate_decr = generic_calibrate_decr,
151 .progress = udbg_progress,
152};