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