2 * Common prep/pmac/chrp boot and setup code.
5 #include <linux/config.h>
6 #include <linux/module.h>
7 #include <linux/string.h>
8 #include <linux/sched.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/reboot.h>
12 #include <linux/delay.h>
13 #include <linux/initrd.h>
14 #include <linux/ide.h>
15 #include <linux/tty.h>
16 #include <linux/bootmem.h>
17 #include <linux/seq_file.h>
18 #include <linux/root_dev.h>
19 #include <linux/cpu.h>
20 #include <linux/console.h>
22 #include <asm/residual.h>
25 #include <asm/processor.h>
26 #include <asm/pgtable.h>
27 #include <asm/setup.h>
28 #include <asm/amigappc.h>
31 #include <asm/cputable.h>
32 #include <asm/bootx.h>
33 #include <asm/btext.h>
34 #include <asm/machdep.h>
35 #include <asm/uaccess.h>
36 #include <asm/system.h>
37 #include <asm/pmac_feature.h>
38 #include <asm/sections.h>
39 #include <asm/nvram.h>
42 #include <asm/serial.h>
49 #if defined CONFIG_KGDB
53 extern void platform_init(void);
54 extern void bootx_init(unsigned long r4, unsigned long phys);
56 extern void ppc6xx_idle(void);
57 extern void power4_idle(void);
59 boot_infos_t *boot_infos;
60 struct ide_machdep_calls ppc_ide_md;
63 EXPORT_SYMBOL_GPL(boot_cpuid);
66 unsigned long ISA_DMA_THRESHOLD;
67 unsigned int DMA_MODE_READ;
68 unsigned int DMA_MODE_WRITE;
72 #ifdef CONFIG_PPC_MULTIPLATFORM
73 extern void prep_init(void);
74 extern void pmac_init(void);
75 extern void chrp_init(void);
78 #endif /* CONFIG_PPC_MULTIPLATFORM */
80 #ifdef CONFIG_MAGIC_SYSRQ
81 unsigned long SYSRQ_KEY = 0x54;
82 #endif /* CONFIG_MAGIC_SYSRQ */
84 #ifdef CONFIG_VGA_CONSOLE
85 unsigned long vgacon_remap_base;
88 struct machdep_calls ppc_md;
89 EXPORT_SYMBOL(ppc_md);
92 * These are used in binfmt_elf.c to put aux entries on the stack
93 * for each elf executable being started.
100 * We're called here very early in the boot. We determine the machine
101 * type and call the appropriate low-level setup functions.
102 * -- Cort <cort@fsmlabs.com>
104 * Note that the kernel may be running at an address which is different
105 * from the address that it was linked at, so we must use RELOC/PTRRELOC
106 * to access static data (including strings). -- paulus
108 unsigned long __init early_init(unsigned long dt_ptr)
110 unsigned long offset = reloc_offset();
112 /* First zero the BSS -- use memset_io, some platforms don't have
114 memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start);
117 * Identify the CPU type and fix up code sections
118 * that depend on which cpu we have.
120 identify_cpu(offset, 0);
121 do_cpu_ftr_fixups(offset);
123 return KERNELBASE + offset;
126 #ifdef CONFIG_PPC_MULTIPLATFORM
128 * The PPC_MULTIPLATFORM version of platform_init...
130 void __init platform_init(void)
132 /* if we didn't get any bootinfo telling us what we are... */
134 /* prep boot loader tells us if we're prep or not */
135 if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) )
136 _machine = _MACH_prep;
139 #ifdef CONFIG_PPC_PREP
140 /* not much more to do here, if prep */
141 if (_machine == _MACH_prep) {
148 if (strstr(cmd_line, "adb_sync")) {
149 extern int __adb_probe_sync;
150 __adb_probe_sync = 1;
152 #endif /* CONFIG_ADB */
155 #ifdef CONFIG_PPC_PMAC
160 #ifdef CONFIG_PPC_CHRP
170 * Find out what kind of machine we're on and save any data we need
171 * from the early boot process (devtree is copied on pmac by prom_init()).
172 * This is called very early on the boot process, after a minimal
173 * MMU environment has been set up but before MMU_init is called.
175 void __init machine_init(unsigned long dt_ptr, unsigned long phys)
177 /* If btext is enabled, we might have a BAT setup for early display,
178 * thus we do enable some very basic udbg output
180 #ifdef CONFIG_BOOTX_TEXT
181 udbg_putc = btext_drawchar;
184 /* Do some early initialization based on the flat device tree */
185 early_init_devtree(__va(dt_ptr));
187 /* Check default command line */
188 #ifdef CONFIG_CMDLINE
189 if (cmd_line[0] == 0)
190 strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
191 #endif /* CONFIG_CMDLINE */
193 /* Base init based on machine type */
197 ppc_md.power_save = ppc6xx_idle;
201 ppc_md.progress("id mach(): done", 0x200);
204 #ifdef CONFIG_BOOKE_WDT
205 /* Checks wdt=x and wdt_period=xx command-line option */
206 int __init early_parse_wdt(char *p)
208 if (p && strncmp(p, "0", 1) != 0)
209 booke_wdt_enabled = 1;
213 early_param("wdt", early_parse_wdt);
215 int __init early_parse_wdt_period (char *p)
218 booke_wdt_period = simple_strtoul(p, NULL, 0);
222 early_param("wdt_period", early_parse_wdt_period);
223 #endif /* CONFIG_BOOKE_WDT */
225 /* Checks "l2cr=xxxx" command-line option */
226 int __init ppc_setup_l2cr(char *str)
228 if (cpu_has_feature(CPU_FTR_L2CR)) {
229 unsigned long val = simple_strtoul(str, NULL, 0);
230 printk(KERN_INFO "l2cr set to %lx\n", val);
231 _set_L2CR(0); /* force invalidate by disable cache */
232 _set_L2CR(val); /* and enable it */
236 __setup("l2cr=", ppc_setup_l2cr);
238 #ifdef CONFIG_GENERIC_NVRAM
240 /* Generic nvram hooks used by drivers/char/gen_nvram.c */
241 unsigned char nvram_read_byte(int addr)
243 if (ppc_md.nvram_read_val)
244 return ppc_md.nvram_read_val(addr);
247 EXPORT_SYMBOL(nvram_read_byte);
249 void nvram_write_byte(unsigned char val, int addr)
251 if (ppc_md.nvram_write_val)
252 ppc_md.nvram_write_val(addr, val);
254 EXPORT_SYMBOL(nvram_write_byte);
256 void nvram_sync(void)
258 if (ppc_md.nvram_sync)
261 EXPORT_SYMBOL(nvram_sync);
263 #endif /* CONFIG_NVRAM */
265 static struct cpu cpu_devices[NR_CPUS];
267 int __init ppc_init(void)
271 /* clear the progress line */
272 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
274 /* register CPU devices */
275 for (i = 0; i < NR_CPUS; i++)
277 register_cpu(&cpu_devices[i], i, NULL);
279 /* call platform init */
280 if (ppc_md.init != NULL) {
286 arch_initcall(ppc_init);
288 /* Warning, IO base is not yet inited */
289 void __init setup_arch(char **cmdline_p)
291 extern void do_init_bootmem(void);
293 /* so udelay does something sensible, assume <= 1000 bogomips */
294 loops_per_jiffy = 500000000 / HZ;
296 unflatten_device_tree();
299 if (ppc_md.init_early)
302 find_legacy_serial_ports();
303 finish_device_tree();
305 smp_setup_cpu_maps();
307 #ifdef CONFIG_XMON_DEFAULT
310 /* Register early console */
311 register_early_udbg_console();
313 #if defined(CONFIG_KGDB)
314 if (ppc_md.kgdb_map_scc)
315 ppc_md.kgdb_map_scc();
317 if (strstr(cmd_line, "gdb")) {
319 ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
320 printk("kgdb breakpoint activated\n");
326 * Set cache line size based on type of cpu as a default.
327 * Systems with OF can look in the properties on the cpu node(s)
328 * for a possibly more accurate value.
330 if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) {
331 dcache_bsize = cur_cpu_spec->dcache_bsize;
332 icache_bsize = cur_cpu_spec->icache_bsize;
335 ucache_bsize = dcache_bsize = icache_bsize
336 = cur_cpu_spec->dcache_bsize;
338 /* reboot on panic */
341 init_mm.start_code = PAGE_OFFSET;
342 init_mm.end_code = (unsigned long) _etext;
343 init_mm.end_data = (unsigned long) _edata;
344 init_mm.brk = klimit;
346 /* Save unparsed command line copy for /proc/cmdline */
347 strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
348 *cmdline_p = cmd_line;
352 /* set up the bootmem stuff with available memory */
354 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
356 #ifdef CONFIG_PPC_OCP
357 /* Initialize OCP device list */
359 if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab);
362 #ifdef CONFIG_DUMMY_CONSOLE
363 conswitchp = &dummy_con;
367 if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
371 /* this is for modules since _machine can be a define -- Cort */
372 ppc_md.ppc_machine = _machine;