2 * Common boot and setup code for both 32-bit and 64-bit.
3 * Extracted from arch/powerpc/kernel/setup_64.c.
5 * Copyright (C) 2001 PPC64 Team, IBM Corp
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
12 #include <linux/config.h>
13 #include <linux/module.h>
14 #include <linux/string.h>
15 #include <linux/sched.h>
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/reboot.h>
19 #include <linux/delay.h>
20 #include <linux/initrd.h>
21 #include <linux/ide.h>
22 #include <linux/seq_file.h>
23 #include <linux/ioport.h>
24 #include <linux/console.h>
25 #include <linux/utsname.h>
26 #include <linux/tty.h>
27 #include <linux/root_dev.h>
28 #include <linux/notifier.h>
29 #include <linux/cpu.h>
30 #include <linux/unistd.h>
31 #include <linux/serial.h>
32 #include <linux/serial_8250.h>
35 #include <asm/processor.h>
36 #include <asm/pgtable.h>
37 #include <asm/bootinfo.h>
40 #include <asm/machdep.h>
42 #include <asm/cputable.h>
43 #include <asm/sections.h>
44 #include <asm/btext.h>
45 #include <asm/nvram.h>
46 #include <asm/setup.h>
47 #include <asm/system.h>
49 #include <asm/iommu.h>
50 #include <asm/serial.h>
51 #include <asm/cache.h>
59 #define DBG(fmt...) udbg_printf(fmt)
65 * This still seems to be needed... -- paulus
67 struct screen_info screen_info = {
70 .orig_video_cols = 80,
71 .orig_video_lines = 25,
72 .orig_video_isVGA = 1,
73 .orig_video_points = 16
77 /* XXX should go elsewhere eventually */
78 int ppc_do_canonicalize_irqs;
79 EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
82 /* also used by kexec */
83 void machine_shutdown(void)
85 if (ppc_md.nvram_sync)
89 void machine_restart(char *cmd)
96 printk(KERN_EMERG "System Halted, OK to turn off power\n");
101 void machine_power_off(void)
108 printk(KERN_EMERG "System Halted, OK to turn off power\n");
112 /* Used by the G5 thermal driver */
113 EXPORT_SYMBOL_GPL(machine_power_off);
115 void (*pm_power_off)(void) = machine_power_off;
116 EXPORT_SYMBOL_GPL(pm_power_off);
118 void machine_halt(void)
125 printk(KERN_EMERG "System Halted, OK to turn off power\n");
132 extern u32 cpu_temp(unsigned long cpu);
133 extern u32 cpu_temp_both(unsigned long cpu);
134 #endif /* CONFIG_TAU */
137 DEFINE_PER_CPU(unsigned int, pvr);
140 static int show_cpuinfo(struct seq_file *m, void *v)
142 unsigned long cpu_id = (unsigned long)v - 1;
147 if (cpu_id == NR_CPUS) {
148 #if defined(CONFIG_SMP) && defined(CONFIG_PPC32)
149 unsigned long bogosum = 0;
151 for (i = 0; i < NR_CPUS; ++i)
153 bogosum += loops_per_jiffy;
154 seq_printf(m, "total bogomips\t: %lu.%02lu\n",
155 bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
156 #endif /* CONFIG_SMP && CONFIG_PPC32 */
157 seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
159 if (ppc_md.show_cpuinfo != NULL)
160 ppc_md.show_cpuinfo(m);
165 /* We only show online cpus: disable preempt (overzealous, I
166 * knew) to prevent cpu going down. */
168 if (!cpu_online(cpu_id)) {
174 #ifdef CONFIG_PPC64 /* XXX for now */
175 pvr = per_cpu(pvr, cpu_id);
177 pvr = cpu_data[cpu_id].pvr;
180 pvr = mfspr(SPRN_PVR);
182 maj = (pvr >> 8) & 0xFF;
185 seq_printf(m, "processor\t: %lu\n", cpu_id);
186 seq_printf(m, "cpu\t\t: ");
188 if (cur_cpu_spec->pvr_mask)
189 seq_printf(m, "%s", cur_cpu_spec->cpu_name);
191 seq_printf(m, "unknown (%08x)", pvr);
193 #ifdef CONFIG_ALTIVEC
194 if (cpu_has_feature(CPU_FTR_ALTIVEC))
195 seq_printf(m, ", altivec supported");
196 #endif /* CONFIG_ALTIVEC */
201 if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) {
202 #ifdef CONFIG_TAU_AVERAGE
203 /* more straightforward, but potentially misleading */
204 seq_printf(m, "temperature \t: %u C (uncalibrated)\n",
207 /* show the actual temp sensor range */
209 temp = cpu_temp_both(i);
210 seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n",
211 temp & 0xff, temp >> 16);
214 #endif /* CONFIG_TAU */
217 * Assume here that all clock rates are the same in a
218 * smp system. -- Cort
221 seq_printf(m, "clock\t\t: %lu.%06luMHz\n",
222 ppc_proc_freq / 1000000, ppc_proc_freq % 1000000);
224 if (ppc_md.show_percpuinfo != NULL)
225 ppc_md.show_percpuinfo(m, cpu_id);
227 /* If we are a Freescale core do a simple check so
228 * we dont have to keep adding cases in the future */
229 if (PVR_VER(pvr) & 0x8000) {
233 switch (PVR_VER(pvr)) {
234 case 0x0020: /* 403 family */
235 maj = PVR_MAJ(pvr) + 1;
238 case 0x1008: /* 740P/750P ?? */
239 maj = ((pvr >> 8) & 0xFF) - 1;
243 maj = (pvr >> 8) & 0xFF;
249 seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n",
250 maj, min, PVR_VER(pvr), PVR_REV(pvr));
253 seq_printf(m, "bogomips\t: %lu.%02lu\n",
254 loops_per_jiffy / (500000/HZ),
255 (loops_per_jiffy / (5000/HZ)) % 100);
266 static void *c_start(struct seq_file *m, loff_t *pos)
268 unsigned long i = *pos;
270 return i <= NR_CPUS ? (void *)(i + 1) : NULL;
273 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
276 return c_start(m, pos);
279 static void c_stop(struct seq_file *m, void *v)
283 struct seq_operations cpuinfo_op = {
287 .show = show_cpuinfo,
290 #ifdef CONFIG_PPC_MULTIPLATFORM
291 static int __init set_preferred_console(void)
293 struct device_node *prom_stdout = NULL;
298 DBG(" -> set_preferred_console()\n");
300 /* The user has requested a console so this is already set up. */
301 if (strstr(saved_command_line, "console=")) {
302 DBG(" console was specified !\n");
307 DBG(" of_chosen is NULL !\n");
310 /* We are getting a weird phandle from OF ... */
311 /* ... So use the full path instead */
312 name = (char *)get_property(of_chosen, "linux,stdout-path", NULL);
314 DBG(" no linux,stdout-path !\n");
317 prom_stdout = of_find_node_by_path(name);
319 DBG(" can't find stdout package %s !\n", name);
322 DBG("stdout is %s\n", prom_stdout->full_name);
324 name = (char *)get_property(prom_stdout, "name", NULL);
326 DBG(" stdout package has no name !\n");
329 spd = (u32 *)get_property(prom_stdout, "current-speed", NULL);
333 #ifdef CONFIG_SERIAL_8250_CONSOLE
334 else if (strcmp(name, "serial") == 0) {
336 u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
352 /* We dont recognise the serial port */
357 #endif /* CONFIG_SERIAL_8250_CONSOLE */
358 #ifdef CONFIG_PPC_PSERIES
359 else if (strcmp(name, "vty") == 0) {
360 u32 *reg = (u32 *)get_property(prom_stdout, "reg", NULL);
361 char *compat = (char *)get_property(prom_stdout, "compatible", NULL);
363 if (reg && compat && (strcmp(compat, "hvterm-protocol") == 0)) {
364 /* Host Virtual Serial Interface */
376 of_node_put(prom_stdout);
377 DBG("Found hvsi console at offset %d\n", offset);
378 return add_preferred_console("hvsi", offset, NULL);
380 /* pSeries LPAR virtual console */
381 of_node_put(prom_stdout);
382 DBG("Found hvc console\n");
383 return add_preferred_console("hvc", 0, NULL);
386 #endif /* CONFIG_PPC_PSERIES */
387 #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
388 else if (strcmp(name, "ch-a") == 0)
390 else if (strcmp(name, "ch-b") == 0)
392 #endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
395 of_node_put(prom_stdout);
397 DBG("Found serial console at ttyS%d\n", offset);
400 static char __initdata opt[16];
401 sprintf(opt, "%d", *spd);
402 return add_preferred_console("ttyS", offset, opt);
404 return add_preferred_console("ttyS", offset, NULL);
407 DBG("No preferred console found !\n");
408 of_node_put(prom_stdout);
411 console_initcall(set_preferred_console);
412 #endif /* CONFIG_PPC_MULTIPLATFORM */