1 // SPDX-License-Identifier: GPL-2.0-only
3 * Pistachio platform setup
5 * Copyright (C) 2014 Google, Inc.
6 * Copyright (C) 2016 Imagination Technologies
9 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/of_address.h>
13 #include <linux/of_fdt.h>
15 #include <asm/cacheflush.h>
16 #include <asm/fw/fw.h>
17 #include <asm/mips-boards/generic.h>
18 #include <asm/mips-cps.h>
20 #include <asm/smp-ops.h>
21 #include <asm/traps.h>
24 * Core revision register decoding
25 * Bits 23 to 20: Major rev
26 * Bits 15 to 8: Minor rev
27 * Bits 7 to 0: Maintenance rev
29 #define PISTACHIO_CORE_REV_REG 0xB81483D0
30 #define PISTACHIO_CORE_REV_A1 0x00100006
31 #define PISTACHIO_CORE_REV_B0 0x00100106
33 const char *get_system_type(void)
38 core_rev = __raw_readl((const void *)PISTACHIO_CORE_REV_REG);
41 case PISTACHIO_CORE_REV_B0:
42 sys_type = "IMG Pistachio SoC (B0)";
45 case PISTACHIO_CORE_REV_A1:
46 sys_type = "IMG Pistachio SoC (A1)";
50 sys_type = "IMG Pistachio SoC";
57 void __init *plat_get_fdt(void)
60 panic("Device-tree not present");
61 return (void *)fw_arg1;
64 void __init plat_mem_setup(void)
66 __dt_setup_arch(plat_get_fdt());
69 #define DEFAULT_CPC_BASE_ADDR 0x1bde0000
70 #define DEFAULT_CDMM_BASE_ADDR 0x1bdd0000
72 phys_addr_t mips_cpc_default_phys_base(void)
74 return DEFAULT_CPC_BASE_ADDR;
77 phys_addr_t mips_cdmm_phys_base(void)
79 return DEFAULT_CDMM_BASE_ADDR;
82 static void __init mips_nmi_setup(void)
87 (void *)(CAC_BASE + 0xa80) :
88 (void *)(CAC_BASE + 0x380);
89 memcpy(base, except_vec_nmi, 0x80);
90 flush_icache_range((unsigned long)base,
91 (unsigned long)base + 0x80);
94 static void __init mips_ejtag_setup(void)
97 extern char except_vec_ejtag_debug[];
100 (void *)(CAC_BASE + 0xa00) :
101 (void *)(CAC_BASE + 0x300);
102 memcpy(base, except_vec_ejtag_debug, 0x80);
103 flush_icache_range((unsigned long)base,
104 (unsigned long)base + 0x80);
107 void __init prom_init(void)
109 board_nmi_handler_setup = mips_nmi_setup;
110 board_ejtag_handler_setup = mips_ejtag_setup;
114 register_cps_smp_ops();
116 pr_info("SoC Type: %s\n", get_system_type());
119 void __init device_tree_init(void)
121 if (!initial_boot_params)
124 unflatten_and_copy_device_tree();