Skip to content

Commit c0cdf02

Browse files
khoatranyjkartben
authored andcommitted
soc: renesas: ra: Add support Renesas RA8T2 SoC
Add support Renesas RA8M2 SoC Signed-off-by: Khoa Tran <[email protected]>
1 parent ac941a3 commit c0cdf02

File tree

10 files changed

+409
-0
lines changed

10 files changed

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

soc/renesas/ra/ra8t2/Kconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_SERIES_RA8T2
5+
select ARM
6+
select CPU_HAS_ARM_SAU
7+
select CPU_HAS_ARM_MPU
8+
select CPU_HAS_FPU
9+
select FPU
10+
select CPU_CORTEX_M_HAS_DWT
11+
select ARMV8_M_DSP
12+
select HAS_SWO
13+
select XIP
14+
select CLOCK_CONTROL_RENESAS_RA_CGC if CLOCK_CONTROL
15+
select HAS_RENESAS_RA_FSP
16+
select SOC_EARLY_INIT_HOOK
17+
select HAS_PM
18+
19+
config SOC_R7KA8T2LFECAC_CM85
20+
select CPU_CORTEX_M85
21+
select GPIO_RA_HAS_VBTICTLR
22+
23+
config SOC_R7KA8T2LFECAC_CM33
24+
select CPU_CORTEX_M33
25+
select SOC_RA_SECOND_CORE_BUILD
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SOC_SERIES_RA8T2
5+
6+
config NUM_IRQS
7+
default 96
8+
9+
DT_CPUCLK0_PATH := $(dt_nodelabel_path,cpuclk0)
10+
DT_CPUCLK1_PATH := $(dt_nodelabel_path,cpuclk1)
11+
DT_LOCO_PATH := $(dt_nodelabel_path,loco)
12+
13+
config SYS_CLOCK_HW_CYCLES_PER_SEC
14+
default $(dt_node_int_prop_int,$(DT_CPUCLK0_PATH),clock-frequency) if SOC_R7KA8T2LFECAC_CM85 && CORTEX_M_SYSTICK
15+
default $(dt_node_int_prop_int,$(DT_CPUCLK1_PATH),clock-frequency) if SOC_R7KA8T2LFECAC_CM33 && CORTEX_M_SYSTICK
16+
default $(dt_node_int_prop_int,$(DT_LOCO_PATH),clock-frequency) if RENESAS_RA_ULPT_TIMER
17+
18+
config CORTEX_M_SYSTICK
19+
default n if RENESAS_RA_ULPT_TIMER
20+
21+
config SYS_CLOCK_TICKS_PER_SEC
22+
default 4096 if RENESAS_RA_ULPT_TIMER
23+
24+
config PM_DEVICE
25+
default y if PM
26+
27+
config PM_STATS
28+
default n if PM
29+
30+
config BUILD_OUTPUT_HEX
31+
default y
32+
33+
config CLOCK_CONTROL
34+
default y
35+
36+
config DCACHE
37+
default n
38+
39+
config CACHE_MANAGEMENT
40+
default n
41+
42+
endif # SOC_SERIES_RA8T2

soc/renesas/ra/ra8t2/Kconfig.soc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_SERIES_RA8T2
5+
bool
6+
select SOC_FAMILY_RENESAS_RA
7+
help
8+
Renesas RA8T2 series
9+
10+
config SOC_R7KA8T2LFECAC
11+
bool
12+
select SOC_SERIES_RA8T2
13+
help
14+
R7KA8T2LFECAC
15+
16+
config SOC_R7KA8T2LFECAC_CM85
17+
bool
18+
select SOC_R7KA8T2LFECAC
19+
20+
config SOC_R7KA8T2LFECAC_CM33
21+
bool
22+
select SOC_R7KA8T2LFECAC
23+
24+
config SOC_SERIES
25+
default "ra8t2" if SOC_SERIES_RA8T2
26+
27+
config SOC
28+
default "r7ka8t2lfecac" if SOC_R7KA8T2LFECAC

soc/renesas/ra/ra8t2/power.c

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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/pm/pm.h>
9+
#include <zephyr/init.h>
10+
#include <soc.h>
11+
#include <r_lpm.h>
12+
13+
#include <zephyr/logging/log.h>
14+
LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL);
15+
16+
/* Low Power Mode instance control structure */
17+
static lpm_instance_ctrl_t pm_state_ctrl;
18+
19+
/* Configuration for Runtime Idle Power State */
20+
const lpm_cfg_t pm_state_runtime_idle_cfg = {
21+
.low_power_mode = LPM_MODE_SLEEP,
22+
.standby_wake_sources = LPM_STANDBY_WAKE_SOURCE_ULP0U,
23+
.output_port_enable = LPM_OUTPUT_PORT_ENABLE_RETAIN,
24+
.io_port_state = LPM_IO_PORT_NO_CHANGE,
25+
.power_supply_state = LPM_POWER_SUPPLY_DEEP_STANDBY_MODE1,
26+
.deep_standby_cancel_source = (lpm_deep_standby_cancel_source_t)0,
27+
.deep_standby_cancel_edge = (lpm_deep_standby_cancel_edge_t)0,
28+
.ram_retention_cfg.ram_retention = (uint16_t)(0x7F),
29+
.ram_retention_cfg.tcm_retention = true,
30+
.ldo_standby_cfg.pll1_ldo = false,
31+
.ldo_standby_cfg.pll2_ldo = false,
32+
.ldo_standby_cfg.hoco_ldo = false,
33+
.p_extend = NULL,
34+
};
35+
36+
/* Configuration for Standby Power State */
37+
const lpm_cfg_t pm_state_standby_cfg = {
38+
.low_power_mode = LPM_MODE_STANDBY,
39+
.standby_wake_sources = LPM_STANDBY_WAKE_SOURCE_ULP0U,
40+
.output_port_enable = LPM_OUTPUT_PORT_ENABLE_RETAIN,
41+
.io_port_state = LPM_IO_PORT_NO_CHANGE,
42+
.power_supply_state = LPM_POWER_SUPPLY_DEEP_STANDBY_MODE1,
43+
.deep_standby_cancel_source = (lpm_deep_standby_cancel_source_t)0,
44+
.deep_standby_cancel_edge = (lpm_deep_standby_cancel_edge_t)0,
45+
.ram_retention_cfg.ram_retention = (uint16_t)(0x7F),
46+
.ram_retention_cfg.tcm_retention = true,
47+
.ldo_standby_cfg.pll1_ldo = false,
48+
.ldo_standby_cfg.pll2_ldo = false,
49+
.ldo_standby_cfg.hoco_ldo = false,
50+
.p_extend = NULL,
51+
};
52+
53+
void pm_state_set(enum pm_state state, uint8_t substate_id)
54+
{
55+
switch (state) {
56+
case PM_STATE_RUNTIME_IDLE:
57+
R_LPM_Open(&pm_state_ctrl, &pm_state_runtime_idle_cfg);
58+
__disable_irq();
59+
__set_BASEPRI(0);
60+
__ISB();
61+
62+
R_LPM_LowPowerModeEnter(&pm_state_ctrl);
63+
__enable_irq();
64+
__ISB();
65+
break;
66+
67+
case PM_STATE_STANDBY:
68+
R_LPM_Open(&pm_state_ctrl, &pm_state_standby_cfg);
69+
__disable_irq();
70+
__set_BASEPRI(0);
71+
__ISB();
72+
73+
R_LPM_LowPowerModeEnter(&pm_state_ctrl);
74+
__enable_irq();
75+
__ISB();
76+
break;
77+
78+
default:
79+
break;
80+
}
81+
}
82+
83+
void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
84+
{
85+
switch (state) {
86+
case PM_STATE_RUNTIME_IDLE:
87+
__fallthrough;
88+
case PM_STATE_STANDBY:
89+
R_LPM_Close(&pm_state_ctrl);
90+
break;
91+
92+
default:
93+
break;
94+
}
95+
irq_unlock(0);
96+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/devicetree.h>
8+
9+
#ifdef CONFIG_USE_RA_FSP_DTC
10+
SECTION_DATA_PROLOGUE(.fsp_dtc_vector_table,(NOLOAD),)
11+
{
12+
/* If DTC is used, put the DTC vector table at the start of SRAM.
13+
This avoids memory holes due to 1K alignment required by it. */
14+
*(.fsp_dtc_vector_table)
15+
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
16+
#endif /* CONFIG_USE_RA_FSP_DTC */

soc/renesas/ra/ra8t2/sections.ld

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/devicetree.h>
8+
9+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_ofs0))
10+
SECTION_DATA_PROLOGUE(.option_setting_ofs0, DT_REG_ADDR(DT_NODELABEL(option_setting_ofs0)),)
11+
{
12+
KEEP(*(.option_setting_ofs0))
13+
} GROUP_LINK_IN(OFS_OFS0_MEMORY)
14+
#endif
15+
16+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_ofs2))
17+
SECTION_DATA_PROLOGUE(.option_setting_ofs2, DT_REG_ADDR(DT_NODELABEL(option_setting_ofs2)),)
18+
{
19+
KEEP(*(.option_setting_ofs2))
20+
} GROUP_LINK_IN(OFS_OFS2_MEMORY)
21+
#endif
22+
23+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_sas))
24+
SECTION_DATA_PROLOGUE(.option_setting_sas, DT_REG_ADDR(DT_NODELABEL(option_setting_sas)),)
25+
{
26+
KEEP(*(.option_setting_sas))
27+
} GROUP_LINK_IN(OFS_SAS_MEMORY)
28+
#endif
29+
30+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_ofs1_sec))
31+
SECTION_DATA_PROLOGUE(.option_setting_ofs1_sec, DT_REG_ADDR(DT_NODELABEL(option_setting_ofs1_sec)),)
32+
{
33+
KEEP(*(.option_setting_ofs1_sec))
34+
} GROUP_LINK_IN(OFS_OFS1_SEC_MEMORY)
35+
#endif
36+
37+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_ofs3_sec))
38+
SECTION_DATA_PROLOGUE(.option_setting_ofs3_sec, DT_REG_ADDR(DT_NODELABEL(option_setting_ofs3_sec)),)
39+
{
40+
KEEP(*(.option_setting_ofs3_sec))
41+
} GROUP_LINK_IN(OFS_OFS3_SEC_MEMORY)
42+
#endif
43+
44+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_ofs1_sel))
45+
SECTION_DATA_PROLOGUE(.option_setting_ofs1_sel, DT_REG_ADDR(DT_NODELABEL(option_setting_ofs1_sel)),)
46+
{
47+
KEEP(*(.option_setting_ofs1_sel))
48+
} GROUP_LINK_IN(OFS_OFS1_SEL_MEMORY)
49+
#endif
50+
51+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_ofs3_sel))
52+
SECTION_DATA_PROLOGUE(.option_setting_ofs3_sel, DT_REG_ADDR(DT_NODELABEL(option_setting_ofs3_sel)),)
53+
{
54+
KEEP(*(.option_setting_ofs3_sel))
55+
} GROUP_LINK_IN(OFS_OFS3_SEL_MEMORY)
56+
#endif
57+
58+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_bps_sec))
59+
SECTION_DATA_PROLOGUE(.option_setting_bps_sec, DT_REG_ADDR(DT_NODELABEL(option_setting_bps_sec)),)
60+
{
61+
KEEP(*(.option_setting_bps_sec))
62+
} GROUP_LINK_IN(OFS_BPS_SEC_MEMORY)
63+
#endif
64+
65+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(option_setting_otp_pbps_sec))
66+
SECTION_DATA_PROLOGUE(.option_setting_otp_pbps_sec, DT_REG_ADDR(DT_NODELABEL(option_setting_otp_pbps_sec)),)
67+
{
68+
KEEP(*(.option_setting_otp_pbps_sec))
69+
} GROUP_LINK_IN(OFS_OTP_PBPS_SEC_MEMORY)
70+
#endif

soc/renesas/ra/ra8t2/soc.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 RA8T2 family processor
10+
*/
11+
12+
#include <zephyr/device.h>
13+
#include <zephyr/init.h>
14+
#include <zephyr/kernel.h>
15+
#include <zephyr/arch/cpu.h>
16+
#include <cmsis_core.h>
17+
#include <zephyr/irq.h>
18+
#include <zephyr/logging/log.h>
19+
#include <zephyr/sys/barrier.h>
20+
#include <zephyr/cache.h>
21+
LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
22+
23+
#include "soc.h"
24+
25+
#define CCR_CACHE_ENABLE (SCB_CCR_IC_Msk | SCB_CCR_BP_Msk | SCB_CCR_LOB_Msk)
26+
27+
uint32_t SystemCoreClock BSP_SECTION_EARLY_INIT;
28+
29+
volatile uint32_t g_protect_pfswe_counter BSP_SECTION_EARLY_INIT;
30+
31+
/**
32+
* @brief Perform basic hardware initialization at boot.
33+
*
34+
* This needs to be run from the very beginning.
35+
*/
36+
void soc_early_init_hook(void)
37+
{
38+
SystemCoreClock = BSP_MOCO_HZ;
39+
g_protect_pfswe_counter = 0;
40+
41+
extern volatile uint16_t g_protect_counters[];
42+
43+
for (uint32_t i = 0; i < 5; i++) {
44+
g_protect_counters[i] = 0;
45+
}
46+
47+
SystemCoreClock = BSP_MOCO_HZ;
48+
49+
#ifdef CONFIG_CPU_CORTEX_M85
50+
#ifdef CONFIG_ICACHE
51+
SCB->CCR = (uint32_t)CCR_CACHE_ENABLE;
52+
barrier_dsync_fence_full();
53+
barrier_isync_fence_full();
54+
#endif
55+
#if defined(CONFIG_DCACHE) && defined(CONFIG_CACHE_MANAGEMENT)
56+
/* Apply Arm Cortex-M85 errata workarounds for D-Cache
57+
* Attributing all cacheable memory as write-through set FORCEWT bit in MSCR register.
58+
* Set bit 16 in ACTLR to 1.
59+
* See erratum 3175626 and 3190818 in the Cortex-M85 AT640 and Cortex-M85 with FPU AT641
60+
* Software Developer Errata Notice (Date of issue: March 07, 2024, Document version: 13.0,
61+
* Document ID: SDEN-2236668).
62+
*/
63+
MEMSYSCTL->MSCR |= MEMSYSCTL_MSCR_FORCEWT_Msk;
64+
barrier_dsync_fence_full();
65+
barrier_isync_fence_full();
66+
ICB->ACTLR |= (1U << 16U);
67+
barrier_dsync_fence_full();
68+
barrier_isync_fence_full();
69+
70+
sys_cache_data_enable();
71+
#endif
72+
#endif /*CONFIG_CPU_CORTEX_M85*/
73+
74+
#ifdef CONFIG_CPU_CORTEX_M33
75+
#if FSP_PRIV_TZ_USE_SECURE_REGS
76+
/* Disable protection using PRCR register. */
77+
R_BSP_RegisterProtectDisable(BSP_REG_PROTECT_SAR);
78+
79+
/* Initialize peripherals to secure mode for flat projects */
80+
R_PSCU->PSARB = 0;
81+
R_PSCU->PSARC = 0;
82+
R_PSCU->PSARD = 0;
83+
R_PSCU->PSARE = 0;
84+
85+
R_CPSCU->ICUSARG = 0;
86+
R_CPSCU->ICUSARH = 0;
87+
R_CPSCU->ICUSARI = 0;
88+
89+
/* Enable protection using PRCR register. */
90+
R_BSP_RegisterProtectEnable(BSP_REG_PROTECT_SAR);
91+
#endif
92+
#endif /*CONFIG_CPU_CORTEX_M33*/
93+
}

0 commit comments

Comments
 (0)