Skip to content

Commit a8ec691

Browse files
committed
plat: renesas: Add support for RZ/A series
Add support for Renesas RZ/A series Signed-off-by: Nhut Nguyen <[email protected]>
1 parent 713ffbf commit a8ec691

File tree

132 files changed

+22173
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+22173
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Copyright (c) 2024-2025, Renesas Electronics Corporation. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
BOARD := a3m_ek_nor
8+
9+
APPLOAD ?= RZ_NOFIP
10+
$(eval $(call add_define,APPLOAD))
11+
12+
include plat/renesas/rza/common/rz_common.mk
13+
14+
XSPI0_DEVICE ?= qspiflash_mx25l25645g
15+
XSPI_DEVICE_TYPE := QSPI
16+
$(eval $(call add_define_val,XSPI_DEVICE_TYPE,\"${XSPI_DEVICE_TYPE}\"))
17+
18+
NAND := 0
19+
RZ_FLASH_SIZE ?= 33554432 # 32MB
20+
$(eval $(call add_define,RZ_FLASH_SIZE))
21+
22+
ifneq (${USE_SDRAM},0)
23+
ifeq (${DDR_PLL4},1333)
24+
DDR_SOURCES += plat/renesas/rza/soc/a3m/drivers/ddr/param_mc_C-011_D3-02-1.c \
25+
plat/renesas/rza/common/drivers/ddr/param_swizzle_T1.c
26+
else
27+
DDR_PLL4 := 1600
28+
DDR_SOURCES += plat/renesas/rza/soc/a3m/drivers/ddr/param_mc_C-011_D3-01-1.c \
29+
plat/renesas/rza/common/drivers/ddr/param_swizzle_T1.c
30+
endif
31+
$(eval $(call add_define,DDR_PLL4))
32+
endif
33+
34+
include plat/renesas/rza/soc/a3m/rz_xspi.mk
35+
include plat/renesas/rza/soc/a3m/soc.mk
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Copyright (c) 2021-2025, Renesas Electronics Corporation. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
BOARD := a3ul_smarc_octal
8+
9+
APPLOAD ?= RZ_NOFIP
10+
$(eval $(call add_define,APPLOAD))
11+
12+
include plat/renesas/rza/common/rz_common.mk
13+
14+
XSPI1_DEVICE ?= octaflash_mx66uw
15+
XSPI1_IF_OPTION ?= .device_size=128*1024*1024
16+
XSPI2_DEVICE ?= octaram_apsxx
17+
XSPI2_IF_OPTION ?= .device_size=64*1024*1024
18+
XSPI_DEVICE_TYPE := OCTA
19+
$(eval $(call add_define_val,XSPI_DEVICE_TYPE,\"${XSPI_DEVICE_TYPE}\"))
20+
21+
NAND := 0
22+
RZ_FLASH_SIZE ?= 134217728 # 128MB
23+
$(eval $(call add_define,RZ_FLASH_SIZE))
24+
25+
ifneq (${USE_SDRAM},0)
26+
DDR_SOURCES += plat/renesas/rza/soc/a3ul/drivers/ddr/param_mc_C-011_D4-01-2.c \
27+
plat/renesas/rza/common/drivers/ddr/param_swizzle_T3bcud2.c
28+
29+
DDR_PLL4 := 1600
30+
$(eval $(call add_define,DDR_PLL4))
31+
endif
32+
33+
include plat/renesas/rza/soc/a3ul/rz_xspi.mk
34+
include plat/renesas/rza/soc/a3ul/soc.mk
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Copyright (c) 2021-2025, Renesas Electronics Corporation. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
BOARD := a3ul_smarc_qspi
8+
9+
APPLOAD ?= RZ_NOFIP
10+
$(eval $(call add_define,APPLOAD))
11+
12+
include plat/renesas/rza/common/rz_common.mk
13+
14+
XSPI0_DEVICE ?= qspiflash_at25
15+
XSPI_DEVICE_TYPE := QSPI
16+
$(eval $(call add_define_val,XSPI_DEVICE_TYPE,\"${XSPI_DEVICE_TYPE}\"))
17+
18+
NAND := 0
19+
RZ_FLASH_SIZE ?= 16777216 # 16MB
20+
$(eval $(call add_define,RZ_FLASH_SIZE))
21+
22+
ifneq (${USE_SDRAM},0)
23+
DDR_SOURCES += plat/renesas/rza/soc/a3ul/drivers/ddr/param_mc_C-011_D4-01-2.c \
24+
plat/renesas/rza/common/drivers/ddr/param_swizzle_T3bcud2.c
25+
26+
DDR_PLL4 := 1600
27+
$(eval $(call add_define,DDR_PLL4))
28+
endif
29+
30+
include plat/renesas/rza/soc/a3ul/rz_xspi.mk
31+
include plat/renesas/rza/soc/a3ul/soc.mk
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3+
* Copyright (c) 2020-2025, Renesas Electronics Corporation. All rights reserved.
4+
*
5+
* SPDX-License-Identifier: BSD-3-Clause
6+
*/
7+
8+
#include <asm_macros.S>
9+
10+
.globl platform_mem_init
11+
.globl plat_my_core_pos
12+
.globl plat_crash_console_init
13+
.globl plat_crash_console_putc
14+
.globl plat_crash_console_flush
15+
16+
func platform_mem_init
17+
ret
18+
endfunc platform_mem_init
19+
20+
func plat_my_core_pos
21+
mrs x0, mpidr_el1
22+
lsr x0, x0, #MPIDR_AFF1_SHIFT
23+
and x0, x0, #MPIDR_CPU_MASK
24+
ret
25+
endfunc plat_my_core_pos
26+
27+
func plat_crash_console_init
28+
mov x0, #1
29+
ret
30+
endfunc plat_crash_console_init
31+
32+
func plat_crash_console_putc
33+
ret
34+
endfunc plat_crash_console_putc
35+
36+
func plat_crash_console_flush
37+
mov x0, #0
38+
ret
39+
endfunc plat_crash_console_flush
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2020-2025, Renesas Electronics Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include <plat/common/platform.h>
8+
#include <platform_def.h>
9+
10+
#include <common/desc_image_load.h>
11+
12+
static bl_mem_params_node_t bl2_mem_params_descs[] = {
13+
#if (APPLOAD == RZ_NOFIP)
14+
{
15+
.image_id = MAX_IMAGE_IDS,
16+
17+
SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
18+
entry_point_info_t,
19+
SECURE | EXECUTABLE | EP_FIRST_EXE),
20+
.ep_info.spsr =
21+
SPSR_64(MODE_EL3, MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS),
22+
.ep_info.pc = BSP_BASE,
23+
.ep_info.args.arg0 = (uintptr_t)PARAMS_BASE,
24+
25+
SET_STATIC_PARAM_HEAD(
26+
image_info, PARAM_EP, VERSION_2, image_info_t,
27+
IMAGE_ATTRIB_PLAT_SETUP | IMAGE_ATTRIB_SKIP_LOADING),
28+
29+
.next_handoff_image_id = INVALID_IMAGE_ID,
30+
}
31+
#else
32+
{
33+
#if RZA3
34+
.image_id = BL31_IMAGE_ID,
35+
36+
SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
37+
entry_point_info_t,
38+
SECURE | EXECUTABLE | EP_FIRST_EXE),
39+
.ep_info.spsr =
40+
SPSR_64(MODE_EL3, MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS),
41+
.ep_info.pc = BSP_BASE,
42+
.ep_info.args.arg0 = (uintptr_t)PARAMS_BASE,
43+
44+
SET_STATIC_PARAM_HEAD(
45+
image_info, PARAM_EP, VERSION_2, image_info_t,
46+
IMAGE_ATTRIB_PLAT_SETUP | IMAGE_ATTRIB_SKIP_LOADING),
47+
.image_info.image_max_size = BSP_LIMIT - BSP_BASE,
48+
.image_info.image_base = BSP_BASE,
49+
50+
.next_handoff_image_id = INVALID_IMAGE_ID,
51+
#endif /* RZA3 */
52+
}
53+
#endif /* (APPLOAD == RZ_NOFIP) */
54+
};
55+
56+
REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* Copyright (c) 2020-2025, Renesas Electronics Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include <assert.h>
8+
#include <string.h>
9+
10+
#include <plat/common/common_def.h>
11+
#include <plat_tzc_def.h>
12+
#include <platform_def.h>
13+
14+
#include <arch.h>
15+
#include <arch_helpers.h>
16+
#include <common/bl_common.h>
17+
#include <common/desc_image_load.h>
18+
#include <cpg.h>
19+
#include <ddr.h>
20+
#include <drivers/generic_delay_timer.h>
21+
#include <lib/mmio.h>
22+
#include <lib/xlat_tables/xlat_tables_compat.h>
23+
#include <pfc.h>
24+
#include <rz_private.h>
25+
#include <rza_ipl_version.h>
26+
#include <rza_mmu.h>
27+
#include <rza_printf.h>
28+
#include <scifa.h>
29+
#include <syc.h>
30+
#include <sys_regs.h>
31+
32+
static console_t console;
33+
34+
int bl2_plat_handle_pre_image_load(unsigned int image_id)
35+
{
36+
return 0;
37+
}
38+
39+
int bl2_plat_handle_post_image_load(unsigned int image_id)
40+
{
41+
static bl2_to_bl31_params_mem_t *params;
42+
bl_mem_params_node_t *bl_mem_params;
43+
44+
if (!params) {
45+
params = (bl2_to_bl31_params_mem_t *)PARAMS_BASE;
46+
memset((void *)PARAMS_BASE, 0, sizeof(*params));
47+
}
48+
49+
bl_mem_params = get_bl_mem_params_node(image_id);
50+
51+
switch (image_id) {
52+
case BL32_IMAGE_ID:
53+
memcpy(&params->bl32_ep_info, &bl_mem_params->ep_info,
54+
sizeof(entry_point_info_t));
55+
break;
56+
case BL33_IMAGE_ID:
57+
memcpy(&params->bl33_ep_info, &bl_mem_params->ep_info,
58+
sizeof(entry_point_info_t));
59+
break;
60+
default:
61+
/* Do nothing in default case */
62+
break;
63+
}
64+
65+
return 0;
66+
}
67+
68+
void bl2_el3_early_platform_setup(u_register_t arg1, u_register_t arg2,
69+
u_register_t arg3, u_register_t arg4)
70+
{
71+
int ret;
72+
73+
/* early setup Clock and Reset */
74+
cpg_early_setup();
75+
76+
/* initialize SYC */
77+
syc_init(PLAT_SYC_INCK_HZ);
78+
79+
/* initialize Timer */
80+
generic_delay_timer_init();
81+
82+
/* setup PFC */
83+
pfc_setup();
84+
85+
/* setup Clock and Reset */
86+
cpg_setup();
87+
88+
/* initialize console driver */
89+
ret = console_rza_register(PLAT_SCIF0_BASE, PLAT_UART_INCK_HZ,
90+
PLAT_UART_BARDRATE, &console);
91+
if (!ret)
92+
panic();
93+
94+
console_set_scope(&console, CONSOLE_FLAG_BOOT | CONSOLE_FLAG_CRASH);
95+
96+
RZA_PRINTF("Initial Program Loader %s\n", RZA_IPL_VERSION_STRING);
97+
}
98+
99+
void bl2_el3_plat_arch_setup(void)
100+
{
101+
rza_mmu_pgtbl_cfg_t g_mmu_pagetable_array[] = {
102+
/* vaddress, paddress, size, attribute */
103+
{ 0x00000000, 0x00000000, 0x00200000,
104+
RZA_MMU_ATTRIBUTE_NORMAL_CACHEABLE },
105+
{ 0x00200000, 0x00200000, 0x0FE00000,
106+
RZA_MMU_ATTRIBUTE_ACCESS_FAULT },
107+
{ 0x10000000, 0x10000000, 0x10000000,
108+
RZA_MMU_ATTRIBUTE_DEVICE },
109+
{ 0x20000000, 0x20000000, 0x10000000,
110+
RZA_MMU_ATTRIBUTE_NORMAL_CACHEABLE },
111+
{ 0x30000000, 0x30000000, 0x10000000,
112+
RZA_MMU_ATTRIBUTE_ACCESS_FAULT },
113+
{ 0x40000000, 0x40000000, 0x40000000,
114+
RZA_MMU_ATTRIBUTE_NORMAL_CACHEABLE },
115+
{ 0x80000000, 0x80000000, 0x40000000,
116+
RZA_MMU_ATTRIBUTE_ACCESS_FAULT },
117+
{ 0xC0000000, 0xC0000000, 0x40000000,
118+
RZA_MMU_ATTRIBUTE_ACCESS_FAULT },
119+
{ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
120+
RZA_MMU_ATTRIBUTE_CONFIG_END }
121+
};
122+
123+
if (0 != plat_mmu_init(g_mmu_pagetable_array)) {
124+
panic();
125+
}
126+
plat_mmu_enable();
127+
}
128+
129+
void bl2_platform_setup(void)
130+
{
131+
/* Setup TZC-400, Access Control */
132+
plat_security_setup();
133+
134+
#if USE_SDRAM
135+
/* initialize DDR */
136+
ddr_setup();
137+
#endif /* DEBUG_FPGA */
138+
139+
rz_io_setup();
140+
141+
RZ_RUN_TESTS();
142+
143+
#if (APPLOAD == RZ_NOFIP)
144+
rza_load_fsp();
145+
#endif
146+
rza_print_descs();
147+
}

0 commit comments

Comments
 (0)