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>
39 #include <asm/machdep.h>
41 #include <asm/cputable.h>
42 #include <asm/sections.h>
43 #include <asm/btext.h>
44 #include <asm/nvram.h>
45 #include <asm/setup.h>
46 #include <asm/system.h>
48 #include <asm/iommu.h>
49 #include <asm/serial.h>
50 #include <asm/cache.h>
58 #define DBG(fmt...) udbg_printf(fmt)
64 * This still seems to be needed... -- paulus
66 struct screen_info screen_info
= {
69 .orig_video_cols
= 80,
70 .orig_video_lines
= 25,
71 .orig_video_isVGA
= 1,
72 .orig_video_points
= 16
76 /* XXX should go elsewhere eventually */
77 int ppc_do_canonicalize_irqs
;
78 EXPORT_SYMBOL(ppc_do_canonicalize_irqs
);
81 /* also used by kexec */
82 void machine_shutdown(void)
84 if (ppc_md
.nvram_sync
)
88 void machine_restart(char *cmd
)
95 printk(KERN_EMERG
"System Halted, OK to turn off power\n");
100 void machine_power_off(void)
107 printk(KERN_EMERG
"System Halted, OK to turn off power\n");
111 /* Used by the G5 thermal driver */
112 EXPORT_SYMBOL_GPL(machine_power_off
);
114 void (*pm_power_off
)(void) = machine_power_off
;
115 EXPORT_SYMBOL_GPL(pm_power_off
);
117 void machine_halt(void)
124 printk(KERN_EMERG
"System Halted, OK to turn off power\n");
131 extern u32
cpu_temp(unsigned long cpu
);
132 extern u32
cpu_temp_both(unsigned long cpu
);
133 #endif /* CONFIG_TAU */
136 DEFINE_PER_CPU(unsigned int, pvr
);
139 static int show_cpuinfo(struct seq_file
*m
, void *v
)
141 unsigned long cpu_id
= (unsigned long)v
- 1;
146 if (cpu_id
== NR_CPUS
) {
147 #if defined(CONFIG_SMP) && defined(CONFIG_PPC32)
148 unsigned long bogosum
= 0;
150 for (i
= 0; i
< NR_CPUS
; ++i
)
152 bogosum
+= loops_per_jiffy
;
153 seq_printf(m
, "total bogomips\t: %lu.%02lu\n",
154 bogosum
/(500000/HZ
), bogosum
/(5000/HZ
) % 100);
155 #endif /* CONFIG_SMP && CONFIG_PPC32 */
156 seq_printf(m
, "timebase\t: %lu\n", ppc_tb_freq
);
158 if (ppc_md
.show_cpuinfo
!= NULL
)
159 ppc_md
.show_cpuinfo(m
);
164 /* We only show online cpus: disable preempt (overzealous, I
165 * knew) to prevent cpu going down. */
167 if (!cpu_online(cpu_id
)) {
173 #ifdef CONFIG_PPC64 /* XXX for now */
174 pvr
= per_cpu(pvr
, cpu_id
);
176 pvr
= cpu_data
[cpu_id
].pvr
;
179 pvr
= mfspr(SPRN_PVR
);
181 maj
= (pvr
>> 8) & 0xFF;
184 seq_printf(m
, "processor\t: %lu\n", cpu_id
);
185 seq_printf(m
, "cpu\t\t: ");
187 if (cur_cpu_spec
->pvr_mask
)
188 seq_printf(m
, "%s", cur_cpu_spec
->cpu_name
);
190 seq_printf(m
, "unknown (%08x)", pvr
);
192 #ifdef CONFIG_ALTIVEC
193 if (cpu_has_feature(CPU_FTR_ALTIVEC
))
194 seq_printf(m
, ", altivec supported");
195 #endif /* CONFIG_ALTIVEC */
200 if (cur_cpu_spec
->cpu_features
& CPU_FTR_TAU
) {
201 #ifdef CONFIG_TAU_AVERAGE
202 /* more straightforward, but potentially misleading */
203 seq_printf(m
, "temperature \t: %u C (uncalibrated)\n",
206 /* show the actual temp sensor range */
208 temp
= cpu_temp_both(i
);
209 seq_printf(m
, "temperature \t: %u-%u C (uncalibrated)\n",
210 temp
& 0xff, temp
>> 16);
213 #endif /* CONFIG_TAU */
216 * Assume here that all clock rates are the same in a
217 * smp system. -- Cort
220 seq_printf(m
, "clock\t\t: %lu.%06luMHz\n",
221 ppc_proc_freq
/ 1000000, ppc_proc_freq
% 1000000);
223 if (ppc_md
.show_percpuinfo
!= NULL
)
224 ppc_md
.show_percpuinfo(m
, cpu_id
);
226 /* If we are a Freescale core do a simple check so
227 * we dont have to keep adding cases in the future */
228 if (PVR_VER(pvr
) & 0x8000) {
232 switch (PVR_VER(pvr
)) {
233 case 0x0020: /* 403 family */
234 maj
= PVR_MAJ(pvr
) + 1;
237 case 0x1008: /* 740P/750P ?? */
238 maj
= ((pvr
>> 8) & 0xFF) - 1;
242 maj
= (pvr
>> 8) & 0xFF;
248 seq_printf(m
, "revision\t: %hd.%hd (pvr %04x %04x)\n",
249 maj
, min
, PVR_VER(pvr
), PVR_REV(pvr
));
252 seq_printf(m
, "bogomips\t: %lu.%02lu\n",
253 loops_per_jiffy
/ (500000/HZ
),
254 (loops_per_jiffy
/ (5000/HZ
)) % 100);
265 static void *c_start(struct seq_file
*m
, loff_t
*pos
)
267 unsigned long i
= *pos
;
269 return i
<= NR_CPUS
? (void *)(i
+ 1) : NULL
;
272 static void *c_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
275 return c_start(m
, pos
);
278 static void c_stop(struct seq_file
*m
, void *v
)
282 struct seq_operations cpuinfo_op
= {
286 .show
= show_cpuinfo
,
289 #ifdef CONFIG_PPC_MULTIPLATFORM
290 static int __init
set_preferred_console(void)
292 struct device_node
*prom_stdout
= NULL
;
297 DBG(" -> set_preferred_console()\n");
299 /* The user has requested a console so this is already set up. */
300 if (strstr(saved_command_line
, "console=")) {
301 DBG(" console was specified !\n");
306 DBG(" of_chosen is NULL !\n");
309 /* We are getting a weird phandle from OF ... */
310 /* ... So use the full path instead */
311 name
= (char *)get_property(of_chosen
, "linux,stdout-path", NULL
);
313 DBG(" no linux,stdout-path !\n");
316 prom_stdout
= of_find_node_by_path(name
);
318 DBG(" can't find stdout package %s !\n", name
);
321 DBG("stdout is %s\n", prom_stdout
->full_name
);
323 name
= (char *)get_property(prom_stdout
, "name", NULL
);
325 DBG(" stdout package has no name !\n");
328 spd
= (u32
*)get_property(prom_stdout
, "current-speed", NULL
);
332 #ifdef CONFIG_SERIAL_8250_CONSOLE
333 else if (strcmp(name
, "serial") == 0) {
335 u32
*reg
= (u32
*)get_property(prom_stdout
, "reg", &i
);
351 /* We dont recognise the serial port */
356 #endif /* CONFIG_SERIAL_8250_CONSOLE */
357 #ifdef CONFIG_PPC_PSERIES
358 else if (strcmp(name
, "vty") == 0) {
359 u32
*reg
= (u32
*)get_property(prom_stdout
, "reg", NULL
);
360 char *compat
= (char *)get_property(prom_stdout
, "compatible", NULL
);
362 if (reg
&& compat
&& (strcmp(compat
, "hvterm-protocol") == 0)) {
363 /* Host Virtual Serial Interface */
374 of_node_put(prom_stdout
);
375 DBG("Found hvsi console at offset %d\n", offset
);
376 return add_preferred_console("hvsi", offset
, NULL
);
378 /* pSeries LPAR virtual console */
379 of_node_put(prom_stdout
);
380 DBG("Found hvc console\n");
381 return add_preferred_console("hvc", 0, NULL
);
384 #endif /* CONFIG_PPC_PSERIES */
385 #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
386 else if (strcmp(name
, "ch-a") == 0)
388 else if (strcmp(name
, "ch-b") == 0)
390 #endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
393 of_node_put(prom_stdout
);
395 DBG("Found serial console at ttyS%d\n", offset
);
398 static char __initdata opt
[16];
399 sprintf(opt
, "%d", *spd
);
400 return add_preferred_console("ttyS", offset
, opt
);
402 return add_preferred_console("ttyS", offset
, NULL
);
405 DBG("No preferred console found !\n");
406 of_node_put(prom_stdout
);
409 console_initcall(set_preferred_console
);
410 #endif /* CONFIG_PPC_MULTIPLATFORM */