Skip to content

Commit 9688b75

Browse files
tiennguyenzgkartben
authored andcommitted
soc: renesas: Add support for Renesas RZ/V2H R8 core
Add support for Renesas RZ/V2H R8 core Signed-off-by: Tien Nguyen <[email protected]>
1 parent f0acbd6 commit 9688b75

File tree

9 files changed

+229
-0
lines changed

9 files changed

+229
-0
lines changed

soc/renesas/rz/rzv2h/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,14 @@ zephyr_include_directories(.)
66
if(CONFIG_SOC_R9A09G057H44GBG_CM33)
77
zephyr_include_directories(cm33)
88
zephyr_sources(cm33/soc.c)
9+
910
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")
11+
12+
elseif(CONFIG_SOC_R9A09G057H44GBG_CR8)
13+
zephyr_include_directories(cr8)
14+
zephyr_sources(cr8/soc.c)
15+
16+
zephyr_sources_ifdef(CONFIG_ARM_MPU cr8/arm_mpu_regions.c)
17+
18+
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld CACHE INTERNAL "")
1019
endif()

soc/renesas/rz/rzv2h/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,16 @@ config SOC_R9A09G057H44GBG_CM33
1010
select SOC_EARLY_INIT_HOOK
1111
select CPU_HAS_FPU
1212
select ARMV8_M_DSP
13+
14+
config SOC_R9A09G057H44GBG_CR8
15+
select ARM
16+
select CPU_CORTEX_R8
17+
select CPU_HAS_ARM_MPU
18+
select CPU_HAS_FPU
19+
select ARM_ARCH_TIMER
20+
select ARM_CUSTOM_INTERRUPT_CONTROLLER
21+
select HAS_RENESAS_RZ_FSP
22+
select VFP_DP_D16
23+
select SOC_EARLY_INIT_HOOK
24+
select CPU_HAS_ICACHE
25+
select CPU_HAS_DCACHE
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SOC_R9A09G057H44GBG_CR8
5+
6+
config NUM_IRQS
7+
default 512
8+
9+
config FPU
10+
default y
11+
12+
config SYS_CLOCK_HW_CYCLES_PER_SEC
13+
default $(div,$(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency),4)
14+
15+
config FLASH_SIZE
16+
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_FLASH),0,K)
17+
18+
config FLASH_BASE_ADDRESS
19+
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH))
20+
21+
config SYS_CLOCK_EXISTS
22+
default y
23+
24+
endif # SOC_R9A09G057H44GBG_CR8

soc/renesas/rz/rzv2h/Kconfig.soc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,11 @@ config SOC_R9A09G057H44GBG_CM33
2222
help
2323
RZ/V2H CM33
2424

25+
config SOC_R9A09G057H44GBG_CR8
26+
bool
27+
select SOC_R9A09G057H44GBG
28+
help
29+
RZ/V2H CR8
30+
2531
config SOC
2632
default "r9a09g057h44gbg" if SOC_R9A09G057H44GBG

soc/renesas/rz/rzv2h/cm33/soc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
/* System core clock is set to 200 MHz after reset */
1616
uint32_t SystemCoreClock = 200000000;
17+
void *gp_renesas_isr_context[BSP_ICU_VECTOR_MAX_ENTRIES];
1718

1819
void soc_early_init_hook(void)
1920
{
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/arch/arm/mpu/arm_mpu.h>
9+
10+
/* clang-format off */
11+
12+
#define MPUTYPE_READ_ONLY \
13+
{ \
14+
.rasr = (P_RO_U_RO_Msk \
15+
| (7 << MPU_RASR_TEX_Pos) \
16+
| MPU_RASR_C_Msk \
17+
| MPU_RASR_B_Msk \
18+
| MPU_RASR_XN_Msk) \
19+
}
20+
21+
#define MPUTYPE_READ_ONLY_PRIV \
22+
{ \
23+
.rasr = (P_RO_U_RO_Msk \
24+
| (5 << MPU_RASR_TEX_Pos) \
25+
| MPU_RASR_B_Msk) \
26+
}
27+
28+
#define MPUTYPE_PRIV_WBWACACHE_XN \
29+
{ \
30+
.rasr = (P_RW_U_NA_Msk \
31+
| (5 << MPU_RASR_TEX_Pos) \
32+
| MPU_RASR_B_Msk \
33+
| MPU_RASR_XN_Msk) \
34+
}
35+
36+
#define MPUTYPE_PRIV_DEVICE \
37+
{ \
38+
.rasr = (P_RW_U_NA_Msk \
39+
| (2 << MPU_RASR_TEX_Pos) \
40+
| MPU_RASR_XN_Msk \
41+
| MPU_RASR_B_Msk \
42+
| MPU_RASR_S_Msk) \
43+
}
44+
45+
/* clang-format on */
46+
47+
extern uint32_t _image_rom_end_order;
48+
static const struct arm_mpu_region mpu_regions[] = {
49+
50+
/* clang-format off */
51+
52+
MPU_REGION_ENTRY("SRAM",
53+
0x00000000,
54+
REGION_256M,
55+
MPUTYPE_PRIV_WBWACACHE_XN),
56+
57+
MPU_REGION_ENTRY("SRAM",
58+
0x00000000,
59+
((uint32_t)&_image_rom_end_order),
60+
MPUTYPE_READ_ONLY_PRIV),
61+
62+
MPU_REGION_ENTRY("REGISTERS",
63+
0x10000000,
64+
REGION_256M,
65+
MPUTYPE_PRIV_DEVICE),
66+
67+
MPU_REGION_ENTRY("FLASH",
68+
0x20000000,
69+
REGION_256M,
70+
MPUTYPE_READ_ONLY),
71+
72+
/* clang-format on */
73+
};
74+
75+
const struct arm_mpu_config mpu_config = {
76+
.num_regions = ARRAY_SIZE(mpu_regions),
77+
.mpu_regions = mpu_regions,
78+
};

soc/renesas/rz/rzv2h/cr8/soc.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @file
9+
* @brief System/hardware module for Renesas RZ/V2H Group
10+
*/
11+
12+
#include <bsp_api.h>
13+
#include <zephyr/init.h>
14+
#include <zephyr/sys/barrier.h>
15+
#include <zephyr/drivers/interrupt_controller/gic.h>
16+
#include <zephyr/irq.h>
17+
#include <zephyr/cache.h>
18+
19+
/* System core clock is set to 800 MHz after reset */
20+
uint32_t SystemCoreClock BSP_SECTION_EARLY_INIT;
21+
void *gp_renesas_isr_context[BSP_ICU_VECTOR_MAX_ENTRIES + BSP_CORTEX_VECTOR_TABLE_ENTRIES];
22+
uint16_t g_current_interrupt_num[32];
23+
uint8_t g_current_interrupt_pointer;
24+
25+
void soc_early_init_hook(void)
26+
{
27+
bsp_clock_init();
28+
29+
/* Initialize SystemCoreClock variable. */
30+
SystemCoreClockUpdate();
31+
32+
/* Enable caches */
33+
sys_cache_instr_enable();
34+
sys_cache_data_enable();
35+
}
36+
37+
unsigned int z_soc_irq_get_active(void)
38+
{
39+
int intid = arm_gic_get_active();
40+
41+
if (intid != 1023) {
42+
g_current_interrupt_num[g_current_interrupt_pointer++] = intid;
43+
}
44+
45+
return intid;
46+
}
47+
48+
void z_soc_irq_eoi(unsigned int intid)
49+
{
50+
if (intid != 1023) {
51+
g_current_interrupt_pointer--;
52+
}
53+
arm_gic_eoi(intid);
54+
}
55+
56+
void z_soc_irq_enable(unsigned int irq)
57+
{
58+
arm_gic_irq_enable(irq);
59+
}
60+
61+
void z_soc_irq_disable(unsigned int irq)
62+
{
63+
arm_gic_irq_disable(irq);
64+
}
65+
66+
int z_soc_irq_is_enabled(unsigned int irq)
67+
{
68+
return arm_gic_irq_is_enabled(irq);
69+
}
70+
71+
void z_soc_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
72+
{
73+
arm_gic_irq_set_priority(irq, prio, flags);
74+
}
75+
76+
void z_soc_irq_init(void)
77+
{
78+
g_current_interrupt_pointer = 0;
79+
}

soc/renesas/rz/rzv2h/cr8/soc.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_SOC_RENESAS_RZV2H_SOC_H_
8+
#define ZEPHYR_SOC_RENESAS_RZV2H_SOC_H_
9+
10+
/* Define CMSIS configurations */
11+
#define __CR_REV 1U
12+
13+
/* Do not let CMSIS to handle GIC and Timer */
14+
#define __GIC_PRESENT 0
15+
#define __TIM_PRESENT 0
16+
#define __FPU_PRESENT 1
17+
18+
#endif /* ZEPHYR_SOC_RENESAS_RZV2H_SOC_H_ */

soc/renesas/rz/soc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ family:
3535
- name: r9a09g057h44gbg
3636
cpuclusters:
3737
- name: cm33
38+
- name: cr8_0
3839
- name: rzv2n
3940
socs:
4041
- name: r9a09g056n48gbg

0 commit comments

Comments
 (0)