Path: blob/master/arch/powerpc/platforms/ps3/setup.c
10818 views
/*1* PS3 platform setup routines.2*3* Copyright (C) 2006 Sony Computer Entertainment Inc.4* Copyright 2006 Sony Corp.5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; version 2 of the License.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/1920#include <linux/kernel.h>21#include <linux/delay.h>22#include <linux/fs.h>23#include <linux/root_dev.h>24#include <linux/console.h>25#include <linux/bootmem.h>2627#include <asm/machdep.h>28#include <asm/firmware.h>29#include <asm/time.h>30#include <asm/iommu.h>31#include <asm/udbg.h>32#include <asm/prom.h>33#include <asm/lv1call.h>34#include <asm/ps3gpu.h>3536#include "platform.h"3738#if defined(DEBUG)39#define DBG udbg_printf40#else41#define DBG pr_debug42#endif4344/* mutex synchronizing GPU accesses and video mode changes */45DEFINE_MUTEX(ps3_gpu_mutex);46EXPORT_SYMBOL_GPL(ps3_gpu_mutex);4748static union ps3_firmware_version ps3_firmware_version;4950void ps3_get_firmware_version(union ps3_firmware_version *v)51{52*v = ps3_firmware_version;53}54EXPORT_SYMBOL_GPL(ps3_get_firmware_version);5556int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev)57{58union ps3_firmware_version x;5960x.pad = 0;61x.major = major;62x.minor = minor;63x.rev = rev;6465return (ps3_firmware_version.raw > x.raw) -66(ps3_firmware_version.raw < x.raw);67}68EXPORT_SYMBOL_GPL(ps3_compare_firmware_version);6970static void ps3_power_save(void)71{72/*73* lv1_pause() puts the PPE thread into inactive state until an74* irq on an unmasked plug exists. MSR[EE] has no effect.75* flags: 0 = wake on DEC interrupt, 1 = ignore DEC interrupt.76*/7778lv1_pause(0);79}8081static void ps3_restart(char *cmd)82{83DBG("%s:%d cmd '%s'\n", __func__, __LINE__, cmd);8485smp_send_stop();86ps3_sys_manager_restart(); /* never returns */87}8889static void ps3_power_off(void)90{91DBG("%s:%d\n", __func__, __LINE__);9293smp_send_stop();94ps3_sys_manager_power_off(); /* never returns */95}9697static void ps3_halt(void)98{99DBG("%s:%d\n", __func__, __LINE__);100101smp_send_stop();102ps3_sys_manager_halt(); /* never returns */103}104105static void ps3_panic(char *str)106{107DBG("%s:%d %s\n", __func__, __LINE__, str);108109smp_send_stop();110printk("\n");111printk(" System does not reboot automatically.\n");112printk(" Please press POWER button.\n");113printk("\n");114115while(1)116lv1_pause(1);117}118119#if defined(CONFIG_FB_PS3) || defined(CONFIG_FB_PS3_MODULE) || \120defined(CONFIG_PS3_FLASH) || defined(CONFIG_PS3_FLASH_MODULE)121static void __init prealloc(struct ps3_prealloc *p)122{123if (!p->size)124return;125126p->address = __alloc_bootmem(p->size, p->align, __pa(MAX_DMA_ADDRESS));127if (!p->address) {128printk(KERN_ERR "%s: Cannot allocate %s\n", __func__,129p->name);130return;131}132133printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size,134p->address);135}136#endif137138#if defined(CONFIG_FB_PS3) || defined(CONFIG_FB_PS3_MODULE)139struct ps3_prealloc ps3fb_videomemory = {140.name = "ps3fb videomemory",141.size = CONFIG_FB_PS3_DEFAULT_SIZE_M*1024*1024,142.align = 1024*1024 /* the GPU requires 1 MiB alignment */143};144EXPORT_SYMBOL_GPL(ps3fb_videomemory);145#define prealloc_ps3fb_videomemory() prealloc(&ps3fb_videomemory)146147static int __init early_parse_ps3fb(char *p)148{149if (!p)150return 1;151152ps3fb_videomemory.size = _ALIGN_UP(memparse(p, &p),153ps3fb_videomemory.align);154return 0;155}156early_param("ps3fb", early_parse_ps3fb);157#else158#define prealloc_ps3fb_videomemory() do { } while (0)159#endif160161#if defined(CONFIG_PS3_FLASH) || defined(CONFIG_PS3_FLASH_MODULE)162struct ps3_prealloc ps3flash_bounce_buffer = {163.name = "ps3flash bounce buffer",164.size = 256*1024,165.align = 256*1024166};167EXPORT_SYMBOL_GPL(ps3flash_bounce_buffer);168#define prealloc_ps3flash_bounce_buffer() prealloc(&ps3flash_bounce_buffer)169170static int __init early_parse_ps3flash(char *p)171{172if (!p)173return 1;174175if (!strcmp(p, "off"))176ps3flash_bounce_buffer.size = 0;177178return 0;179}180early_param("ps3flash", early_parse_ps3flash);181#else182#define prealloc_ps3flash_bounce_buffer() do { } while (0)183#endif184185static int ps3_set_dabr(unsigned long dabr)186{187enum {DABR_USER = 1, DABR_KERNEL = 2,};188189return lv1_set_dabr(dabr, DABR_KERNEL | DABR_USER) ? -1 : 0;190}191192static void __init ps3_setup_arch(void)193{194195DBG(" -> %s:%d\n", __func__, __LINE__);196197lv1_get_version_info(&ps3_firmware_version.raw);198printk(KERN_INFO "PS3 firmware version %u.%u.%u\n",199ps3_firmware_version.major, ps3_firmware_version.minor,200ps3_firmware_version.rev);201202ps3_spu_set_platform();203204#ifdef CONFIG_SMP205smp_init_ps3();206#endif207208#ifdef CONFIG_DUMMY_CONSOLE209conswitchp = &dummy_con;210#endif211212prealloc_ps3fb_videomemory();213prealloc_ps3flash_bounce_buffer();214215ppc_md.power_save = ps3_power_save;216ps3_os_area_init();217218DBG(" <- %s:%d\n", __func__, __LINE__);219}220221static void __init ps3_progress(char *s, unsigned short hex)222{223printk("*** %04x : %s\n", hex, s ? s : "");224}225226static int __init ps3_probe(void)227{228unsigned long htab_size;229unsigned long dt_root;230231DBG(" -> %s:%d\n", __func__, __LINE__);232233dt_root = of_get_flat_dt_root();234if (!of_flat_dt_is_compatible(dt_root, "sony,ps3"))235return 0;236237powerpc_firmware_features |= FW_FEATURE_PS3_POSSIBLE;238239ps3_os_area_save_params();240ps3_mm_init();241ps3_mm_vas_create(&htab_size);242ps3_hpte_init(htab_size);243244DBG(" <- %s:%d\n", __func__, __LINE__);245return 1;246}247248#if defined(CONFIG_KEXEC)249static void ps3_kexec_cpu_down(int crash_shutdown, int secondary)250{251int cpu = smp_processor_id();252253DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);254255ps3_smp_cleanup_cpu(cpu);256ps3_shutdown_IRQ(cpu);257258DBG(" <- %s:%d\n", __func__, __LINE__);259}260#endif261262define_machine(ps3) {263.name = "PS3",264.probe = ps3_probe,265.setup_arch = ps3_setup_arch,266.init_IRQ = ps3_init_IRQ,267.panic = ps3_panic,268.get_boot_time = ps3_get_boot_time,269.set_dabr = ps3_set_dabr,270.calibrate_decr = ps3_calibrate_decr,271.progress = ps3_progress,272.restart = ps3_restart,273.power_off = ps3_power_off,274.halt = ps3_halt,275#if defined(CONFIG_KEXEC)276.kexec_cpu_down = ps3_kexec_cpu_down,277#endif278};279280281