2005-09-26 14:04:21 +08:00
|
|
|
/*
|
2005-10-22 14:02:39 +08:00
|
|
|
* Powermac setup and early boot code plus other random bits.
|
2005-09-26 14:04:21 +08:00
|
|
|
*
|
|
|
|
* PowerPC version
|
|
|
|
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
|
|
|
|
*
|
|
|
|
* Adapted for Power Macintosh by Paul Mackerras
|
2005-10-22 14:02:39 +08:00
|
|
|
* Copyright (C) 1996 Paul Mackerras (paulus@samba.org)
|
2005-09-26 14:04:21 +08:00
|
|
|
*
|
|
|
|
* Derived from "arch/alpha/kernel/setup.c"
|
|
|
|
* Copyright (C) 1995 Linus Torvalds
|
|
|
|
*
|
|
|
|
* Maintained by Benjamin Herrenschmidt (benh@kernel.crashing.org)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* bootup setup stuff..
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
#include <linux/ptrace.h>
|
2011-05-27 22:46:24 +08:00
|
|
|
#include <linux/export.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
#include <linux/user.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/initrd.h>
|
|
|
|
#include <linux/vt_kern.h>
|
|
|
|
#include <linux/console.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/adb.h>
|
|
|
|
#include <linux/cuda.h>
|
|
|
|
#include <linux/pmu.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/root_dev.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/suspend.h>
|
2007-11-14 01:13:03 +08:00
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/of_platform.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
#include <asm/reg.h>
|
|
|
|
#include <asm/sections.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/pci-bridge.h>
|
|
|
|
#include <asm/ohare.h>
|
|
|
|
#include <asm/mediabay.h>
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/dma.h>
|
|
|
|
#include <asm/cputable.h>
|
|
|
|
#include <asm/btext.h>
|
|
|
|
#include <asm/pmac_feature.h>
|
|
|
|
#include <asm/time.h>
|
|
|
|
#include <asm/mmu_context.h>
|
2005-10-22 14:02:39 +08:00
|
|
|
#include <asm/iommu.h>
|
|
|
|
#include <asm/smu.h>
|
|
|
|
#include <asm/pmc.h>
|
2005-11-23 14:57:25 +08:00
|
|
|
#include <asm/udbg.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2005-10-10 20:58:41 +08:00
|
|
|
#include "pmac.h"
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
#undef SHOW_GATWICK_IRQS
|
|
|
|
|
|
|
|
int ppc_override_l2cr = 0;
|
|
|
|
int ppc_override_l2cr_value;
|
|
|
|
int has_l2cache = 0;
|
|
|
|
|
2006-01-23 05:19:02 +08:00
|
|
|
int pmac_newworld;
|
2005-10-06 10:06:20 +08:00
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
static int current_root_goodness = -1;
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
extern struct machdep_calls pmac_md;
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
#define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
int sccdbg;
|
2005-09-26 14:04:21 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;
|
2005-10-22 14:02:39 +08:00
|
|
|
EXPORT_SYMBOL(sys_ctrler);
|
|
|
|
|
2005-10-20 18:48:19 +08:00
|
|
|
static void pmac_show_cpuinfo(struct seq_file *m)
|
2005-09-26 14:04:21 +08:00
|
|
|
{
|
|
|
|
struct device_node *np;
|
2006-07-12 13:40:29 +08:00
|
|
|
const char *pp;
|
2005-09-26 14:04:21 +08:00
|
|
|
int plen;
|
2005-10-20 18:48:19 +08:00
|
|
|
int mbmodel;
|
|
|
|
unsigned int mbflags;
|
2005-09-26 14:04:21 +08:00
|
|
|
char* mbname;
|
|
|
|
|
2005-10-20 18:48:19 +08:00
|
|
|
mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL,
|
|
|
|
PMAC_MB_INFO_MODEL, 0);
|
|
|
|
mbflags = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL,
|
|
|
|
PMAC_MB_INFO_FLAGS, 0);
|
|
|
|
if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME,
|
|
|
|
(long) &mbname) != 0)
|
2005-09-26 14:04:21 +08:00
|
|
|
mbname = "Unknown";
|
|
|
|
|
|
|
|
/* find motherboard type */
|
|
|
|
seq_printf(m, "machine\t\t: ");
|
2005-10-20 18:48:19 +08:00
|
|
|
np = of_find_node_by_path("/");
|
2005-09-26 14:04:21 +08:00
|
|
|
if (np != NULL) {
|
2007-04-03 20:26:41 +08:00
|
|
|
pp = of_get_property(np, "model", NULL);
|
2005-09-26 14:04:21 +08:00
|
|
|
if (pp != NULL)
|
|
|
|
seq_printf(m, "%s\n", pp);
|
|
|
|
else
|
|
|
|
seq_printf(m, "PowerMac\n");
|
2007-04-03 20:26:41 +08:00
|
|
|
pp = of_get_property(np, "compatible", &plen);
|
2005-09-26 14:04:21 +08:00
|
|
|
if (pp != NULL) {
|
|
|
|
seq_printf(m, "motherboard\t:");
|
|
|
|
while (plen > 0) {
|
|
|
|
int l = strlen(pp) + 1;
|
|
|
|
seq_printf(m, " %s", pp);
|
|
|
|
plen -= l;
|
|
|
|
pp += l;
|
|
|
|
}
|
|
|
|
seq_printf(m, "\n");
|
|
|
|
}
|
2005-10-20 18:48:19 +08:00
|
|
|
of_node_put(np);
|
2005-09-26 14:04:21 +08:00
|
|
|
} else
|
|
|
|
seq_printf(m, "PowerMac\n");
|
|
|
|
|
|
|
|
/* print parsed model */
|
|
|
|
seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname);
|
|
|
|
seq_printf(m, "pmac flags\t: %08x\n", mbflags);
|
|
|
|
|
|
|
|
/* find l2 cache info */
|
2005-10-20 18:48:19 +08:00
|
|
|
np = of_find_node_by_name(NULL, "l2-cache");
|
|
|
|
if (np == NULL)
|
|
|
|
np = of_find_node_by_type(NULL, "cache");
|
|
|
|
if (np != NULL) {
|
2007-04-03 20:26:41 +08:00
|
|
|
const unsigned int *ic =
|
|
|
|
of_get_property(np, "i-cache-size", NULL);
|
|
|
|
const unsigned int *dc =
|
|
|
|
of_get_property(np, "d-cache-size", NULL);
|
2005-09-26 14:04:21 +08:00
|
|
|
seq_printf(m, "L2 cache\t:");
|
|
|
|
has_l2cache = 1;
|
2007-04-03 20:26:41 +08:00
|
|
|
if (of_get_property(np, "cache-unified", NULL) != 0 && dc) {
|
2005-09-26 14:04:21 +08:00
|
|
|
seq_printf(m, " %dK unified", *dc / 1024);
|
|
|
|
} else {
|
|
|
|
if (ic)
|
|
|
|
seq_printf(m, " %dK instruction", *ic / 1024);
|
|
|
|
if (dc)
|
|
|
|
seq_printf(m, "%s %dK data",
|
|
|
|
(ic? " +": ""), *dc / 1024);
|
|
|
|
}
|
2007-04-03 20:26:41 +08:00
|
|
|
pp = of_get_property(np, "ram-type", NULL);
|
2005-09-26 14:04:21 +08:00
|
|
|
if (pp)
|
|
|
|
seq_printf(m, " %s", pp);
|
|
|
|
seq_printf(m, "\n");
|
2005-10-20 18:48:19 +08:00
|
|
|
of_node_put(np);
|
2005-09-26 14:04:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Indicate newworld/oldworld */
|
|
|
|
seq_printf(m, "pmac-generation\t: %s\n",
|
|
|
|
pmac_newworld ? "NewWorld" : "OldWorld");
|
|
|
|
}
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
#ifndef CONFIG_ADB_CUDA
|
|
|
|
int find_via_cuda(void)
|
|
|
|
{
|
2007-04-24 11:53:04 +08:00
|
|
|
struct device_node *dn = of_find_node_by_name(NULL, "via-cuda");
|
|
|
|
|
|
|
|
if (!dn)
|
2005-10-22 14:02:39 +08:00
|
|
|
return 0;
|
2007-04-24 11:53:04 +08:00
|
|
|
of_node_put(dn);
|
2005-10-22 14:02:39 +08:00
|
|
|
printk("WARNING ! Your machine is CUDA-based but your kernel\n");
|
|
|
|
printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
#ifndef CONFIG_ADB_PMU
|
|
|
|
int find_via_pmu(void)
|
2005-09-26 14:04:21 +08:00
|
|
|
{
|
2007-04-24 11:53:04 +08:00
|
|
|
struct device_node *dn = of_find_node_by_name(NULL, "via-pmu");
|
|
|
|
|
|
|
|
if (!dn)
|
2005-10-22 14:02:39 +08:00
|
|
|
return 0;
|
2007-04-24 11:53:04 +08:00
|
|
|
of_node_put(dn);
|
2005-10-22 14:02:39 +08:00
|
|
|
printk("WARNING ! Your machine is PMU-based but your kernel\n");
|
|
|
|
printk(" wasn't compiled with CONFIG_ADB_PMU option !\n");
|
2005-10-23 15:23:21 +08:00
|
|
|
return 0;
|
2005-10-22 14:02:39 +08:00
|
|
|
}
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
#ifndef CONFIG_PMAC_SMU
|
|
|
|
int smu_init(void)
|
|
|
|
{
|
|
|
|
/* should check and warn if SMU is present */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
static volatile u32 *sysctrl_regs;
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
static void __init ohare_init(void)
|
|
|
|
{
|
2007-04-24 11:53:04 +08:00
|
|
|
struct device_node *dn;
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/* this area has the CPU identification register
|
|
|
|
and some registers used by smp boards */
|
|
|
|
sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
/*
|
|
|
|
* Turn on the L2 cache.
|
|
|
|
* We assume that we have a PSX memory controller iff
|
|
|
|
* we have an ohare I/O controller.
|
|
|
|
*/
|
2007-04-24 11:53:04 +08:00
|
|
|
dn = of_find_node_by_name(NULL, "ohare");
|
|
|
|
if (dn) {
|
|
|
|
of_node_put(dn);
|
2005-10-22 14:02:39 +08:00
|
|
|
if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) {
|
|
|
|
if (sysctrl_regs[4] & 0x10)
|
|
|
|
sysctrl_regs[4] |= 0x04000020;
|
|
|
|
else
|
|
|
|
sysctrl_regs[4] |= 0x04000000;
|
|
|
|
if(has_l2cache)
|
|
|
|
printk(KERN_INFO "Level 2 cache enabled\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
static void __init l2cr_init(void)
|
|
|
|
{
|
2005-09-26 14:04:21 +08:00
|
|
|
/* Checks "l2cr-value" property in the registry */
|
|
|
|
if (cpu_has_feature(CPU_FTR_L2CR)) {
|
2007-04-24 11:51:59 +08:00
|
|
|
struct device_node *np = of_find_node_by_name(NULL, "cpus");
|
2005-09-26 14:04:21 +08:00
|
|
|
if (np == 0)
|
2007-04-24 11:51:59 +08:00
|
|
|
np = of_find_node_by_type(NULL, "cpu");
|
2005-09-26 14:04:21 +08:00
|
|
|
if (np != 0) {
|
2006-07-12 13:40:29 +08:00
|
|
|
const unsigned int *l2cr =
|
2007-04-03 20:26:41 +08:00
|
|
|
of_get_property(np, "l2cr-value", NULL);
|
2005-09-26 14:04:21 +08:00
|
|
|
if (l2cr != 0) {
|
|
|
|
ppc_override_l2cr = 1;
|
|
|
|
ppc_override_l2cr_value = *l2cr;
|
|
|
|
_set_L2CR(0);
|
|
|
|
_set_L2CR(ppc_override_l2cr_value);
|
|
|
|
}
|
2007-04-24 11:51:59 +08:00
|
|
|
of_node_put(np);
|
2005-09-26 14:04:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ppc_override_l2cr)
|
2005-10-22 14:02:39 +08:00
|
|
|
printk(KERN_INFO "L2CR overridden (0x%x), "
|
|
|
|
"backside cache is %s\n",
|
|
|
|
ppc_override_l2cr_value,
|
|
|
|
(ppc_override_l2cr_value & 0x80000000)
|
2005-09-26 14:04:21 +08:00
|
|
|
? "enabled" : "disabled");
|
2005-10-22 14:02:39 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-11 08:00:03 +08:00
|
|
|
static void __init pmac_setup_arch(void)
|
2005-10-22 14:02:39 +08:00
|
|
|
{
|
2005-10-23 15:23:21 +08:00
|
|
|
struct device_node *cpu, *ic;
|
2006-07-12 13:40:29 +08:00
|
|
|
const int *fp;
|
2005-10-22 14:02:39 +08:00
|
|
|
unsigned long pvr;
|
|
|
|
|
|
|
|
pvr = PVR_VER(mfspr(SPRN_PVR));
|
|
|
|
|
|
|
|
/* Set loops_per_jiffy to a half-way reasonable value,
|
|
|
|
for use until calibrate_delay gets called. */
|
|
|
|
loops_per_jiffy = 50000000 / HZ;
|
|
|
|
cpu = of_find_node_by_type(NULL, "cpu");
|
|
|
|
if (cpu != NULL) {
|
2007-04-03 20:26:41 +08:00
|
|
|
fp = of_get_property(cpu, "clock-frequency", NULL);
|
2005-10-22 14:02:39 +08:00
|
|
|
if (fp != NULL) {
|
|
|
|
if (pvr >= 0x30 && pvr < 0x80)
|
|
|
|
/* PPC970 etc. */
|
|
|
|
loops_per_jiffy = *fp / (3 * HZ);
|
|
|
|
else if (pvr == 4 || pvr >= 8)
|
|
|
|
/* 604, G3, G4 etc. */
|
|
|
|
loops_per_jiffy = *fp / HZ;
|
|
|
|
else
|
|
|
|
/* 601, 603, etc. */
|
|
|
|
loops_per_jiffy = *fp / (2 * HZ);
|
|
|
|
}
|
|
|
|
of_node_put(cpu);
|
|
|
|
}
|
|
|
|
|
2005-10-23 15:23:21 +08:00
|
|
|
/* See if newworld or oldworld */
|
2008-11-13 02:20:43 +08:00
|
|
|
ic = of_find_node_with_property(NULL, "interrupt-controller");
|
2006-01-23 05:19:02 +08:00
|
|
|
if (ic) {
|
|
|
|
pmac_newworld = 1;
|
2005-10-23 15:23:21 +08:00
|
|
|
of_node_put(ic);
|
2006-01-23 05:19:02 +08:00
|
|
|
}
|
2005-10-23 15:23:21 +08:00
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
/* Lookup PCI hosts */
|
|
|
|
pmac_pci_init();
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
ohare_init();
|
|
|
|
l2cr_init();
|
|
|
|
#endif /* CONFIG_PPC32 */
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
find_via_cuda();
|
|
|
|
find_via_pmu();
|
2005-10-22 14:02:39 +08:00
|
|
|
smu_init();
|
|
|
|
|
2008-04-29 09:42:32 +08:00
|
|
|
#if defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE) || \
|
|
|
|
defined(CONFIG_PPC64)
|
2005-09-26 14:04:21 +08:00
|
|
|
pmac_nvram_init();
|
|
|
|
#endif
|
2005-10-22 14:02:39 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
2005-09-26 14:04:21 +08:00
|
|
|
#ifdef CONFIG_BLK_DEV_INITRD
|
|
|
|
if (initrd_start)
|
|
|
|
ROOT_DEV = Root_RAM0;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
ROOT_DEV = DEFAULT_ROOT_DEVICE;
|
2005-10-22 14:02:39 +08:00
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
#ifdef CONFIG_ADB
|
2014-09-17 12:39:36 +08:00
|
|
|
if (strstr(boot_command_line, "adb_sync")) {
|
2006-03-28 20:15:54 +08:00
|
|
|
extern int __adb_probe_sync;
|
|
|
|
__adb_probe_sync = 1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_ADB */
|
2005-09-26 14:04:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCSI
|
2007-05-23 11:28:03 +08:00
|
|
|
void note_scsi_host(struct device_node *node, void *host)
|
2005-09-26 14:04:21 +08:00
|
|
|
{
|
|
|
|
}
|
2005-10-06 10:06:20 +08:00
|
|
|
EXPORT_SYMBOL(note_scsi_host);
|
2005-09-26 14:04:21 +08:00
|
|
|
#endif
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
static int initializing = 1;
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
static int pmac_late_init(void)
|
|
|
|
{
|
|
|
|
initializing = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-01-03 03:14:28 +08:00
|
|
|
machine_late_initcall(powermac, pmac_late_init);
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2007-10-04 10:00:28 +08:00
|
|
|
/*
|
2016-08-03 05:03:33 +08:00
|
|
|
* This is __ref because we check for "initializing" before
|
2007-10-04 10:00:28 +08:00
|
|
|
* touching any of the __init sensitive things and "initializing"
|
|
|
|
* will be false after __init time. This can't be __init because it
|
|
|
|
* can be called whenever a disk is first accessed.
|
|
|
|
*/
|
2016-08-03 05:03:33 +08:00
|
|
|
void __ref note_bootable_part(dev_t dev, int part, int goodness)
|
2005-09-26 14:04:21 +08:00
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if (!initializing)
|
|
|
|
return;
|
|
|
|
if ((goodness <= current_root_goodness) &&
|
|
|
|
ROOT_DEV != DEFAULT_ROOT_DEVICE)
|
|
|
|
return;
|
2007-02-12 16:54:17 +08:00
|
|
|
p = strstr(boot_command_line, "root=");
|
|
|
|
if (p != NULL && (p == boot_command_line || p[-1] == ' '))
|
2005-09-26 14:04:21 +08:00
|
|
|
return;
|
|
|
|
|
2007-10-04 11:47:06 +08:00
|
|
|
ROOT_DEV = dev + part;
|
|
|
|
current_root_goodness = goodness;
|
2005-09-26 14:04:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_ADB_CUDA
|
2016-07-12 08:54:52 +08:00
|
|
|
static void __noreturn cuda_restart(void)
|
2005-10-22 14:02:39 +08:00
|
|
|
{
|
2005-09-26 14:04:21 +08:00
|
|
|
struct adb_request req;
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_RESET_SYSTEM);
|
|
|
|
for (;;)
|
|
|
|
cuda_poll();
|
|
|
|
}
|
|
|
|
|
2016-07-12 08:54:52 +08:00
|
|
|
static void __noreturn cuda_shutdown(void)
|
2005-10-22 14:02:39 +08:00
|
|
|
{
|
|
|
|
struct adb_request req;
|
|
|
|
|
|
|
|
cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_POWERDOWN);
|
|
|
|
for (;;)
|
|
|
|
cuda_poll();
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define cuda_restart()
|
|
|
|
#define cuda_shutdown()
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_ADB_PMU
|
|
|
|
#define pmu_restart()
|
|
|
|
#define pmu_shutdown()
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_PMAC_SMU
|
|
|
|
#define smu_restart()
|
|
|
|
#define smu_shutdown()
|
|
|
|
#endif
|
|
|
|
|
2016-07-12 08:54:52 +08:00
|
|
|
static void __noreturn pmac_restart(char *cmd)
|
2005-10-22 14:02:39 +08:00
|
|
|
{
|
2005-09-26 14:04:21 +08:00
|
|
|
switch (sys_ctrler) {
|
|
|
|
case SYS_CTRLER_CUDA:
|
2005-10-22 14:02:39 +08:00
|
|
|
cuda_restart();
|
2005-09-26 14:04:21 +08:00
|
|
|
break;
|
|
|
|
case SYS_CTRLER_PMU:
|
|
|
|
pmu_restart();
|
|
|
|
break;
|
2005-10-22 14:02:39 +08:00
|
|
|
case SYS_CTRLER_SMU:
|
|
|
|
smu_restart();
|
|
|
|
break;
|
2005-09-26 14:04:21 +08:00
|
|
|
default: ;
|
|
|
|
}
|
2016-07-12 08:54:52 +08:00
|
|
|
while (1) ;
|
2005-09-26 14:04:21 +08:00
|
|
|
}
|
|
|
|
|
2016-07-12 08:54:52 +08:00
|
|
|
static void __noreturn pmac_power_off(void)
|
2005-09-26 14:04:21 +08:00
|
|
|
{
|
|
|
|
switch (sys_ctrler) {
|
|
|
|
case SYS_CTRLER_CUDA:
|
2005-10-22 14:02:39 +08:00
|
|
|
cuda_shutdown();
|
2005-09-26 14:04:21 +08:00
|
|
|
break;
|
|
|
|
case SYS_CTRLER_PMU:
|
|
|
|
pmu_shutdown();
|
|
|
|
break;
|
2005-10-22 14:02:39 +08:00
|
|
|
case SYS_CTRLER_SMU:
|
|
|
|
smu_shutdown();
|
|
|
|
break;
|
2005-09-26 14:04:21 +08:00
|
|
|
default: ;
|
|
|
|
}
|
2016-07-12 08:54:52 +08:00
|
|
|
while (1) ;
|
2005-09-26 14:04:21 +08:00
|
|
|
}
|
|
|
|
|
2016-07-12 08:54:52 +08:00
|
|
|
static void __noreturn
|
2005-09-26 14:04:21 +08:00
|
|
|
pmac_halt(void)
|
|
|
|
{
|
|
|
|
pmac_power_off();
|
|
|
|
}
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
/*
|
|
|
|
* Early initialization.
|
|
|
|
*/
|
2016-07-05 13:04:06 +08:00
|
|
|
static void __init pmac_init(void)
|
2005-10-22 14:02:39 +08:00
|
|
|
{
|
2005-11-23 14:57:25 +08:00
|
|
|
/* Enable early btext debug if requested */
|
2014-09-17 12:39:36 +08:00
|
|
|
if (strstr(boot_command_line, "btextdbg")) {
|
2005-11-23 14:57:25 +08:00
|
|
|
udbg_adb_init_early();
|
|
|
|
register_early_udbg_console();
|
2005-10-22 14:02:39 +08:00
|
|
|
}
|
|
|
|
|
2005-11-23 14:57:25 +08:00
|
|
|
/* Probe motherboard chipset */
|
|
|
|
pmac_feature_init();
|
|
|
|
|
|
|
|
/* Initialize debug stuff */
|
2014-09-17 12:39:36 +08:00
|
|
|
udbg_scc_init(!!strstr(boot_command_line, "sccdbg"));
|
|
|
|
udbg_adb_init(!!strstr(boot_command_line, "btextdbg"));
|
2005-11-23 14:57:25 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_PPC64
|
2015-03-31 13:00:49 +08:00
|
|
|
iommu_init_early_dart(&pmac_pci_controller_ops);
|
2005-10-22 14:02:39 +08:00
|
|
|
#endif
|
2009-06-19 07:30:07 +08:00
|
|
|
|
|
|
|
/* SMP Init has to be done early as we need to patch up
|
2010-04-26 23:32:44 +08:00
|
|
|
* cpu_possible_mask before interrupt stacks are allocated
|
2009-06-19 07:30:07 +08:00
|
|
|
* or kaboom...
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
pmac_setup_smp();
|
|
|
|
#endif
|
2005-10-22 14:02:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init pmac_declare_of_platform_devices(void)
|
2005-09-26 14:04:21 +08:00
|
|
|
{
|
2006-01-07 08:35:26 +08:00
|
|
|
struct device_node *np;
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-01-07 08:30:44 +08:00
|
|
|
np = of_find_node_by_name(NULL, "valkyrie");
|
2011-08-21 14:10:01 +08:00
|
|
|
if (np) {
|
2005-10-22 14:02:39 +08:00
|
|
|
of_platform_device_create(np, "valkyrie", NULL);
|
2011-08-21 14:10:01 +08:00
|
|
|
of_node_put(np);
|
|
|
|
}
|
2006-01-07 08:30:44 +08:00
|
|
|
np = of_find_node_by_name(NULL, "platinum");
|
2011-08-21 14:10:01 +08:00
|
|
|
if (np) {
|
2005-10-22 14:02:39 +08:00
|
|
|
of_platform_device_create(np, "platinum", NULL);
|
2011-08-21 14:10:01 +08:00
|
|
|
of_node_put(np);
|
|
|
|
}
|
2005-10-22 14:02:39 +08:00
|
|
|
np = of_find_node_by_type(NULL, "smu");
|
|
|
|
if (np) {
|
|
|
|
of_platform_device_create(np, "smu", NULL);
|
|
|
|
of_node_put(np);
|
|
|
|
}
|
2010-12-05 13:05:37 +08:00
|
|
|
np = of_find_node_by_type(NULL, "fcu");
|
|
|
|
if (np == NULL) {
|
|
|
|
/* Some machines have strangely broken device-tree */
|
|
|
|
np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e");
|
|
|
|
}
|
|
|
|
if (np) {
|
|
|
|
of_platform_device_create(np, "temperature", NULL);
|
|
|
|
of_node_put(np);
|
|
|
|
}
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-01-03 03:14:28 +08:00
|
|
|
machine_device_initcall(powermac, pmac_declare_of_platform_devices);
|
2005-10-22 14:02:39 +08:00
|
|
|
|
2008-07-28 11:49:15 +08:00
|
|
|
#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
|
|
|
|
/*
|
|
|
|
* This is called very early, as part of console_init() (typically just after
|
|
|
|
* time_init()). This function is respondible for trying to find a good
|
|
|
|
* default console on serial ports. It tries to match the open firmware
|
|
|
|
* default output with one of the available serial console drivers.
|
|
|
|
*/
|
|
|
|
static int __init check_pmac_serial_console(void)
|
|
|
|
{
|
|
|
|
struct device_node *prom_stdout = NULL;
|
|
|
|
int offset = 0;
|
|
|
|
const char *name;
|
|
|
|
#ifdef CONFIG_SERIAL_PMACZILOG_TTYS
|
|
|
|
char *devname = "ttyS";
|
|
|
|
#else
|
|
|
|
char *devname = "ttyPZ";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pr_debug(" -> check_pmac_serial_console()\n");
|
|
|
|
|
|
|
|
/* The user has requested a console so this is already set up. */
|
|
|
|
if (strstr(boot_command_line, "console=")) {
|
|
|
|
pr_debug(" console was specified !\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!of_chosen) {
|
|
|
|
pr_debug(" of_chosen is NULL !\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We are getting a weird phandle from OF ... */
|
|
|
|
/* ... So use the full path instead */
|
|
|
|
name = of_get_property(of_chosen, "linux,stdout-path", NULL);
|
|
|
|
if (name == NULL) {
|
|
|
|
pr_debug(" no linux,stdout-path !\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
prom_stdout = of_find_node_by_path(name);
|
|
|
|
if (!prom_stdout) {
|
|
|
|
pr_debug(" can't find stdout package %s !\n", name);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
pr_debug("stdout is %s\n", prom_stdout->full_name);
|
|
|
|
|
|
|
|
name = of_get_property(prom_stdout, "name", NULL);
|
|
|
|
if (!name) {
|
|
|
|
pr_debug(" stdout package has no name !\n");
|
|
|
|
goto not_found;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(name, "ch-a") == 0)
|
|
|
|
offset = 0;
|
|
|
|
else if (strcmp(name, "ch-b") == 0)
|
|
|
|
offset = 1;
|
|
|
|
else
|
|
|
|
goto not_found;
|
|
|
|
of_node_put(prom_stdout);
|
|
|
|
|
|
|
|
pr_debug("Found serial console at %s%d\n", devname, offset);
|
|
|
|
|
|
|
|
return add_preferred_console(devname, offset, NULL);
|
|
|
|
|
|
|
|
not_found:
|
|
|
|
pr_debug("No preferred console found !\n");
|
|
|
|
of_node_put(prom_stdout);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
console_initcall(check_pmac_serial_console);
|
|
|
|
|
|
|
|
#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
/*
|
|
|
|
* Called very early, MMU is off, device-tree isn't unflattened
|
|
|
|
*/
|
2006-03-28 20:15:54 +08:00
|
|
|
static int __init pmac_probe(void)
|
2005-10-22 14:02:39 +08:00
|
|
|
{
|
2016-07-05 13:04:00 +08:00
|
|
|
if (!of_machine_is_compatible("Power Macintosh") &&
|
|
|
|
!of_machine_is_compatible("MacRISC"))
|
|
|
|
return 0;
|
2005-10-22 14:02:39 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
/* isa_io_base gets set in pmac_pci_init */
|
|
|
|
ISA_DMA_THRESHOLD = ~0L;
|
|
|
|
DMA_MODE_READ = 1;
|
|
|
|
DMA_MODE_WRITE = 2;
|
|
|
|
#endif /* CONFIG_PPC32 */
|
|
|
|
|
2014-10-13 22:01:09 +08:00
|
|
|
pm_power_off = pmac_power_off;
|
|
|
|
|
2016-07-05 13:04:06 +08:00
|
|
|
pmac_init();
|
|
|
|
|
2005-10-22 14:02:39 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
define_machine(powermac) {
|
|
|
|
.name = "PowerMac",
|
2005-10-22 14:02:39 +08:00
|
|
|
.probe = pmac_probe,
|
|
|
|
.setup_arch = pmac_setup_arch,
|
|
|
|
.show_cpuinfo = pmac_show_cpuinfo,
|
|
|
|
.init_IRQ = pmac_pic_init,
|
2005-12-13 15:01:21 +08:00
|
|
|
.get_irq = NULL, /* changed later */
|
2006-11-11 14:24:51 +08:00
|
|
|
.pci_irq_fixup = pmac_pci_irq_fixup,
|
2005-10-22 14:02:39 +08:00
|
|
|
.restart = pmac_restart,
|
|
|
|
.halt = pmac_halt,
|
|
|
|
.time_init = pmac_time_init,
|
|
|
|
.get_boot_time = pmac_get_boot_time,
|
|
|
|
.set_rtc_time = pmac_set_rtc_time,
|
|
|
|
.get_rtc_time = pmac_get_rtc_time,
|
|
|
|
.calibrate_decr = pmac_calibrate_decr,
|
|
|
|
.feature_call = pmac_do_feature_call,
|
2005-12-21 06:37:07 +08:00
|
|
|
.progress = udbg_progress,
|
2005-10-22 14:02:39 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2006-03-27 12:03:03 +08:00
|
|
|
.power_save = power4_idle,
|
2005-10-22 14:02:39 +08:00
|
|
|
.enable_pmcs = power4_enable_pmcs,
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 20:35:00 +08:00
|
|
|
#endif /* CONFIG_PPC64 */
|
2005-10-22 14:02:39 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
.pcibios_after_init = pmac_pcibios_after_init,
|
|
|
|
.phys_mem_access_prot = pci_phys_mem_access_prot,
|
|
|
|
#endif
|
|
|
|
};
|