blob: 0f0c4680bf013071dd11ba50c13e50e73acbe0c3 [file] [log] [blame]
Ishizaki Kouc347b792007-02-02 16:47:17 +09001/*
2 * Celleb setup code
3 *
4 * (C) Copyright 2006-2007 TOSHIBA CORPORATION
5 *
6 * This code is based on arch/powerpc/platforms/cell/setup.c:
7 * Copyright (C) 1995 Linus Torvalds
8 * Adapted from 'alpha' version by Gary Thomas
9 * Modified by Cort Dougan (cort@cs.nmt.edu)
10 * Modified by PPC64 Team, IBM Corp
11 * Modified by Cell Team, IBM Deutschland Entwicklung GmbH
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27
28#undef DEBUG
29
30#include <linux/cpu.h>
31#include <linux/sched.h>
32#include <linux/kernel.h>
33#include <linux/mm.h>
34#include <linux/stddef.h>
35#include <linux/unistd.h>
36#include <linux/reboot.h>
37#include <linux/init.h>
38#include <linux/delay.h>
39#include <linux/irq.h>
40#include <linux/seq_file.h>
41#include <linux/root_dev.h>
42#include <linux/console.h>
Jon Loeligerd8caf742007-11-13 11:10:58 -060043#include <linux/of_platform.h>
Ishizaki Kouc347b792007-02-02 16:47:17 +090044
45#include <asm/mmu.h>
46#include <asm/processor.h>
47#include <asm/io.h>
48#include <asm/kexec.h>
49#include <asm/prom.h>
50#include <asm/machdep.h>
51#include <asm/cputable.h>
52#include <asm/irq.h>
Tony Breedse7bda182007-10-30 14:55:04 +110053#include <asm/time.h>
Ishizaki Kouc347b792007-02-02 16:47:17 +090054#include <asm/spu_priv1.h>
55#include <asm/firmware.h>
Ishizaki Kou9858ee82007-12-04 19:38:24 +110056#include <asm/rtas.h>
57#include <asm/cell-regs.h>
Ishizaki Kouc347b792007-02-02 16:47:17 +090058
59#include "interrupt.h"
60#include "beat_wrapper.h"
61#include "beat.h"
62#include "pci.h"
Ishizaki Kou9858ee82007-12-04 19:38:24 +110063#include "../cell/interrupt.h"
64#include "../cell/pervasive.h"
65#include "../cell/ras.h"
Ishizaki Kouc347b792007-02-02 16:47:17 +090066
67static char celleb_machine_type[128] = "Celleb";
68
69static void celleb_show_cpuinfo(struct seq_file *m)
70{
71 struct device_node *root;
72 const char *model = "";
73
74 root = of_find_node_by_path("/");
75 if (root)
Stephen Rothwelle2eb6392007-04-03 22:26:41 +100076 model = of_get_property(root, "model", NULL);
Ishizaki Kouc347b792007-02-02 16:47:17 +090077 /* using "CHRP" is to trick anaconda into installing FCx into Celleb */
78 seq_printf(m, "machine\t\t: %s %s\n", celleb_machine_type, model);
79 of_node_put(root);
80}
81
Ishizaki Koua4ebd012007-07-26 20:02:27 +100082static int __init celleb_machine_type_hack(char *ptr)
Ishizaki Kouc347b792007-02-02 16:47:17 +090083{
84 strncpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
85 celleb_machine_type[sizeof(celleb_machine_type)-1] = 0;
86 return 0;
87}
88
Ishizaki Koub4f8b102007-05-09 17:38:03 +100089__setup("celleb_machine_type_hack=", celleb_machine_type_hack);
Ishizaki Kouc347b792007-02-02 16:47:17 +090090
91static void celleb_progress(char *s, unsigned short hex)
92{
93 printk("*** %04x : %s\n", hex, s ? s : "");
94}
95
Ishizaki Kou7e1961f2007-12-13 21:13:14 +110096static void __init celleb_setup_arch_common(void)
Ishizaki Kouc347b792007-02-02 16:47:17 +090097{
Ishizaki Kou7e1961f2007-12-13 21:13:14 +110098 /* init to some ~sane value until calibrate_delay() runs */
99 loops_per_jiffy = 50000000;
100
101#ifdef CONFIG_DUMMY_CONSOLE
102 conswitchp = &dummy_con;
103#endif
Ishizaki Kou9858ee82007-12-04 19:38:24 +1100104}
105
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100106static struct of_device_id celleb_bus_ids[] __initdata = {
107 { .type = "scc", },
108 { .type = "ioif", }, /* old style */
109 {},
110};
111
112static int __init celleb_publish_devices(void)
113{
114 if (!machine_is(celleb_beat) &&
115 !machine_is(celleb_native))
116 return -ENODEV;
117
118 /* Publish OF platform devices for southbridge IOs */
119 of_platform_bus_probe(NULL, celleb_bus_ids, NULL);
120
121 celleb_pci_workaround_init();
122
123 return 0;
124}
125device_initcall(celleb_publish_devices);
126
127
128/*
129 * functions for Celleb-Beat
130 */
Ishizaki Kou9858ee82007-12-04 19:38:24 +1100131static void __init celleb_setup_arch_beat(void)
132{
Ishizaki Kouc347b792007-02-02 16:47:17 +0900133#ifdef CONFIG_SPU_BASE
Ishizaki Kou9858ee82007-12-04 19:38:24 +1100134 spu_priv1_ops = &spu_priv1_beat_ops;
135 spu_management_ops = &spu_management_of_ops;
Ishizaki Kouc347b792007-02-02 16:47:17 +0900136#endif
137
138#ifdef CONFIG_SMP
139 smp_init_celleb();
140#endif
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100141
142 celleb_setup_arch_common();
143}
144
145static int __init celleb_probe_beat(void)
146{
147 unsigned long root = of_get_flat_dt_root();
148
149 if (!of_flat_dt_is_compatible(root, "Beat"))
150 return 0;
151
152 powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS
153 | FW_FEATURE_BEAT | FW_FEATURE_LPAR;
154 hpte_init_beat_v3();
155
156 return 1;
157}
158
159
160/*
161 * functions for Celleb-native
162 */
163static void __init celleb_init_IRQ_native(void)
164{
165 iic_init_IRQ();
166 spider_init_IRQ();
Ishizaki Kou9858ee82007-12-04 19:38:24 +1100167}
168
169static void __init celleb_setup_arch_native(void)
170{
Ishizaki Kou9858ee82007-12-04 19:38:24 +1100171#ifdef CONFIG_SPU_BASE
172 spu_priv1_ops = &spu_priv1_mmio_ops;
173 spu_management_ops = &spu_management_of_ops;
174#endif
175
176 cbe_regs_init();
177
178#ifdef CONFIG_CBE_RAS
179 cbe_ras_init();
180#endif
181
182#ifdef CONFIG_SMP
183 smp_init_cell();
184#endif
185
186 cbe_pervasive_init();
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100187
188 /* XXX: nvram initialization should be added */
189
190 celleb_setup_arch_common();
Ishizaki Kou9858ee82007-12-04 19:38:24 +1100191}
192
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100193static int __init celleb_probe_native(void)
Ishizaki Kouc347b792007-02-02 16:47:17 +0900194{
195 unsigned long root = of_get_flat_dt_root();
196
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100197 if (of_flat_dt_is_compatible(root, "Beat") ||
198 !of_flat_dt_is_compatible(root, "TOSHIBA,Celleb"))
Ishizaki Kouc347b792007-02-02 16:47:17 +0900199 return 0;
200
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100201 powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS;
202 hpte_init_native();
Ishizaki Kouc347b792007-02-02 16:47:17 +0900203
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100204 return 1;
Ishizaki Kouc347b792007-02-02 16:47:17 +0900205}
Ishizaki Kouc347b792007-02-02 16:47:17 +0900206
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100207
208/*
209 * machine definitions
210 */
211define_machine(celleb_beat) {
212 .name = "Cell Reference Set (Beat)",
213 .probe = celleb_probe_beat,
214 .setup_arch = celleb_setup_arch_beat,
Ishizaki Kouc347b792007-02-02 16:47:17 +0900215 .show_cpuinfo = celleb_show_cpuinfo,
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100216 .restart = beat_restart,
217 .power_off = beat_power_off,
218 .halt = beat_halt,
219 .get_rtc_time = beat_get_rtc_time,
220 .set_rtc_time = beat_set_rtc_time,
221 .calibrate_decr = generic_calibrate_decr,
222 .progress = celleb_progress,
223 .power_save = beat_power_save,
224 .nvram_size = beat_nvram_get_size,
225 .nvram_read = beat_nvram_read,
226 .nvram_write = beat_nvram_write,
227 .set_dabr = beat_set_xdabr,
228 .init_IRQ = beatic_init_IRQ,
229 .get_irq = beatic_get_irq,
230 .pci_probe_mode = celleb_pci_probe_mode,
231 .pci_setup_phb = celleb_setup_phb,
232#ifdef CONFIG_KEXEC
233 .kexec_cpu_down = beat_kexec_cpu_down,
234 .machine_kexec = default_machine_kexec,
235 .machine_kexec_prepare = default_machine_kexec_prepare,
236 .machine_crash_shutdown = default_machine_crash_shutdown,
237#endif
238};
239
240define_machine(celleb_native) {
241 .name = "Cell Reference Set (native)",
242 .probe = celleb_probe_native,
243 .setup_arch = celleb_setup_arch_native,
244 .show_cpuinfo = celleb_show_cpuinfo,
245 .restart = rtas_restart,
246 .power_off = rtas_power_off,
247 .halt = rtas_halt,
248 .get_boot_time = rtas_get_boot_time,
249 .get_rtc_time = rtas_get_rtc_time,
250 .set_rtc_time = rtas_set_rtc_time,
Ishizaki Kouc347b792007-02-02 16:47:17 +0900251 .calibrate_decr = generic_calibrate_decr,
Ishizaki Kouc347b792007-02-02 16:47:17 +0900252 .progress = celleb_progress,
Ishizaki Kouc347b792007-02-02 16:47:17 +0900253 .pci_probe_mode = celleb_pci_probe_mode,
254 .pci_setup_phb = celleb_setup_phb,
Ishizaki Kou7e1961f2007-12-13 21:13:14 +1100255 .init_IRQ = celleb_init_IRQ_native,
Ishizaki Kouc347b792007-02-02 16:47:17 +0900256#ifdef CONFIG_KEXEC
Ishizaki Kouc347b792007-02-02 16:47:17 +0900257 .machine_kexec = default_machine_kexec,
258 .machine_kexec_prepare = default_machine_kexec_prepare,
259 .machine_crash_shutdown = default_machine_crash_shutdown,
260#endif
261};