]> Git Repo - linux.git/blame - arch/powerpc/kernel/setup_32.c
[PATCH] powerpc: serial port discovery (#2)
[linux.git] / arch / powerpc / kernel / setup_32.c
CommitLineData
9b6b563c
PM
1/*
2 * Common prep/pmac/chrp boot and setup code.
3 */
4
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>
21
22#include <asm/residual.h>
23#include <asm/io.h>
24#include <asm/prom.h>
25#include <asm/processor.h>
26#include <asm/pgtable.h>
9b6b563c
PM
27#include <asm/setup.h>
28#include <asm/amigappc.h>
29#include <asm/smp.h>
30#include <asm/elf.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>
40#include <asm/xmon.h>
6d7f58b0 41#include <asm/time.h>
463ce0e1 42#include <asm/serial.h>
9b6b563c 43
66ba135c
SR
44#include "setup.h"
45
03501dab
PM
46#define DBG(fmt...)
47
9b6b563c
PM
48#if defined CONFIG_KGDB
49#include <asm/kgdb.h>
50#endif
51
52extern void platform_init(void);
53extern void bootx_init(unsigned long r4, unsigned long phys);
54
55extern void ppc6xx_idle(void);
56extern void power4_idle(void);
57
58boot_infos_t *boot_infos;
59struct ide_machdep_calls ppc_ide_md;
60
80579e1f
PM
61int boot_cpuid;
62EXPORT_SYMBOL_GPL(boot_cpuid);
63int boot_cpuid_phys;
64
9b6b563c
PM
65unsigned long ISA_DMA_THRESHOLD;
66unsigned int DMA_MODE_READ;
67unsigned int DMA_MODE_WRITE;
68
e574d238
PM
69int have_of = 1;
70
9b6b563c 71#ifdef CONFIG_PPC_MULTIPLATFORM
9b6b563c
PM
72extern void prep_init(void);
73extern void pmac_init(void);
74extern void chrp_init(void);
75
76dev_t boot_dev;
77#endif /* CONFIG_PPC_MULTIPLATFORM */
78
79#ifdef CONFIG_MAGIC_SYSRQ
80unsigned long SYSRQ_KEY = 0x54;
81#endif /* CONFIG_MAGIC_SYSRQ */
82
83#ifdef CONFIG_VGA_CONSOLE
84unsigned long vgacon_remap_base;
85#endif
86
87struct machdep_calls ppc_md;
e574d238 88EXPORT_SYMBOL(ppc_md);
9b6b563c
PM
89
90/*
91 * These are used in binfmt_elf.c to put aux entries on the stack
92 * for each elf executable being started.
93 */
94int dcache_bsize;
95int icache_bsize;
96int ucache_bsize;
97
9b6b563c
PM
98/*
99 * We're called here very early in the boot. We determine the machine
100 * type and call the appropriate low-level setup functions.
101 * -- Cort <[email protected]>
102 *
103 * Note that the kernel may be running at an address which is different
104 * from the address that it was linked at, so we must use RELOC/PTRRELOC
105 * to access static data (including strings). -- paulus
106 */
107unsigned long __init early_init(unsigned long dt_ptr)
108{
109 unsigned long offset = reloc_offset();
110
dd184343
PM
111 /* First zero the BSS -- use memset_io, some platforms don't have
112 * caches on yet */
113 memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start);
114
9b6b563c
PM
115 /*
116 * Identify the CPU type and fix up code sections
117 * that depend on which cpu we have.
118 */
119 identify_cpu(offset, 0);
120 do_cpu_ftr_fixups(offset);
121
9b6b563c
PM
122 return KERNELBASE + offset;
123}
124
9b6b563c
PM
125#ifdef CONFIG_PPC_MULTIPLATFORM
126/*
127 * The PPC_MULTIPLATFORM version of platform_init...
128 */
129void __init platform_init(void)
130{
131 /* if we didn't get any bootinfo telling us what we are... */
132 if (_machine == 0) {
133 /* prep boot loader tells us if we're prep or not */
134 if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) )
135 _machine = _MACH_prep;
136 }
137
138#ifdef CONFIG_PPC_PREP
139 /* not much more to do here, if prep */
140 if (_machine == _MACH_prep) {
141 prep_init();
142 return;
143 }
144#endif
145
146#ifdef CONFIG_ADB
147 if (strstr(cmd_line, "adb_sync")) {
148 extern int __adb_probe_sync;
149 __adb_probe_sync = 1;
150 }
151#endif /* CONFIG_ADB */
152
153 switch (_machine) {
154#ifdef CONFIG_PPC_PMAC
155 case _MACH_Pmac:
156 pmac_init();
157 break;
158#endif
159#ifdef CONFIG_PPC_CHRP
160 case _MACH_chrp:
161 chrp_init();
162 break;
163#endif
164 }
165}
03501dab 166#endif
9b6b563c 167
9b6b563c
PM
168/*
169 * Find out what kind of machine we're on and save any data we need
170 * from the early boot process (devtree is copied on pmac by prom_init()).
171 * This is called very early on the boot process, after a minimal
172 * MMU environment has been set up but before MMU_init is called.
173 */
174void __init machine_init(unsigned long dt_ptr, unsigned long phys)
175{
176 early_init_devtree(__va(dt_ptr));
177
178#ifdef CONFIG_CMDLINE
179 strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
180#endif /* CONFIG_CMDLINE */
181
35499c01
PM
182 platform_init();
183
9b6b563c
PM
184#ifdef CONFIG_6xx
185 ppc_md.power_save = ppc6xx_idle;
186#endif
9b6b563c
PM
187
188 if (ppc_md.progress)
189 ppc_md.progress("id mach(): done", 0x200);
190}
191
192#ifdef CONFIG_BOOKE_WDT
193/* Checks wdt=x and wdt_period=xx command-line option */
194int __init early_parse_wdt(char *p)
195{
196 if (p && strncmp(p, "0", 1) != 0)
197 booke_wdt_enabled = 1;
198
199 return 0;
200}
201early_param("wdt", early_parse_wdt);
202
203int __init early_parse_wdt_period (char *p)
204{
205 if (p)
206 booke_wdt_period = simple_strtoul(p, NULL, 0);
207
208 return 0;
209}
210early_param("wdt_period", early_parse_wdt_period);
211#endif /* CONFIG_BOOKE_WDT */
212
213/* Checks "l2cr=xxxx" command-line option */
214int __init ppc_setup_l2cr(char *str)
215{
216 if (cpu_has_feature(CPU_FTR_L2CR)) {
217 unsigned long val = simple_strtoul(str, NULL, 0);
218 printk(KERN_INFO "l2cr set to %lx\n", val);
219 _set_L2CR(0); /* force invalidate by disable cache */
220 _set_L2CR(val); /* and enable it */
221 }
222 return 1;
223}
224__setup("l2cr=", ppc_setup_l2cr);
225
226#ifdef CONFIG_GENERIC_NVRAM
227
228/* Generic nvram hooks used by drivers/char/gen_nvram.c */
229unsigned char nvram_read_byte(int addr)
230{
231 if (ppc_md.nvram_read_val)
232 return ppc_md.nvram_read_val(addr);
233 return 0xff;
234}
235EXPORT_SYMBOL(nvram_read_byte);
236
237void nvram_write_byte(unsigned char val, int addr)
238{
239 if (ppc_md.nvram_write_val)
240 ppc_md.nvram_write_val(addr, val);
241}
242EXPORT_SYMBOL(nvram_write_byte);
243
244void nvram_sync(void)
245{
246 if (ppc_md.nvram_sync)
247 ppc_md.nvram_sync();
248}
249EXPORT_SYMBOL(nvram_sync);
250
251#endif /* CONFIG_NVRAM */
252
253static struct cpu cpu_devices[NR_CPUS];
254
255int __init ppc_init(void)
256{
257 int i;
258
259 /* clear the progress line */
260 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
261
262 /* register CPU devices */
263 for (i = 0; i < NR_CPUS; i++)
264 if (cpu_possible(i))
265 register_cpu(&cpu_devices[i], i, NULL);
266
267 /* call platform init */
268 if (ppc_md.init != NULL) {
269 ppc_md.init();
270 }
271 return 0;
272}
273
274arch_initcall(ppc_init);
275
276/* Warning, IO base is not yet inited */
277void __init setup_arch(char **cmdline_p)
278{
9b6b563c
PM
279 extern void do_init_bootmem(void);
280
281 /* so udelay does something sensible, assume <= 1000 bogomips */
282 loops_per_jiffy = 500000000 / HZ;
283
9b6b563c 284 unflatten_device_tree();
a82765b6 285 check_for_initrd();
463ce0e1
BH
286
287 if (ppc_md.init_early)
288 ppc_md.init_early();
289
290#ifdef CONFIG_PPC_MULTIPLATFORM
291 find_legacy_serial_ports();
292#endif
9b6b563c
PM
293 finish_device_tree();
294
5ad57078
PM
295 smp_setup_cpu_maps();
296
30cd4a4e
PM
297#ifdef CONFIG_BOOTX_TEXT
298 init_boot_display();
299#endif
300
03501dab 301#ifdef CONFIG_PPC_PMAC
9b6b563c
PM
302 /* This could be called "early setup arch", it must be done
303 * now because xmon need it
304 */
305 if (_machine == _MACH_Pmac)
306 pmac_feature_init(); /* New cool way */
307#endif
308
fca5dcd4
PM
309#ifdef CONFIG_XMON_DEFAULT
310 xmon_init(1);
311#endif
9b6b563c
PM
312
313#if defined(CONFIG_KGDB)
314 if (ppc_md.kgdb_map_scc)
315 ppc_md.kgdb_map_scc();
316 set_debug_traps();
317 if (strstr(cmd_line, "gdb")) {
318 if (ppc_md.progress)
319 ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
320 printk("kgdb breakpoint activated\n");
321 breakpoint();
322 }
323#endif
324
325 /*
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.
329 */
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;
333 ucache_bsize = 0;
334 } else
335 ucache_bsize = dcache_bsize = icache_bsize
336 = cur_cpu_spec->dcache_bsize;
337
338 /* reboot on panic */
339 panic_timeout = 180;
340
341 init_mm.start_code = PAGE_OFFSET;
342 init_mm.end_code = (unsigned long) _etext;
343 init_mm.end_data = (unsigned long) _edata;
49b09853 344 init_mm.brk = klimit;
9b6b563c
PM
345
346 /* Save unparsed command line copy for /proc/cmdline */
347 strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
348 *cmdline_p = cmd_line;
349
350 parse_early_param();
351
352 /* set up the bootmem stuff with available memory */
353 do_init_bootmem();
354 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
355
356#ifdef CONFIG_PPC_OCP
357 /* Initialize OCP device list */
358 ocp_early_init();
359 if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab);
360#endif
361
362#ifdef CONFIG_DUMMY_CONSOLE
363 conswitchp = &dummy_con;
364#endif
365
366 ppc_md.setup_arch();
367 if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
368
369 paging_init();
370
371 /* this is for modules since _machine can be a define -- Cort */
372 ppc_md.ppc_machine = _machine;
373}
This page took 0.138197 seconds and 4 git commands to generate.