Skip to content

Commit fc9d39a

Browse files
Hoang Nguyenkartben
authored andcommitted
soc: renesas: Add support for Renesas RZ/N2L
Add support for Renesas RZ/N2L Signed-off-by: Hoang Nguyen <[email protected]> Signed-off-by: Nhut Nguyen <[email protected]>
1 parent fa82af2 commit fc9d39a

File tree

11 files changed

+418
-0
lines changed

11 files changed

+418
-0
lines changed

dts/arm/renesas/rz/rzn/r9a07g084.dtsi

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <mem.h>
7+
#include <arm/armv8-r.dtsi>
8+
#include <zephyr/dt-bindings/interrupt-controller/arm-gic.h>
9+
10+
/ {
11+
#address-cells = <1>;
12+
#size-cells = <1>;
13+
compatible = "renesas,r9a07g084";
14+
15+
cpus {
16+
#address-cells = <1>;
17+
#size-cells = <0>;
18+
19+
cpu@0 {
20+
device_type = "cpu";
21+
compatible = "arm,cortex-r52";
22+
reg = <0>;
23+
};
24+
};
25+
26+
arch_timer: timer {
27+
compatible = "arm,armv8-timer";
28+
interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>,
29+
<GIC_PPI 14 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>,
30+
<GIC_PPI 11 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>,
31+
<GIC_PPI 10 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>;
32+
interrupt-parent = <&gic>;
33+
};
34+
35+
soc {
36+
interrupt-parent = <&gic>;
37+
38+
gic: interrupt-controller@94000000 {
39+
compatible = "arm,gic-v3", "arm,gic";
40+
reg = <0x94000000 0x10000>,
41+
<0x94100000 0x80000>;
42+
interrupt-controller;
43+
#interrupt-cells = <4>;
44+
status = "okay";
45+
};
46+
47+
atcm: memory@0 {
48+
compatible = "mmio-sram";
49+
reg = <0x00000000 DT_SIZE_K(128)>;
50+
};
51+
52+
btcm: memory@100000 {
53+
compatible = "mmio-sram";
54+
reg = <0x00100000 DT_SIZE_K(128)>;
55+
};
56+
57+
sram: memory@10000000 {
58+
compatible = "mmio-sram";
59+
reg = <0x10000000 (DT_SIZE_M(1) + DT_SIZE_K(512))>;
60+
};
61+
62+
xspi0_cs0: memory@60000000 {
63+
compatible = "mmio-sram";
64+
reg = <0x60000000 DT_SIZE_M(64)>;
65+
66+
partitions {
67+
compatible = "fixed-partitions";
68+
#address-cells = <1>;
69+
#size-cells = <1>;
70+
71+
loader_param: partition@0 {
72+
label = "loader-param";
73+
reg = <0x00000000 0x4C>;
74+
read-only;
75+
};
76+
77+
loader_program: partition@4C {
78+
label = "loader-program";
79+
reg = <0x0000004C (DT_SIZE_K(56) - 0x4C)>;
80+
read-only;
81+
};
82+
83+
slot0_partition: partition@E000 {
84+
label = "image-0";
85+
reg = <0x0000E000 (DT_SIZE_M(64) - DT_SIZE_K(56))>;
86+
read-only;
87+
};
88+
};
89+
};
90+
};
91+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/devicetree.h>
8+
#include <zephyr/linker/sections.h>
9+
10+
#define ROM_START (CONFIG_FLASH_BASE_ADDRESS + DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition)))
11+
#define RAM_START _image_ram_start // Require CONFIG_XIP=n
12+
#define APP_SIZE _image_ram_size
13+
14+
_ASM_FILE_PROLOGUE
15+
16+
GTEXT(loader_program)
17+
18+
/*
19+
* Loader program
20+
*/
21+
SECTION_FUNC(loader_text, loader_program)
22+
ldr r0, =ROM_START // Src in ROM
23+
ldr r1, =RAM_START // Des in RAM
24+
ldr r2, =APP_SIZE
25+
26+
cmp r2, #0
27+
beq exit
28+
29+
loop:
30+
ldrb r3, [r0], #1 // Load byte from src and increment src pointer
31+
strb r3, [r1], #1 // Store byte to des and increment des pointer
32+
subs r2, r2, #1 // Decrement size and updates the condition flags
33+
bne loop // If size is not 0, repeat loop
34+
35+
done:
36+
dsb sy
37+
ldr pc, =__start
38+
39+
exit:
40+
wfi

soc/renesas/rz/rzn2l/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
zephyr_sources(
5+
soc.c
6+
loader_param.c
7+
../common/loader_program.S
8+
)
9+
10+
zephyr_include_directories(.)
11+
12+
zephyr_linker_sources(SECTIONS sections.ld)
13+
14+
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_r/scripts/linker.ld CACHE INTERNAL "")

soc/renesas/rz/rzn2l/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_SERIES_RZN2L
5+
select ARM
6+
select CPU_CORTEX_R52
7+
select CPU_HAS_ARM_MPU
8+
select HAS_RENESAS_RZ_FSP
9+
select ARM_ARCH_TIMER
10+
select GIC_SINGLE_SECURITY_STATE
11+
select SOC_RESET_HOOK
12+
select SOC_EARLY_INIT_HOOK
13+
select ARM_CUSTOM_INTERRUPT_CONTROLLER
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SOC_SERIES_RZN2L
5+
6+
config NUM_IRQS
7+
default 480
8+
9+
config SYS_CLOCK_HW_CYCLES_PER_SEC
10+
default 25000000
11+
12+
config FPU
13+
default y
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+
DT_CHOSEN_IMAGE_ZEPHYR = zephyr,code-partition
22+
23+
config BUILD_OUTPUT_ADJUST_LMA
24+
default "($(dt_chosen_reg_addr_hex,$(DT_CHOSEN_IMAGE_ZEPHYR)) + \
25+
$(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH)))"
26+
27+
config BUILD_OUTPUT_ADJUST_LMA_SECTIONS
28+
default "*;!.loader"
29+
30+
endif # SOC_SERIES_RZN2L

soc/renesas/rz/rzn2l/Kconfig.soc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_SERIES_RZN2L
5+
bool
6+
select SOC_FAMILY_RENESAS_RZ
7+
help
8+
Renesas RZ/N2L series
9+
10+
config SOC_SERIES
11+
default "rzn2l" if SOC_SERIES_RZN2L
12+
13+
config SOC_R9A07G084M04GBG
14+
bool
15+
select SOC_SERIES_RZN2L
16+
help
17+
R9A07G084M04GBG
18+
19+
config SOC
20+
default "r9a07g084m04gbg" if SOC_R9A07G084M04GBG

soc/renesas/rz/rzn2l/loader_param.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <stdint.h>
8+
#include <zephyr/linker/section_tags.h>
9+
10+
#define CACHE_FLG (0x00000000)
11+
#define CS0BCR_V_WRAPCFG_V (0x00000000)
12+
#define CS0WCR_V_COMCFG_V (0x00000000)
13+
#define DUMMY0_BMCFG_V (0x00000000)
14+
#define BSC_FLG_xSPI_FLG (0x00000000)
15+
#define LDR_ADDR_NML (0x6000004C)
16+
#define LDR_SIZE_NML (0x00006000)
17+
#define DEST_ADDR_NML (0x00102000)
18+
#define DUMMY1 (0x00000000)
19+
#define DUMMY2 (0x00000000)
20+
#define DUMMY3_CSSCTL_V (0x0000003F)
21+
#define DUMMY4_LIOCFGCS0_V (0x00070000)
22+
#define DUMMY5 (0x00000000)
23+
#define DUMMY6 (0x00000000)
24+
#define DUMMY7 (0x00000000)
25+
#define DUMMY8 (0x00000000)
26+
#define DUMMY9 (0x00000000)
27+
#define DUMMY10_ACCESS_SPEED (0x00000006)
28+
#define CHECK_SUM (0xE0A8)
29+
#define LOADER_PARAM_MAX (19)
30+
31+
#define __loader_param Z_GENERIC_SECTION(.loader_param)
32+
33+
const uint32_t loader_param[LOADER_PARAM_MAX] __loader_param = {
34+
CACHE_FLG,
35+
CS0BCR_V_WRAPCFG_V,
36+
CS0WCR_V_COMCFG_V,
37+
DUMMY0_BMCFG_V,
38+
BSC_FLG_xSPI_FLG,
39+
LDR_ADDR_NML,
40+
LDR_SIZE_NML,
41+
DEST_ADDR_NML,
42+
DUMMY1,
43+
DUMMY2,
44+
DUMMY3_CSSCTL_V,
45+
DUMMY4_LIOCFGCS0_V,
46+
DUMMY5,
47+
DUMMY6,
48+
DUMMY7,
49+
DUMMY8,
50+
DUMMY9,
51+
DUMMY10_ACCESS_SPEED,
52+
CHECK_SUM,
53+
};

soc/renesas/rz/rzn2l/sections.ld

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <zephyr/devicetree.h>
7+
8+
SECTION_PROLOGUE(.loader, CONFIG_FLASH_BASE_ADDRESS,)
9+
{
10+
__loader_param_start = .;
11+
KEEP(*(.loader_param))
12+
__loader_param_end = .;
13+
. = DT_REG_ADDR(DT_NODELABEL(loader_program));
14+
__loader_program_start = .;
15+
KEEP(*(.loader_text.*))
16+
__loader_program_end = .;
17+
} GROUP_LINK_IN(FLASH)

soc/renesas/rz/rzn2l/soc.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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/N2L 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+
18+
extern void bsp_global_system_counter_init(void);
19+
20+
void *gp_renesas_isr_context[BSP_ICU_VECTOR_MAX_ENTRIES + BSP_CORTEX_VECTOR_TABLE_ENTRIES];
21+
IRQn_Type g_current_interrupt_num[32];
22+
uint8_t g_current_interrupt_pointer;
23+
24+
void soc_reset_hook(void)
25+
{
26+
/* Enable peripheral port access at EL1 and EL0 */
27+
__asm__ volatile("mrc p15, 0, r0, c15, c0, 0\n");
28+
__asm__ volatile("orr r0, #1\n");
29+
__asm__ volatile("mcr p15, 0, r0, c15, c0, 0\n");
30+
barrier_dsync_fence_full();
31+
barrier_isync_fence_full();
32+
}
33+
34+
void soc_early_init_hook(void)
35+
{
36+
/* Configure system clocks. */
37+
bsp_clock_init();
38+
39+
/* Initialize SystemCoreClock variable. */
40+
SystemCoreClockUpdate();
41+
42+
/* Initialize global system counter. The counter is enabled and is incrementing. */
43+
bsp_global_system_counter_init();
44+
}
45+
46+
unsigned int z_soc_irq_get_active(void)
47+
{
48+
int intid = arm_gic_get_active();
49+
50+
g_current_interrupt_num[g_current_interrupt_pointer++] = intid;
51+
52+
return intid;
53+
}
54+
55+
void z_soc_irq_eoi(unsigned int intid)
56+
{
57+
g_current_interrupt_pointer--;
58+
arm_gic_eoi(intid);
59+
}
60+
61+
void z_soc_irq_enable(unsigned int irq)
62+
{
63+
arm_gic_irq_enable(irq);
64+
}
65+
66+
void z_soc_irq_disable(unsigned int irq)
67+
{
68+
arm_gic_irq_disable(irq);
69+
}
70+
71+
int z_soc_irq_is_enabled(unsigned int irq)
72+
{
73+
return arm_gic_irq_is_enabled(irq);
74+
}
75+
76+
void z_soc_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
77+
{
78+
arm_gic_irq_set_priority(irq, prio, flags);
79+
}
80+
81+
void z_soc_irq_init(void)
82+
{
83+
g_current_interrupt_pointer = 0;
84+
}
85+
86+
/* Porting FSP IRQ configuration by an empty function */
87+
/* Let Zephyr handle IRQ configuration */
88+
void bsp_irq_core_cfg(void)
89+
{
90+
/* Do nothing */
91+
}

0 commit comments

Comments
 (0)