Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 1 | /* |
| 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 Loeliger | d8caf74 | 2007-11-13 11:10:58 -0600 | [diff] [blame] | 43 | #include <linux/of_platform.h> |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 44 | |
| 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 Breeds | e7bda18 | 2007-10-30 14:55:04 +1100 | [diff] [blame] | 53 | #include <asm/time.h> |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 54 | #include <asm/spu_priv1.h> |
| 55 | #include <asm/firmware.h> |
Ishizaki Kou | 9858ee8 | 2007-12-04 19:38:24 +1100 | [diff] [blame] | 56 | #include <asm/rtas.h> |
| 57 | #include <asm/cell-regs.h> |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 58 | |
| 59 | #include "interrupt.h" |
| 60 | #include "beat_wrapper.h" |
| 61 | #include "beat.h" |
| 62 | #include "pci.h" |
Ishizaki Kou | 9858ee8 | 2007-12-04 19:38:24 +1100 | [diff] [blame] | 63 | #include "../cell/interrupt.h" |
| 64 | #include "../cell/pervasive.h" |
| 65 | #include "../cell/ras.h" |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 66 | |
| 67 | static char celleb_machine_type[128] = "Celleb"; |
| 68 | |
| 69 | static 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 Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 76 | model = of_get_property(root, "model", NULL); |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 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); |
| 80 | } |
| 81 | |
Ishizaki Kou | a4ebd01 | 2007-07-26 20:02:27 +1000 | [diff] [blame] | 82 | static int __init celleb_machine_type_hack(char *ptr) |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 83 | { |
| 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 Kou | b4f8b10 | 2007-05-09 17:38:03 +1000 | [diff] [blame] | 89 | __setup("celleb_machine_type_hack=", celleb_machine_type_hack); |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 90 | |
| 91 | static void celleb_progress(char *s, unsigned short hex) |
| 92 | { |
| 93 | printk("*** %04x : %s\n", hex, s ? s : ""); |
| 94 | } |
| 95 | |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 96 | static void __init celleb_setup_arch_common(void) |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 97 | { |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 98 | /* 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 Kou | 9858ee8 | 2007-12-04 19:38:24 +1100 | [diff] [blame] | 104 | } |
| 105 | |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 106 | static struct of_device_id celleb_bus_ids[] __initdata = { |
| 107 | { .type = "scc", }, |
| 108 | { .type = "ioif", }, /* old style */ |
| 109 | {}, |
| 110 | }; |
| 111 | |
| 112 | static int __init celleb_publish_devices(void) |
| 113 | { |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 114 | /* Publish OF platform devices for southbridge IOs */ |
| 115 | of_platform_bus_probe(NULL, celleb_bus_ids, NULL); |
| 116 | |
| 117 | celleb_pci_workaround_init(); |
| 118 | |
| 119 | return 0; |
| 120 | } |
Grant Likely | e25c47f | 2008-01-03 06:14:36 +1100 | [diff] [blame] | 121 | machine_device_initcall(celleb_beat, celleb_publish_devices); |
| 122 | machine_device_initcall(celleb_native, celleb_publish_devices); |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 123 | |
| 124 | |
| 125 | /* |
| 126 | * functions for Celleb-Beat |
| 127 | */ |
Ishizaki Kou | 9858ee8 | 2007-12-04 19:38:24 +1100 | [diff] [blame] | 128 | static void __init celleb_setup_arch_beat(void) |
| 129 | { |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 130 | #ifdef CONFIG_SPU_BASE |
Ishizaki Kou | 9858ee8 | 2007-12-04 19:38:24 +1100 | [diff] [blame] | 131 | spu_priv1_ops = &spu_priv1_beat_ops; |
| 132 | spu_management_ops = &spu_management_of_ops; |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 133 | #endif |
| 134 | |
| 135 | #ifdef CONFIG_SMP |
| 136 | smp_init_celleb(); |
| 137 | #endif |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 138 | |
| 139 | celleb_setup_arch_common(); |
| 140 | } |
| 141 | |
| 142 | static int __init celleb_probe_beat(void) |
| 143 | { |
| 144 | unsigned long root = of_get_flat_dt_root(); |
| 145 | |
| 146 | if (!of_flat_dt_is_compatible(root, "Beat")) |
| 147 | return 0; |
| 148 | |
| 149 | powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS |
| 150 | | FW_FEATURE_BEAT | FW_FEATURE_LPAR; |
| 151 | hpte_init_beat_v3(); |
| 152 | |
| 153 | return 1; |
| 154 | } |
| 155 | |
| 156 | |
| 157 | /* |
| 158 | * functions for Celleb-native |
| 159 | */ |
| 160 | static void __init celleb_init_IRQ_native(void) |
| 161 | { |
| 162 | iic_init_IRQ(); |
| 163 | spider_init_IRQ(); |
Ishizaki Kou | 9858ee8 | 2007-12-04 19:38:24 +1100 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | static void __init celleb_setup_arch_native(void) |
| 167 | { |
Ishizaki Kou | 9858ee8 | 2007-12-04 19:38:24 +1100 | [diff] [blame] | 168 | #ifdef CONFIG_SPU_BASE |
| 169 | spu_priv1_ops = &spu_priv1_mmio_ops; |
| 170 | spu_management_ops = &spu_management_of_ops; |
| 171 | #endif |
| 172 | |
| 173 | cbe_regs_init(); |
| 174 | |
| 175 | #ifdef CONFIG_CBE_RAS |
| 176 | cbe_ras_init(); |
| 177 | #endif |
| 178 | |
| 179 | #ifdef CONFIG_SMP |
| 180 | smp_init_cell(); |
| 181 | #endif |
| 182 | |
| 183 | cbe_pervasive_init(); |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 184 | |
| 185 | /* XXX: nvram initialization should be added */ |
| 186 | |
| 187 | celleb_setup_arch_common(); |
Ishizaki Kou | 9858ee8 | 2007-12-04 19:38:24 +1100 | [diff] [blame] | 188 | } |
| 189 | |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 190 | static int __init celleb_probe_native(void) |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 191 | { |
| 192 | unsigned long root = of_get_flat_dt_root(); |
| 193 | |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 194 | if (of_flat_dt_is_compatible(root, "Beat") || |
| 195 | !of_flat_dt_is_compatible(root, "TOSHIBA,Celleb")) |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 196 | return 0; |
| 197 | |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 198 | powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS; |
| 199 | hpte_init_native(); |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 200 | |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 201 | return 1; |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 202 | } |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 203 | |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 204 | |
| 205 | /* |
| 206 | * machine definitions |
| 207 | */ |
| 208 | define_machine(celleb_beat) { |
| 209 | .name = "Cell Reference Set (Beat)", |
| 210 | .probe = celleb_probe_beat, |
| 211 | .setup_arch = celleb_setup_arch_beat, |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 212 | .show_cpuinfo = celleb_show_cpuinfo, |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 213 | .restart = beat_restart, |
| 214 | .power_off = beat_power_off, |
| 215 | .halt = beat_halt, |
| 216 | .get_rtc_time = beat_get_rtc_time, |
| 217 | .set_rtc_time = beat_set_rtc_time, |
| 218 | .calibrate_decr = generic_calibrate_decr, |
| 219 | .progress = celleb_progress, |
| 220 | .power_save = beat_power_save, |
| 221 | .nvram_size = beat_nvram_get_size, |
| 222 | .nvram_read = beat_nvram_read, |
| 223 | .nvram_write = beat_nvram_write, |
| 224 | .set_dabr = beat_set_xdabr, |
| 225 | .init_IRQ = beatic_init_IRQ, |
| 226 | .get_irq = beatic_get_irq, |
| 227 | .pci_probe_mode = celleb_pci_probe_mode, |
| 228 | .pci_setup_phb = celleb_setup_phb, |
| 229 | #ifdef CONFIG_KEXEC |
| 230 | .kexec_cpu_down = beat_kexec_cpu_down, |
| 231 | .machine_kexec = default_machine_kexec, |
| 232 | .machine_kexec_prepare = default_machine_kexec_prepare, |
| 233 | .machine_crash_shutdown = default_machine_crash_shutdown, |
| 234 | #endif |
| 235 | }; |
| 236 | |
| 237 | define_machine(celleb_native) { |
| 238 | .name = "Cell Reference Set (native)", |
| 239 | .probe = celleb_probe_native, |
| 240 | .setup_arch = celleb_setup_arch_native, |
| 241 | .show_cpuinfo = celleb_show_cpuinfo, |
| 242 | .restart = rtas_restart, |
| 243 | .power_off = rtas_power_off, |
| 244 | .halt = rtas_halt, |
| 245 | .get_boot_time = rtas_get_boot_time, |
| 246 | .get_rtc_time = rtas_get_rtc_time, |
| 247 | .set_rtc_time = rtas_set_rtc_time, |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 248 | .calibrate_decr = generic_calibrate_decr, |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 249 | .progress = celleb_progress, |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 250 | .pci_probe_mode = celleb_pci_probe_mode, |
| 251 | .pci_setup_phb = celleb_setup_phb, |
Ishizaki Kou | 7e1961f | 2007-12-13 21:13:14 +1100 | [diff] [blame] | 252 | .init_IRQ = celleb_init_IRQ_native, |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 253 | #ifdef CONFIG_KEXEC |
Ishizaki Kou | c347b79 | 2007-02-02 16:47:17 +0900 | [diff] [blame] | 254 | .machine_kexec = default_machine_kexec, |
| 255 | .machine_kexec_prepare = default_machine_kexec_prepare, |
| 256 | .machine_crash_shutdown = default_machine_crash_shutdown, |
| 257 | #endif |
| 258 | }; |