blob: 00f6d100bed8ba34bd695a1e82ba66346b1d6be9 [file] [log] [blame]
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02001/*
2 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
3 * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#include <arch.h>
9#include <arch_helpers.h>
10#include <bl_common.h>
11#include <bl31.h>
12#include <cci.h>
13#include <console.h>
14#include <mmio.h>
15#include <platform.h>
16#include <stddef.h>
17#include <debug.h>
18#include "pwrc.h"
19#include "rcar_def.h"
20#include "rcar_private.h"
21#include "rcar_version.h"
22
23IMPORT_SYM(uint64_t, __RO_START__, BL31_RO_BASE)
24IMPORT_SYM(uint64_t, __RO_END__, BL31_RO_LIMIT)
25
26#if USE_COHERENT_MEM
27IMPORT_SYM(uint64_t, __COHERENT_RAM_START__, BL31_COHERENT_RAM_BASE)
28IMPORT_SYM(uint64_t, __COHERENT_RAM_END__, BL31_COHERENT_RAM_LIMIT)
29#endif
30
31extern void plat_rcar_gic_driver_init(void);
32extern void plat_rcar_gic_init(void);
33
34u_register_t rcar_boot_mpidr;
35
36static int cci_map[] = {
37 CCI500_CLUSTER0_SL_IFACE_IX_FOR_M3,
38 CCI500_CLUSTER1_SL_IFACE_IX_FOR_M3
39};
40
41void plat_cci_init(void)
42{
43 uint32_t prd;
44
45 prd = mmio_read_32(RCAR_PRR) & (RCAR_PRODUCT_MASK | RCAR_CUT_MASK);
46
47 if (RCAR_PRODUCT_H3_CUT10 == prd || RCAR_PRODUCT_H3_CUT11 == prd) {
48 cci_map[0U] = CCI500_CLUSTER0_SL_IFACE_IX;
49 cci_map[1U] = CCI500_CLUSTER1_SL_IFACE_IX;
50 }
51
52 cci_init(RCAR_CCI_BASE, cci_map, ARRAY_SIZE(cci_map));
53}
54
55void plat_cci_enable(void)
56{
57 cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
58}
59
60void plat_cci_disable(void)
61{
62 cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
63}
64
65entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
66{
67 bl2_to_bl31_params_mem_t *from_bl2 = (bl2_to_bl31_params_mem_t *)
68 PARAMS_BASE;
69 entry_point_info_t *next_image_info;
70
71 next_image_info = (type == NON_SECURE) ?
72 &from_bl2->bl33_ep_info : &from_bl2->bl32_ep_info;
73
74 return next_image_info->pc ? next_image_info : NULL;
75}
76
77void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
78 u_register_t arg2, u_register_t arg3)
79{
80 /* dummy config: the actual console configuration (platform specific)
81 is done in the driver (scif.c) */
82 console_init(1, 0, 0);
83
84 NOTICE("BL3-1 : Rev.%s\n", version_of_renesas);
85
86 if (RCAR_CLUSTER_A53A57 == rcar_pwrc_get_cluster()) {
87 plat_cci_init();
88 plat_cci_enable();
89 }
90}
91
92void bl31_plat_arch_setup(void)
93{
94 rcar_configure_mmu_el3(BL31_BASE,
95 BL31_LIMIT - BL31_BASE,
96 BL31_RO_BASE, BL31_RO_LIMIT
97#if USE_COHERENT_MEM
98 , BL31_COHERENT_RAM_BASE, BL31_COHERENT_RAM_LIMIT
99#endif
100 );
101}
102
103void bl31_platform_setup(void)
104{
105 plat_rcar_gic_driver_init();
106 plat_rcar_gic_init();
107
108 /* enable the system level generic timer */
109 mmio_write_32(RCAR_CNTC_BASE + CNTCR_OFF, CNTCR_FCREQ(U(0)) | CNTCR_EN);
110
111 rcar_pwrc_setup();
112#if 0
113 /* TODO: there is a broad number of rcar-gen3 SoC configurations; to
114 support all of them, Renesas use the pwrc driver to discover what
115 cores are on/off before announcing the topology.
116 This code hasnt been ported yet
117 */
118
119 rcar_setup_topology();
120#endif
121
122 /* mask should match the kernel's MPIDR_HWID_BITMASK so the core can be
123 identified during cpuhotplug (check the kernel's psci migrate set of
124 functions */
125 rcar_boot_mpidr = read_mpidr_el1() & 0x0000ffffU;
126}