Skip to content

Commit 4f6b48e

Browse files
Appana Durga Kedareswara raokartben
authored andcommitted
soc: amd: Add support for AMD Versal Gen 2 RPU
Add support for the RPU, real-time processing unit on Versal Gen 2 SoC. It is based on Cortext-R52 processor. The patch contains initial wiring and configuration for generic board with OCM(1MB) and DDR(2G) memories, cpu, interrupt controller, global timer and UART. versal2.dtsi contains common peripherals integrated into Versal Gen 2 SoC, and versal2_r52.dtsi has peripherals which are private to Cortex-R52 processor. Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
1 parent ca182ed commit 4f6b48e

File tree

10 files changed

+241
-0
lines changed

10 files changed

+241
-0
lines changed

dts/arm/xilinx/versal2_r52.dtsi

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2025, Advanced Micro Devices, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
9+
#include <mem.h>
10+
#include <arm/armv8-r.dtsi>
11+
#include <zephyr/dt-bindings/interrupt-controller/arm-gic.h>
12+
#include <amd/versal2.dtsi>
13+
14+
/ {
15+
model = "Versal Gen 2 RPU";
16+
17+
cpus {
18+
#address-cells = <1>;
19+
#size-cells = <0>;
20+
21+
cpu0: cpu@0 {
22+
device_type = "cpu";
23+
compatible = "arm,cortex-r52";
24+
reg = <0>;
25+
};
26+
};
27+
28+
arch_timer: timer {
29+
compatible = "arm,armv8-timer";
30+
interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>,
31+
<GIC_PPI 14 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>,
32+
<GIC_PPI 11 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>,
33+
<GIC_PPI 10 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>;
34+
interrupt-parent = <&gic>;
35+
status = "okay";
36+
};
37+
};
38+
39+
&soc {
40+
interrupt-parent = <&gic>;
41+
42+
gic: interrupt-controller@e2000000 {
43+
compatible = "arm,gic-v3", "arm,gic";
44+
reg = <0xe2000000 0x10000>, <0xe2100000 0x80000>;
45+
interrupt-controller;
46+
#interrupt-cells = <4>;
47+
status = "okay";
48+
};
49+
};

dts/vendor/amd/versal2.dtsi

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2025, Advanced Micro Devices, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
soc: soc {
9+
ocm: memory@bbf00000 {
10+
compatible = "zephyr,memory-region";
11+
reg = <0xbbf00000 DT_SIZE_M(1)>;
12+
status = "disabled";
13+
zephyr,memory-region = "OCM";
14+
};
15+
16+
uart0: uart@f1920000 {
17+
compatible = "arm,sbsa-uart";
18+
reg = <0xf1920000 0x4c>;
19+
status = "disabled";
20+
interrupt-names = "irq_0";
21+
interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>;
22+
};
23+
24+
uart1: uart@f1930000 {
25+
compatible = "arm,sbsa-uart";
26+
reg = <0xf1930000 0x1000>;
27+
status = "disabled";
28+
interrupt-names = "irq_1";
29+
interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>;
30+
};
31+
};
32+
};

soc/xlnx/versal2/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
zephyr_sources(
8+
soc.c
9+
)
10+
zephyr_sources_ifdef(
11+
CONFIG_ARM_MPU
12+
arm_mpu_regions.c
13+
)
14+
15+
zephyr_include_directories(.)
16+
17+
if(CONFIG_SOC_AMD_VERSAL2_RPU)
18+
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld CACHE INTERNAL "")
19+
endif()

soc/xlnx/versal2/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
config SOC_AMD_VERSAL2_RPU
8+
select ARM
9+
select ARM_ARCH_TIMER
10+
select CPU_CORTEX_R52
11+
select SOC_EARLY_INIT_HOOK
12+
select CPU_HAS_DCLS
13+
select GIC_SINGLE_SECURITY_STATE
14+
select CPU_HAS_ARM_MPU
15+
select ARM_MPU

soc/xlnx/versal2/Kconfig.defconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
if SOC_AMD_VERSAL2
8+
9+
if SOC_AMD_VERSAL2_RPU
10+
11+
config NUM_IRQS
12+
# must be >= the highest interrupt number used
13+
# - include the UART interrupts
14+
default 256
15+
16+
config SYS_CLOCK_HW_CYCLES_PER_SEC
17+
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)
18+
19+
endif # SOC_AMD_VERSAL2_RPU
20+
21+
endif # SOC_VERSAL2_AMD

soc/xlnx/versal2/Kconfig.soc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
config SOC_AMD_VERSAL2
8+
bool
9+
10+
config SOC_AMD_VERSAL2_RPU
11+
bool
12+
select SOC_AMD_VERSAL2
13+
help
14+
AMD Versal Gen 2 RPU
15+
16+
config SOC_FAMILY
17+
default "amd_versal2" if SOC_AMD_VERSAL2
18+
19+
config SOC
20+
default "amd_versal2_rpu" if SOC_AMD_VERSAL2_RPU

soc/xlnx/versal2/arm_mpu_regions.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2025 Advanced Micro Devices, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/linker/linker-defs.h>
9+
#include <zephyr/arch/arm/mpu/arm_mpu.h>
10+
11+
#define DEVICE_REGION_START 0xE2000000U
12+
#define DEVICE_REGION_END 0xF8000000U
13+
14+
static const struct arm_mpu_region mpu_regions[] = {
15+
MPU_REGION_ENTRY("vector",
16+
(uintptr_t)_vector_start,
17+
REGION_RAM_TEXT_ATTR((uintptr_t)_vector_end)),
18+
19+
MPU_REGION_ENTRY("SRAM_TEXT",
20+
(uintptr_t)__text_region_start,
21+
REGION_RAM_TEXT_ATTR((uintptr_t)__rodata_region_start)),
22+
23+
MPU_REGION_ENTRY("SRAM_RODATA",
24+
(uintptr_t)__rodata_region_start,
25+
REGION_RAM_RO_ATTR((uintptr_t)__rodata_region_end)),
26+
27+
MPU_REGION_ENTRY("SRAM_DATA",
28+
(uintptr_t)__rom_region_end,
29+
REGION_RAM_ATTR((uintptr_t)__kernel_ram_end)),
30+
31+
MPU_REGION_ENTRY("DEVICE",
32+
DEVICE_REGION_START,
33+
REGION_DEVICE_ATTR(DEVICE_REGION_END)),
34+
};
35+
36+
const struct arm_mpu_config mpu_config = {
37+
.num_regions = ARRAY_SIZE(mpu_regions),
38+
.mpu_regions = mpu_regions,
39+
};

soc/xlnx/versal2/soc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2025 Advanced Micro Devices, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/cache.h>
8+
#include <zephyr/device.h>
9+
#include <zephyr/kernel.h>
10+
11+
void soc_early_init_hook(void)
12+
{
13+
if (IS_ENABLED(CONFIG_ICACHE)) {
14+
if (!(__get_SCTLR() & SCTLR_I_Msk)) {
15+
L1C_InvalidateICacheAll();
16+
__set_SCTLR(__get_SCTLR() | SCTLR_I_Msk);
17+
barrier_isync_fence_full();
18+
}
19+
}
20+
21+
if (IS_ENABLED(CONFIG_DCACHE)) {
22+
if (!(__get_SCTLR() & SCTLR_C_Msk)) {
23+
L1C_InvalidateDCacheAll();
24+
__set_SCTLR(__get_SCTLR() | SCTLR_C_Msk);
25+
barrier_dsync_fence_full();
26+
}
27+
}
28+
}

soc/xlnx/versal2/soc.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2025 Advanced Micro Devices, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef _SOC_XLNX_VERSAL2_SOC_H_
8+
#define _SOC_XLNX_VERSAL2_SOC_H_
9+
10+
/* Define CMSIS configurations */
11+
#define __GIC_PRESENT 0
12+
#define __TIM_PRESENT 0
13+
14+
#endif /* _SOC_XLNX_VERSAL2_SOC_H_ */

soc/xlnx/versal2/soc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
family:
2+
- name: amd_versal2
3+
socs:
4+
- name: amd_versal2_rpu

0 commit comments

Comments
 (0)