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