Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 2 | * Common prep boot and setup code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <asm/sections.h> |
| 39 | #include <asm/nvram.h> |
| 40 | #include <asm/xmon.h> |
| 41 | #include <asm/ocp.h> |
| 42 | |
Kumar Gala | 8e8fff0 | 2005-09-03 15:55:34 -0700 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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; |
Jon Loeliger | b8f114d | 2005-09-21 14:54:51 -0500 | [diff] [blame] | 72 | unsigned int DMA_MODE_READ; |
| 73 | unsigned int DMA_MODE_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 75 | #ifdef CONFIG_PPC_PREP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | extern void prep_init(unsigned long r3, unsigned long r4, |
| 77 | unsigned long r5, unsigned long r6, unsigned long r7); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 78 | |
| 79 | dev_t boot_dev; |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 80 | #endif /* CONFIG_PPC_PREP */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Paul Mackerras | fd582ec | 2005-10-11 22:08:12 +1000 | [diff] [blame] | 82 | int have_of; |
| 83 | EXPORT_SYMBOL(have_of); |
| 84 | |
Paul Mackerras | 35d81a4 | 2005-10-11 22:03:09 +1000 | [diff] [blame] | 85 | #ifdef __DO_IRQ_CANON |
| 86 | int ppc_do_canonicalize_irqs; |
| 87 | EXPORT_SYMBOL(ppc_do_canonicalize_irqs); |
| 88 | #endif |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | #ifdef CONFIG_MAGIC_SYSRQ |
| 91 | unsigned long SYSRQ_KEY = 0x54; |
| 92 | #endif /* CONFIG_MAGIC_SYSRQ */ |
| 93 | |
| 94 | #ifdef CONFIG_VGA_CONSOLE |
| 95 | unsigned long vgacon_remap_base; |
| 96 | #endif |
| 97 | |
| 98 | struct machdep_calls ppc_md; |
| 99 | |
| 100 | /* |
| 101 | * These are used in binfmt_elf.c to put aux entries on the stack |
| 102 | * for each elf executable being started. |
| 103 | */ |
| 104 | int dcache_bsize; |
| 105 | int icache_bsize; |
| 106 | int ucache_bsize; |
| 107 | |
| 108 | #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_FB_VGA16) || \ |
| 109 | defined(CONFIG_FB_VGA16_MODULE) || defined(CONFIG_FB_VESA) |
| 110 | struct screen_info screen_info = { |
| 111 | 0, 25, /* orig-x, orig-y */ |
| 112 | 0, /* unused */ |
| 113 | 0, /* orig-video-page */ |
| 114 | 0, /* orig-video-mode */ |
| 115 | 80, /* orig-video-cols */ |
| 116 | 0,0,0, /* ega_ax, ega_bx, ega_cx */ |
| 117 | 25, /* orig-video-lines */ |
| 118 | 1, /* orig-video-isVGA */ |
| 119 | 16 /* orig-video-points */ |
| 120 | }; |
| 121 | #endif /* CONFIG_VGA_CONSOLE || CONFIG_FB_VGA16 || CONFIG_FB_VESA */ |
| 122 | |
| 123 | void machine_restart(char *cmd) |
| 124 | { |
| 125 | #ifdef CONFIG_NVRAM |
| 126 | nvram_sync(); |
| 127 | #endif |
| 128 | ppc_md.restart(cmd); |
| 129 | } |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | void machine_power_off(void) |
| 132 | { |
| 133 | #ifdef CONFIG_NVRAM |
| 134 | nvram_sync(); |
| 135 | #endif |
| 136 | ppc_md.power_off(); |
| 137 | } |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | void machine_halt(void) |
| 140 | { |
| 141 | #ifdef CONFIG_NVRAM |
| 142 | nvram_sync(); |
| 143 | #endif |
| 144 | ppc_md.halt(); |
| 145 | } |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | void (*pm_power_off)(void) = machine_power_off; |
| 148 | |
| 149 | #ifdef CONFIG_TAU |
| 150 | extern u32 cpu_temp(unsigned long cpu); |
| 151 | extern u32 cpu_temp_both(unsigned long cpu); |
| 152 | #endif /* CONFIG_TAU */ |
| 153 | |
| 154 | int show_cpuinfo(struct seq_file *m, void *v) |
| 155 | { |
| 156 | int i = (int) v - 1; |
| 157 | int err = 0; |
| 158 | unsigned int pvr; |
| 159 | unsigned short maj, min; |
| 160 | unsigned long lpj; |
| 161 | |
| 162 | if (i >= NR_CPUS) { |
| 163 | /* Show summary information */ |
| 164 | #ifdef CONFIG_SMP |
| 165 | unsigned long bogosum = 0; |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 166 | for_each_online_cpu(i) |
| 167 | bogosum += cpu_data[i].loops_per_jiffy; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", |
| 169 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); |
| 170 | #endif /* CONFIG_SMP */ |
| 171 | |
| 172 | if (ppc_md.show_cpuinfo != NULL) |
| 173 | err = ppc_md.show_cpuinfo(m); |
| 174 | return err; |
| 175 | } |
| 176 | |
| 177 | #ifdef CONFIG_SMP |
| 178 | if (!cpu_online(i)) |
| 179 | return 0; |
| 180 | pvr = cpu_data[i].pvr; |
| 181 | lpj = cpu_data[i].loops_per_jiffy; |
| 182 | #else |
| 183 | pvr = mfspr(SPRN_PVR); |
| 184 | lpj = loops_per_jiffy; |
| 185 | #endif |
| 186 | |
| 187 | seq_printf(m, "processor\t: %d\n", i); |
| 188 | seq_printf(m, "cpu\t\t: "); |
| 189 | |
Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 190 | if (cur_cpu_spec->pvr_mask) |
| 191 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | else |
| 193 | seq_printf(m, "unknown (%08x)", pvr); |
| 194 | #ifdef CONFIG_ALTIVEC |
Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 195 | if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | seq_printf(m, ", altivec supported"); |
| 197 | #endif |
| 198 | seq_printf(m, "\n"); |
| 199 | |
| 200 | #ifdef CONFIG_TAU |
Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 201 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | #ifdef CONFIG_TAU_AVERAGE |
| 203 | /* more straightforward, but potentially misleading */ |
| 204 | seq_printf(m, "temperature \t: %u C (uncalibrated)\n", |
| 205 | cpu_temp(i)); |
| 206 | #else |
| 207 | /* show the actual temp sensor range */ |
| 208 | u32 temp; |
| 209 | temp = cpu_temp_both(i); |
| 210 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", |
| 211 | temp & 0xff, temp >> 16); |
| 212 | #endif |
| 213 | } |
| 214 | #endif /* CONFIG_TAU */ |
| 215 | |
| 216 | if (ppc_md.show_percpuinfo != NULL) { |
| 217 | err = ppc_md.show_percpuinfo(m, i); |
| 218 | if (err) |
| 219 | return err; |
| 220 | } |
| 221 | |
Kumar Gala | 696c2b9 | 2005-05-05 16:15:10 -0700 | [diff] [blame] | 222 | /* If we are a Freescale core do a simple check so |
| 223 | * we dont have to keep adding cases in the future */ |
| 224 | if ((PVR_VER(pvr) & 0x8000) == 0x8000) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | maj = PVR_MAJ(pvr); |
| 226 | min = PVR_MIN(pvr); |
Kumar Gala | 696c2b9 | 2005-05-05 16:15:10 -0700 | [diff] [blame] | 227 | } else { |
| 228 | switch (PVR_VER(pvr)) { |
| 229 | case 0x0020: /* 403 family */ |
| 230 | maj = PVR_MAJ(pvr) + 1; |
| 231 | min = PVR_MIN(pvr); |
| 232 | break; |
| 233 | case 0x1008: /* 740P/750P ?? */ |
| 234 | maj = ((pvr >> 8) & 0xFF) - 1; |
| 235 | min = pvr & 0xFF; |
| 236 | break; |
| 237 | default: |
| 238 | maj = (pvr >> 8) & 0xFF; |
| 239 | min = pvr & 0xFF; |
| 240 | break; |
| 241 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", |
| 245 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); |
| 246 | |
| 247 | seq_printf(m, "bogomips\t: %lu.%02lu\n", |
| 248 | lpj / (500000/HZ), (lpj / (5000/HZ)) % 100); |
| 249 | |
Kumar Gala | 8e8fff0 | 2005-09-03 15:55:34 -0700 | [diff] [blame] | 250 | #if USES_PPC_SYS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | if (cur_ppc_sys_spec->ppc_sys_name) |
| 252 | seq_printf(m, "chipset\t\t: %s\n", |
| 253 | cur_ppc_sys_spec->ppc_sys_name); |
| 254 | #endif |
| 255 | |
| 256 | #ifdef CONFIG_SMP |
| 257 | seq_printf(m, "\n"); |
| 258 | #endif |
| 259 | |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 264 | { |
| 265 | int i = *pos; |
| 266 | |
| 267 | return i <= NR_CPUS? (void *) (i + 1): NULL; |
| 268 | } |
| 269 | |
| 270 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 271 | { |
| 272 | ++*pos; |
| 273 | return c_start(m, pos); |
| 274 | } |
| 275 | |
| 276 | static void c_stop(struct seq_file *m, void *v) |
| 277 | { |
| 278 | } |
| 279 | |
| 280 | struct seq_operations cpuinfo_op = { |
| 281 | .start =c_start, |
| 282 | .next = c_next, |
| 283 | .stop = c_stop, |
| 284 | .show = show_cpuinfo, |
| 285 | }; |
| 286 | |
| 287 | /* |
| 288 | * We're called here very early in the boot. We determine the machine |
| 289 | * type and call the appropriate low-level setup functions. |
| 290 | * -- Cort <cort@fsmlabs.com> |
| 291 | * |
| 292 | * Note that the kernel may be running at an address which is different |
| 293 | * from the address that it was linked at, so we must use RELOC/PTRRELOC |
| 294 | * to access static data (including strings). -- paulus |
| 295 | */ |
| 296 | __init |
| 297 | unsigned long |
| 298 | early_init(int r3, int r4, int r5) |
| 299 | { |
| 300 | unsigned long phys; |
| 301 | unsigned long offset = reloc_offset(); |
| 302 | |
| 303 | /* Default */ |
| 304 | phys = offset + KERNELBASE; |
| 305 | |
| 306 | /* First zero the BSS -- use memset, some arches don't have |
| 307 | * caches on yet */ |
| 308 | memset_io(PTRRELOC(&__bss_start), 0, _end - __bss_start); |
| 309 | |
| 310 | /* |
| 311 | * Identify the CPU type and fix up code sections |
| 312 | * that depend on which cpu we have. |
| 313 | */ |
| 314 | identify_cpu(offset, 0); |
| 315 | do_cpu_ftr_fixups(offset); |
| 316 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | return phys; |
| 318 | } |
| 319 | |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 320 | #ifdef CONFIG_PPC_PREP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | /* |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 322 | * The PPC_PREP version of platform_init... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | */ |
| 324 | void __init |
| 325 | platform_init(unsigned long r3, unsigned long r4, unsigned long r5, |
| 326 | unsigned long r6, unsigned long r7) |
| 327 | { |
| 328 | #ifdef CONFIG_BOOTX_TEXT |
| 329 | if (boot_text_mapped) { |
| 330 | btext_clearscreen(); |
| 331 | btext_welcome(); |
| 332 | } |
| 333 | #endif |
| 334 | |
| 335 | parse_bootinfo(find_bootinfo()); |
| 336 | |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 337 | prep_init(r3, r4, r5, r6, r7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | } |
Paul Mackerras | 0a26b13 | 2006-03-28 10:22:10 +1100 | [diff] [blame] | 339 | #endif /* CONFIG_PPC_PREP */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
| 341 | struct bi_record *find_bootinfo(void) |
| 342 | { |
| 343 | struct bi_record *rec; |
| 344 | |
| 345 | rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20)); |
| 346 | if ( rec->tag != BI_FIRST ) { |
| 347 | /* |
| 348 | * This 0x10000 offset is a terrible hack but it will go away when |
| 349 | * we have the bootloader handle all the relocation and |
| 350 | * prom calls -- Cort |
| 351 | */ |
| 352 | rec = (struct bi_record *)_ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20)); |
| 353 | if ( rec->tag != BI_FIRST ) |
| 354 | return NULL; |
| 355 | } |
| 356 | return rec; |
| 357 | } |
| 358 | |
| 359 | void parse_bootinfo(struct bi_record *rec) |
| 360 | { |
| 361 | if (rec == NULL || rec->tag != BI_FIRST) |
| 362 | return; |
| 363 | while (rec->tag != BI_LAST) { |
| 364 | ulong *data = rec->data; |
| 365 | switch (rec->tag) { |
| 366 | case BI_CMD_LINE: |
| 367 | strlcpy(cmd_line, (void *)data, sizeof(cmd_line)); |
| 368 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | #ifdef CONFIG_BLK_DEV_INITRD |
| 370 | case BI_INITRD: |
| 371 | initrd_start = data[0] + KERNELBASE; |
| 372 | initrd_end = data[0] + data[1] + KERNELBASE; |
| 373 | break; |
| 374 | #endif /* CONFIG_BLK_DEV_INITRD */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | case BI_MEMSIZE: |
| 376 | boot_mem_size = data[0]; |
| 377 | break; |
| 378 | } |
| 379 | rec = (struct bi_record *)((ulong)rec + rec->size); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | /* |
| 384 | * Find out what kind of machine we're on and save any data we need |
| 385 | * from the early boot process (devtree is copied on pmac by prom_init()). |
| 386 | * This is called very early on the boot process, after a minimal |
| 387 | * MMU environment has been set up but before MMU_init is called. |
| 388 | */ |
| 389 | void __init |
| 390 | machine_init(unsigned long r3, unsigned long r4, unsigned long r5, |
| 391 | unsigned long r6, unsigned long r7) |
| 392 | { |
| 393 | #ifdef CONFIG_CMDLINE |
| 394 | strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); |
| 395 | #endif /* CONFIG_CMDLINE */ |
| 396 | |
| 397 | #ifdef CONFIG_6xx |
| 398 | ppc_md.power_save = ppc6xx_idle; |
| 399 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | |
| 401 | platform_init(r3, r4, r5, r6, r7); |
| 402 | |
| 403 | if (ppc_md.progress) |
| 404 | ppc_md.progress("id mach(): done", 0x200); |
| 405 | } |
Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 406 | #ifdef CONFIG_BOOKE_WDT |
| 407 | /* Checks wdt=x and wdt_period=xx command-line option */ |
| 408 | int __init early_parse_wdt(char *p) |
| 409 | { |
Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 410 | if (p && strncmp(p, "0", 1) != 0) |
Kumar Gala | 39cdc4b | 2005-09-03 15:55:39 -0700 | [diff] [blame] | 411 | booke_wdt_enabled = 1; |
Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 412 | |
| 413 | return 0; |
| 414 | } |
| 415 | early_param("wdt", early_parse_wdt); |
| 416 | |
| 417 | int __init early_parse_wdt_period (char *p) |
| 418 | { |
Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 419 | if (p) |
Kumar Gala | 39cdc4b | 2005-09-03 15:55:39 -0700 | [diff] [blame] | 420 | booke_wdt_period = simple_strtoul(p, NULL, 0); |
Kumar Gala | a2f40cc | 2005-09-03 15:55:33 -0700 | [diff] [blame] | 421 | |
| 422 | return 0; |
| 423 | } |
| 424 | early_param("wdt_period", early_parse_wdt_period); |
| 425 | #endif /* CONFIG_BOOKE_WDT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
| 427 | /* Checks "l2cr=xxxx" command-line option */ |
| 428 | int __init ppc_setup_l2cr(char *str) |
| 429 | { |
| 430 | if (cpu_has_feature(CPU_FTR_L2CR)) { |
| 431 | unsigned long val = simple_strtoul(str, NULL, 0); |
| 432 | printk(KERN_INFO "l2cr set to %lx\n", val); |
| 433 | _set_L2CR(0); /* force invalidate by disable cache */ |
| 434 | _set_L2CR(val); /* and enable it */ |
| 435 | } |
| 436 | return 1; |
| 437 | } |
| 438 | __setup("l2cr=", ppc_setup_l2cr); |
| 439 | |
| 440 | #ifdef CONFIG_GENERIC_NVRAM |
| 441 | |
| 442 | /* Generic nvram hooks used by drivers/char/gen_nvram.c */ |
| 443 | unsigned char nvram_read_byte(int addr) |
| 444 | { |
| 445 | if (ppc_md.nvram_read_val) |
| 446 | return ppc_md.nvram_read_val(addr); |
| 447 | return 0xff; |
| 448 | } |
| 449 | EXPORT_SYMBOL(nvram_read_byte); |
| 450 | |
| 451 | void nvram_write_byte(unsigned char val, int addr) |
| 452 | { |
| 453 | if (ppc_md.nvram_write_val) |
| 454 | ppc_md.nvram_write_val(addr, val); |
| 455 | } |
| 456 | EXPORT_SYMBOL(nvram_write_byte); |
| 457 | |
| 458 | void nvram_sync(void) |
| 459 | { |
| 460 | if (ppc_md.nvram_sync) |
| 461 | ppc_md.nvram_sync(); |
| 462 | } |
| 463 | EXPORT_SYMBOL(nvram_sync); |
| 464 | |
| 465 | #endif /* CONFIG_NVRAM */ |
| 466 | |
| 467 | static struct cpu cpu_devices[NR_CPUS]; |
| 468 | |
| 469 | int __init ppc_init(void) |
| 470 | { |
| 471 | int i; |
| 472 | |
| 473 | /* clear the progress line */ |
| 474 | if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff); |
| 475 | |
| 476 | /* register CPU devices */ |
KAMEZAWA Hiroyuki | b848e0a | 2006-03-28 14:50:52 -0800 | [diff] [blame^] | 477 | for_each_possible_cpu(i) |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 478 | register_cpu(&cpu_devices[i], i, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | |
| 480 | /* call platform init */ |
| 481 | if (ppc_md.init != NULL) { |
| 482 | ppc_md.init(); |
| 483 | } |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | arch_initcall(ppc_init); |
| 488 | |
| 489 | /* Warning, IO base is not yet inited */ |
| 490 | void __init setup_arch(char **cmdline_p) |
| 491 | { |
| 492 | extern char *klimit; |
| 493 | extern void do_init_bootmem(void); |
| 494 | |
| 495 | /* so udelay does something sensible, assume <= 1000 bogomips */ |
| 496 | loops_per_jiffy = 500000000 / HZ; |
| 497 | |
Benjamin Herrenschmidt | 51d3082 | 2005-11-23 17:57:25 +1100 | [diff] [blame] | 498 | if (ppc_md.init_early) |
| 499 | ppc_md.init_early(); |
| 500 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | #ifdef CONFIG_XMON |
Paul Mackerras | fd582ec | 2005-10-11 22:08:12 +1000 | [diff] [blame] | 502 | xmon_init(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | if (strstr(cmd_line, "xmon")) |
| 504 | xmon(NULL); |
| 505 | #endif /* CONFIG_XMON */ |
| 506 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: enter", 0x3eab); |
| 507 | |
| 508 | #if defined(CONFIG_KGDB) |
| 509 | if (ppc_md.kgdb_map_scc) |
| 510 | ppc_md.kgdb_map_scc(); |
| 511 | set_debug_traps(); |
| 512 | if (strstr(cmd_line, "gdb")) { |
| 513 | if (ppc_md.progress) |
| 514 | ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000); |
| 515 | printk("kgdb breakpoint activated\n"); |
| 516 | breakpoint(); |
| 517 | } |
| 518 | #endif |
| 519 | |
| 520 | /* |
| 521 | * Set cache line size based on type of cpu as a default. |
| 522 | * Systems with OF can look in the properties on the cpu node(s) |
| 523 | * for a possibly more accurate value. |
| 524 | */ |
| 525 | if (cpu_has_feature(CPU_FTR_SPLIT_ID_CACHE)) { |
Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 526 | dcache_bsize = cur_cpu_spec->dcache_bsize; |
| 527 | icache_bsize = cur_cpu_spec->icache_bsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | ucache_bsize = 0; |
| 529 | } else |
| 530 | ucache_bsize = dcache_bsize = icache_bsize |
Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 531 | = cur_cpu_spec->dcache_bsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | |
| 533 | /* reboot on panic */ |
| 534 | panic_timeout = 180; |
| 535 | |
| 536 | init_mm.start_code = PAGE_OFFSET; |
| 537 | init_mm.end_code = (unsigned long) _etext; |
| 538 | init_mm.end_data = (unsigned long) _edata; |
| 539 | init_mm.brk = (unsigned long) klimit; |
| 540 | |
| 541 | /* Save unparsed command line copy for /proc/cmdline */ |
| 542 | strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE); |
| 543 | *cmdline_p = cmd_line; |
| 544 | |
Paul Mackerras | 19bbdf0 | 2005-05-17 16:48:39 +1000 | [diff] [blame] | 545 | parse_early_param(); |
| 546 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | /* set up the bootmem stuff with available memory */ |
| 548 | do_init_bootmem(); |
| 549 | if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); |
| 550 | |
| 551 | #ifdef CONFIG_PPC_OCP |
| 552 | /* Initialize OCP device list */ |
| 553 | ocp_early_init(); |
| 554 | if ( ppc_md.progress ) ppc_md.progress("ocp: exit", 0x3eab); |
| 555 | #endif |
| 556 | |
| 557 | #ifdef CONFIG_DUMMY_CONSOLE |
| 558 | conswitchp = &dummy_con; |
| 559 | #endif |
| 560 | |
| 561 | ppc_md.setup_arch(); |
| 562 | if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); |
| 563 | |
| 564 | paging_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | } |