blob: fd3e5609e3e004492fdbded682e899f4da21eec8 [file] [log] [blame]
Arnd Bergmannfef1c772005-06-23 09:43:37 +10001/*
Arnd Bergmannf3f66f52005-10-31 20:08:37 -05002 * linux/arch/powerpc/platforms/cell/cell_setup.c
Arnd Bergmannfef1c772005-06-23 09:43:37 +10003 *
4 * Copyright (C) 1995 Linus Torvalds
5 * Adapted from 'alpha' version by Gary Thomas
6 * Modified by Cort Dougan (cort@cs.nmt.edu)
7 * Modified by PPC64 Team, IBM Corp
Arnd Bergmannf3f66f52005-10-31 20:08:37 -05008 * Modified by Cell Team, IBM Deutschland Entwicklung GmbH
Arnd Bergmannfef1c772005-06-23 09:43:37 +10009 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15#undef DEBUG
16
17#include <linux/config.h>
18#include <linux/sched.h>
19#include <linux/kernel.h>
20#include <linux/mm.h>
21#include <linux/stddef.h>
22#include <linux/unistd.h>
23#include <linux/slab.h>
24#include <linux/user.h>
25#include <linux/reboot.h>
26#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/irq.h>
29#include <linux/seq_file.h>
30#include <linux/root_dev.h>
31#include <linux/console.h>
Joel H Schoppbed120c2006-05-01 12:16:11 -070032#include <linux/mutex.h>
33#include <linux/memory_hotplug.h>
Arnd Bergmannfef1c772005-06-23 09:43:37 +100034
35#include <asm/mmu.h>
36#include <asm/processor.h>
37#include <asm/io.h>
Michael Ellerman3d1229d2005-11-14 23:35:00 +110038#include <asm/kexec.h>
Arnd Bergmannfef1c772005-06-23 09:43:37 +100039#include <asm/pgtable.h>
40#include <asm/prom.h>
41#include <asm/rtas.h>
42#include <asm/pci-bridge.h>
43#include <asm/iommu.h>
44#include <asm/dma.h>
45#include <asm/machdep.h>
46#include <asm/time.h>
47#include <asm/nvram.h>
48#include <asm/cputable.h>
Stephen Rothwelld3878992005-09-28 02:50:25 +100049#include <asm/ppc-pci.h>
Paul Mackerras40ef8cb2005-10-10 22:50:37 +100050#include <asm/irq.h>
Joel H Schoppbed120c2006-05-01 12:16:11 -070051#include <asm/spu.h>
Arnd Bergmannfef1c772005-06-23 09:43:37 +100052
Arnd Bergmannf3f66f52005-10-31 20:08:37 -050053#include "interrupt.h"
54#include "iommu.h"
Arnd Bergmannc902be72006-01-04 19:55:53 +000055#include "pervasive.h"
Arnd Bergmannfef1c772005-06-23 09:43:37 +100056
57#ifdef DEBUG
58#define DBG(fmt...) udbg_printf(fmt)
59#else
60#define DBG(fmt...)
61#endif
62
Arnd Bergmann8fce10a2006-01-11 23:07:11 +000063static void cell_show_cpuinfo(struct seq_file *m)
Arnd Bergmannfef1c772005-06-23 09:43:37 +100064{
65 struct device_node *root;
66 const char *model = "";
67
68 root = of_find_node_by_path("/");
69 if (root)
70 model = get_property(root, "model", NULL);
Arnd Bergmannf3f66f52005-10-31 20:08:37 -050071 seq_printf(m, "machine\t\t: CHRP %s\n", model);
Arnd Bergmannfef1c772005-06-23 09:43:37 +100072 of_node_put(root);
73}
74
Arnd Bergmannf3f66f52005-10-31 20:08:37 -050075static void cell_progress(char *s, unsigned short hex)
Arnd Bergmannfef1c772005-06-23 09:43:37 +100076{
77 printk("*** %04x : %s\n", hex, s ? s : "");
78}
79
Arnd Bergmannf3f66f52005-10-31 20:08:37 -050080static void __init cell_setup_arch(void)
Arnd Bergmannfef1c772005-06-23 09:43:37 +100081{
Arnd Bergmanncebf5892005-06-23 09:43:43 +100082 ppc_md.init_IRQ = iic_init_IRQ;
83 ppc_md.get_irq = iic_get_irq;
84
Arnd Bergmannfef1c772005-06-23 09:43:37 +100085#ifdef CONFIG_SMP
Arnd Bergmannf3f66f52005-10-31 20:08:37 -050086 smp_init_cell();
Arnd Bergmannfef1c772005-06-23 09:43:37 +100087#endif
88
89 /* init to some ~sane value until calibrate_delay() runs */
90 loops_per_jiffy = 50000000;
91
92 if (ROOT_DEV == 0) {
93 printk("No ramdisk, default root is /dev/hda2\n");
94 ROOT_DEV = Root_HDA2;
95 }
96
97 /* Find and initialize PCI host bridges */
98 init_pci_config_tokens();
99 find_and_init_phbs();
Arnd Bergmanncebf5892005-06-23 09:43:43 +1000100 spider_init_IRQ();
Arnd Bergmannc902be72006-01-04 19:55:53 +0000101 cell_pervasive_init();
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000102#ifdef CONFIG_DUMMY_CONSOLE
103 conswitchp = &dummy_con;
104#endif
105
Arnd Bergmannf3f66f52005-10-31 20:08:37 -0500106 mmio_nvram_init();
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000107}
108
109/*
110 * Early initialization. Relocation is on but do not reference unbolted pages
111 */
Arnd Bergmannf3f66f52005-10-31 20:08:37 -0500112static void __init cell_init_early(void)
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000113{
Arnd Bergmannf3f66f52005-10-31 20:08:37 -0500114 DBG(" -> cell_init_early()\n");
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000115
116 hpte_init_native();
117
Arnd Bergmannf3f66f52005-10-31 20:08:37 -0500118 cell_init_iommu();
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000119
Arnd Bergmannf3f66f52005-10-31 20:08:37 -0500120 ppc64_interrupt_controller = IC_CELL_PIC;
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000121
Arnd Bergmannf3f66f52005-10-31 20:08:37 -0500122 DBG(" <- cell_init_early()\n");
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000123}
124
125
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100126static int __init cell_probe(void)
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000127{
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100128 unsigned long root = of_get_flat_dt_root();
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000129
Arnd Bergmann133dda12006-06-07 12:04:18 +1000130 if (of_flat_dt_is_compatible(root, "IBM,CBEA") ||
131 of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
132 return 1;
133
134 return 0;
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000135}
136
David Woodhoused52771f2005-12-09 19:04:21 +0100137/*
138 * Cell has no legacy IO; anything calling this function has to
139 * fail or bad things will happen
140 */
141static int cell_check_legacy_ioport(unsigned int baseport)
142{
143 return -ENODEV;
144}
145
Benjamin Herrenschmidte8222502006-03-28 23:15:54 +1100146define_machine(cell) {
147 .name = "Cell",
Arnd Bergmannf3f66f52005-10-31 20:08:37 -0500148 .probe = cell_probe,
149 .setup_arch = cell_setup_arch,
150 .init_early = cell_init_early,
151 .show_cpuinfo = cell_show_cpuinfo,
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000152 .restart = rtas_restart,
153 .power_off = rtas_power_off,
154 .halt = rtas_halt,
155 .get_boot_time = rtas_get_boot_time,
156 .get_rtc_time = rtas_get_rtc_time,
157 .set_rtc_time = rtas_set_rtc_time,
158 .calibrate_decr = generic_calibrate_decr,
David Woodhoused52771f2005-12-09 19:04:21 +0100159 .check_legacy_ioport = cell_check_legacy_ioport,
Arnd Bergmannf3f66f52005-10-31 20:08:37 -0500160 .progress = cell_progress,
Michael Ellerman3d1229d2005-11-14 23:35:00 +1100161#ifdef CONFIG_KEXEC
162 .machine_kexec = default_machine_kexec,
163 .machine_kexec_prepare = default_machine_kexec_prepare,
Michael Ellermancc532912005-12-04 18:39:43 +1100164 .machine_crash_shutdown = default_machine_crash_shutdown,
Michael Ellerman3d1229d2005-11-14 23:35:00 +1100165#endif
Arnd Bergmannfef1c772005-06-23 09:43:37 +1000166};