2019-06-01 16:08:37 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2015-03-17 05:43:10 +08:00
|
|
|
/*
|
|
|
|
* Pistachio platform setup
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Google, Inc.
|
2016-04-19 22:46:55 +08:00
|
|
|
* Copyright (C) 2016 Imagination Technologies
|
2015-03-17 05:43:10 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
2016-04-19 22:46:55 +08:00
|
|
|
#include <linux/io.h>
|
2015-03-17 05:43:10 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/of_address.h>
|
|
|
|
#include <linux/of_fdt.h>
|
|
|
|
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <asm/dma-coherence.h>
|
|
|
|
#include <asm/fw/fw.h>
|
|
|
|
#include <asm/mips-boards/generic.h>
|
2017-08-13 10:49:41 +08:00
|
|
|
#include <asm/mips-cps.h>
|
2015-03-17 05:43:10 +08:00
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/smp-ops.h>
|
|
|
|
#include <asm/traps.h>
|
|
|
|
|
2016-04-19 22:46:55 +08:00
|
|
|
/*
|
|
|
|
* Core revision register decoding
|
|
|
|
* Bits 23 to 20: Major rev
|
|
|
|
* Bits 15 to 8: Minor rev
|
|
|
|
* Bits 7 to 0: Maintenance rev
|
|
|
|
*/
|
|
|
|
#define PISTACHIO_CORE_REV_REG 0xB81483D0
|
|
|
|
#define PISTACHIO_CORE_REV_A1 0x00100006
|
|
|
|
#define PISTACHIO_CORE_REV_B0 0x00100106
|
|
|
|
|
2015-03-17 05:43:10 +08:00
|
|
|
const char *get_system_type(void)
|
|
|
|
{
|
2016-04-19 22:46:55 +08:00
|
|
|
u32 core_rev;
|
|
|
|
const char *sys_type;
|
|
|
|
|
|
|
|
core_rev = __raw_readl((const void *)PISTACHIO_CORE_REV_REG);
|
|
|
|
|
|
|
|
switch (core_rev) {
|
|
|
|
case PISTACHIO_CORE_REV_B0:
|
|
|
|
sys_type = "IMG Pistachio SoC (B0)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PISTACHIO_CORE_REV_A1:
|
|
|
|
sys_type = "IMG Pistachio SoC (A1)";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
sys_type = "IMG Pistachio SoC";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sys_type;
|
2015-03-17 05:43:10 +08:00
|
|
|
}
|
|
|
|
|
2016-05-25 19:58:40 +08:00
|
|
|
void __init *plat_get_fdt(void)
|
2015-03-17 05:43:10 +08:00
|
|
|
{
|
|
|
|
if (fw_arg0 != -2)
|
|
|
|
panic("Device-tree not present");
|
2016-05-25 19:58:40 +08:00
|
|
|
return (void *)fw_arg1;
|
|
|
|
}
|
2015-03-17 05:43:10 +08:00
|
|
|
|
2016-05-25 19:58:40 +08:00
|
|
|
void __init plat_mem_setup(void)
|
|
|
|
{
|
|
|
|
__dt_setup_arch(plat_get_fdt());
|
2015-03-17 05:43:10 +08:00
|
|
|
}
|
|
|
|
|
2015-04-17 17:44:16 +08:00
|
|
|
#define DEFAULT_CPC_BASE_ADDR 0x1bde0000
|
|
|
|
#define DEFAULT_CDMM_BASE_ADDR 0x1bdd0000
|
2015-03-17 05:43:10 +08:00
|
|
|
|
|
|
|
phys_addr_t mips_cpc_default_phys_base(void)
|
|
|
|
{
|
|
|
|
return DEFAULT_CPC_BASE_ADDR;
|
|
|
|
}
|
|
|
|
|
2015-04-17 17:44:16 +08:00
|
|
|
phys_addr_t mips_cdmm_phys_base(void)
|
|
|
|
{
|
|
|
|
return DEFAULT_CDMM_BASE_ADDR;
|
|
|
|
}
|
|
|
|
|
2015-03-17 05:43:10 +08:00
|
|
|
static void __init mips_nmi_setup(void)
|
|
|
|
{
|
|
|
|
void *base;
|
2020-05-23 23:50:34 +08:00
|
|
|
extern char except_vec_nmi[];
|
2015-03-17 05:43:10 +08:00
|
|
|
|
|
|
|
base = cpu_has_veic ?
|
|
|
|
(void *)(CAC_BASE + 0xa80) :
|
|
|
|
(void *)(CAC_BASE + 0x380);
|
2020-05-23 23:50:34 +08:00
|
|
|
memcpy(base, except_vec_nmi, 0x80);
|
2015-03-17 05:43:10 +08:00
|
|
|
flush_icache_range((unsigned long)base,
|
|
|
|
(unsigned long)base + 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init mips_ejtag_setup(void)
|
|
|
|
{
|
|
|
|
void *base;
|
2020-05-23 23:50:34 +08:00
|
|
|
extern char except_vec_ejtag_debug[];
|
2015-03-17 05:43:10 +08:00
|
|
|
|
|
|
|
base = cpu_has_veic ?
|
|
|
|
(void *)(CAC_BASE + 0xa00) :
|
|
|
|
(void *)(CAC_BASE + 0x300);
|
2020-05-23 23:50:34 +08:00
|
|
|
memcpy(base, except_vec_ejtag_debug, 0x80);
|
2015-03-17 05:43:10 +08:00
|
|
|
flush_icache_range((unsigned long)base,
|
|
|
|
(unsigned long)base + 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init prom_init(void)
|
|
|
|
{
|
|
|
|
board_nmi_handler_setup = mips_nmi_setup;
|
|
|
|
board_ejtag_handler_setup = mips_ejtag_setup;
|
|
|
|
|
|
|
|
mips_cm_probe();
|
|
|
|
mips_cpc_probe();
|
|
|
|
register_cps_smp_ops();
|
2016-04-19 22:46:55 +08:00
|
|
|
|
|
|
|
pr_info("SoC Type: %s\n", get_system_type());
|
2015-03-17 05:43:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void __init prom_free_prom_memory(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init device_tree_init(void)
|
|
|
|
{
|
|
|
|
if (!initial_boot_params)
|
|
|
|
return;
|
|
|
|
|
|
|
|
unflatten_and_copy_device_tree();
|
|
|
|
}
|