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