platform: generic: add CVA6 platform and support for PMU
Samuel Holland
samuel.holland at sifive.com
Mon Dec 8 21:35:26 PST 2025
On 2025-12-05 12:57 AM, LE RHUN Jimmy wrote:
> Classified as: {OPEN}
>
> Add a new generic platform called CVA6 (https://github.com/openhwgroup/cva6).
> Add support for Performance Monitoring Unit for this platform.
>
> I hope it is in the right place this time.
>
> Signed-off-by: Jimmy Le Rhun <jimmy.lerhun at thalesgroup.com>
>
> ---
> platform/generic/Kconfig | 4 +
> platform/generic/configs/defconfig | 1 +
> platform/generic/openhwgroup/cva6.c | 185 ++++++++++++++++++++++++++++++++
> platform/generic/openhwgroup/objects.mk | 3 +
> 4 files changed, 193 insertions(+)
>
> diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig index 4b9bcfc..b8adb16 100644
> --- a/platform/generic/Kconfig
> +++ b/platform/generic/Kconfig
> @@ -43,6 +43,10 @@ config PLATFORM_ANDES_QILAI
> select ANDES_SBI
> default n
>
> +config PLATFORM_OPENHWGROUP_CVA6
> + bool "OpenHWGroup CVA6 support"
> + default n
> +
> config PLATFORM_OPENHWGROUP_OPENPITON
> bool "OpenHWGroup Openpiton support"
> default n
> diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
> index fb90bb3..f705934 100644
> --- a/platform/generic/configs/defconfig
> +++ b/platform/generic/configs/defconfig
> @@ -9,6 +9,7 @@ CONFIG_PLATFORM_STARFIVE_JH7110=y CONFIG_PLATFORM_THEAD=y CONFIG_PLATFORM_MIPS_P8700=y CONFIG_PLATFORM_OPENHWGROUP_OPENPITON=y
> +CONFIG_PLATFORM_OPENHWGROUP_CVA6=y
> CONFIG_FDT_CPPC=y
> CONFIG_FDT_CPPC_RPMI=y
> CONFIG_FDT_GPIO=y
> diff --git a/platform/generic/openhwgroup/cva6.c b/platform/generic/openhwgroup/cva6.c
> new file mode 100644
> index 0000000..bf44a50
> --- /dev/null
> +++ b/platform/generic/openhwgroup/cva6.c
> @@ -0,0 +1,185 @@
> +/* SPDX-License-Identifier: BSD-2-Clause */
> +/*
> + * Copyright (C) 2019 FORTH-ICS/CARV
> + * Panagiotis Peristerakis <perister at ics.forth.gr>
> + * Copyright (C) 2025 Thales Research & Technology
> + * Jimmy Le Rhun <jimmy.lerhun at thalesgroup.com>
> + */
> +
> +#include <platform_override.h>
> +#include <sbi/sbi_console.h>
> +#include <sbi/sbi_pmu.h>
> +#include <sbi_utils/fdt/fdt_helper.h>
> +#include <sbi_utils/fdt/fdt_fixup.h>
> +#include <sbi_utils/ipi/aclint_mswi.h>
> +#include <sbi_utils/irqchip/plic.h>
> +#include <sbi_utils/serial/uart8250.h>
> +#include <sbi_utils/timer/aclint_mtimer.h>
> +
> +#define CVA6_UART_ADDR 0x10000000ULL
> +#define CVA6_UART_FREQ 50000000
> +#define CVA6_UART_BAUDRATE 115200
> +#define CVA6_UART_REG_SHIFT 2
> +#define CVA6_UART_REG_WIDTH 4
> +#define CVA6_UART_REG_OFFSET 0
> +#define CVA6_UART_CAPS 0
> +#define CVA6_PLIC_ADDR 0xc000000ULL
> +#define CVA6_PLIC_SIZE (0x200000 + \
> + (CVA6_HART_COUNT * 0x1000))
> +#define CVA6_PLIC_NUM_SOURCES 3
> +#define CVA6_HART_COUNT 1
> +#define CVA6_CLINT_ADDR 0x2000000ULL
> +#define CVA6_ACLINT_MTIMER_FREQ 1000000
> +#define CVA6_ACLINT_MSWI_ADDR (CVA6_CLINT_ADDR + \
> + CLINT_MSWI_OFFSET)
> +#define CVA6_ACLINT_MTIMER_ADDR (CVA6_CLINT_ADDR + \
> + CLINT_MTIMER_OFFSET)
> +
> +#define CVA6_PERFCOUNTER_MASK 0x000001F8 //six configurable counters
> +#define CVA6_PERFEVENTS 22 //number of available events
> +#define CVA6_PERFEVENTS_RANGE 0x0000001F //five bits to encode 22 events
> +
> +static struct plic_data plic = {
> + .addr = (unsigned long)CVA6_PLIC_ADDR,
> + .size = CVA6_PLIC_SIZE,
> + .num_src = CVA6_PLIC_NUM_SOURCES,
> + .flags = PLIC_FLAG_ARIANE_BUG,
> + .context_map = {
> + [0] = { 0, 1 },
> + },
> +};
> +
> +static struct aclint_mswi_data mswi = {
> + .addr = (unsigned long)CVA6_ACLINT_MSWI_ADDR,
> + .size = ACLINT_MSWI_SIZE,
> + .first_hartid = 0,
> + .hart_count = CVA6_HART_COUNT,
> +};
> +
> +static struct aclint_mtimer_data mtimer = {
> + .mtime_freq = CVA6_ACLINT_MTIMER_FREQ,
> + .mtime_addr = (unsigned long)CVA6_ACLINT_MTIMER_ADDR +
> + ACLINT_DEFAULT_MTIME_OFFSET,
> + .mtime_size = ACLINT_DEFAULT_MTIME_SIZE,
> + .mtimecmp_addr = (unsigned long)CVA6_ACLINT_MTIMER_ADDR +
> + ACLINT_DEFAULT_MTIMECMP_OFFSET,
> + .mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE,
> + .first_hartid = 0,
> + .hart_count = CVA6_HART_COUNT,
> + .has_64bit_mmio = true,
> +};
Please don't add new platforms with hardcoded device addresses/configurations.
As Anup points out, all of this information should come from the devicetree. If
you don't want OpenSBI to depend on an external FDT blob, you can embed the FDT
by setting FW_FDT_PATH.
Regards,
Samuel
More information about the opensbi
mailing list