linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / ppc / kernel / setup.c
1 /*
2  * Common prep/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/sections.h>
39 #include <asm/nvram.h>
40 #include <asm/xmon.h>
41 #include <asm/ocp.h>
42
43 #define USES_PPC_SYS (defined(CONFIG_85xx) || defined(CONFIG_83xx) || \
44                       defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \
45                       defined(CONFIG_PPC_MPC52xx))
46
47 #if USES_PPC_SYS
48 #include <asm/ppc_sys.h>
49 #endif
50
51 #if defined CONFIG_KGDB
52 #include <asm/kgdb.h>
53 #endif
54
55 extern void platform_init(unsigned long r3, unsigned long r4,
56                 unsigned long r5, unsigned long r6, unsigned long r7);
57 extern void identify_cpu(unsigned long offset, unsigned long cpu);
58 extern void do_cpu_ftr_fixups(unsigned long offset);
59 extern void reloc_got2(unsigned long offset);
60
61 extern void ppc6xx_idle(void);
62 extern void power4_idle(void);
63
64 extern boot_infos_t *boot_infos;
65 struct ide_machdep_calls ppc_ide_md;
66
67 /* Used with the BI_MEMSIZE bootinfo parameter to store the memory
68    size value reported by the boot loader. */
69 unsigned long boot_mem_size;
70
71 unsigned long ISA_DMA_THRESHOLD;
72 unsigned int DMA_MODE_READ;
73 unsigned int DMA_MODE_WRITE;
74
75 #ifdef CONFIG_PPC_MULTIPLATFORM
76 int _machine = 0;
77 EXPORT_SYMBOL(_machine);
78
79 extern void prep_init(unsigned long r3, unsigned long r4,
80                 unsigned long r5, unsigned long r6, unsigned long r7);
81 extern void chrp_init(unsigned long r3, unsigned long r4,
82                 unsigned long r5, unsigned long r6, unsigned long r7);
83
84 dev_t boot_dev;
85 #endif /* CONFIG_PPC_MULTIPLATFORM */
86
87 int have_of;
88 EXPORT_SYMBOL(have_of);
89
90 #ifdef __DO_IRQ_CANON
91 int ppc_do_canonicalize_irqs;
92 EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
93 #endif
94
95 #ifdef CONFIG_MAGIC_SYSRQ
96 unsigned long SYSRQ_KEY = 0x54;
97 #endif /* CONFIG_MAGIC_SYSRQ */
98
99 #ifdef CONFIG_VGA_CONSOLE
100 unsigned long vgacon_remap_base;
101 #endif
102
103 struct 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  */
109 int dcache_bsize;
110 int icache_bsize;
111 int ucache_bsize;
112
113 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_FB_VGA16) || \
114     defined(CONFIG_FB_VGA16_MODULE) || defined(CONFIG_FB_VESA)
115 struct 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
128 void machine_restart(char *cmd)
129 {
130 #ifdef CONFIG_NVRAM
131         nvram_sync();
132 #endif
133         ppc_md.restart(cmd);
134 }
135
136 void machine_power_off(void)
137 {
138 #ifdef CONFIG_NVRAM
139         nvram_sync();
140 #endif
141         ppc_md.power_off();
142 }
143
144 void machine_halt(void)
145 {
146 #ifdef CONFIG_NVRAM
147         nvram_sync();
148 #endif
149         ppc_md.halt();
150 }
151
152 void (*pm_power_off)(void) = machine_power_off;
153
154 #ifdef CONFIG_TAU
155 extern u32 cpu_temp(unsigned long cpu);
156 extern u32 cpu_temp_both(unsigned long cpu);
157 #endif /* CONFIG_TAU */
158
159 int 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
196         if (cur_cpu_spec->pvr_mask)
197                 seq_printf(m, "%s", cur_cpu_spec->cpu_name);
198         else
199                 seq_printf(m, "unknown (%08x)", pvr);
200 #ifdef CONFIG_ALTIVEC
201         if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
202                 seq_printf(m, ", altivec supported");
203 #endif
204         seq_printf(m, "\n");
205
206 #ifdef CONFIG_TAU
207         if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) {
208 #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
228         /* 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) {
231                 maj = PVR_MAJ(pvr);
232                 min = PVR_MIN(pvr);
233         } 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                 }
248         }
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
256 #if USES_PPC_SYS
257         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
269 static 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
276 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
277 {
278         ++*pos;
279         return c_start(m, pos);
280 }
281
282 static void c_stop(struct seq_file *m, void *v)
283 {
284 }
285
286 struct 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
303 unsigned long
304 early_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_OF)
324         reloc_got2(offset);
325
326         /*
327          * don't do anything on prep
328          * for now, don't use bootinfo because it breaks yaboot 0.5
329          * and assume that if we didn't find a magic number, we have OF
330          */
331         if (*(unsigned long *)(0) != 0xdeadc0de)
332                 phys = prom_init(r3, r4, (prom_entry)r5);
333
334         reloc_got2(-offset);
335 #endif
336
337         return phys;
338 }
339
340 #ifdef CONFIG_PPC_OF
341 /*
342  * Assume here that all clock rates are the same in a
343  * smp system.  -- Cort
344  */
345 int
346 of_show_percpuinfo(struct seq_file *m, int i)
347 {
348         struct device_node *cpu_node;
349         u32 *fp;
350         int s;
351         
352         cpu_node = find_type_devices("cpu");
353         if (!cpu_node)
354                 return 0;
355         for (s = 0; s < i && cpu_node->next; s++)
356                 cpu_node = cpu_node->next;
357         fp = (u32 *)get_property(cpu_node, "clock-frequency", NULL);
358         if (fp)
359                 seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000);
360         return 0;
361 }
362
363 void __init
364 intuit_machine_type(void)
365 {
366         char *model;
367         struct device_node *root;
368         
369         /* ask the OF info if we're a chrp or pmac */
370         root = find_path_device("/");
371         if (root != 0) {
372                 /* assume pmac unless proven to be chrp -- Cort */
373                 _machine = _MACH_Pmac;
374                 model = get_property(root, "device_type", NULL);
375                 if (model && !strncmp("chrp", model, 4))
376                         _machine = _MACH_chrp;
377                 else {
378                         model = get_property(root, "model", NULL);
379                         if (model && !strncmp(model, "IBM", 3))
380                                 _machine = _MACH_chrp;
381                 }
382         }
383 }
384 #endif
385
386 #ifdef CONFIG_PPC_MULTIPLATFORM
387 /*
388  * The PPC_MULTIPLATFORM version of platform_init...
389  */
390 void __init
391 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
392               unsigned long r6, unsigned long r7)
393 {
394 #ifdef CONFIG_BOOTX_TEXT
395         if (boot_text_mapped) {
396                 btext_clearscreen();
397                 btext_welcome();
398         }
399 #endif
400
401         parse_bootinfo(find_bootinfo());
402
403         /* if we didn't get any bootinfo telling us what we are... */
404         if (_machine == 0) {
405                 /* prep boot loader tells us if we're prep or not */
406                 if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) )
407                         _machine = _MACH_prep;
408         }
409
410 #ifdef CONFIG_PPC_PREP
411         /* not much more to do here, if prep */
412         if (_machine == _MACH_prep) {
413                 prep_init(r3, r4, r5, r6, r7);
414                 return;
415         }
416 #endif
417
418 #ifdef CONFIG_PPC_OF
419         have_of = 1;
420
421         /* prom_init has already been called from __start */
422         if (boot_infos)
423                 relocate_nodes();
424
425         /* If we aren't PReP, we can find out if we're Pmac
426          * or CHRP with this. */
427         if (_machine == 0)
428                 intuit_machine_type();
429
430         /* finish_device_tree may need _machine defined. */
431         finish_device_tree();
432
433         /*
434          * If we were booted via quik, r3 points to the physical
435          * address of the command-line parameters.
436          * If we were booted from an xcoff image (i.e. netbooted or
437          * booted from floppy), we get the command line from the
438          * bootargs property of the /chosen node.
439          * If an initial ramdisk is present, r3 and r4
440          * are used for initrd_start and initrd_size,
441          * otherwise they contain 0xdeadbeef.
442          */
443         if (r3 >= 0x4000 && r3 < 0x800000 && r4 == 0) {
444                 strlcpy(cmd_line, (char *)r3 + KERNELBASE,
445                         sizeof(cmd_line));
446         } else if (boot_infos != 0) {
447                 /* booted by BootX - check for ramdisk */
448                 if (boot_infos->kernelParamsOffset != 0)
449                         strlcpy(cmd_line, (char *) boot_infos
450                                 + boot_infos->kernelParamsOffset,
451                                 sizeof(cmd_line));
452 #ifdef CONFIG_BLK_DEV_INITRD
453                 if (boot_infos->ramDisk) {
454                         initrd_start = (unsigned long) boot_infos
455                                 + boot_infos->ramDisk;
456                         initrd_end = initrd_start + boot_infos->ramDiskSize;
457                         initrd_below_start_ok = 1;
458                 }
459 #endif
460         } else {
461                 struct device_node *chosen;
462                 char *p;
463         
464 #ifdef CONFIG_BLK_DEV_INITRD
465                 if (r3 && r4 && r4 != 0xdeadbeef) {
466                         if (r3 < KERNELBASE)
467                                 r3 += KERNELBASE;
468                         initrd_start = r3;
469                         initrd_end = r3 + r4;
470                         ROOT_DEV = Root_RAM0;
471                         initrd_below_start_ok = 1;
472                 }
473 #endif
474                 chosen = find_devices("chosen");
475                 if (chosen != NULL) {
476                         p = get_property(chosen, "bootargs", NULL);
477                         if (p && *p) {
478                                 strlcpy(cmd_line, p, sizeof(cmd_line));
479                         }
480                 }
481         }
482 #ifdef CONFIG_ADB
483         if (strstr(cmd_line, "adb_sync")) {
484                 extern int __adb_probe_sync;
485                 __adb_probe_sync = 1;
486         }
487 #endif /* CONFIG_ADB */
488
489         switch (_machine) {
490 #ifdef CONFIG_PPC_CHRP
491         case _MACH_chrp:
492                 chrp_init(r3, r4, r5, r6, r7);
493                 break;
494 #endif
495         }
496 #endif /* CONFIG_PPC_OF */
497 }
498 #endif /* CONFIG_PPC_MULTIPLATFORM */
499
500 #ifdef CONFIG_PPC_OF
501 #ifdef CONFIG_SERIAL_CORE_CONSOLE
502 extern char *of_stdout_device;
503
504 static int __init set_preferred_console(void)
505 {
506         struct device_node *prom_stdout;
507         char *name;
508         int offset = 0;
509
510         if (of_stdout_device == NULL)
511                 return -ENODEV;
512
513         /* The user has requested a console so this is already set up. */
514         if (strstr(saved_command_line, "console="))
515                 return -EBUSY;
516
517         prom_stdout = find_path_device(of_stdout_device);
518         if (!prom_stdout)
519                 return -ENODEV;
520
521         name = (char *)get_property(prom_stdout, "name", NULL);
522         if (!name)
523                 return -ENODEV;
524
525         if (strcmp(name, "serial") == 0) {
526                 int i;
527                 u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
528                 if (i > 8) {
529                         switch (reg[1]) {
530                                 case 0x3f8:
531                                         offset = 0;
532                                         break;
533                                 case 0x2f8:
534                                         offset = 1;
535                                         break;
536                                 case 0x898:
537                                         offset = 2;
538                                         break;
539                                 case 0x890:
540                                         offset = 3;
541                                         break;
542                                 default:
543                                         /* We dont recognise the serial port */
544                                         return -ENODEV;
545                         }
546                 }
547         } else if (strcmp(name, "ch-a") == 0)
548                 offset = 0;
549         else if (strcmp(name, "ch-b") == 0)
550                 offset = 1;
551         else
552                 return -ENODEV;
553         return add_preferred_console("ttyS", offset, NULL);
554 }
555 console_initcall(set_preferred_console);
556 #endif /* CONFIG_SERIAL_CORE_CONSOLE */
557 #endif /* CONFIG_PPC_OF */
558
559 struct bi_record *find_bootinfo(void)
560 {
561         struct bi_record *rec;
562
563         rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20));
564         if ( rec->tag != BI_FIRST ) {
565                 /*
566                  * This 0x10000 offset is a terrible hack but it will go away when
567                  * we have the bootloader handle all the relocation and
568                  * prom calls -- Cort
569                  */
570                 rec = (struct bi_record *)_ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20));
571                 if ( rec->tag != BI_FIRST )
572                         return NULL;
573         }
574         return rec;
575 }
576
577 void parse_bootinfo(struct bi_record *rec)
578 {
579         if (rec == NULL || rec->tag != BI_FIRST)
580                 return;
581         while (rec->tag != BI_LAST) {
582                 ulong *data = rec->data;
583                 switch (rec->tag) {
584                 case BI_CMD_LINE:
585                         strlcpy(cmd_line, (void *)data, sizeof(cmd_line));
586                         break;
587 #ifdef CONFIG_BLK_DEV_INITRD
588                 case BI_INITRD:
589                         initrd_start = data[0] + KERNELBASE;
590                         initrd_end = data[0] + data[1] + KERNELBASE;
591                         break;
592 #endif /* CONFIG_BLK_DEV_INITRD */
593 #ifdef CONFIG_PPC_MULTIPLATFORM
594                 case BI_MACHTYPE:
595                         /* Machine types changed with the merge. Since the
596                          * bootinfo are now deprecated, we can just hard code
597                          * the appropriate conversion here for when we are
598                          * called with yaboot which passes us a machine type
599                          * this way.
600                          */
601                         switch(data[0]) {
602                         case 1: _machine = _MACH_prep; break;
603                         case 2: _machine = _MACH_Pmac; break;
604                         case 4: _machine = _MACH_chrp; break;
605                         default:
606                                 _machine = data[0];
607                         }
608                         break;
609 #endif
610                 case BI_MEMSIZE:
611                         boot_mem_size = data[0];
612                         break;
613                 }
614                 rec = (struct bi_record *)((ulong)rec + rec->size);
615         }
616 }
617
618 /*
619  * Find out what kind of machine we're on and save any data we need
620  * from the early boot process (devtree is copied on pmac by prom_init()).
621  * This is called very early on the boot process, after a minimal
622  * MMU environment has been set up but before MMU_init is called.
623  */
624 void __init
625 machine_init(unsigned long r3, unsigned long r4, unsigned long r5,
626              unsigned long r6, unsigned long r7)
627 {
628 #ifdef CONFIG_CMDLINE
629         strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
630 #endif /* CONFIG_CMDLINE */
631
632 #ifdef CONFIG_6xx
633         ppc_md.power_save = ppc6xx_idle;
634 #endif
635 #ifdef CONFIG_POWER4
636         ppc_md.power_save = power4_idle;
637 #endif
638
639         platform_init(r3, r4, r5, r6, r7);
640
641         if (ppc_md.progress)
642                 ppc_md.progress("id mach(): done", 0x200);
643 }
644 #ifdef CONFIG_BOOKE_WDT
645 /* Checks wdt=x and wdt_period=xx command-line option */
646 int __init early_parse_wdt(char *p)
647 {
648         if (p && strncmp(p, "0", 1) != 0)
649                booke_wdt_enabled = 1;
650
651         return 0;
652 }
653 early_param("wdt", early_parse_wdt);
654
655 int __init early_parse_wdt_period (char *p)
656 {
657         if (p)
658                 booke_wdt_period = simple_strtoul(p, NULL, 0);
659
660         return 0;
661 }
662 early_param("wdt_period", early_parse_wdt_period);
663 #endif  /* CONFIG_BOOKE_WDT */
664
665 /* Checks "l2cr=xxxx" command-line option */
666 int __init ppc_setup_l2cr(char *str)
667 {
668         if (cpu_has_feature(CPU_FTR_L2CR)) {
669                 unsigned long val = simple_strtoul(str, NULL, 0);
670                 printk(KERN_INFO "l2cr set to %lx\n", val);
671                 _set_L2CR(0);           /* force invalidate by disable cache */
672                 _set_L2CR(val);         /* and enable it */
673         }
674         return 1;
675 }
676 __setup("l2cr=", ppc_setup_l2cr);
677
678 #ifdef CONFIG_GENERIC_NVRAM
679
680 /* Generic nvram hooks used by drivers/char/gen_nvram.c */
681 unsigned char nvram_read_byte(int addr)
682 {
683         if (ppc_md.nvram_read_val)
684                 return ppc_md.nvram_read_val(addr);
685         return 0xff;
686 }
687 EXPORT_SYMBOL(nvram_read_byte);
688
689 void nvram_write_byte(unsigned char val, int addr)
690 {
691         if (ppc_md.nvram_write_val)
692                 ppc_md.nvram_write_val(addr, val);
693 }
694 EXPORT_SYMBOL(nvram_write_byte);
695
696 void nvram_sync(void)
697 {
698         if (ppc_md.nvram_sync)
699                 ppc_md.nvram_sync();
700 }
701 EXPORT_SYMBOL(nvram_sync);
702
703 #endif /* CONFIG_NVRAM */
704
705 static struct cpu cpu_devices[NR_CPUS];
706
707 int __init ppc_init(void)
708 {
709         int i;
710
711         /* clear the progress line */
712         if ( ppc_md.progress ) ppc_md.progress("             ", 0xffff);
713
714         /* register CPU devices */
715         for (i = 0; i < NR_CPUS; i++)
716                 if (cpu_possible(i))
717                         register_cpu(&cpu_devices[i], i, NULL);
718
719         /* call platform init */
720         if (ppc_md.init != NULL) {
721                 ppc_md.init();
722         }
723         return 0;
724 }
725
726 arch_initcall(ppc_init);
727
728 /* Warning, IO base is not yet inited */
729 void __init setup_arch(char **cmdline_p)
730 {
731         extern char *klimit;
732         extern void do_init_bootmem(void);
733
734         /* so udelay does something sensible, assume <= 1000 bogomips */
735         loops_per_jiffy = 500000000 / HZ;
736
737         if (ppc_md.init_early)
738                 ppc_md.init_early();
739
740 #ifdef CONFIG_XMON
741         xmon_init(1);
742         if (strstr(cmd_line, "xmon"))
743                 xmon(NULL);
744 #endif /* CONFIG_XMON */
745         if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab);
746
747 #if defined(CONFIG_KGDB)
748         if (ppc_md.kgdb_map_scc)
749                 ppc_md.kgdb_map_scc();
750         set_debug_traps();
751         if (strstr(cmd_line, "gdb")) {
752                 if (ppc_md.progress)
753                         ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
754                 printk("kgdb breakpoint activated\n");
755                 breakpoint();
756         }
757 #endif
758
759         /*
760          * Set cache line size based on type of cpu as a default.
761          * Systems with OF can look in the properties on the cpu node(s)
762          * for a possibly more accurate value.
763          */
764         if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) {
765                 dcache_bsize = cur_cpu_spec->dcache_bsize;
766                 icache_bsize = cur_cpu_spec->icache_bsize;
767                 ucache_bsize = 0;
768         } else
769                 ucache_bsize = dcache_bsize = icache_bsize
770                         = cur_cpu_spec->dcache_bsize;
771
772         /* reboot on panic */
773         panic_timeout = 180;
774
775         init_mm.start_code = PAGE_OFFSET;
776         init_mm.end_code = (unsigned long) _etext;
777         init_mm.end_data = (unsigned long) _edata;
778         init_mm.brk = (unsigned long) klimit;
779
780         /* Save unparsed command line copy for /proc/cmdline */
781         strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
782         *cmdline_p = cmd_line;
783
784         parse_early_param();
785
786         /* set up the bootmem stuff with available memory */
787         do_init_bootmem();
788         if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
789
790 #ifdef CONFIG_PPC_OCP
791         /* Initialize OCP device list */
792         ocp_early_init();
793         if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab);
794 #endif
795
796 #ifdef CONFIG_DUMMY_CONSOLE
797         conswitchp = &dummy_con;
798 #endif
799
800         ppc_md.setup_arch();
801         if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
802
803         paging_init();
804
805         /* this is for modules since _machine can be a define -- Cort */
806         ppc_md.ppc_machine = _machine;
807 }