blob: fae6335193efc66a74f82d7d0e62c47eabbf9c77 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
27#include <asm/bootinfo.h>
28#include <asm/setup.h>
29#include <asm/amigappc.h>
30#include <asm/smp.h>
31#include <asm/elf.h>
32#include <asm/cputable.h>
33#include <asm/bootx.h>
34#include <asm/btext.h>
35#include <asm/machdep.h>
36#include <asm/uaccess.h>
37#include <asm/system.h>
38#include <asm/pmac_feature.h>
39#include <asm/sections.h>
40#include <asm/nvram.h>
41#include <asm/xmon.h>
42#include <asm/ocp.h>
43
Kumar Gala8e8fff02005-09-03 15:55:34 -070044#define USES_PPC_SYS (defined(CONFIG_85xx) || defined(CONFIG_83xx) || \
45 defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \
46 defined(CONFIG_PPC_MPC52xx))
47
48#if USES_PPC_SYS
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include <asm/ppc_sys.h>
50#endif
51
52#if defined CONFIG_KGDB
53#include <asm/kgdb.h>
54#endif
55
56extern void platform_init(unsigned long r3, unsigned long r4,
57 unsigned long r5, unsigned long r6, unsigned long r7);
58extern void bootx_init(unsigned long r4, unsigned long phys);
59extern void identify_cpu(unsigned long offset, unsigned long cpu);
60extern void do_cpu_ftr_fixups(unsigned long offset);
61extern void reloc_got2(unsigned long offset);
62
63extern void ppc6xx_idle(void);
64extern void power4_idle(void);
65
66extern boot_infos_t *boot_infos;
67struct ide_machdep_calls ppc_ide_md;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69/* Used with the BI_MEMSIZE bootinfo parameter to store the memory
70 size value reported by the boot loader. */
71unsigned long boot_mem_size;
72
73unsigned long ISA_DMA_THRESHOLD;
Jon Loeligerb8f114d2005-09-21 14:54:51 -050074unsigned int DMA_MODE_READ;
75unsigned int DMA_MODE_WRITE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77#ifdef CONFIG_PPC_MULTIPLATFORM
78int _machine = 0;
79
80extern void prep_init(unsigned long r3, unsigned long r4,
81 unsigned long r5, unsigned long r6, unsigned long r7);
82extern void pmac_init(unsigned long r3, unsigned long r4,
83 unsigned long r5, unsigned long r6, unsigned long r7);
84extern void chrp_init(unsigned long r3, unsigned long r4,
85 unsigned long r5, unsigned long r6, unsigned long r7);
Paul Mackerras14cf11a2005-09-26 16:04:21 +100086
87dev_t boot_dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#endif /* CONFIG_PPC_MULTIPLATFORM */
89
Paul Mackerras35d81a42005-10-11 22:03:09 +100090#ifdef __DO_IRQ_CANON
91int ppc_do_canonicalize_irqs;
92EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
93#endif
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#ifdef CONFIG_MAGIC_SYSRQ
96unsigned long SYSRQ_KEY = 0x54;
97#endif /* CONFIG_MAGIC_SYSRQ */
98
99#ifdef CONFIG_VGA_CONSOLE
100unsigned long vgacon_remap_base;
101#endif
102
103struct machdep_calls ppc_md;
104
105/*
106 * These are used in binfmt_elf.c to put aux entries on the stack
107 * for each elf executable being started.
108 */
109int dcache_bsize;
110int icache_bsize;
111int ucache_bsize;
112
113#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_FB_VGA16) || \
114 defined(CONFIG_FB_VGA16_MODULE) || defined(CONFIG_FB_VESA)
115struct screen_info screen_info = {
116 0, 25, /* orig-x, orig-y */
117 0, /* unused */
118 0, /* orig-video-page */
119 0, /* orig-video-mode */
120 80, /* orig-video-cols */
121 0,0,0, /* ega_ax, ega_bx, ega_cx */
122 25, /* orig-video-lines */
123 1, /* orig-video-isVGA */
124 16 /* orig-video-points */
125};
126#endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */
127
128void machine_restart(char *cmd)
129{
130#ifdef CONFIG_NVRAM
131 nvram_sync();
132#endif
133 ppc_md.restart(cmd);
134}
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136void machine_power_off(void)
137{
138#ifdef CONFIG_NVRAM
139 nvram_sync();
140#endif
141 ppc_md.power_off();
142}
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144void machine_halt(void)
145{
146#ifdef CONFIG_NVRAM
147 nvram_sync();
148#endif
149 ppc_md.halt();
150}
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152void (*pm_power_off)(void) = machine_power_off;
153
154#ifdef CONFIG_TAU
155extern u32 cpu_temp(unsigned long cpu);
156extern u32 cpu_temp_both(unsigned long cpu);
157#endif /* CONFIG_TAU */
158
159int show_cpuinfo(struct seq_file *m, void *v)
160{
161 int i = (int) v - 1;
162 int err = 0;
163 unsigned int pvr;
164 unsigned short maj, min;
165 unsigned long lpj;
166
167 if (i >= NR_CPUS) {
168 /* Show summary information */
169#ifdef CONFIG_SMP
170 unsigned long bogosum = 0;
171 for (i = 0; i < NR_CPUS; ++i)
172 if (cpu_online(i))
173 bogosum += cpu_data[i].loops_per_jiffy;
174 seq_printf(m, "total bogomips\t: %lu.%02lu\n",
175 bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
176#endif /* CONFIG_SMP */
177
178 if (ppc_md.show_cpuinfo != NULL)
179 err = ppc_md.show_cpuinfo(m);
180 return err;
181 }
182
183#ifdef CONFIG_SMP
184 if (!cpu_online(i))
185 return 0;
186 pvr = cpu_data[i].pvr;
187 lpj = cpu_data[i].loops_per_jiffy;
188#else
189 pvr = mfspr(SPRN_PVR);
190 lpj = loops_per_jiffy;
191#endif
192
193 seq_printf(m, "processor\t: %d\n", i);
194 seq_printf(m, "cpu\t\t: ");
195
Kumar Gala400d2212005-09-27 15:13:12 -0500196 if (cur_cpu_spec->pvr_mask)
197 seq_printf(m, "%s", cur_cpu_spec->cpu_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 else
199 seq_printf(m, "unknown (%08x)", pvr);
200#ifdef CONFIG_ALTIVEC
Kumar Gala400d2212005-09-27 15:13:12 -0500201 if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 seq_printf(m, ", altivec supported");
203#endif
204 seq_printf(m, "\n");
205
206#ifdef CONFIG_TAU
Kumar Gala400d2212005-09-27 15:13:12 -0500207 if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208#ifdef CONFIG_TAU_AVERAGE
209 /* more straightforward, but potentially misleading */
210 seq_printf(m, "temperature \t: %u C (uncalibrated)\n",
211 cpu_temp(i));
212#else
213 /* show the actual temp sensor range */
214 u32 temp;
215 temp = cpu_temp_both(i);
216 seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n",
217 temp & 0xff, temp >> 16);
218#endif
219 }
220#endif /* CONFIG_TAU */
221
222 if (ppc_md.show_percpuinfo != NULL) {
223 err = ppc_md.show_percpuinfo(m, i);
224 if (err)
225 return err;
226 }
227
Kumar Gala696c2b92005-05-05 16:15:10 -0700228 /* If we are a Freescale core do a simple check so
229 * we dont have to keep adding cases in the future */
230 if ((PVR_VER(pvr) & 0x8000) == 0x8000) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 maj = PVR_MAJ(pvr);
232 min = PVR_MIN(pvr);
Kumar Gala696c2b92005-05-05 16:15:10 -0700233 } else {
234 switch (PVR_VER(pvr)) {
235 case 0x0020: /* 403 family */
236 maj = PVR_MAJ(pvr) + 1;
237 min = PVR_MIN(pvr);
238 break;
239 case 0x1008: /* 740P/750P ?? */
240 maj = ((pvr >> 8) & 0xFF) - 1;
241 min = pvr & 0xFF;
242 break;
243 default:
244 maj = (pvr >> 8) & 0xFF;
245 min = pvr & 0xFF;
246 break;
247 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 }
249
250 seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n",
251 maj, min, PVR_VER(pvr), PVR_REV(pvr));
252
253 seq_printf(m, "bogomips\t: %lu.%02lu\n",
254 lpj / (500000/HZ), (lpj / (5000/HZ)) % 100);
255
Kumar Gala8e8fff02005-09-03 15:55:34 -0700256#if USES_PPC_SYS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 if (cur_ppc_sys_spec->ppc_sys_name)
258 seq_printf(m, "chipset\t\t: %s\n",
259 cur_ppc_sys_spec->ppc_sys_name);
260#endif
261
262#ifdef CONFIG_SMP
263 seq_printf(m, "\n");
264#endif
265
266 return 0;
267}
268
269static void *c_start(struct seq_file *m, loff_t *pos)
270{
271 int i = *pos;
272
273 return i <= NR_CPUS? (void *) (i + 1): NULL;
274}
275
276static void *c_next(struct seq_file *m, void *v, loff_t *pos)
277{
278 ++*pos;
279 return c_start(m, pos);
280}
281
282static void c_stop(struct seq_file *m, void *v)
283{
284}
285
286struct seq_operations cpuinfo_op = {
287 .start =c_start,
288 .next = c_next,
289 .stop = c_stop,
290 .show = show_cpuinfo,
291};
292
293/*
294 * We're called here very early in the boot. We determine the machine
295 * type and call the appropriate low-level setup functions.
296 * -- Cort <cort@fsmlabs.com>
297 *
298 * Note that the kernel may be running at an address which is different
299 * from the address that it was linked at, so we must use RELOC/PTRRELOC
300 * to access static data (including strings). -- paulus
301 */
302__init
303unsigned long
304early_init(int r3, int r4, int r5)
305{
306 unsigned long phys;
307 unsigned long offset = reloc_offset();
308
309 /* Default */
310 phys = offset + KERNELBASE;
311
312 /* First zero the BSS -- use memset, some arches don't have
313 * caches on yet */
314 memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start);
315
316 /*
317 * Identify the CPU type and fix up code sections
318 * that depend on which cpu we have.
319 */
320 identify_cpu(offset, 0);
321 do_cpu_ftr_fixups(offset);
322
323#if defined(CONFIG_PPC_MULTIPLATFORM)
324 reloc_got2(offset);
325
326 /* If we came here from BootX, clear the screen,
327 * set up some pointers and return. */
328 if ((r3 == 0x426f6f58) && (r5 == 0))
329 bootx_init(r4, phys);
330
331 /*
332 * don't do anything on prep
333 * for now, don't use bootinfo because it breaks yaboot 0.5
334 * and assume that if we didn't find a magic number, we have OF
335 */
336 else if (*(unsigned long *)(0) != 0xdeadc0de)
337 phys = prom_init(r3, r4, (prom_entry)r5);
338
339 reloc_got2(-offset);
340#endif
341
342 return phys;
343}
344
345#ifdef CONFIG_PPC_OF
346/*
347 * Assume here that all clock rates are the same in a
348 * smp system. -- Cort
349 */
Jon Loeligerf495a8b2005-09-17 10:35:08 -0500350int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351of_show_percpuinfo(struct seq_file *m, int i)
352{
353 struct device_node *cpu_node;
354 u32 *fp;
355 int s;
356
357 cpu_node = find_type_devices("cpu");
358 if (!cpu_node)
359 return 0;
360 for (s = 0; s < i && cpu_node->next; s++)
361 cpu_node = cpu_node->next;
362 fp = (u32 *)get_property(cpu_node, "clock-frequency", NULL);
363 if (fp)
364 seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000);
365 return 0;
366}
367
368void __init
369intuit_machine_type(void)
370{
371 char *model;
372 struct device_node *root;
373
374 /* ask the OF info if we're a chrp or pmac */
375 root = find_path_device("/");
376 if (root != 0) {
377 /* assume pmac unless proven to be chrp -- Cort */
378 _machine = _MACH_Pmac;
379 model = get_property(root, "device_type", NULL);
380 if (model && !strncmp("chrp", model, 4))
381 _machine = _MACH_chrp;
382 else {
383 model = get_property(root, "model", NULL);
384 if (model && !strncmp(model, "IBM", 3))
385 _machine = _MACH_chrp;
386 }
387 }
388}
389#endif
390
391#ifdef CONFIG_PPC_MULTIPLATFORM
392/*
393 * The PPC_MULTIPLATFORM version of platform_init...
394 */
395void __init
396platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
397 unsigned long r6, unsigned long r7)
398{
399#ifdef CONFIG_BOOTX_TEXT
400 if (boot_text_mapped) {
401 btext_clearscreen();
402 btext_welcome();
403 }
404#endif
405
406 parse_bootinfo(find_bootinfo());
407
408 /* if we didn't get any bootinfo telling us what we are... */
409 if (_machine == 0) {
410 /* prep boot loader tells us if we're prep or not */
411 if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) )
412 _machine = _MACH_prep;
413 }
414
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000415#ifdef CONFIG_PPC_PREP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 /* not much more to do here, if prep */
417 if (_machine == _MACH_prep) {
418 prep_init(r3, r4, r5, r6, r7);
419 return;
420 }
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000421#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422
423 /* prom_init has already been called from __start */
424 if (boot_infos)
425 relocate_nodes();
426
427 /* If we aren't PReP, we can find out if we're Pmac
428 * or CHRP with this. */
429 if (_machine == 0)
430 intuit_machine_type();
431
432 /* finish_device_tree may need _machine defined. */
433 finish_device_tree();
434
435 /*
436 * If we were booted via quik, r3 points to the physical
437 * address of the command-line parameters.
438 * If we were booted from an xcoff image (i.e. netbooted or
439 * booted from floppy), we get the command line from the
440 * bootargs property of the /chosen node.
441 * If an initial ramdisk is present, r3 and r4
442 * are used for initrd_start and initrd_size,
443 * otherwise they contain 0xdeadbeef.
444 */
445 if (r3 >= 0x4000 && r3 < 0x800000 && r4 == 0) {
446 strlcpy(cmd_line, (char *)r3 + KERNELBASE,
447 sizeof(cmd_line));
448 } else if (boot_infos != 0) {
449 /* booted by BootX - check for ramdisk */
450 if (boot_infos->kernelParamsOffset != 0)
451 strlcpy(cmd_line, (char *) boot_infos
452 + boot_infos->kernelParamsOffset,
453 sizeof(cmd_line));
454#ifdef CONFIG_BLK_DEV_INITRD
455 if (boot_infos->ramDisk) {
456 initrd_start = (unsigned long) boot_infos
457 + boot_infos->ramDisk;
458 initrd_end = initrd_start + boot_infos->ramDiskSize;
459 initrd_below_start_ok = 1;
460 }
461#endif
462 } else {
463 struct device_node *chosen;
464 char *p;
465
466#ifdef CONFIG_BLK_DEV_INITRD
467 if (r3 && r4 && r4 != 0xdeadbeef) {
468 if (r3 < KERNELBASE)
469 r3 += KERNELBASE;
470 initrd_start = r3;
471 initrd_end = r3 + r4;
472 ROOT_DEV = Root_RAM0;
473 initrd_below_start_ok = 1;
474 }
475#endif
476 chosen = find_devices("chosen");
477 if (chosen != NULL) {
478 p = get_property(chosen, "bootargs", NULL);
479 if (p && *p) {
480 strlcpy(cmd_line, p, sizeof(cmd_line));
481 }
482 }
483 }
484#ifdef CONFIG_ADB
485 if (strstr(cmd_line, "adb_sync")) {
486 extern int __adb_probe_sync;
487 __adb_probe_sync = 1;
488 }
489#endif /* CONFIG_ADB */
490
491 switch (_machine) {
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000492#ifdef CONFIG_PPC_PMAC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 case _MACH_Pmac:
494 pmac_init(r3, r4, r5, r6, r7);
495 break;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000496#endif
497#ifdef CONFIG_PPC_CHRP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 case _MACH_chrp:
499 chrp_init(r3, r4, r5, r6, r7);
500 break;
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000501#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 }
503}
504
505#ifdef CONFIG_SERIAL_CORE_CONSOLE
506extern char *of_stdout_device;
507
508static int __init set_preferred_console(void)
509{
510 struct device_node *prom_stdout;
511 char *name;
Paul Mackerras45fed462005-05-20 16:45:58 +1000512 int offset = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513
514 if (of_stdout_device == NULL)
515 return -ENODEV;
516
517 /* The user has requested a console so this is already set up. */
518 if (strstr(saved_command_line, "console="))
519 return -EBUSY;
520
521 prom_stdout = find_path_device(of_stdout_device);
522 if (!prom_stdout)
523 return -ENODEV;
524
525 name = (char *)get_property(prom_stdout, "name", NULL);
526 if (!name)
527 return -ENODEV;
528
529 if (strcmp(name, "serial") == 0) {
530 int i;
531 u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
532 if (i > 8) {
533 switch (reg[1]) {
534 case 0x3f8:
535 offset = 0;
536 break;
537 case 0x2f8:
538 offset = 1;
539 break;
540 case 0x898:
541 offset = 2;
542 break;
543 case 0x890:
544 offset = 3;
545 break;
546 default:
547 /* We dont recognise the serial port */
548 return -ENODEV;
549 }
550 }
551 } else if (strcmp(name, "ch-a") == 0)
552 offset = 0;
553 else if (strcmp(name, "ch-b") == 0)
554 offset = 1;
555 else
556 return -ENODEV;
557 return add_preferred_console("ttyS", offset, NULL);
558}
559console_initcall(set_preferred_console);
560#endif /* CONFIG_SERIAL_CORE_CONSOLE */
561#endif /* CONFIG_PPC_MULTIPLATFORM */
562
563struct bi_record *find_bootinfo(void)
564{
565 struct bi_record *rec;
566
567 rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20));
568 if ( rec->tag != BI_FIRST ) {
569 /*
570 * This 0x10000 offset is a terrible hack but it will go away when
571 * we have the bootloader handle all the relocation and
572 * prom calls -- Cort
573 */
574 rec = (struct bi_record *)_ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20));
575 if ( rec->tag != BI_FIRST )
576 return NULL;
577 }
578 return rec;
579}
580
581void parse_bootinfo(struct bi_record *rec)
582{
583 if (rec == NULL || rec->tag != BI_FIRST)
584 return;
585 while (rec->tag != BI_LAST) {
586 ulong *data = rec->data;
587 switch (rec->tag) {
588 case BI_CMD_LINE:
589 strlcpy(cmd_line, (void *)data, sizeof(cmd_line));
590 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591#ifdef CONFIG_BLK_DEV_INITRD
592 case BI_INITRD:
593 initrd_start = data[0] + KERNELBASE;
594 initrd_end = data[0] + data[1] + KERNELBASE;
595 break;
596#endif /* CONFIG_BLK_DEV_INITRD */
597#ifdef CONFIG_PPC_MULTIPLATFORM
598 case BI_MACHTYPE:
599 _machine = data[0];
600 break;
601#endif
602 case BI_MEMSIZE:
603 boot_mem_size = data[0];
604 break;
605 }
606 rec = (struct bi_record *)((ulong)rec + rec->size);
607 }
608}
609
610/*
611 * Find out what kind of machine we're on and save any data we need
612 * from the early boot process (devtree is copied on pmac by prom_init()).
613 * This is called very early on the boot process, after a minimal
614 * MMU environment has been set up but before MMU_init is called.
615 */
616void __init
617machine_init(unsigned long r3, unsigned long r4, unsigned long r5,
618 unsigned long r6, unsigned long r7)
619{
620#ifdef CONFIG_CMDLINE
621 strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
622#endif /* CONFIG_CMDLINE */
623
624#ifdef CONFIG_6xx
625 ppc_md.power_save = ppc6xx_idle;
626#endif
627#ifdef CONFIG_POWER4
628 ppc_md.power_save = power4_idle;
629#endif
630
631 platform_init(r3, r4, r5, r6, r7);
632
633 if (ppc_md.progress)
634 ppc_md.progress("id mach(): done", 0x200);
635}
Kumar Galaa2f40cc2005-09-03 15:55:33 -0700636#ifdef CONFIG_BOOKE_WDT
637/* Checks wdt=x and wdt_period=xx command-line option */
638int __init early_parse_wdt(char *p)
639{
Kumar Galaa2f40cc2005-09-03 15:55:33 -0700640 if (p && strncmp(p, "0", 1) != 0)
Kumar Gala39cdc4b2005-09-03 15:55:39 -0700641 booke_wdt_enabled = 1;
Kumar Galaa2f40cc2005-09-03 15:55:33 -0700642
643 return 0;
644}
645early_param("wdt", early_parse_wdt);
646
647int __init early_parse_wdt_period (char *p)
648{
Kumar Galaa2f40cc2005-09-03 15:55:33 -0700649 if (p)
Kumar Gala39cdc4b2005-09-03 15:55:39 -0700650 booke_wdt_period = simple_strtoul(p, NULL, 0);
Kumar Galaa2f40cc2005-09-03 15:55:33 -0700651
652 return 0;
653}
654early_param("wdt_period", early_parse_wdt_period);
655#endif /* CONFIG_BOOKE_WDT */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656
657/* Checks "l2cr=xxxx" command-line option */
658int __init ppc_setup_l2cr(char *str)
659{
660 if (cpu_has_feature(CPU_FTR_L2CR)) {
661 unsigned long val = simple_strtoul(str, NULL, 0);
662 printk(KERN_INFO "l2cr set to %lx\n", val);
663 _set_L2CR(0); /* force invalidate by disable cache */
664 _set_L2CR(val); /* and enable it */
665 }
666 return 1;
667}
668__setup("l2cr=", ppc_setup_l2cr);
669
670#ifdef CONFIG_GENERIC_NVRAM
671
672/* Generic nvram hooks used by drivers/char/gen_nvram.c */
673unsigned char nvram_read_byte(int addr)
674{
675 if (ppc_md.nvram_read_val)
676 return ppc_md.nvram_read_val(addr);
677 return 0xff;
678}
679EXPORT_SYMBOL(nvram_read_byte);
680
681void nvram_write_byte(unsigned char val, int addr)
682{
683 if (ppc_md.nvram_write_val)
684 ppc_md.nvram_write_val(addr, val);
685}
686EXPORT_SYMBOL(nvram_write_byte);
687
688void nvram_sync(void)
689{
690 if (ppc_md.nvram_sync)
691 ppc_md.nvram_sync();
692}
693EXPORT_SYMBOL(nvram_sync);
694
695#endif /* CONFIG_NVRAM */
696
697static struct cpu cpu_devices[NR_CPUS];
698
699int __init ppc_init(void)
700{
701 int i;
702
703 /* clear the progress line */
704 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
705
706 /* register CPU devices */
707 for (i = 0; i < NR_CPUS; i++)
708 if (cpu_possible(i))
709 register_cpu(&cpu_devices[i], i, NULL);
710
711 /* call platform init */
712 if (ppc_md.init != NULL) {
713 ppc_md.init();
714 }
715 return 0;
716}
717
718arch_initcall(ppc_init);
719
720/* Warning, IO base is not yet inited */
721void __init setup_arch(char **cmdline_p)
722{
723 extern char *klimit;
724 extern void do_init_bootmem(void);
725
726 /* so udelay does something sensible, assume <= 1000 bogomips */
727 loops_per_jiffy = 500000000 / HZ;
728
729#ifdef CONFIG_PPC_MULTIPLATFORM
730 /* This could be called "early setup arch", it must be done
731 * now because xmon need it
732 */
733 if (_machine == _MACH_Pmac)
734 pmac_feature_init(); /* New cool way */
735#endif
736
737#ifdef CONFIG_XMON
738 xmon_map_scc();
739 if (strstr(cmd_line, "xmon"))
740 xmon(NULL);
741#endif /* CONFIG_XMON */
742 if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab);
743
744#if defined(CONFIG_KGDB)
745 if (ppc_md.kgdb_map_scc)
746 ppc_md.kgdb_map_scc();
747 set_debug_traps();
748 if (strstr(cmd_line, "gdb")) {
749 if (ppc_md.progress)
750 ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
751 printk("kgdb breakpoint activated\n");
752 breakpoint();
753 }
754#endif
755
756 /*
757 * Set cache line size based on type of cpu as a default.
758 * Systems with OF can look in the properties on the cpu node(s)
759 * for a possibly more accurate value.
760 */
761 if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) {
Kumar Gala400d2212005-09-27 15:13:12 -0500762 dcache_bsize = cur_cpu_spec->dcache_bsize;
763 icache_bsize = cur_cpu_spec->icache_bsize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 ucache_bsize = 0;
765 } else
766 ucache_bsize = dcache_bsize = icache_bsize
Kumar Gala400d2212005-09-27 15:13:12 -0500767 = cur_cpu_spec->dcache_bsize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768
769 /* reboot on panic */
770 panic_timeout = 180;
771
772 init_mm.start_code = PAGE_OFFSET;
773 init_mm.end_code = (unsigned long) _etext;
774 init_mm.end_data = (unsigned long) _edata;
775 init_mm.brk = (unsigned long) klimit;
776
777 /* Save unparsed command line copy for /proc/cmdline */
778 strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
779 *cmdline_p = cmd_line;
780
Paul Mackerras19bbdf02005-05-17 16:48:39 +1000781 parse_early_param();
782
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 /* set up the bootmem stuff with available memory */
784 do_init_bootmem();
785 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
786
787#ifdef CONFIG_PPC_OCP
788 /* Initialize OCP device list */
789 ocp_early_init();
790 if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab);
791#endif
792
793#ifdef CONFIG_DUMMY_CONSOLE
794 conswitchp = &dummy_con;
795#endif
796
797 ppc_md.setup_arch();
798 if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
799
800 paging_init();
801
802 /* this is for modules since _machine can be a define -- Cort */
803 ppc_md.ppc_machine = _machine;
804}