2006-11-23 07:46:51 +08:00
|
|
|
/*
|
|
|
|
* PS3 platform setup routines.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Sony Computer Entertainment Inc.
|
|
|
|
* Copyright 2006 Sony Corp.
|
|
|
|
*
|
|
|
|
* 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; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/root_dev.h>
|
|
|
|
#include <linux/console.h>
|
2011-05-27 22:46:24 +08:00
|
|
|
#include <linux/export.h>
|
2007-02-12 16:55:22 +08:00
|
|
|
#include <linux/bootmem.h>
|
2006-11-23 07:46:51 +08:00
|
|
|
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/firmware.h>
|
|
|
|
#include <asm/time.h>
|
|
|
|
#include <asm/iommu.h>
|
|
|
|
#include <asm/udbg.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/lv1call.h>
|
2009-06-10 12:38:48 +08:00
|
|
|
#include <asm/ps3gpu.h>
|
2006-11-23 07:46:51 +08:00
|
|
|
|
|
|
|
#include "platform.h"
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
2007-06-16 05:19:23 +08:00
|
|
|
#define DBG udbg_printf
|
2006-11-23 07:46:51 +08:00
|
|
|
#else
|
2007-06-16 05:19:23 +08:00
|
|
|
#define DBG pr_debug
|
2006-11-23 07:46:51 +08:00
|
|
|
#endif
|
|
|
|
|
2008-10-30 16:12:58 +08:00
|
|
|
/* mutex synchronizing GPU accesses and video mode changes */
|
|
|
|
DEFINE_MUTEX(ps3_gpu_mutex);
|
|
|
|
EXPORT_SYMBOL_GPL(ps3_gpu_mutex);
|
|
|
|
|
2007-06-16 05:18:48 +08:00
|
|
|
static union ps3_firmware_version ps3_firmware_version;
|
|
|
|
|
|
|
|
void ps3_get_firmware_version(union ps3_firmware_version *v)
|
2007-01-27 11:08:21 +08:00
|
|
|
{
|
2007-06-16 05:18:48 +08:00
|
|
|
*v = ps3_firmware_version;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(ps3_get_firmware_version);
|
2007-01-27 11:08:21 +08:00
|
|
|
|
2007-06-16 05:18:48 +08:00
|
|
|
int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev)
|
|
|
|
{
|
|
|
|
union ps3_firmware_version x;
|
|
|
|
|
|
|
|
x.pad = 0;
|
|
|
|
x.major = major;
|
|
|
|
x.minor = minor;
|
|
|
|
x.rev = rev;
|
2007-01-27 11:08:21 +08:00
|
|
|
|
2007-08-29 19:30:25 +08:00
|
|
|
return (ps3_firmware_version.raw > x.raw) -
|
|
|
|
(ps3_firmware_version.raw < x.raw);
|
2007-01-27 11:08:21 +08:00
|
|
|
}
|
2007-06-16 05:18:48 +08:00
|
|
|
EXPORT_SYMBOL_GPL(ps3_compare_firmware_version);
|
2007-01-27 11:08:21 +08:00
|
|
|
|
2006-11-23 07:46:51 +08:00
|
|
|
static void ps3_power_save(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* lv1_pause() puts the PPE thread into inactive state until an
|
|
|
|
* irq on an unmasked plug exists. MSR[EE] has no effect.
|
|
|
|
* flags: 0 = wake on DEC interrupt, 1 = ignore DEC interrupt.
|
|
|
|
*/
|
|
|
|
|
|
|
|
lv1_pause(0);
|
|
|
|
}
|
|
|
|
|
2016-07-12 08:54:52 +08:00
|
|
|
static void __noreturn ps3_restart(char *cmd)
|
2007-02-08 04:20:01 +08:00
|
|
|
{
|
|
|
|
DBG("%s:%d cmd '%s'\n", __func__, __LINE__, cmd);
|
|
|
|
|
|
|
|
smp_send_stop();
|
|
|
|
ps3_sys_manager_restart(); /* never returns */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ps3_power_off(void)
|
|
|
|
{
|
|
|
|
DBG("%s:%d\n", __func__, __LINE__);
|
|
|
|
|
|
|
|
smp_send_stop();
|
|
|
|
ps3_sys_manager_power_off(); /* never returns */
|
|
|
|
}
|
|
|
|
|
2016-07-12 08:54:52 +08:00
|
|
|
static void __noreturn ps3_halt(void)
|
2008-03-27 08:38:31 +08:00
|
|
|
{
|
|
|
|
DBG("%s:%d\n", __func__, __LINE__);
|
|
|
|
|
|
|
|
smp_send_stop();
|
|
|
|
ps3_sys_manager_halt(); /* never returns */
|
|
|
|
}
|
|
|
|
|
2017-12-04 13:27:25 +08:00
|
|
|
static void ps3_panic(char *str)
|
|
|
|
{
|
|
|
|
DBG("%s:%d %s\n", __func__, __LINE__, str);
|
|
|
|
|
|
|
|
smp_send_stop();
|
|
|
|
printk("\n");
|
|
|
|
printk(" System does not reboot automatically.\n");
|
|
|
|
printk(" Please press POWER button.\n");
|
|
|
|
printk("\n");
|
powerpc/pseries, ps3: panic flush kernel messages before halting system
Platforms with a panic handler that halts the system can have problems
getting kernel messages out, because the panic notifiers are called
before kernel/panic.c does its flushing of printk buffers an console
etc.
This was attempted to be solved with commit a3b2cb30f252 ("powerpc: Do
not call ppc_md.panic in fadump panic notifier"), but that wasn't the
right approach and caused other problems, and was reverted by commit
ab9dbf771ff9.
Instead, the powernv shutdown paths have already had a similar
problem, fixed by taking the message flushing sequence from
kernel/panic.c. That's a little bit ugly, but while we have the code
duplicated, it will work for this case as well. So have ppc panic
handlers do the same flushing before they terminate.
Without this patch, a qemu pseries_le_defconfig guest stops silently
when issued the nmi command when xmon is off and no crash dumpers
enabled. Afterwards, an oops is printed by each CPU as expected.
Fixes: ab9dbf771ff9 ("Revert "powerpc: Do not call ppc_md.panic in fadump panic notifier"")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-12-24 00:49:23 +08:00
|
|
|
panic_flush_kmsg_end();
|
2017-12-04 13:27:25 +08:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
lv1_pause(1);
|
|
|
|
}
|
|
|
|
|
2007-06-21 22:14:20 +08:00
|
|
|
#if defined(CONFIG_FB_PS3) || defined(CONFIG_FB_PS3_MODULE) || \
|
|
|
|
defined(CONFIG_PS3_FLASH) || defined(CONFIG_PS3_FLASH_MODULE)
|
2007-07-31 15:22:00 +08:00
|
|
|
static void __init prealloc(struct ps3_prealloc *p)
|
2007-02-12 16:55:22 +08:00
|
|
|
{
|
|
|
|
if (!p->size)
|
|
|
|
return;
|
|
|
|
|
powerpc: Remove more traces of bootmem
Although we are now selecting NO_BOOTMEM, we still have some traces of
bootmem lying around. That is because even with NO_BOOTMEM there is
still a shim that converts bootmem calls into memblock calls, but
ultimately we want to remove all traces of bootmem.
Most of the patch is conversions from alloc_bootmem() to
memblock_virt_alloc(). In general a call such as:
p = (struct foo *)alloc_bootmem(x);
Becomes:
p = memblock_virt_alloc(x, 0);
We don't need the cast because memblock_virt_alloc() returns a void *.
The alignment value of zero tells memblock to use the default alignment,
which is SMP_CACHE_BYTES, the same value alloc_bootmem() uses.
We remove a number of NULL checks on the result of
memblock_virt_alloc(). That is because memblock_virt_alloc() will panic
if it can't allocate, in exactly the same way as alloc_bootmem(), so the
NULL checks are and always have been redundant.
The memory returned by memblock_virt_alloc() is already zeroed, so we
remove several memsets of the result of memblock_virt_alloc().
Finally we convert a few uses of __alloc_bootmem(x, y, MAX_DMA_ADDRESS)
to just plain memblock_virt_alloc(). We don't use memblock_alloc_base()
because MAX_DMA_ADDRESS is ~0ul on powerpc, so limiting the allocation
to that is pointless, 16XB ought to be enough for anyone.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-11-18 13:47:35 +08:00
|
|
|
p->address = memblock_virt_alloc(p->size, p->align);
|
2007-02-12 16:55:22 +08:00
|
|
|
|
|
|
|
printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size,
|
|
|
|
p->address);
|
|
|
|
}
|
2007-06-21 22:14:20 +08:00
|
|
|
#endif
|
2007-02-12 16:55:22 +08:00
|
|
|
|
2007-06-21 22:14:20 +08:00
|
|
|
#if defined(CONFIG_FB_PS3) || defined(CONFIG_FB_PS3_MODULE)
|
2007-02-12 16:55:22 +08:00
|
|
|
struct ps3_prealloc ps3fb_videomemory = {
|
2007-06-16 06:05:38 +08:00
|
|
|
.name = "ps3fb videomemory",
|
|
|
|
.size = CONFIG_FB_PS3_DEFAULT_SIZE_M*1024*1024,
|
|
|
|
.align = 1024*1024 /* the GPU requires 1 MiB alignment */
|
2007-02-12 16:55:22 +08:00
|
|
|
};
|
2007-06-16 06:05:38 +08:00
|
|
|
EXPORT_SYMBOL_GPL(ps3fb_videomemory);
|
2007-02-12 16:55:22 +08:00
|
|
|
#define prealloc_ps3fb_videomemory() prealloc(&ps3fb_videomemory)
|
|
|
|
|
|
|
|
static int __init early_parse_ps3fb(char *p)
|
|
|
|
{
|
|
|
|
if (!p)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
ps3fb_videomemory.size = _ALIGN_UP(memparse(p, &p),
|
|
|
|
ps3fb_videomemory.align);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
early_param("ps3fb", early_parse_ps3fb);
|
|
|
|
#else
|
|
|
|
#define prealloc_ps3fb_videomemory() do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
2007-06-21 22:14:20 +08:00
|
|
|
#if defined(CONFIG_PS3_FLASH) || defined(CONFIG_PS3_FLASH_MODULE)
|
|
|
|
struct ps3_prealloc ps3flash_bounce_buffer = {
|
|
|
|
.name = "ps3flash bounce buffer",
|
|
|
|
.size = 256*1024,
|
|
|
|
.align = 256*1024
|
|
|
|
};
|
|
|
|
EXPORT_SYMBOL_GPL(ps3flash_bounce_buffer);
|
|
|
|
#define prealloc_ps3flash_bounce_buffer() prealloc(&ps3flash_bounce_buffer)
|
|
|
|
|
|
|
|
static int __init early_parse_ps3flash(char *p)
|
|
|
|
{
|
|
|
|
if (!p)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (!strcmp(p, "off"))
|
|
|
|
ps3flash_bounce_buffer.size = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
early_param("ps3flash", early_parse_ps3flash);
|
|
|
|
#else
|
|
|
|
#define prealloc_ps3flash_bounce_buffer() do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
2012-09-07 05:24:56 +08:00
|
|
|
static int ps3_set_dabr(unsigned long dabr, unsigned long dabrx)
|
2007-05-01 05:00:50 +08:00
|
|
|
{
|
2012-09-07 05:24:56 +08:00
|
|
|
/* Have to set at least one bit in the DABRX */
|
|
|
|
if (dabrx == 0 && dabr == 0)
|
|
|
|
dabrx = DABRX_USER;
|
|
|
|
/* hypervisor only allows us to set BTI, Kernel and user */
|
|
|
|
dabrx &= DABRX_BTI | DABRX_KERNEL | DABRX_USER;
|
2007-05-01 05:00:50 +08:00
|
|
|
|
2012-09-07 05:24:56 +08:00
|
|
|
return lv1_set_dabr(dabr, dabrx) ? -1 : 0;
|
2007-05-01 05:00:50 +08:00
|
|
|
}
|
2007-02-12 16:55:22 +08:00
|
|
|
|
2006-11-23 07:46:51 +08:00
|
|
|
static void __init ps3_setup_arch(void)
|
|
|
|
{
|
2011-11-29 23:38:50 +08:00
|
|
|
u64 tmp;
|
2007-01-27 11:08:21 +08:00
|
|
|
|
2006-11-23 07:46:51 +08:00
|
|
|
DBG(" -> %s:%d\n", __func__, __LINE__);
|
|
|
|
|
2011-11-29 23:38:50 +08:00
|
|
|
lv1_get_version_info(&ps3_firmware_version.raw, &tmp);
|
|
|
|
|
2007-06-16 05:18:48 +08:00
|
|
|
printk(KERN_INFO "PS3 firmware version %u.%u.%u\n",
|
|
|
|
ps3_firmware_version.major, ps3_firmware_version.minor,
|
|
|
|
ps3_firmware_version.rev);
|
2007-01-27 11:08:21 +08:00
|
|
|
|
2006-11-23 07:46:51 +08:00
|
|
|
ps3_spu_set_platform();
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
smp_init_ps3();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_DUMMY_CONSOLE
|
|
|
|
conswitchp = &dummy_con;
|
|
|
|
#endif
|
|
|
|
|
2007-02-12 16:55:22 +08:00
|
|
|
prealloc_ps3fb_videomemory();
|
2007-06-21 22:14:20 +08:00
|
|
|
prealloc_ps3flash_bounce_buffer();
|
|
|
|
|
2006-11-23 07:46:51 +08:00
|
|
|
ppc_md.power_save = ps3_power_save;
|
2007-10-07 05:35:47 +08:00
|
|
|
ps3_os_area_init();
|
2006-11-23 07:46:51 +08:00
|
|
|
|
|
|
|
DBG(" <- %s:%d\n", __func__, __LINE__);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init ps3_progress(char *s, unsigned short hex)
|
|
|
|
{
|
|
|
|
printk("*** %04x : %s\n", hex, s ? s : "");
|
|
|
|
}
|
|
|
|
|
2016-07-05 13:03:51 +08:00
|
|
|
void __init ps3_early_mm_init(void)
|
2006-11-23 07:46:51 +08:00
|
|
|
{
|
|
|
|
unsigned long htab_size;
|
2016-07-05 13:03:51 +08:00
|
|
|
|
|
|
|
ps3_mm_init();
|
|
|
|
ps3_mm_vas_create(&htab_size);
|
|
|
|
ps3_hpte_init(htab_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init ps3_probe(void)
|
|
|
|
{
|
2006-11-23 07:46:51 +08:00
|
|
|
DBG(" -> %s:%d\n", __func__, __LINE__);
|
|
|
|
|
2016-07-05 13:04:00 +08:00
|
|
|
if (!of_machine_is_compatible("sony,ps3"))
|
2006-11-23 07:46:51 +08:00
|
|
|
return 0;
|
|
|
|
|
2007-10-07 05:35:44 +08:00
|
|
|
ps3_os_area_save_params();
|
2016-07-05 13:04:00 +08:00
|
|
|
|
2014-10-13 22:01:09 +08:00
|
|
|
pm_power_off = ps3_power_off;
|
2006-11-23 07:46:51 +08:00
|
|
|
|
|
|
|
DBG(" <- %s:%d\n", __func__, __LINE__);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-11-29 20:45:50 +08:00
|
|
|
#if defined(CONFIG_KEXEC_CORE)
|
2006-11-23 07:46:51 +08:00
|
|
|
static void ps3_kexec_cpu_down(int crash_shutdown, int secondary)
|
|
|
|
{
|
2007-06-16 05:19:32 +08:00
|
|
|
int cpu = smp_processor_id();
|
2006-11-23 07:46:51 +08:00
|
|
|
|
2007-06-16 05:19:32 +08:00
|
|
|
DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);
|
2006-11-23 07:46:51 +08:00
|
|
|
|
2007-06-16 05:19:32 +08:00
|
|
|
ps3_smp_cleanup_cpu(cpu);
|
|
|
|
ps3_shutdown_IRQ(cpu);
|
2006-11-23 07:46:51 +08:00
|
|
|
|
|
|
|
DBG(" <- %s:%d\n", __func__, __LINE__);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
define_machine(ps3) {
|
|
|
|
.name = "PS3",
|
|
|
|
.probe = ps3_probe,
|
|
|
|
.setup_arch = ps3_setup_arch,
|
|
|
|
.init_IRQ = ps3_init_IRQ,
|
2017-12-04 13:27:25 +08:00
|
|
|
.panic = ps3_panic,
|
2006-11-23 07:46:51 +08:00
|
|
|
.get_boot_time = ps3_get_boot_time,
|
2007-05-01 05:00:50 +08:00
|
|
|
.set_dabr = ps3_set_dabr,
|
2006-11-23 07:46:51 +08:00
|
|
|
.calibrate_decr = ps3_calibrate_decr,
|
|
|
|
.progress = ps3_progress,
|
2007-02-08 04:20:01 +08:00
|
|
|
.restart = ps3_restart,
|
2008-03-27 08:38:31 +08:00
|
|
|
.halt = ps3_halt,
|
2016-11-29 20:45:50 +08:00
|
|
|
#if defined(CONFIG_KEXEC_CORE)
|
2006-11-23 07:46:51 +08:00
|
|
|
.kexec_cpu_down = ps3_kexec_cpu_down,
|
|
|
|
#endif
|
|
|
|
};
|