Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1 | /* |
| 2 | * arch/ppc/platforms/setup.c |
| 3 | * |
| 4 | * PowerPC version |
| 5 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) |
| 6 | * |
| 7 | * Adapted for Power Macintosh by Paul Mackerras |
| 8 | * Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au) |
| 9 | * |
| 10 | * Derived from "arch/alpha/kernel/setup.c" |
| 11 | * Copyright (C) 1995 Linus Torvalds |
| 12 | * |
| 13 | * Maintained by Benjamin Herrenschmidt (benh@kernel.crashing.org) |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License |
| 17 | * as published by the Free Software Foundation; either version |
| 18 | * 2 of the License, or (at your option) any later version. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * bootup setup stuff.. |
| 24 | */ |
| 25 | |
| 26 | #include <linux/config.h> |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/errno.h> |
| 29 | #include <linux/sched.h> |
| 30 | #include <linux/kernel.h> |
| 31 | #include <linux/mm.h> |
| 32 | #include <linux/stddef.h> |
| 33 | #include <linux/unistd.h> |
| 34 | #include <linux/ptrace.h> |
| 35 | #include <linux/slab.h> |
| 36 | #include <linux/user.h> |
| 37 | #include <linux/a.out.h> |
| 38 | #include <linux/tty.h> |
| 39 | #include <linux/string.h> |
| 40 | #include <linux/delay.h> |
| 41 | #include <linux/ioport.h> |
| 42 | #include <linux/major.h> |
| 43 | #include <linux/initrd.h> |
| 44 | #include <linux/vt_kern.h> |
| 45 | #include <linux/console.h> |
| 46 | #include <linux/ide.h> |
| 47 | #include <linux/pci.h> |
| 48 | #include <linux/adb.h> |
| 49 | #include <linux/cuda.h> |
| 50 | #include <linux/pmu.h> |
| 51 | #include <linux/irq.h> |
| 52 | #include <linux/seq_file.h> |
| 53 | #include <linux/root_dev.h> |
| 54 | #include <linux/bitops.h> |
| 55 | #include <linux/suspend.h> |
| 56 | |
| 57 | #include <asm/reg.h> |
| 58 | #include <asm/sections.h> |
| 59 | #include <asm/prom.h> |
| 60 | #include <asm/system.h> |
| 61 | #include <asm/pgtable.h> |
| 62 | #include <asm/io.h> |
| 63 | #include <asm/pci-bridge.h> |
| 64 | #include <asm/ohare.h> |
| 65 | #include <asm/mediabay.h> |
| 66 | #include <asm/machdep.h> |
| 67 | #include <asm/dma.h> |
| 68 | #include <asm/bootx.h> |
| 69 | #include <asm/cputable.h> |
| 70 | #include <asm/btext.h> |
| 71 | #include <asm/pmac_feature.h> |
| 72 | #include <asm/time.h> |
| 73 | #include <asm/of_device.h> |
| 74 | #include <asm/mmu_context.h> |
| 75 | |
| 76 | #include "pmac_pic.h" |
| 77 | |
| 78 | #undef SHOW_GATWICK_IRQS |
| 79 | |
| 80 | extern long pmac_time_init(void); |
| 81 | extern unsigned long pmac_get_rtc_time(void); |
| 82 | extern int pmac_set_rtc_time(unsigned long nowtime); |
| 83 | extern void pmac_read_rtc_time(void); |
| 84 | extern void pmac_calibrate_decr(void); |
| 85 | extern void pmac_pcibios_fixup(void); |
| 86 | extern void pmac_find_bridges(void); |
| 87 | extern unsigned long pmac_ide_get_base(int index); |
| 88 | extern void pmac_ide_init_hwif_ports(hw_regs_t *hw, |
| 89 | unsigned long data_port, unsigned long ctrl_port, int *irq); |
| 90 | |
| 91 | extern void pmac_nvram_update(void); |
| 92 | extern unsigned char pmac_nvram_read_byte(int addr); |
| 93 | extern void pmac_nvram_write_byte(int addr, unsigned char val); |
| 94 | extern int pmac_pci_enable_device_hook(struct pci_dev *dev, int initial); |
| 95 | extern void pmac_pcibios_after_init(void); |
| 96 | extern int of_show_percpuinfo(struct seq_file *m, int i); |
| 97 | |
| 98 | unsigned char drive_info; |
| 99 | |
| 100 | int ppc_override_l2cr = 0; |
| 101 | int ppc_override_l2cr_value; |
| 102 | int has_l2cache = 0; |
| 103 | |
| 104 | static int current_root_goodness = -1; |
| 105 | |
| 106 | extern int pmac_newworld; |
| 107 | |
| 108 | #define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */ |
| 109 | |
| 110 | extern void zs_kgdb_hook(int tty_num); |
| 111 | static void ohare_init(void); |
| 112 | #ifdef CONFIG_BOOTX_TEXT |
| 113 | static void pmac_progress(char *s, unsigned short hex); |
| 114 | #endif |
| 115 | |
| 116 | sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN; |
| 117 | |
| 118 | #ifdef CONFIG_SMP |
| 119 | extern struct smp_ops_t psurge_smp_ops; |
| 120 | extern struct smp_ops_t core99_smp_ops; |
| 121 | #endif /* CONFIG_SMP */ |
| 122 | |
| 123 | static int |
| 124 | pmac_show_cpuinfo(struct seq_file *m) |
| 125 | { |
| 126 | struct device_node *np; |
| 127 | char *pp; |
| 128 | int plen; |
| 129 | int mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO, |
| 130 | NULL, PMAC_MB_INFO_MODEL, 0); |
| 131 | unsigned int mbflags = (unsigned int)pmac_call_feature(PMAC_FTR_GET_MB_INFO, |
| 132 | NULL, PMAC_MB_INFO_FLAGS, 0); |
| 133 | char* mbname; |
| 134 | |
| 135 | if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME, (int)&mbname) != 0) |
| 136 | mbname = "Unknown"; |
| 137 | |
| 138 | /* find motherboard type */ |
| 139 | seq_printf(m, "machine\t\t: "); |
| 140 | np = find_devices("device-tree"); |
| 141 | if (np != NULL) { |
| 142 | pp = (char *) get_property(np, "model", NULL); |
| 143 | if (pp != NULL) |
| 144 | seq_printf(m, "%s\n", pp); |
| 145 | else |
| 146 | seq_printf(m, "PowerMac\n"); |
| 147 | pp = (char *) get_property(np, "compatible", &plen); |
| 148 | if (pp != NULL) { |
| 149 | seq_printf(m, "motherboard\t:"); |
| 150 | while (plen > 0) { |
| 151 | int l = strlen(pp) + 1; |
| 152 | seq_printf(m, " %s", pp); |
| 153 | plen -= l; |
| 154 | pp += l; |
| 155 | } |
| 156 | seq_printf(m, "\n"); |
| 157 | } |
| 158 | } else |
| 159 | seq_printf(m, "PowerMac\n"); |
| 160 | |
| 161 | /* print parsed model */ |
| 162 | seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname); |
| 163 | seq_printf(m, "pmac flags\t: %08x\n", mbflags); |
| 164 | |
| 165 | /* find l2 cache info */ |
| 166 | np = find_devices("l2-cache"); |
| 167 | if (np == 0) |
| 168 | np = find_type_devices("cache"); |
| 169 | if (np != 0) { |
| 170 | unsigned int *ic = (unsigned int *) |
| 171 | get_property(np, "i-cache-size", NULL); |
| 172 | unsigned int *dc = (unsigned int *) |
| 173 | get_property(np, "d-cache-size", NULL); |
| 174 | seq_printf(m, "L2 cache\t:"); |
| 175 | has_l2cache = 1; |
| 176 | if (get_property(np, "cache-unified", NULL) != 0 && dc) { |
| 177 | seq_printf(m, " %dK unified", *dc / 1024); |
| 178 | } else { |
| 179 | if (ic) |
| 180 | seq_printf(m, " %dK instruction", *ic / 1024); |
| 181 | if (dc) |
| 182 | seq_printf(m, "%s %dK data", |
| 183 | (ic? " +": ""), *dc / 1024); |
| 184 | } |
| 185 | pp = get_property(np, "ram-type", NULL); |
| 186 | if (pp) |
| 187 | seq_printf(m, " %s", pp); |
| 188 | seq_printf(m, "\n"); |
| 189 | } |
| 190 | |
| 191 | /* find ram info */ |
| 192 | np = find_devices("memory"); |
| 193 | if (np != 0) { |
| 194 | int n; |
| 195 | struct reg_property *reg = (struct reg_property *) |
| 196 | get_property(np, "reg", &n); |
| 197 | |
| 198 | if (reg != 0) { |
| 199 | unsigned long total = 0; |
| 200 | |
| 201 | for (n /= sizeof(struct reg_property); n > 0; --n) |
| 202 | total += (reg++)->size; |
| 203 | seq_printf(m, "memory\t\t: %luMB\n", total >> 20); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | /* Checks "l2cr-value" property in the registry */ |
| 208 | np = find_devices("cpus"); |
| 209 | if (np == 0) |
| 210 | np = find_type_devices("cpu"); |
| 211 | if (np != 0) { |
| 212 | unsigned int *l2cr = (unsigned int *) |
| 213 | get_property(np, "l2cr-value", NULL); |
| 214 | if (l2cr != 0) { |
| 215 | seq_printf(m, "l2cr override\t: 0x%x\n", *l2cr); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | /* Indicate newworld/oldworld */ |
| 220 | seq_printf(m, "pmac-generation\t: %s\n", |
| 221 | pmac_newworld ? "NewWorld" : "OldWorld"); |
| 222 | |
| 223 | |
| 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | static int |
| 228 | pmac_show_percpuinfo(struct seq_file *m, int i) |
| 229 | { |
| 230 | #ifdef CONFIG_CPU_FREQ_PMAC |
| 231 | extern unsigned int pmac_get_one_cpufreq(int i); |
| 232 | unsigned int freq = pmac_get_one_cpufreq(i); |
| 233 | if (freq != 0) { |
| 234 | seq_printf(m, "clock\t\t: %dMHz\n", freq/1000); |
| 235 | return 0; |
| 236 | } |
| 237 | #endif /* CONFIG_CPU_FREQ_PMAC */ |
| 238 | return of_show_percpuinfo(m, i); |
| 239 | } |
| 240 | |
| 241 | static volatile u32 *sysctrl_regs; |
| 242 | |
| 243 | void __init |
| 244 | pmac_setup_arch(void) |
| 245 | { |
| 246 | struct device_node *cpu; |
| 247 | int *fp; |
| 248 | unsigned long pvr; |
| 249 | |
| 250 | pvr = PVR_VER(mfspr(SPRN_PVR)); |
| 251 | |
| 252 | /* Set loops_per_jiffy to a half-way reasonable value, |
| 253 | for use until calibrate_delay gets called. */ |
| 254 | cpu = find_type_devices("cpu"); |
| 255 | if (cpu != 0) { |
| 256 | fp = (int *) get_property(cpu, "clock-frequency", NULL); |
| 257 | if (fp != 0) { |
| 258 | if (pvr == 4 || pvr >= 8) |
| 259 | /* 604, G3, G4 etc. */ |
| 260 | loops_per_jiffy = *fp / HZ; |
| 261 | else |
| 262 | /* 601, 603, etc. */ |
| 263 | loops_per_jiffy = *fp / (2*HZ); |
| 264 | } else |
| 265 | loops_per_jiffy = 50000000 / HZ; |
| 266 | } |
| 267 | |
| 268 | /* this area has the CPU identification register |
| 269 | and some registers used by smp boards */ |
| 270 | sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000); |
| 271 | ohare_init(); |
| 272 | |
| 273 | /* Lookup PCI hosts */ |
| 274 | pmac_find_bridges(); |
| 275 | |
| 276 | /* Checks "l2cr-value" property in the registry */ |
| 277 | if (cpu_has_feature(CPU_FTR_L2CR)) { |
| 278 | struct device_node *np = find_devices("cpus"); |
| 279 | if (np == 0) |
| 280 | np = find_type_devices("cpu"); |
| 281 | if (np != 0) { |
| 282 | unsigned int *l2cr = (unsigned int *) |
| 283 | get_property(np, "l2cr-value", NULL); |
| 284 | if (l2cr != 0) { |
| 285 | ppc_override_l2cr = 1; |
| 286 | ppc_override_l2cr_value = *l2cr; |
| 287 | _set_L2CR(0); |
| 288 | _set_L2CR(ppc_override_l2cr_value); |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | if (ppc_override_l2cr) |
| 294 | printk(KERN_INFO "L2CR overriden (0x%x), backside cache is %s\n", |
| 295 | ppc_override_l2cr_value, (ppc_override_l2cr_value & 0x80000000) |
| 296 | ? "enabled" : "disabled"); |
| 297 | |
| 298 | #ifdef CONFIG_KGDB |
| 299 | zs_kgdb_hook(0); |
| 300 | #endif |
| 301 | |
| 302 | #ifdef CONFIG_ADB_CUDA |
| 303 | find_via_cuda(); |
| 304 | #else |
| 305 | if (find_devices("via-cuda")) { |
| 306 | printk("WARNING ! Your machine is Cuda based but your kernel\n"); |
| 307 | printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n"); |
| 308 | } |
| 309 | #endif |
| 310 | #ifdef CONFIG_ADB_PMU |
| 311 | find_via_pmu(); |
| 312 | #else |
| 313 | if (find_devices("via-pmu")) { |
| 314 | printk("WARNING ! Your machine is PMU based but your kernel\n"); |
| 315 | printk(" wasn't compiled with CONFIG_ADB_PMU option !\n"); |
| 316 | } |
| 317 | #endif |
| 318 | #ifdef CONFIG_NVRAM |
| 319 | pmac_nvram_init(); |
| 320 | #endif |
| 321 | #ifdef CONFIG_BLK_DEV_INITRD |
| 322 | if (initrd_start) |
| 323 | ROOT_DEV = Root_RAM0; |
| 324 | else |
| 325 | #endif |
| 326 | ROOT_DEV = DEFAULT_ROOT_DEVICE; |
| 327 | |
| 328 | #ifdef CONFIG_SMP |
| 329 | /* Check for Core99 */ |
| 330 | if (find_devices("uni-n") || find_devices("u3")) |
| 331 | ppc_md.smp_ops = &core99_smp_ops; |
| 332 | else |
| 333 | ppc_md.smp_ops = &psurge_smp_ops; |
| 334 | #endif /* CONFIG_SMP */ |
| 335 | |
| 336 | pci_create_OF_bus_map(); |
| 337 | } |
| 338 | |
| 339 | static void __init ohare_init(void) |
| 340 | { |
| 341 | /* |
| 342 | * Turn on the L2 cache. |
| 343 | * We assume that we have a PSX memory controller iff |
| 344 | * we have an ohare I/O controller. |
| 345 | */ |
| 346 | if (find_devices("ohare") != NULL) { |
| 347 | if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) { |
| 348 | if (sysctrl_regs[4] & 0x10) |
| 349 | sysctrl_regs[4] |= 0x04000020; |
| 350 | else |
| 351 | sysctrl_regs[4] |= 0x04000000; |
| 352 | if(has_l2cache) |
| 353 | printk(KERN_INFO "Level 2 cache enabled\n"); |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | extern char *bootpath; |
| 359 | extern char *bootdevice; |
| 360 | void *boot_host; |
| 361 | int boot_target; |
| 362 | int boot_part; |
| 363 | extern dev_t boot_dev; |
| 364 | |
| 365 | #ifdef CONFIG_SCSI |
| 366 | void __init |
| 367 | note_scsi_host(struct device_node *node, void *host) |
| 368 | { |
| 369 | int l; |
| 370 | char *p; |
| 371 | |
| 372 | l = strlen(node->full_name); |
| 373 | if (bootpath != NULL && bootdevice != NULL |
| 374 | && strncmp(node->full_name, bootdevice, l) == 0 |
| 375 | && (bootdevice[l] == '/' || bootdevice[l] == 0)) { |
| 376 | boot_host = host; |
| 377 | /* |
| 378 | * There's a bug in OF 1.0.5. (Why am I not surprised.) |
| 379 | * If you pass a path like scsi/sd@1:0 to canon, it returns |
| 380 | * something like /bandit@F2000000/gc@10/53c94@10000/sd@0,0 |
| 381 | * That is, the scsi target number doesn't get preserved. |
| 382 | * So we pick the target number out of bootpath and use that. |
| 383 | */ |
| 384 | p = strstr(bootpath, "/sd@"); |
| 385 | if (p != NULL) { |
| 386 | p += 4; |
| 387 | boot_target = simple_strtoul(p, NULL, 10); |
| 388 | p = strchr(p, ':'); |
| 389 | if (p != NULL) |
| 390 | boot_part = simple_strtoul(p + 1, NULL, 10); |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | #endif |
| 395 | |
| 396 | #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC) |
| 397 | static dev_t __init |
| 398 | find_ide_boot(void) |
| 399 | { |
| 400 | char *p; |
| 401 | int n; |
| 402 | dev_t __init pmac_find_ide_boot(char *bootdevice, int n); |
| 403 | |
| 404 | if (bootdevice == NULL) |
| 405 | return 0; |
| 406 | p = strrchr(bootdevice, '/'); |
| 407 | if (p == NULL) |
| 408 | return 0; |
| 409 | n = p - bootdevice; |
| 410 | |
| 411 | return pmac_find_ide_boot(bootdevice, n); |
| 412 | } |
| 413 | #endif /* CONFIG_BLK_DEV_IDE && CONFIG_BLK_DEV_IDE_PMAC */ |
| 414 | |
| 415 | static void __init |
| 416 | find_boot_device(void) |
| 417 | { |
| 418 | #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC) |
| 419 | boot_dev = find_ide_boot(); |
| 420 | #endif |
| 421 | } |
| 422 | |
| 423 | static int initializing = 1; |
| 424 | /* TODO: Merge the suspend-to-ram with the common code !!! |
| 425 | * currently, this is a stub implementation for suspend-to-disk |
| 426 | * only |
| 427 | */ |
| 428 | |
| 429 | #ifdef CONFIG_SOFTWARE_SUSPEND |
| 430 | |
| 431 | static int pmac_pm_prepare(suspend_state_t state) |
| 432 | { |
| 433 | printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state); |
| 434 | |
| 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | static int pmac_pm_enter(suspend_state_t state) |
| 439 | { |
| 440 | printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state); |
| 441 | |
| 442 | /* Giveup the lazy FPU & vec so we don't have to back them |
| 443 | * up from the low level code |
| 444 | */ |
| 445 | enable_kernel_fp(); |
| 446 | |
| 447 | #ifdef CONFIG_ALTIVEC |
Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 448 | if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 449 | enable_kernel_altivec(); |
| 450 | #endif /* CONFIG_ALTIVEC */ |
| 451 | |
| 452 | return 0; |
| 453 | } |
| 454 | |
| 455 | static int pmac_pm_finish(suspend_state_t state) |
| 456 | { |
| 457 | printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state); |
| 458 | |
| 459 | /* Restore userland MMU context */ |
| 460 | set_context(current->active_mm->context, current->active_mm->pgd); |
| 461 | |
| 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | static struct pm_ops pmac_pm_ops = { |
| 466 | .pm_disk_mode = PM_DISK_SHUTDOWN, |
| 467 | .prepare = pmac_pm_prepare, |
| 468 | .enter = pmac_pm_enter, |
| 469 | .finish = pmac_pm_finish, |
| 470 | }; |
| 471 | |
| 472 | #endif /* CONFIG_SOFTWARE_SUSPEND */ |
| 473 | |
| 474 | static int pmac_late_init(void) |
| 475 | { |
| 476 | initializing = 0; |
| 477 | #ifdef CONFIG_SOFTWARE_SUSPEND |
| 478 | pm_set_ops(&pmac_pm_ops); |
| 479 | #endif /* CONFIG_SOFTWARE_SUSPEND */ |
| 480 | return 0; |
| 481 | } |
| 482 | |
| 483 | late_initcall(pmac_late_init); |
| 484 | |
| 485 | /* can't be __init - can be called whenever a disk is first accessed */ |
| 486 | void |
| 487 | note_bootable_part(dev_t dev, int part, int goodness) |
| 488 | { |
| 489 | static int found_boot = 0; |
| 490 | char *p; |
| 491 | |
| 492 | if (!initializing) |
| 493 | return; |
| 494 | if ((goodness <= current_root_goodness) && |
| 495 | ROOT_DEV != DEFAULT_ROOT_DEVICE) |
| 496 | return; |
| 497 | p = strstr(saved_command_line, "root="); |
| 498 | if (p != NULL && (p == saved_command_line || p[-1] == ' ')) |
| 499 | return; |
| 500 | |
| 501 | if (!found_boot) { |
| 502 | find_boot_device(); |
| 503 | found_boot = 1; |
| 504 | } |
| 505 | if (!boot_dev || dev == boot_dev) { |
| 506 | ROOT_DEV = dev + part; |
| 507 | boot_dev = 0; |
| 508 | current_root_goodness = goodness; |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | static void |
| 513 | pmac_restart(char *cmd) |
| 514 | { |
| 515 | #ifdef CONFIG_ADB_CUDA |
| 516 | struct adb_request req; |
| 517 | #endif /* CONFIG_ADB_CUDA */ |
| 518 | |
| 519 | switch (sys_ctrler) { |
| 520 | #ifdef CONFIG_ADB_CUDA |
| 521 | case SYS_CTRLER_CUDA: |
| 522 | cuda_request(&req, NULL, 2, CUDA_PACKET, |
| 523 | CUDA_RESET_SYSTEM); |
| 524 | for (;;) |
| 525 | cuda_poll(); |
| 526 | break; |
| 527 | #endif /* CONFIG_ADB_CUDA */ |
| 528 | #ifdef CONFIG_ADB_PMU |
| 529 | case SYS_CTRLER_PMU: |
| 530 | pmu_restart(); |
| 531 | break; |
| 532 | #endif /* CONFIG_ADB_PMU */ |
| 533 | default: ; |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | static void |
| 538 | pmac_power_off(void) |
| 539 | { |
| 540 | #ifdef CONFIG_ADB_CUDA |
| 541 | struct adb_request req; |
| 542 | #endif /* CONFIG_ADB_CUDA */ |
| 543 | |
| 544 | switch (sys_ctrler) { |
| 545 | #ifdef CONFIG_ADB_CUDA |
| 546 | case SYS_CTRLER_CUDA: |
| 547 | cuda_request(&req, NULL, 2, CUDA_PACKET, |
| 548 | CUDA_POWERDOWN); |
| 549 | for (;;) |
| 550 | cuda_poll(); |
| 551 | break; |
| 552 | #endif /* CONFIG_ADB_CUDA */ |
| 553 | #ifdef CONFIG_ADB_PMU |
| 554 | case SYS_CTRLER_PMU: |
| 555 | pmu_shutdown(); |
| 556 | break; |
| 557 | #endif /* CONFIG_ADB_PMU */ |
| 558 | default: ; |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | static void |
| 563 | pmac_halt(void) |
| 564 | { |
| 565 | pmac_power_off(); |
| 566 | } |
| 567 | |
| 568 | void __init |
| 569 | pmac_init(unsigned long r3, unsigned long r4, unsigned long r5, |
| 570 | unsigned long r6, unsigned long r7) |
| 571 | { |
| 572 | /* isa_io_base gets set in pmac_find_bridges */ |
| 573 | isa_mem_base = PMAC_ISA_MEM_BASE; |
| 574 | pci_dram_offset = PMAC_PCI_DRAM_OFFSET; |
| 575 | ISA_DMA_THRESHOLD = ~0L; |
| 576 | DMA_MODE_READ = 1; |
| 577 | DMA_MODE_WRITE = 2; |
| 578 | |
| 579 | ppc_md.setup_arch = pmac_setup_arch; |
| 580 | ppc_md.show_cpuinfo = pmac_show_cpuinfo; |
| 581 | ppc_md.show_percpuinfo = pmac_show_percpuinfo; |
| 582 | ppc_md.irq_canonicalize = NULL; |
| 583 | ppc_md.init_IRQ = pmac_pic_init; |
| 584 | ppc_md.get_irq = pmac_get_irq; /* Changed later on ... */ |
| 585 | |
| 586 | ppc_md.pcibios_fixup = pmac_pcibios_fixup; |
| 587 | ppc_md.pcibios_enable_device_hook = pmac_pci_enable_device_hook; |
| 588 | ppc_md.pcibios_after_init = pmac_pcibios_after_init; |
| 589 | ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot; |
| 590 | |
| 591 | ppc_md.restart = pmac_restart; |
| 592 | ppc_md.power_off = pmac_power_off; |
| 593 | ppc_md.halt = pmac_halt; |
| 594 | |
| 595 | ppc_md.time_init = pmac_time_init; |
| 596 | ppc_md.set_rtc_time = pmac_set_rtc_time; |
| 597 | ppc_md.get_rtc_time = pmac_get_rtc_time; |
| 598 | ppc_md.calibrate_decr = pmac_calibrate_decr; |
| 599 | |
| 600 | ppc_md.feature_call = pmac_do_feature_call; |
| 601 | |
| 602 | #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) |
| 603 | #ifdef CONFIG_BLK_DEV_IDE_PMAC |
| 604 | ppc_ide_md.ide_init_hwif = pmac_ide_init_hwif_ports; |
| 605 | ppc_ide_md.default_io_base = pmac_ide_get_base; |
| 606 | #endif /* CONFIG_BLK_DEV_IDE_PMAC */ |
| 607 | #endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */ |
| 608 | |
| 609 | #ifdef CONFIG_BOOTX_TEXT |
| 610 | ppc_md.progress = pmac_progress; |
| 611 | #endif /* CONFIG_BOOTX_TEXT */ |
| 612 | |
| 613 | if (ppc_md.progress) ppc_md.progress("pmac_init(): exit", 0); |
| 614 | |
| 615 | } |
| 616 | |
| 617 | #ifdef CONFIG_BOOTX_TEXT |
| 618 | static void __init |
| 619 | pmac_progress(char *s, unsigned short hex) |
| 620 | { |
| 621 | if (boot_text_mapped) { |
| 622 | btext_drawstring(s); |
| 623 | btext_drawchar('\n'); |
| 624 | } |
| 625 | } |
| 626 | #endif /* CONFIG_BOOTX_TEXT */ |
| 627 | |
| 628 | static int __init |
| 629 | pmac_declare_of_platform_devices(void) |
| 630 | { |
| 631 | struct device_node *np; |
| 632 | |
| 633 | np = find_devices("uni-n"); |
| 634 | if (np) { |
| 635 | for (np = np->child; np != NULL; np = np->sibling) |
| 636 | if (strncmp(np->name, "i2c", 3) == 0) { |
| 637 | of_platform_device_create(np, "uni-n-i2c", |
| 638 | NULL); |
| 639 | break; |
| 640 | } |
| 641 | } |
| 642 | np = find_devices("u3"); |
| 643 | if (np) { |
| 644 | for (np = np->child; np != NULL; np = np->sibling) |
| 645 | if (strncmp(np->name, "i2c", 3) == 0) { |
| 646 | of_platform_device_create(np, "u3-i2c", |
| 647 | NULL); |
| 648 | break; |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | np = find_devices("valkyrie"); |
| 653 | if (np) |
| 654 | of_platform_device_create(np, "valkyrie", NULL); |
| 655 | np = find_devices("platinum"); |
| 656 | if (np) |
| 657 | of_platform_device_create(np, "platinum", NULL); |
| 658 | |
| 659 | return 0; |
| 660 | } |
| 661 | |
| 662 | device_initcall(pmac_declare_of_platform_devices); |