Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Common boot and setup code for both 32-bit and 64-bit. |
| 3 | * Extracted from arch/powerpc/kernel/setup_64.c. |
| 4 | * |
| 5 | * Copyright (C) 2001 PPC64 Team, IBM Corp |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the License, or (at your option) any later version. |
| 11 | */ |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 12 | |
| 13 | #undef DEBUG |
| 14 | |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 15 | #include <linux/module.h> |
| 16 | #include <linux/string.h> |
| 17 | #include <linux/sched.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/reboot.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/initrd.h> |
Michael Neuling | e5c6c8e | 2006-03-14 00:11:50 -0500 | [diff] [blame] | 23 | #include <linux/platform_device.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 24 | #include <linux/seq_file.h> |
| 25 | #include <linux/ioport.h> |
| 26 | #include <linux/console.h> |
| 27 | #include <linux/utsname.h> |
Jon Smirl | 894673e | 2006-07-10 04:44:13 -0700 | [diff] [blame] | 28 | #include <linux/screen_info.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 29 | #include <linux/root_dev.h> |
| 30 | #include <linux/notifier.h> |
| 31 | #include <linux/cpu.h> |
| 32 | #include <linux/unistd.h> |
| 33 | #include <linux/serial.h> |
| 34 | #include <linux/serial_8250.h> |
Michael Ellerman | 94a3807 | 2007-06-20 10:54:19 +1000 | [diff] [blame] | 35 | #include <linux/debugfs.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 36 | #include <asm/io.h> |
| 37 | #include <asm/prom.h> |
| 38 | #include <asm/processor.h> |
Benjamin Herrenschmidt | a7f290d | 2005-11-11 21:15:21 +1100 | [diff] [blame] | 39 | #include <asm/vdso_datapage.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 40 | #include <asm/pgtable.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 41 | #include <asm/smp.h> |
| 42 | #include <asm/elf.h> |
| 43 | #include <asm/machdep.h> |
| 44 | #include <asm/time.h> |
| 45 | #include <asm/cputable.h> |
| 46 | #include <asm/sections.h> |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 47 | #include <asm/firmware.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 48 | #include <asm/btext.h> |
| 49 | #include <asm/nvram.h> |
| 50 | #include <asm/setup.h> |
| 51 | #include <asm/system.h> |
| 52 | #include <asm/rtas.h> |
| 53 | #include <asm/iommu.h> |
| 54 | #include <asm/serial.h> |
| 55 | #include <asm/cache.h> |
| 56 | #include <asm/page.h> |
| 57 | #include <asm/mmu.h> |
| 58 | #include <asm/lmb.h> |
Paul Mackerras | fca5dcd | 2005-11-08 22:55:08 +1100 | [diff] [blame] | 59 | #include <asm/xmon.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 60 | |
Stephen Rothwell | 66ba135 | 2005-11-09 11:01:06 +1100 | [diff] [blame] | 61 | #include "setup.h" |
| 62 | |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 63 | #ifdef DEBUG |
Michael Ellerman | f9e4ec5 | 2005-11-15 15:16:38 +1100 | [diff] [blame] | 64 | #include <asm/udbg.h> |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 65 | #define DBG(fmt...) udbg_printf(fmt) |
| 66 | #else |
| 67 | #define DBG(fmt...) |
| 68 | #endif |
| 69 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 70 | /* The main machine-dep calls structure |
| 71 | */ |
| 72 | struct machdep_calls ppc_md; |
| 73 | EXPORT_SYMBOL(ppc_md); |
| 74 | struct machdep_calls *machine_id; |
| 75 | EXPORT_SYMBOL(machine_id); |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 76 | |
Paul Mackerras | 49b0985 | 2005-11-10 15:53:40 +1100 | [diff] [blame] | 77 | unsigned long klimit = (unsigned long) _end; |
| 78 | |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 79 | /* |
| 80 | * This still seems to be needed... -- paulus |
| 81 | */ |
| 82 | struct screen_info screen_info = { |
| 83 | .orig_x = 0, |
| 84 | .orig_y = 25, |
| 85 | .orig_video_cols = 80, |
| 86 | .orig_video_lines = 25, |
| 87 | .orig_video_isVGA = 1, |
| 88 | .orig_video_points = 16 |
| 89 | }; |
| 90 | |
| 91 | #ifdef __DO_IRQ_CANON |
| 92 | /* XXX should go elsewhere eventually */ |
| 93 | int ppc_do_canonicalize_irqs; |
| 94 | EXPORT_SYMBOL(ppc_do_canonicalize_irqs); |
| 95 | #endif |
| 96 | |
| 97 | /* also used by kexec */ |
| 98 | void machine_shutdown(void) |
| 99 | { |
Michael Ellerman | 3d1229d | 2005-11-14 23:35:00 +1100 | [diff] [blame] | 100 | if (ppc_md.machine_shutdown) |
| 101 | ppc_md.machine_shutdown(); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | void machine_restart(char *cmd) |
| 105 | { |
| 106 | machine_shutdown(); |
Kumar Gala | b8e383d | 2006-01-13 10:15:17 -0600 | [diff] [blame] | 107 | if (ppc_md.restart) |
| 108 | ppc_md.restart(cmd); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 109 | #ifdef CONFIG_SMP |
| 110 | smp_send_stop(); |
| 111 | #endif |
| 112 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); |
| 113 | local_irq_disable(); |
| 114 | while (1) ; |
| 115 | } |
| 116 | |
| 117 | void machine_power_off(void) |
| 118 | { |
| 119 | machine_shutdown(); |
Kumar Gala | b8e383d | 2006-01-13 10:15:17 -0600 | [diff] [blame] | 120 | if (ppc_md.power_off) |
| 121 | ppc_md.power_off(); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 122 | #ifdef CONFIG_SMP |
| 123 | smp_send_stop(); |
| 124 | #endif |
| 125 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); |
| 126 | local_irq_disable(); |
| 127 | while (1) ; |
| 128 | } |
| 129 | /* Used by the G5 thermal driver */ |
| 130 | EXPORT_SYMBOL_GPL(machine_power_off); |
| 131 | |
| 132 | void (*pm_power_off)(void) = machine_power_off; |
| 133 | EXPORT_SYMBOL_GPL(pm_power_off); |
| 134 | |
| 135 | void machine_halt(void) |
| 136 | { |
| 137 | machine_shutdown(); |
Kumar Gala | b8e383d | 2006-01-13 10:15:17 -0600 | [diff] [blame] | 138 | if (ppc_md.halt) |
| 139 | ppc_md.halt(); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 140 | #ifdef CONFIG_SMP |
| 141 | smp_send_stop(); |
| 142 | #endif |
| 143 | printk(KERN_EMERG "System Halted, OK to turn off power\n"); |
| 144 | local_irq_disable(); |
| 145 | while (1) ; |
| 146 | } |
| 147 | |
| 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 | #ifdef CONFIG_SMP |
| 155 | DEFINE_PER_CPU(unsigned int, pvr); |
| 156 | #endif |
| 157 | |
| 158 | static int show_cpuinfo(struct seq_file *m, void *v) |
| 159 | { |
| 160 | unsigned long cpu_id = (unsigned long)v - 1; |
| 161 | unsigned int pvr; |
| 162 | unsigned short maj; |
| 163 | unsigned short min; |
| 164 | |
| 165 | if (cpu_id == NR_CPUS) { |
| 166 | #if defined(CONFIG_SMP) && defined(CONFIG_PPC32) |
| 167 | unsigned long bogosum = 0; |
| 168 | int i; |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 169 | for_each_online_cpu(i) |
| 170 | bogosum += loops_per_jiffy; |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 171 | seq_printf(m, "total bogomips\t: %lu.%02lu\n", |
| 172 | bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); |
| 173 | #endif /* CONFIG_SMP && CONFIG_PPC32 */ |
| 174 | seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq); |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 175 | if (ppc_md.name) |
| 176 | seq_printf(m, "platform\t: %s\n", ppc_md.name); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 177 | if (ppc_md.show_cpuinfo != NULL) |
| 178 | ppc_md.show_cpuinfo(m); |
| 179 | |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | /* We only show online cpus: disable preempt (overzealous, I |
| 184 | * knew) to prevent cpu going down. */ |
| 185 | preempt_disable(); |
| 186 | if (!cpu_online(cpu_id)) { |
| 187 | preempt_enable(); |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | #ifdef CONFIG_SMP |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 192 | pvr = per_cpu(pvr, cpu_id); |
| 193 | #else |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 194 | pvr = mfspr(SPRN_PVR); |
| 195 | #endif |
| 196 | maj = (pvr >> 8) & 0xFF; |
| 197 | min = pvr & 0xFF; |
| 198 | |
| 199 | seq_printf(m, "processor\t: %lu\n", cpu_id); |
| 200 | seq_printf(m, "cpu\t\t: "); |
| 201 | |
| 202 | if (cur_cpu_spec->pvr_mask) |
| 203 | seq_printf(m, "%s", cur_cpu_spec->cpu_name); |
| 204 | else |
| 205 | seq_printf(m, "unknown (%08x)", pvr); |
| 206 | |
| 207 | #ifdef CONFIG_ALTIVEC |
| 208 | if (cpu_has_feature(CPU_FTR_ALTIVEC)) |
| 209 | seq_printf(m, ", altivec supported"); |
| 210 | #endif /* CONFIG_ALTIVEC */ |
| 211 | |
| 212 | seq_printf(m, "\n"); |
| 213 | |
| 214 | #ifdef CONFIG_TAU |
| 215 | if (cur_cpu_spec->cpu_features & CPU_FTR_TAU) { |
| 216 | #ifdef CONFIG_TAU_AVERAGE |
| 217 | /* more straightforward, but potentially misleading */ |
| 218 | seq_printf(m, "temperature \t: %u C (uncalibrated)\n", |
Paul Mackerras | bccfd58 | 2005-11-02 15:06:22 +1100 | [diff] [blame] | 219 | cpu_temp(cpu_id)); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 220 | #else |
| 221 | /* show the actual temp sensor range */ |
| 222 | u32 temp; |
Paul Mackerras | bccfd58 | 2005-11-02 15:06:22 +1100 | [diff] [blame] | 223 | temp = cpu_temp_both(cpu_id); |
Paul Mackerras | 03501da | 2005-10-26 17:11:18 +1000 | [diff] [blame] | 224 | seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", |
| 225 | temp & 0xff, temp >> 16); |
| 226 | #endif |
| 227 | } |
| 228 | #endif /* CONFIG_TAU */ |
| 229 | |
| 230 | /* |
| 231 | * Assume here that all clock rates are the same in a |
| 232 | * smp system. -- Cort |
| 233 | */ |
| 234 | if (ppc_proc_freq) |
| 235 | seq_printf(m, "clock\t\t: %lu.%06luMHz\n", |
| 236 | ppc_proc_freq / 1000000, ppc_proc_freq % 1000000); |
| 237 | |
| 238 | if (ppc_md.show_percpuinfo != NULL) |
| 239 | ppc_md.show_percpuinfo(m, cpu_id); |
| 240 | |
| 241 | /* If we are a Freescale core do a simple check so |
| 242 | * we dont have to keep adding cases in the future */ |
| 243 | if (PVR_VER(pvr) & 0x8000) { |
| 244 | maj = PVR_MAJ(pvr); |
| 245 | min = PVR_MIN(pvr); |
| 246 | } else { |
| 247 | switch (PVR_VER(pvr)) { |
| 248 | case 0x0020: /* 403 family */ |
| 249 | maj = PVR_MAJ(pvr) + 1; |
| 250 | min = PVR_MIN(pvr); |
| 251 | break; |
| 252 | case 0x1008: /* 740P/750P ?? */ |
| 253 | maj = ((pvr >> 8) & 0xFF) - 1; |
| 254 | min = pvr & 0xFF; |
| 255 | break; |
| 256 | default: |
| 257 | maj = (pvr >> 8) & 0xFF; |
| 258 | min = pvr & 0xFF; |
| 259 | break; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", |
| 264 | maj, min, PVR_VER(pvr), PVR_REV(pvr)); |
| 265 | |
| 266 | #ifdef CONFIG_PPC32 |
| 267 | seq_printf(m, "bogomips\t: %lu.%02lu\n", |
| 268 | loops_per_jiffy / (500000/HZ), |
| 269 | (loops_per_jiffy / (5000/HZ)) % 100); |
| 270 | #endif |
| 271 | |
| 272 | #ifdef CONFIG_SMP |
| 273 | seq_printf(m, "\n"); |
| 274 | #endif |
| 275 | |
| 276 | preempt_enable(); |
| 277 | return 0; |
| 278 | } |
| 279 | |
| 280 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 281 | { |
| 282 | unsigned long i = *pos; |
| 283 | |
| 284 | return i <= NR_CPUS ? (void *)(i + 1) : NULL; |
| 285 | } |
| 286 | |
| 287 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 288 | { |
| 289 | ++*pos; |
| 290 | return c_start(m, pos); |
| 291 | } |
| 292 | |
| 293 | static void c_stop(struct seq_file *m, void *v) |
| 294 | { |
| 295 | } |
| 296 | |
| 297 | struct seq_operations cpuinfo_op = { |
| 298 | .start =c_start, |
| 299 | .next = c_next, |
| 300 | .stop = c_stop, |
| 301 | .show = show_cpuinfo, |
| 302 | }; |
| 303 | |
David Woodhouse | a82765b | 2005-11-02 22:34:20 +0000 | [diff] [blame] | 304 | void __init check_for_initrd(void) |
| 305 | { |
| 306 | #ifdef CONFIG_BLK_DEV_INITRD |
David Gibson | 30437b3 | 2007-02-28 14:12:29 +1100 | [diff] [blame] | 307 | DBG(" -> check_for_initrd() initrd_start=0x%lx initrd_end=0x%lx\n", |
| 308 | initrd_start, initrd_end); |
David Woodhouse | a82765b | 2005-11-02 22:34:20 +0000 | [diff] [blame] | 309 | |
| 310 | /* If we were passed an initrd, set the ROOT_DEV properly if the values |
| 311 | * look sensible. If not, clear initrd reference. |
| 312 | */ |
Michael Ellerman | 51fae6de | 2005-12-04 18:39:15 +1100 | [diff] [blame] | 313 | if (is_kernel_addr(initrd_start) && is_kernel_addr(initrd_end) && |
David Woodhouse | a82765b | 2005-11-02 22:34:20 +0000 | [diff] [blame] | 314 | initrd_end > initrd_start) |
| 315 | ROOT_DEV = Root_RAM0; |
David Woodhouse | 6761c4a | 2005-11-11 08:07:11 +0000 | [diff] [blame] | 316 | else |
David Woodhouse | a82765b | 2005-11-02 22:34:20 +0000 | [diff] [blame] | 317 | initrd_start = initrd_end = 0; |
David Woodhouse | a82765b | 2005-11-02 22:34:20 +0000 | [diff] [blame] | 318 | |
| 319 | if (initrd_start) |
| 320 | printk("Found initrd at 0x%lx:0x%lx\n", initrd_start, initrd_end); |
| 321 | |
| 322 | DBG(" <- check_for_initrd()\n"); |
| 323 | #endif /* CONFIG_BLK_DEV_INITRD */ |
| 324 | } |
| 325 | |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 326 | #ifdef CONFIG_SMP |
| 327 | |
| 328 | /** |
| 329 | * setup_cpu_maps - initialize the following cpu maps: |
| 330 | * cpu_possible_map |
| 331 | * cpu_present_map |
| 332 | * cpu_sibling_map |
| 333 | * |
| 334 | * Having the possible map set up early allows us to restrict allocations |
| 335 | * of things like irqstacks to num_possible_cpus() rather than NR_CPUS. |
| 336 | * |
| 337 | * We do not initialize the online map here; cpus set their own bits in |
| 338 | * cpu_online_map as they come up. |
| 339 | * |
| 340 | * This function is valid only for Open Firmware systems. finish_device_tree |
| 341 | * must be called before using this. |
| 342 | * |
| 343 | * While we're here, we may as well set the "physical" cpu ids in the paca. |
Anton Blanchard | 4df2046 | 2006-03-25 17:25:17 +1100 | [diff] [blame] | 344 | * |
| 345 | * NOTE: This must match the parsing done in early_init_dt_scan_cpus. |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 346 | */ |
| 347 | void __init smp_setup_cpu_maps(void) |
| 348 | { |
| 349 | struct device_node *dn = NULL; |
| 350 | int cpu = 0; |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 351 | |
| 352 | while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < NR_CPUS) { |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 353 | const int *intserv; |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 354 | int j, len = sizeof(u32), nthreads = 1; |
| 355 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 356 | intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", |
| 357 | &len); |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 358 | if (intserv) |
| 359 | nthreads = len / sizeof(int); |
| 360 | else { |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 361 | intserv = of_get_property(dn, "reg", NULL); |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 362 | if (!intserv) |
| 363 | intserv = &cpu; /* assume logical == phys */ |
| 364 | } |
| 365 | |
| 366 | for (j = 0; j < nthreads && cpu < NR_CPUS; j++) { |
| 367 | cpu_set(cpu, cpu_present_map); |
| 368 | set_hard_smp_processor_id(cpu, intserv[j]); |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 369 | cpu_set(cpu, cpu_possible_map); |
| 370 | cpu++; |
| 371 | } |
| 372 | } |
| 373 | |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 374 | #ifdef CONFIG_PPC64 |
| 375 | /* |
| 376 | * On pSeries LPAR, we need to know how many cpus |
| 377 | * could possibly be added to this partition. |
| 378 | */ |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 379 | if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) && |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 380 | (dn = of_find_node_by_path("/rtas"))) { |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 381 | int num_addr_cell, num_size_cell, maxcpus; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 382 | const unsigned int *ireg; |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 383 | |
Stephen Rothwell | a8bda5d | 2007-04-03 10:56:50 +1000 | [diff] [blame] | 384 | num_addr_cell = of_n_addr_cells(dn); |
Stephen Rothwell | 9213fee | 2007-04-03 10:57:48 +1000 | [diff] [blame] | 385 | num_size_cell = of_n_size_cells(dn); |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 386 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 387 | ireg = of_get_property(dn, "ibm,lrdr-capacity", NULL); |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 388 | |
| 389 | if (!ireg) |
| 390 | goto out; |
| 391 | |
| 392 | maxcpus = ireg[num_addr_cell + num_size_cell]; |
| 393 | |
| 394 | /* Double maxcpus for processors which have SMT capability */ |
| 395 | if (cpu_has_feature(CPU_FTR_SMT)) |
| 396 | maxcpus *= 2; |
| 397 | |
| 398 | if (maxcpus > NR_CPUS) { |
| 399 | printk(KERN_WARNING |
| 400 | "Partition configured for %d cpus, " |
| 401 | "operating system maximum is %d.\n", |
| 402 | maxcpus, NR_CPUS); |
| 403 | maxcpus = NR_CPUS; |
| 404 | } else |
| 405 | printk(KERN_INFO "Partition configured for %d cpus.\n", |
| 406 | maxcpus); |
| 407 | |
| 408 | for (cpu = 0; cpu < maxcpus; cpu++) |
| 409 | cpu_set(cpu, cpu_possible_map); |
| 410 | out: |
| 411 | of_node_put(dn); |
| 412 | } |
| 413 | |
| 414 | /* |
| 415 | * Do the sibling map; assume only two threads per processor. |
| 416 | */ |
KAMEZAWA Hiroyuki | 0e55195 | 2006-03-28 14:50:51 -0800 | [diff] [blame] | 417 | for_each_possible_cpu(cpu) { |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 418 | cpu_set(cpu, cpu_sibling_map[cpu]); |
| 419 | if (cpu_has_feature(CPU_FTR_SMT)) |
| 420 | cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]); |
| 421 | } |
| 422 | |
Benjamin Herrenschmidt | a7f290d | 2005-11-11 21:15:21 +1100 | [diff] [blame] | 423 | vdso_data->processorCount = num_present_cpus(); |
Paul Mackerras | 5ad5707 | 2005-11-05 10:33:55 +1100 | [diff] [blame] | 424 | #endif /* CONFIG_PPC64 */ |
| 425 | } |
| 426 | #endif /* CONFIG_SMP */ |
Paul Mackerras | fca5dcd | 2005-11-08 22:55:08 +1100 | [diff] [blame] | 427 | |
Michael Neuling | e5c6c8e | 2006-03-14 00:11:50 -0500 | [diff] [blame] | 428 | static __init int add_pcspkr(void) |
| 429 | { |
| 430 | struct device_node *np; |
| 431 | struct platform_device *pd; |
| 432 | int ret; |
| 433 | |
| 434 | np = of_find_compatible_node(NULL, NULL, "pnpPNP,100"); |
| 435 | of_node_put(np); |
| 436 | if (!np) |
| 437 | return -ENODEV; |
| 438 | |
| 439 | pd = platform_device_alloc("pcspkr", -1); |
| 440 | if (!pd) |
| 441 | return -ENOMEM; |
| 442 | |
| 443 | ret = platform_device_add(pd); |
| 444 | if (ret) |
| 445 | platform_device_put(pd); |
| 446 | |
| 447 | return ret; |
| 448 | } |
| 449 | device_initcall(add_pcspkr); |
Dmitry Torokhov | 95d465f | 2006-04-02 00:08:05 -0500 | [diff] [blame] | 450 | |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 451 | void probe_machine(void) |
| 452 | { |
| 453 | extern struct machdep_calls __machine_desc_start; |
| 454 | extern struct machdep_calls __machine_desc_end; |
| 455 | |
| 456 | /* |
| 457 | * Iterate all ppc_md structures until we find the proper |
| 458 | * one for the current machine type |
| 459 | */ |
| 460 | DBG("Probing machine type ...\n"); |
| 461 | |
| 462 | for (machine_id = &__machine_desc_start; |
| 463 | machine_id < &__machine_desc_end; |
| 464 | machine_id++) { |
| 465 | DBG(" %s ...", machine_id->name); |
| 466 | memcpy(&ppc_md, machine_id, sizeof(struct machdep_calls)); |
| 467 | if (ppc_md.probe()) { |
| 468 | DBG(" match !\n"); |
| 469 | break; |
| 470 | } |
| 471 | DBG("\n"); |
| 472 | } |
| 473 | /* What can we do if we didn't find ? */ |
| 474 | if (machine_id >= &__machine_desc_end) { |
| 475 | DBG("No suitable machine found !\n"); |
| 476 | for (;;); |
| 477 | } |
| 478 | |
| 479 | printk(KERN_INFO "Using %s machine description\n", ppc_md.name); |
| 480 | } |
David Woodhouse | 1269277a | 2006-04-24 23:22:17 +0100 | [diff] [blame] | 481 | |
Olaf Hering | 8d8a024 | 2007-04-26 06:36:56 +1000 | [diff] [blame] | 482 | /* Match a class of boards, not a specific device configuration. */ |
David Woodhouse | 1269277a | 2006-04-24 23:22:17 +0100 | [diff] [blame] | 483 | int check_legacy_ioport(unsigned long base_port) |
| 484 | { |
Olaf Hering | 8d8a024 | 2007-04-26 06:36:56 +1000 | [diff] [blame] | 485 | struct device_node *parent, *np = NULL; |
| 486 | int ret = -ENODEV; |
| 487 | |
| 488 | switch(base_port) { |
| 489 | case I8042_DATA_REG: |
Wade Farnsworth | db0dbae | 2007-06-20 10:15:10 +1000 | [diff] [blame] | 490 | if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303"))) |
| 491 | np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03"); |
| 492 | if (np) { |
| 493 | parent = of_get_parent(np); |
| 494 | of_node_put(np); |
| 495 | np = parent; |
| 496 | break; |
| 497 | } |
Olaf Hering | 8d8a024 | 2007-04-26 06:36:56 +1000 | [diff] [blame] | 498 | np = of_find_node_by_type(NULL, "8042"); |
Alan Curry | f5d834f | 2007-07-25 11:28:32 +1000 | [diff] [blame] | 499 | /* Pegasos has no device_type on its 8042 node, look for the |
| 500 | * name instead */ |
| 501 | if (!np) |
| 502 | np = of_find_node_by_name(NULL, "8042"); |
Olaf Hering | 8d8a024 | 2007-04-26 06:36:56 +1000 | [diff] [blame] | 503 | break; |
| 504 | case FDC_BASE: /* FDC1 */ |
| 505 | np = of_find_node_by_type(NULL, "fdc"); |
| 506 | break; |
| 507 | #ifdef CONFIG_PPC_PREP |
| 508 | case _PIDXR: |
| 509 | case _PNPWRP: |
| 510 | case PNPBIOS_BASE: |
| 511 | /* implement me */ |
| 512 | #endif |
| 513 | default: |
| 514 | /* ipmi is supposed to fail here */ |
| 515 | break; |
| 516 | } |
| 517 | if (!np) |
| 518 | return ret; |
| 519 | parent = of_get_parent(np); |
| 520 | if (parent) { |
| 521 | if (strcmp(parent->type, "isa") == 0) |
| 522 | ret = 0; |
| 523 | of_node_put(parent); |
| 524 | } |
| 525 | of_node_put(np); |
| 526 | return ret; |
David Woodhouse | 1269277a | 2006-04-24 23:22:17 +0100 | [diff] [blame] | 527 | } |
| 528 | EXPORT_SYMBOL(check_legacy_ioport); |
Kumar Gala | 7e99026 | 2006-05-05 00:02:08 -0500 | [diff] [blame] | 529 | |
| 530 | static int ppc_panic_event(struct notifier_block *this, |
| 531 | unsigned long event, void *ptr) |
| 532 | { |
| 533 | ppc_md.panic(ptr); /* May not return */ |
| 534 | return NOTIFY_DONE; |
| 535 | } |
| 536 | |
| 537 | static struct notifier_block ppc_panic_block = { |
| 538 | .notifier_call = ppc_panic_event, |
| 539 | .priority = INT_MIN /* may not return; must be done last */ |
| 540 | }; |
| 541 | |
| 542 | void __init setup_panic(void) |
| 543 | { |
| 544 | atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block); |
| 545 | } |
Dale Farnsworth | 06cce43 | 2007-05-12 10:57:35 +1000 | [diff] [blame] | 546 | |
| 547 | #ifdef CONFIG_CHECK_CACHE_COHERENCY |
| 548 | /* |
| 549 | * For platforms that have configurable cache-coherency. This function |
| 550 | * checks that the cache coherency setting of the kernel matches the setting |
| 551 | * left by the firmware, as indicated in the device tree. Since a mismatch |
| 552 | * will eventually result in DMA failures, we print * and error and call |
| 553 | * BUG() in that case. |
| 554 | */ |
| 555 | |
| 556 | #ifdef CONFIG_NOT_COHERENT_CACHE |
| 557 | #define KERNEL_COHERENCY 0 |
| 558 | #else |
| 559 | #define KERNEL_COHERENCY 1 |
| 560 | #endif |
| 561 | |
| 562 | static int __init check_cache_coherency(void) |
| 563 | { |
| 564 | struct device_node *np; |
| 565 | const void *prop; |
| 566 | int devtree_coherency; |
| 567 | |
| 568 | np = of_find_node_by_path("/"); |
| 569 | prop = of_get_property(np, "coherency-off", NULL); |
| 570 | of_node_put(np); |
| 571 | |
| 572 | devtree_coherency = prop ? 0 : 1; |
| 573 | |
| 574 | if (devtree_coherency != KERNEL_COHERENCY) { |
| 575 | printk(KERN_ERR |
| 576 | "kernel coherency:%s != device tree_coherency:%s\n", |
| 577 | KERNEL_COHERENCY ? "on" : "off", |
| 578 | devtree_coherency ? "on" : "off"); |
| 579 | BUG(); |
| 580 | } |
| 581 | |
| 582 | return 0; |
| 583 | } |
| 584 | |
| 585 | late_initcall(check_cache_coherency); |
| 586 | #endif /* CONFIG_CHECK_CACHE_COHERENCY */ |
Michael Ellerman | 94a3807 | 2007-06-20 10:54:19 +1000 | [diff] [blame] | 587 | |
| 588 | #ifdef CONFIG_DEBUG_FS |
| 589 | struct dentry *powerpc_debugfs_root; |
| 590 | |
| 591 | static int powerpc_debugfs_init(void) |
| 592 | { |
| 593 | powerpc_debugfs_root = debugfs_create_dir("powerpc", NULL); |
| 594 | |
| 595 | return powerpc_debugfs_root == NULL; |
| 596 | } |
| 597 | arch_initcall(powerpc_debugfs_init); |
| 598 | #endif |