powerpc: Convert power off logic to pm_power_off
[linux-2.6/btrfs-unstable.git] / arch / powerpc / platforms / cell / celleb_setup.c
blob90be8ec5168646b338c0249e8c5c529f0cf09a74
1 /*
2 * Celleb setup code
4 * (C) Copyright 2006-2007 TOSHIBA CORPORATION
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
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.
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.
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.
28 #undef DEBUG
30 #include <linux/cpu.h>
31 #include <linux/sched.h>
32 #include <linux/kernel.h>
33 #include <linux/export.h>
34 #include <linux/mm.h>
35 #include <linux/stddef.h>
36 #include <linux/unistd.h>
37 #include <linux/reboot.h>
38 #include <linux/init.h>
39 #include <linux/delay.h>
40 #include <linux/irq.h>
41 #include <linux/seq_file.h>
42 #include <linux/root_dev.h>
43 #include <linux/console.h>
44 #include <linux/of_platform.h>
46 #include <asm/mmu.h>
47 #include <asm/processor.h>
48 #include <asm/io.h>
49 #include <asm/prom.h>
50 #include <asm/machdep.h>
51 #include <asm/cputable.h>
52 #include <asm/irq.h>
53 #include <asm/time.h>
54 #include <asm/spu_priv1.h>
55 #include <asm/firmware.h>
56 #include <asm/rtas.h>
57 #include <asm/cell-regs.h>
59 #include "beat_interrupt.h"
60 #include "beat_wrapper.h"
61 #include "beat.h"
62 #include "celleb_pci.h"
63 #include "interrupt.h"
64 #include "pervasive.h"
65 #include "ras.h"
67 static char celleb_machine_type[128] = "Celleb";
69 static void celleb_show_cpuinfo(struct seq_file *m)
71 struct device_node *root;
72 const char *model = "";
74 root = of_find_node_by_path("/");
75 if (root)
76 model = of_get_property(root, "model", NULL);
77 /* 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);
82 static int __init celleb_machine_type_hack(char *ptr)
84 strlcpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
85 return 0;
88 __setup("celleb_machine_type_hack=", celleb_machine_type_hack);
90 static void celleb_progress(char *s, unsigned short hex)
92 printk("*** %04x : %s\n", hex, s ? s : "");
95 static void __init celleb_setup_arch_common(void)
97 /* init to some ~sane value until calibrate_delay() runs */
98 loops_per_jiffy = 50000000;
100 #ifdef CONFIG_DUMMY_CONSOLE
101 conswitchp = &dummy_con;
102 #endif
105 static const struct of_device_id celleb_bus_ids[] __initconst = {
106 { .type = "scc", },
107 { .type = "ioif", }, /* old style */
111 static int __init celleb_publish_devices(void)
113 /* Publish OF platform devices for southbridge IOs */
114 of_platform_bus_probe(NULL, celleb_bus_ids, NULL);
116 return 0;
118 machine_device_initcall(celleb_beat, celleb_publish_devices);
119 machine_device_initcall(celleb_native, celleb_publish_devices);
123 * functions for Celleb-Beat
125 static void __init celleb_setup_arch_beat(void)
127 #ifdef CONFIG_SPU_BASE
128 spu_priv1_ops = &spu_priv1_beat_ops;
129 spu_management_ops = &spu_management_of_ops;
130 #endif
132 celleb_setup_arch_common();
135 static int __init celleb_probe_beat(void)
137 unsigned long root = of_get_flat_dt_root();
139 if (!of_flat_dt_is_compatible(root, "Beat"))
140 return 0;
142 powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS
143 | FW_FEATURE_BEAT | FW_FEATURE_LPAR;
144 hpte_init_beat_v3();
145 pm_power_off = beat_power_off;
147 return 1;
152 * functions for Celleb-native
154 static void __init celleb_init_IRQ_native(void)
156 iic_init_IRQ();
157 spider_init_IRQ();
160 static void __init celleb_setup_arch_native(void)
162 #ifdef CONFIG_SPU_BASE
163 spu_priv1_ops = &spu_priv1_mmio_ops;
164 spu_management_ops = &spu_management_of_ops;
165 #endif
167 cbe_regs_init();
169 #ifdef CONFIG_CBE_RAS
170 cbe_ras_init();
171 #endif
173 #ifdef CONFIG_SMP
174 smp_init_cell();
175 #endif
177 cbe_pervasive_init();
179 /* XXX: nvram initialization should be added */
181 celleb_setup_arch_common();
184 static int __init celleb_probe_native(void)
186 unsigned long root = of_get_flat_dt_root();
188 if (of_flat_dt_is_compatible(root, "Beat") ||
189 !of_flat_dt_is_compatible(root, "TOSHIBA,Celleb"))
190 return 0;
192 powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS;
193 hpte_init_native();
194 pm_power_off = rtas_power_off;
196 return 1;
201 * machine definitions
203 define_machine(celleb_beat) {
204 .name = "Cell Reference Set (Beat)",
205 .probe = celleb_probe_beat,
206 .setup_arch = celleb_setup_arch_beat,
207 .show_cpuinfo = celleb_show_cpuinfo,
208 .restart = beat_restart,
209 .halt = beat_halt,
210 .get_rtc_time = beat_get_rtc_time,
211 .set_rtc_time = beat_set_rtc_time,
212 .calibrate_decr = generic_calibrate_decr,
213 .progress = celleb_progress,
214 .power_save = beat_power_save,
215 .nvram_size = beat_nvram_get_size,
216 .nvram_read = beat_nvram_read,
217 .nvram_write = beat_nvram_write,
218 .set_dabr = beat_set_xdabr,
219 .init_IRQ = beatic_init_IRQ,
220 .get_irq = beatic_get_irq,
221 .pci_probe_mode = celleb_pci_probe_mode,
222 .pci_setup_phb = celleb_setup_phb,
223 #ifdef CONFIG_KEXEC
224 .kexec_cpu_down = beat_kexec_cpu_down,
225 #endif
228 define_machine(celleb_native) {
229 .name = "Cell Reference Set (native)",
230 .probe = celleb_probe_native,
231 .setup_arch = celleb_setup_arch_native,
232 .show_cpuinfo = celleb_show_cpuinfo,
233 .restart = rtas_restart,
234 .halt = rtas_halt,
235 .get_boot_time = rtas_get_boot_time,
236 .get_rtc_time = rtas_get_rtc_time,
237 .set_rtc_time = rtas_set_rtc_time,
238 .calibrate_decr = generic_calibrate_decr,
239 .progress = celleb_progress,
240 .pci_probe_mode = celleb_pci_probe_mode,
241 .pci_setup_phb = celleb_setup_phb,
242 .init_IRQ = celleb_init_IRQ_native,