Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 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> |
| 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> |
Kumar Gala | 6d7f58b | 2005-10-25 23:57:33 -0500 | [diff] [blame^] | 42 | #include <asm/time.h> |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 43 | |
| 44 | #if defined CONFIG_KGDB |
| 45 | #include <asm/kgdb.h> |
| 46 | #endif |
| 47 | |
| 48 | extern void platform_init(void); |
| 49 | extern void bootx_init(unsigned long r4, unsigned long phys); |
| 50 | |
| 51 | extern void ppc6xx_idle(void); |
| 52 | extern void power4_idle(void); |
| 53 | |
| 54 | boot_infos_t *boot_infos; |
| 55 | struct ide_machdep_calls ppc_ide_md; |
| 56 | |
| 57 | /* Used with the BI_MEMSIZE bootinfo parameter to store the memory |
| 58 | size value reported by the boot loader. */ |
| 59 | unsigned long boot_mem_size; |
| 60 | |
| 61 | unsigned long ISA_DMA_THRESHOLD; |
| 62 | unsigned int DMA_MODE_READ; |
| 63 | unsigned int DMA_MODE_WRITE; |
| 64 | |
Paul Mackerras | e574d23 | 2005-10-10 22:58:10 +1000 | [diff] [blame] | 65 | int have_of = 1; |
| 66 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 67 | #ifdef CONFIG_PPC_MULTIPLATFORM |
| 68 | int _machine = 0; |
| 69 | |
| 70 | extern void prep_init(void); |
| 71 | extern void pmac_init(void); |
| 72 | extern void chrp_init(void); |
| 73 | |
| 74 | dev_t boot_dev; |
| 75 | #endif /* CONFIG_PPC_MULTIPLATFORM */ |
| 76 | |
| 77 | #ifdef CONFIG_MAGIC_SYSRQ |
| 78 | unsigned long SYSRQ_KEY = 0x54; |
| 79 | #endif /* CONFIG_MAGIC_SYSRQ */ |
| 80 | |
| 81 | #ifdef CONFIG_VGA_CONSOLE |
| 82 | unsigned long vgacon_remap_base; |
| 83 | #endif |
| 84 | |
| 85 | struct machdep_calls ppc_md; |
Paul Mackerras | e574d23 | 2005-10-10 22:58:10 +1000 | [diff] [blame] | 86 | EXPORT_SYMBOL(ppc_md); |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 87 | |
| 88 | /* |
| 89 | * These are used in binfmt_elf.c to put aux entries on the stack |
| 90 | * for each elf executable being started. |
| 91 | */ |
| 92 | int dcache_bsize; |
| 93 | int icache_bsize; |
| 94 | int ucache_bsize; |
| 95 | |
| 96 | #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_FB_VGA16) || \ |
| 97 | defined(CONFIG_FB_VGA16_MODULE) || defined(CONFIG_FB_VESA) |
| 98 | struct screen_info screen_info = { |
| 99 | 0, 25, /* orig-x, orig-y */ |
| 100 | 0, /* unused */ |
| 101 | 0, /* orig-video-page */ |
| 102 | 0, /* orig-video-mode */ |
| 103 | 80, /* orig-video-cols */ |
| 104 | 0,0,0, /* ega_ax, ega_bx, ega_cx */ |
| 105 | 25, /* orig-video-lines */ |
| 106 | 1, /* orig-video-isVGA */ |
| 107 | 16 /* orig-video-points */ |
| 108 | }; |
| 109 | #endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */ |
| 110 | |
| 111 | void machine_restart(char *cmd) |
| 112 | { |
| 113 | #ifdef CONFIG_NVRAM |
| 114 | nvram_sync(); |
| 115 | #endif |
| 116 | ppc_md.restart(cmd); |
| 117 | } |
| 118 | |
| 119 | void machine_power_off(void) |
| 120 | { |
| 121 | #ifdef CONFIG_NVRAM |
| 122 | nvram_sync(); |
| 123 | #endif |
| 124 | ppc_md.power_off(); |
| 125 | } |
| 126 | |
| 127 | void machine_halt(void) |
| 128 | { |
| 129 | #ifdef CONFIG_NVRAM |
| 130 | nvram_sync(); |
| 131 | #endif |
| 132 | ppc_md.halt(); |
| 133 | } |
| 134 | |
| 135 | void (*pm_power_off)(void) = machine_power_off; |
| 136 | |
| 137 | #ifdef CONFIG_TAU |
| 138 | extern u32 cpu_temp(unsigned long cpu); |
| 139 | extern u32 cpu_temp_both(unsigned long cpu); |
| 140 | #endif /* CONFIG_TAU */ |
| 141 | |
| 142 | int show_cpuinfo(struct seq_file *m, void *v) |
| 143 | { |
| 144 | int i = (int) v - 1; |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 145 | unsigned int pvr; |
| 146 | unsigned short maj, min; |
| 147 | unsigned long lpj; |
| 148 | |
| 149 | if (i >= NR_CPUS) { |
| 150 | /* Show summary information */ |
| 151 | #ifdef CONFIG_SMP |
| 152 | unsigned long bogosum = 0; |
| 153 | for (i = 0; i < NR_CPUS; ++i) |
| 154 | if (cpu_online(i)) |
| 155 | bogosum += cpu_data[i].loops_per_jiffy; |
| 156 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", |
| 157 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); |
| 158 | #endif /* CONFIG_SMP */ |
| 159 | |
| 160 | if (ppc_md.show_cpuinfo != NULL) |
Paul Mackerras | 0dd194d | 2005-10-20 20:48:19 +1000 | [diff] [blame] | 161 | ppc_md.show_cpuinfo(m); |
| 162 | return 0; |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | #ifdef CONFIG_SMP |
| 166 | if (!cpu_online(i)) |
| 167 | return 0; |
| 168 | pvr = cpu_data[i].pvr; |
| 169 | lpj = cpu_data[i].loops_per_jiffy; |
| 170 | #else |
| 171 | pvr = mfspr(SPRN_PVR); |
| 172 | lpj = loops_per_jiffy; |
| 173 | #endif |
| 174 | |
| 175 | seq_printf(m, "processor\t: %d\n", i); |
| 176 | seq_printf(m, "cpu\t\t: "); |
| 177 | |
| 178 | if (cur_cpu_spec->pvr_mask) |
| 179 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); |
| 180 | else |
| 181 | seq_printf(m, "unknown (%08x)", pvr); |
| 182 | #ifdef CONFIG_ALTIVEC |
| 183 | if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC) |
| 184 | seq_printf(m, ", altivec supported"); |
| 185 | #endif |
| 186 | seq_printf(m, "\n"); |
| 187 | |
| 188 | #ifdef CONFIG_TAU |
| 189 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { |
| 190 | #ifdef CONFIG_TAU_AVERAGE |
| 191 | /* more straightforward, but potentially misleading */ |
| 192 | seq_printf(m, "temperature \t: %u C (uncalibrated)\n", |
| 193 | cpu_temp(i)); |
| 194 | #else |
| 195 | /* show the actual temp sensor range */ |
| 196 | u32 temp; |
| 197 | temp = cpu_temp_both(i); |
| 198 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", |
| 199 | temp & 0xff, temp >> 16); |
| 200 | #endif |
| 201 | } |
| 202 | #endif /* CONFIG_TAU */ |
| 203 | |
Paul Mackerras | 0dd194d | 2005-10-20 20:48:19 +1000 | [diff] [blame] | 204 | if (ppc_md.show_percpuinfo != NULL) |
| 205 | ppc_md.show_percpuinfo(m, i); |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 206 | |
| 207 | /* If we are a Freescale core do a simple check so |
| 208 | * we dont have to keep adding cases in the future */ |
Paul Mackerras | 0dd194d | 2005-10-20 20:48:19 +1000 | [diff] [blame] | 209 | if (PVR_VER(pvr) & 0x8000) { |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 210 | maj = PVR_MAJ(pvr); |
| 211 | min = PVR_MIN(pvr); |
| 212 | } else { |
| 213 | switch (PVR_VER(pvr)) { |
| 214 | case 0x0020: /* 403 family */ |
| 215 | maj = PVR_MAJ(pvr) + 1; |
| 216 | min = PVR_MIN(pvr); |
| 217 | break; |
| 218 | case 0x1008: /* 740P/750P ?? */ |
| 219 | maj = ((pvr >> 8) & 0xFF) - 1; |
| 220 | min = pvr & 0xFF; |
| 221 | break; |
| 222 | default: |
| 223 | maj = (pvr >> 8) & 0xFF; |
| 224 | min = pvr & 0xFF; |
| 225 | break; |
| 226 | } |
| 227 | } |
| 228 | |
Kumar Gala | 6d7f58b | 2005-10-25 23:57:33 -0500 | [diff] [blame^] | 229 | /* |
| 230 | * Assume here that all clock rates are the same in a |
| 231 | * smp system. -- Cort |
| 232 | */ |
| 233 | seq_printf(m, "clock\t\t: %lu.%06luMHz\n", ppc_proc_freq / 1000000, |
| 234 | ppc_proc_freq % 1000000); |
| 235 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 236 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", |
| 237 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); |
| 238 | |
| 239 | seq_printf(m, "bogomips\t: %lu.%02lu\n", |
| 240 | lpj / (500000/HZ), (lpj / (5000/HZ)) % 100); |
| 241 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 242 | #ifdef CONFIG_SMP |
| 243 | seq_printf(m, "\n"); |
| 244 | #endif |
| 245 | |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 250 | { |
| 251 | int i = *pos; |
| 252 | |
| 253 | return i <= NR_CPUS? (void *) (i + 1): NULL; |
| 254 | } |
| 255 | |
| 256 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 257 | { |
| 258 | ++*pos; |
| 259 | return c_start(m, pos); |
| 260 | } |
| 261 | |
| 262 | static void c_stop(struct seq_file *m, void *v) |
| 263 | { |
| 264 | } |
| 265 | |
| 266 | struct seq_operations cpuinfo_op = { |
| 267 | .start =c_start, |
| 268 | .next = c_next, |
| 269 | .stop = c_stop, |
| 270 | .show = show_cpuinfo, |
| 271 | }; |
| 272 | |
| 273 | /* |
| 274 | * We're called here very early in the boot. We determine the machine |
| 275 | * type and call the appropriate low-level setup functions. |
| 276 | * -- Cort <cort@fsmlabs.com> |
| 277 | * |
| 278 | * Note that the kernel may be running at an address which is different |
| 279 | * from the address that it was linked at, so we must use RELOC/PTRRELOC |
| 280 | * to access static data (including strings). -- paulus |
| 281 | */ |
| 282 | unsigned long __init early_init(unsigned long dt_ptr) |
| 283 | { |
| 284 | unsigned long offset = reloc_offset(); |
| 285 | |
Paul Mackerras | dd184343 | 2005-10-17 20:13:47 +1000 | [diff] [blame] | 286 | /* First zero the BSS -- use memset_io, some platforms don't have |
| 287 | * caches on yet */ |
| 288 | memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start); |
| 289 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 290 | /* |
| 291 | * Identify the CPU type and fix up code sections |
| 292 | * that depend on which cpu we have. |
| 293 | */ |
| 294 | identify_cpu(offset, 0); |
| 295 | do_cpu_ftr_fixups(offset); |
| 296 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 297 | return KERNELBASE + offset; |
| 298 | } |
| 299 | |
| 300 | #ifdef CONFIG_PPC_OF |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 301 | void __init |
| 302 | intuit_machine_type(void) |
| 303 | { |
| 304 | char *model; |
| 305 | struct device_node *root; |
| 306 | |
| 307 | /* ask the OF info if we're a chrp or pmac */ |
| 308 | root = find_path_device("/"); |
| 309 | if (root != 0) { |
| 310 | /* assume pmac unless proven to be chrp -- Cort */ |
| 311 | _machine = _MACH_Pmac; |
| 312 | model = get_property(root, "device_type", NULL); |
| 313 | if (model && !strncmp("chrp", model, 4)) |
| 314 | _machine = _MACH_chrp; |
| 315 | else { |
| 316 | model = get_property(root, "model", NULL); |
| 317 | if (model && !strncmp(model, "IBM", 3)) |
| 318 | _machine = _MACH_chrp; |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | #endif |
| 323 | |
| 324 | #ifdef CONFIG_PPC_MULTIPLATFORM |
| 325 | /* |
| 326 | * The PPC_MULTIPLATFORM version of platform_init... |
| 327 | */ |
| 328 | void __init platform_init(void) |
| 329 | { |
| 330 | /* if we didn't get any bootinfo telling us what we are... */ |
| 331 | if (_machine == 0) { |
| 332 | /* prep boot loader tells us if we're prep or not */ |
| 333 | if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) ) |
| 334 | _machine = _MACH_prep; |
| 335 | } |
| 336 | |
| 337 | #ifdef CONFIG_PPC_PREP |
| 338 | /* not much more to do here, if prep */ |
| 339 | if (_machine == _MACH_prep) { |
| 340 | prep_init(); |
| 341 | return; |
| 342 | } |
| 343 | #endif |
| 344 | |
| 345 | #ifdef CONFIG_ADB |
| 346 | if (strstr(cmd_line, "adb_sync")) { |
| 347 | extern int __adb_probe_sync; |
| 348 | __adb_probe_sync = 1; |
| 349 | } |
| 350 | #endif /* CONFIG_ADB */ |
| 351 | |
| 352 | switch (_machine) { |
| 353 | #ifdef CONFIG_PPC_PMAC |
| 354 | case _MACH_Pmac: |
| 355 | pmac_init(); |
| 356 | break; |
| 357 | #endif |
| 358 | #ifdef CONFIG_PPC_CHRP |
| 359 | case _MACH_chrp: |
| 360 | chrp_init(); |
| 361 | break; |
| 362 | #endif |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | #ifdef CONFIG_SERIAL_CORE_CONSOLE |
| 367 | extern char *of_stdout_device; |
| 368 | |
| 369 | static int __init set_preferred_console(void) |
| 370 | { |
| 371 | struct device_node *prom_stdout; |
| 372 | char *name; |
| 373 | int offset = 0; |
| 374 | |
| 375 | if (of_stdout_device == NULL) |
| 376 | return -ENODEV; |
| 377 | |
| 378 | /* The user has requested a console so this is already set up. */ |
| 379 | if (strstr(saved_command_line, "console=")) |
| 380 | return -EBUSY; |
| 381 | |
| 382 | prom_stdout = find_path_device(of_stdout_device); |
| 383 | if (!prom_stdout) |
| 384 | return -ENODEV; |
| 385 | |
| 386 | name = (char *)get_property(prom_stdout, "name", NULL); |
| 387 | if (!name) |
| 388 | return -ENODEV; |
| 389 | |
| 390 | if (strcmp(name, "serial") == 0) { |
| 391 | int i; |
| 392 | u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i); |
| 393 | if (i > 8) { |
| 394 | switch (reg[1]) { |
| 395 | case 0x3f8: |
| 396 | offset = 0; |
| 397 | break; |
| 398 | case 0x2f8: |
| 399 | offset = 1; |
| 400 | break; |
| 401 | case 0x898: |
| 402 | offset = 2; |
| 403 | break; |
| 404 | case 0x890: |
| 405 | offset = 3; |
| 406 | break; |
| 407 | default: |
| 408 | /* We dont recognise the serial port */ |
| 409 | return -ENODEV; |
| 410 | } |
| 411 | } |
| 412 | } else if (strcmp(name, "ch-a") == 0) |
| 413 | offset = 0; |
| 414 | else if (strcmp(name, "ch-b") == 0) |
| 415 | offset = 1; |
| 416 | else |
| 417 | return -ENODEV; |
| 418 | return add_preferred_console("ttyS", offset, NULL); |
| 419 | } |
| 420 | console_initcall(set_preferred_console); |
| 421 | #endif /* CONFIG_SERIAL_CORE_CONSOLE */ |
| 422 | #endif /* CONFIG_PPC_MULTIPLATFORM */ |
| 423 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 424 | /* |
| 425 | * Find out what kind of machine we're on and save any data we need |
| 426 | * from the early boot process (devtree is copied on pmac by prom_init()). |
| 427 | * This is called very early on the boot process, after a minimal |
| 428 | * MMU environment has been set up but before MMU_init is called. |
| 429 | */ |
| 430 | void __init machine_init(unsigned long dt_ptr, unsigned long phys) |
| 431 | { |
| 432 | early_init_devtree(__va(dt_ptr)); |
| 433 | |
| 434 | #ifdef CONFIG_CMDLINE |
| 435 | strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); |
| 436 | #endif /* CONFIG_CMDLINE */ |
| 437 | |
Paul Mackerras | 35499c0 | 2005-10-22 16:02:39 +1000 | [diff] [blame] | 438 | platform_init(); |
| 439 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 440 | #ifdef CONFIG_6xx |
| 441 | ppc_md.power_save = ppc6xx_idle; |
| 442 | #endif |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 443 | |
| 444 | if (ppc_md.progress) |
| 445 | ppc_md.progress("id mach(): done", 0x200); |
| 446 | } |
| 447 | |
| 448 | #ifdef CONFIG_BOOKE_WDT |
| 449 | /* Checks wdt=x and wdt_period=xx command-line option */ |
| 450 | int __init early_parse_wdt(char *p) |
| 451 | { |
| 452 | if (p && strncmp(p, "0", 1) != 0) |
| 453 | booke_wdt_enabled = 1; |
| 454 | |
| 455 | return 0; |
| 456 | } |
| 457 | early_param("wdt", early_parse_wdt); |
| 458 | |
| 459 | int __init early_parse_wdt_period (char *p) |
| 460 | { |
| 461 | if (p) |
| 462 | booke_wdt_period = simple_strtoul(p, NULL, 0); |
| 463 | |
| 464 | return 0; |
| 465 | } |
| 466 | early_param("wdt_period", early_parse_wdt_period); |
| 467 | #endif /* CONFIG_BOOKE_WDT */ |
| 468 | |
| 469 | /* Checks "l2cr=xxxx" command-line option */ |
| 470 | int __init ppc_setup_l2cr(char *str) |
| 471 | { |
| 472 | if (cpu_has_feature(CPU_FTR_L2CR)) { |
| 473 | unsigned long val = simple_strtoul(str, NULL, 0); |
| 474 | printk(KERN_INFO "l2cr set to %lx\n", val); |
| 475 | _set_L2CR(0); /* force invalidate by disable cache */ |
| 476 | _set_L2CR(val); /* and enable it */ |
| 477 | } |
| 478 | return 1; |
| 479 | } |
| 480 | __setup("l2cr=", ppc_setup_l2cr); |
| 481 | |
| 482 | #ifdef CONFIG_GENERIC_NVRAM |
| 483 | |
| 484 | /* Generic nvram hooks used by drivers/char/gen_nvram.c */ |
| 485 | unsigned char nvram_read_byte(int addr) |
| 486 | { |
| 487 | if (ppc_md.nvram_read_val) |
| 488 | return ppc_md.nvram_read_val(addr); |
| 489 | return 0xff; |
| 490 | } |
| 491 | EXPORT_SYMBOL(nvram_read_byte); |
| 492 | |
| 493 | void nvram_write_byte(unsigned char val, int addr) |
| 494 | { |
| 495 | if (ppc_md.nvram_write_val) |
| 496 | ppc_md.nvram_write_val(addr, val); |
| 497 | } |
| 498 | EXPORT_SYMBOL(nvram_write_byte); |
| 499 | |
| 500 | void nvram_sync(void) |
| 501 | { |
| 502 | if (ppc_md.nvram_sync) |
| 503 | ppc_md.nvram_sync(); |
| 504 | } |
| 505 | EXPORT_SYMBOL(nvram_sync); |
| 506 | |
| 507 | #endif /* CONFIG_NVRAM */ |
| 508 | |
| 509 | static struct cpu cpu_devices[NR_CPUS]; |
| 510 | |
| 511 | int __init ppc_init(void) |
| 512 | { |
| 513 | int i; |
| 514 | |
| 515 | /* clear the progress line */ |
| 516 | if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff); |
| 517 | |
| 518 | /* register CPU devices */ |
| 519 | for (i = 0; i < NR_CPUS; i++) |
| 520 | if (cpu_possible(i)) |
| 521 | register_cpu(&cpu_devices[i], i, NULL); |
| 522 | |
| 523 | /* call platform init */ |
| 524 | if (ppc_md.init != NULL) { |
| 525 | ppc_md.init(); |
| 526 | } |
| 527 | return 0; |
| 528 | } |
| 529 | |
| 530 | arch_initcall(ppc_init); |
| 531 | |
| 532 | /* Warning, IO base is not yet inited */ |
| 533 | void __init setup_arch(char **cmdline_p) |
| 534 | { |
| 535 | extern char *klimit; |
| 536 | extern void do_init_bootmem(void); |
| 537 | |
| 538 | /* so udelay does something sensible, assume <= 1000 bogomips */ |
| 539 | loops_per_jiffy = 500000000 / HZ; |
| 540 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 541 | unflatten_device_tree(); |
| 542 | finish_device_tree(); |
| 543 | |
Paul Mackerras | 30cd4a4 | 2005-10-17 19:20:46 +1000 | [diff] [blame] | 544 | #ifdef CONFIG_BOOTX_TEXT |
| 545 | init_boot_display(); |
| 546 | #endif |
| 547 | |
Paul Mackerras | 9b6b563 | 2005-10-06 12:06:20 +1000 | [diff] [blame] | 548 | #ifdef CONFIG_PPC_MULTIPLATFORM |
| 549 | /* This could be called "early setup arch", it must be done |
| 550 | * now because xmon need it |
| 551 | */ |
| 552 | if (_machine == _MACH_Pmac) |
| 553 | pmac_feature_init(); /* New cool way */ |
| 554 | #endif |
| 555 | |
| 556 | #ifdef CONFIG_XMON |
| 557 | xmon_map_scc(); |
| 558 | if (strstr(cmd_line, "xmon")) |
| 559 | xmon(NULL); |
| 560 | #endif /* CONFIG_XMON */ |
| 561 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab); |
| 562 | |
| 563 | #if defined(CONFIG_KGDB) |
| 564 | if (ppc_md.kgdb_map_scc) |
| 565 | ppc_md.kgdb_map_scc(); |
| 566 | set_debug_traps(); |
| 567 | if (strstr(cmd_line, "gdb")) { |
| 568 | if (ppc_md.progress) |
| 569 | ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000); |
| 570 | printk("kgdb breakpoint activated\n"); |
| 571 | breakpoint(); |
| 572 | } |
| 573 | #endif |
| 574 | |
| 575 | /* |
| 576 | * Set cache line size based on type of cpu as a default. |
| 577 | * Systems with OF can look in the properties on the cpu node(s) |
| 578 | * for a possibly more accurate value. |
| 579 | */ |
| 580 | if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) { |
| 581 | dcache_bsize = cur_cpu_spec->dcache_bsize; |
| 582 | icache_bsize = cur_cpu_spec->icache_bsize; |
| 583 | ucache_bsize = 0; |
| 584 | } else |
| 585 | ucache_bsize = dcache_bsize = icache_bsize |
| 586 | = cur_cpu_spec->dcache_bsize; |
| 587 | |
| 588 | /* reboot on panic */ |
| 589 | panic_timeout = 180; |
| 590 | |
| 591 | init_mm.start_code = PAGE_OFFSET; |
| 592 | init_mm.end_code = (unsigned long) _etext; |
| 593 | init_mm.end_data = (unsigned long) _edata; |
| 594 | init_mm.brk = (unsigned long) klimit; |
| 595 | |
| 596 | /* Save unparsed command line copy for /proc/cmdline */ |
| 597 | strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE); |
| 598 | *cmdline_p = cmd_line; |
| 599 | |
| 600 | parse_early_param(); |
| 601 | |
| 602 | /* set up the bootmem stuff with available memory */ |
| 603 | do_init_bootmem(); |
| 604 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); |
| 605 | |
| 606 | #ifdef CONFIG_PPC_OCP |
| 607 | /* Initialize OCP device list */ |
| 608 | ocp_early_init(); |
| 609 | if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab); |
| 610 | #endif |
| 611 | |
| 612 | #ifdef CONFIG_DUMMY_CONSOLE |
| 613 | conswitchp = &dummy_con; |
| 614 | #endif |
| 615 | |
| 616 | ppc_md.setup_arch(); |
| 617 | if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); |
| 618 | |
| 619 | paging_init(); |
| 620 | |
| 621 | /* this is for modules since _machine can be a define -- Cort */ |
| 622 | ppc_md.ppc_machine = _machine; |
| 623 | } |