From 70b3113ab301b9dc890ab283566630d4452fe790 Mon Sep 17 00:00:00 2001 From: sophgo-forum-service Date: Sat, 20 Jul 2024 21:40:47 +0800 Subject: [PATCH] opensbi: weekly rls 2024.07.20 -0aa741, support cv181x/cv180x suspend to ram. Change-Id: I64dcb0ff942aa7238a88ef3bd1da2c67f5d089b4 --- opensbi/Makefile | 21 ++++ opensbi/docs/domain_support.md | 5 + opensbi/include/sbi/sbi_domain.h | 2 + opensbi/include/sbi/sbi_ecall.h | 1 + opensbi/include/sbi/sbi_ecall_interface.h | 8 ++ opensbi/include/sbi/sbi_hsm.h | 4 + opensbi/include/sbi/sbi_system.h | 26 +++++ opensbi/lib/sbi/objects.mk | 1 + opensbi/lib/sbi/sbi_domain.c | 3 + opensbi/lib/sbi/sbi_ecall.c | 3 + opensbi/lib/sbi/sbi_ecall_susp.c | 60 ++++++++++ opensbi/lib/sbi/sbi_hsm.c | 21 +++- opensbi/lib/sbi/sbi_init.c | 4 + opensbi/lib/sbi/sbi_system.c | 85 ++++++++++++++ opensbi/lib/utils/fdt/fdt_domain.c | 7 ++ opensbi/platform/generic/cvitek_riscv.c | 107 ++++++++++++++++++ .../generic/include/platform_override.h | 5 + opensbi/platform/generic/objects.mk | 1 + opensbi/platform/generic/platform.c | 3 +- opensbi/pm_default_cv180x.bin | Bin 0 -> 1808 bytes opensbi/pm_default_cv181x.bin | Bin 0 -> 1800 bytes 21 files changed, 363 insertions(+), 4 deletions(-) create mode 100644 opensbi/lib/sbi/sbi_ecall_susp.c create mode 100644 opensbi/platform/generic/cvitek_riscv.c create mode 100755 opensbi/pm_default_cv180x.bin create mode 100755 opensbi/pm_default_cv181x.bin diff --git a/opensbi/Makefile b/opensbi/Makefile index eeffe6bad..598674e40 100644 --- a/opensbi/Makefile +++ b/opensbi/Makefile @@ -143,6 +143,20 @@ deps-y+=$(libsbi-objs-path-y:.o=.dep) deps-y+=$(libsbiutils-objs-path-y:.o=.dep) deps-y+=$(firmware-objs-path-y:.o=.dep) +ifeq (,$(wildcard ${PM_SRAM_BIN_PATH})) + ifeq (${CHIP_ARCH},CV180X) + PM_SRAM_BIN_PATH=${OPENSBI_PATH}/pm_default_cv180x.bin + endif + ifeq (${CHIP_ARCH},CV181X) + PM_SRAM_BIN_PATH=${OPENSBI_PATH}/pm_default_cv181x.bin + endif +else +ifeq ($(filter clean %clean clean%,$(MAKECMDGOALS)),) +$(shell touch -c platform\generic\cvitek_riscv.c > /dev/null) +endif +endif +$(info PM_SRAM_BIN_PATH is '${PM_SRAM_BIN_PATH}') + # Setup platform ABI, ISA and Code Model ifndef PLATFORM_RISCV_ABI ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1) @@ -212,6 +226,13 @@ CFLAGS += $(GENFLAGS) CFLAGS += $(platform-cflags-y) CFLAGS += -fno-pie -no-pie CFLAGS += $(firmware-cflags-y) +CFLAGS += -DPM_SRAM_BIN_PATH=$(PM_SRAM_BIN_PATH) +ifeq ($(CHIP_ARCH),CV180X) +CFLAGS += -DCONFIG_CV180X +endif +ifeq (${CHIP_ARCH},CV181X) +CFLAGS += -DCONFIG_CV181X +endif CPPFLAGS += $(GENFLAGS) CPPFLAGS += $(platform-cppflags-y) diff --git a/opensbi/docs/domain_support.md b/opensbi/docs/domain_support.md index 73931f1da..2a883ed87 100644 --- a/opensbi/docs/domain_support.md +++ b/opensbi/docs/domain_support.md @@ -52,6 +52,7 @@ has following details: * **next_mode** - Privilege mode of the next booting stage for this domain. This can be either S-mode or U-mode. * **system_reset_allowed** - Is domain allowed to reset the system? +* **system_suspend_allowed** - Is domain allowed to suspend the system? The memory regions represented by **regions** in **struct sbi_domain** have following additional constraints to align with RISC-V PMP requirements: @@ -91,6 +92,7 @@ following manner: * **next_mode** - Next booting stage mode in coldboot HART scratch space is the next mode for the ROOT domain * **system_reset_allowed** - The ROOT domain is allowed to reset the system +* **system_suspend_allowed** - The ROOT domain is allowed to suspend the system Domain Effects -------------- @@ -187,6 +189,8 @@ The DT properties of a domain instance DT node are as follows: stage mode of coldboot HART** is used as default value. * **system-reset-allowed** (Optional) - A boolean flag representing whether the domain instance is allowed to do system reset. +* **system-suspend-allowed** (Optional) - A boolean flag representing + whether the domain instance is allowed to do system suspend. ### Assigning HART To Domain Instance @@ -252,6 +256,7 @@ be done: next-addr = <0x0 0x80100000>; next-mode = <0x0>; system-reset-allowed; + system-suspend-allowed; }; udomain: untrusted-domain { diff --git a/opensbi/include/sbi/sbi_domain.h b/opensbi/include/sbi/sbi_domain.h index 15e3a5397..3a4afc2d0 100644 --- a/opensbi/include/sbi/sbi_domain.h +++ b/opensbi/include/sbi/sbi_domain.h @@ -78,6 +78,8 @@ struct sbi_domain { unsigned long next_mode; /** Is domain allowed to reset the system */ bool system_reset_allowed; + /** Is domain allowed to suspend the system */ + bool system_suspend_allowed; }; /** The root domain instance */ diff --git a/opensbi/include/sbi/sbi_ecall.h b/opensbi/include/sbi/sbi_ecall.h index 63ef866ba..8396fc12d 100644 --- a/opensbi/include/sbi/sbi_ecall.h +++ b/opensbi/include/sbi/sbi_ecall.h @@ -39,6 +39,7 @@ extern struct sbi_ecall_extension ecall_ipi; extern struct sbi_ecall_extension ecall_vendor; extern struct sbi_ecall_extension ecall_hsm; extern struct sbi_ecall_extension ecall_srst; +extern struct sbi_ecall_extension ecall_susp; u16 sbi_ecall_version_major(void); diff --git a/opensbi/include/sbi/sbi_ecall_interface.h b/opensbi/include/sbi/sbi_ecall_interface.h index 743a21f07..7301cfff7 100644 --- a/opensbi/include/sbi/sbi_ecall_interface.h +++ b/opensbi/include/sbi/sbi_ecall_interface.h @@ -28,6 +28,7 @@ #define SBI_EXT_RFENCE 0x52464E43 #define SBI_EXT_HSM 0x48534D #define SBI_EXT_SRST 0x53525354 +#define SBI_EXT_SUSP 0x53555350 /* SBI function IDs for BASE extension*/ #define SBI_EXT_BASE_GET_SPEC_VERSION 0x0 @@ -111,6 +112,13 @@ #define SBI_ERR_INVALID_ADDRESS -5 #define SBI_ERR_ALREADY_AVAILABLE -6 +/* SBI function IDs for SUSP extension */ +#define SBI_EXT_SUSP_SUSPEND 0x0 + +#define SBI_SUSP_SLEEP_TYPE_SUSPEND 0x0 +#define SBI_SUSP_SLEEP_TYPE_LAST SBI_SUSP_SLEEP_TYPE_SUSPEND +#define SBI_SUSP_PLATFORM_SLEEP_START 0x80000000 + #define SBI_LAST_ERR SBI_ERR_ALREADY_AVAILABLE /* clang-format on */ diff --git a/opensbi/include/sbi/sbi_hsm.h b/opensbi/include/sbi/sbi_hsm.h index c16e87180..8251e9514 100644 --- a/opensbi/include/sbi/sbi_hsm.h +++ b/opensbi/include/sbi/sbi_hsm.h @@ -57,9 +57,13 @@ void sbi_hsm_hart_resume_start(struct sbi_scratch *scratch); void sbi_hsm_hart_resume_finish(struct sbi_scratch *scratch); int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type, ulong raddr, ulong rmode, ulong priv); +int sbi_hsm_hart_change_state(struct sbi_scratch *scratch, long oldstate, + long newstate); +int __sbi_hsm_hart_get_state(u32 hartid); int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid); int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom, ulong hbase, ulong *out_hmask); +void __sbi_hsm_suspend_non_ret_save(struct sbi_scratch *scratch); void sbi_hsm_prepare_next_jump(struct sbi_scratch *scratch, u32 hartid); #endif diff --git a/opensbi/include/sbi/sbi_system.h b/opensbi/include/sbi/sbi_system.h index a9fa5466b..374992991 100644 --- a/opensbi/include/sbi/sbi_system.h +++ b/opensbi/include/sbi/sbi_system.h @@ -32,4 +32,30 @@ bool sbi_system_reset_supported(u32 reset_type, u32 reset_reason); void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason); +/** System suspend device */ +struct sbi_system_suspend_device { + /** Name of the system suspend device */ + char name[32]; + + /* Check whether sleep type is supported by the device */ + int (*system_suspend_check)(u32 sleep_type); + + /** + * Suspend the system + * + * @sleep_type: The sleep type identifier passed to the SBI call. + * @mmode_resume_addr: + * This is the same as sbi_scratch.warmboot_addr. Some platforms + * may not be able to return from system_suspend(), so they will + * jump directly to this address instead. Platforms which can + * return from system_suspend() may ignore this parameter. + */ + int (*system_suspend)(u32 sleep_type, unsigned long mmode_resume_addr); +}; + +const struct sbi_system_suspend_device *sbi_system_suspend_get_device(void); +void sbi_system_suspend_set_device(struct sbi_system_suspend_device *dev); +bool sbi_system_suspend_supported(u32 sleep_type); +int sbi_system_suspend(u32 sleep_type, ulong resume_addr, ulong opaque); + #endif diff --git a/opensbi/lib/sbi/objects.mk b/opensbi/lib/sbi/objects.mk index 6f2c06f5b..084a6f642 100644 --- a/opensbi/lib/sbi/objects.mk +++ b/opensbi/lib/sbi/objects.mk @@ -22,6 +22,7 @@ libsbi-objs-y += sbi_ecall_hsm.o libsbi-objs-y += sbi_ecall_legacy.o libsbi-objs-y += sbi_ecall_replace.o libsbi-objs-y += sbi_ecall_vendor.o +libsbi-objs-y += sbi_ecall_susp.o libsbi-objs-y += sbi_emulate_csr.o libsbi-objs-y += sbi_fifo.o libsbi-objs-y += sbi_hart.o diff --git a/opensbi/lib/sbi/sbi_domain.c b/opensbi/lib/sbi/sbi_domain.c index 84f30b935..8ba5b7733 100644 --- a/opensbi/lib/sbi/sbi_domain.c +++ b/opensbi/lib/sbi/sbi_domain.c @@ -34,6 +34,7 @@ struct sbi_domain root = { .possible_harts = &root_hmask, .regions = root_memregs, .system_reset_allowed = TRUE, + .system_suspend_allowed = TRUE, }; bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartid) @@ -383,6 +384,8 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix) sbi_printf("Domain%d SysReset %s: %s\n", dom->index, suffix, (dom->system_reset_allowed) ? "yes" : "no"); + sbi_printf("Domain%d SysSuspend %s: %s\n", + dom->index, suffix, (dom->system_suspend_allowed) ? "yes" : "no"); } void sbi_domain_dump_all(const char *suffix) diff --git a/opensbi/lib/sbi/sbi_ecall.c b/opensbi/lib/sbi/sbi_ecall.c index e92a53930..16cf5b9f7 100644 --- a/opensbi/lib/sbi/sbi_ecall.c +++ b/opensbi/lib/sbi/sbi_ecall.c @@ -168,6 +168,9 @@ int sbi_ecall_init(void) if (ret) return ret; ret = sbi_ecall_register_extension(&ecall_vendor); + if (ret) + return ret; + ret = sbi_ecall_register_extension(&ecall_susp); if (ret) return ret; diff --git a/opensbi/lib/sbi/sbi_ecall_susp.c b/opensbi/lib/sbi/sbi_ecall_susp.c new file mode 100644 index 000000000..f880c252f --- /dev/null +++ b/opensbi/lib/sbi/sbi_ecall_susp.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: BSD-2-Clause +#include +#include +#include +#include +#include + +static int sbi_ecall_susp_handler(unsigned long extid, unsigned long funcid, + const struct sbi_trap_regs *regs, + unsigned long *out_val, + struct sbi_trap_info *out_trap) +{ + int ret = SBI_ENOTSUPP; + + if (funcid == SBI_EXT_SUSP_SUSPEND) + ret = sbi_system_suspend(regs->a0, regs->a1, regs->a2); + + if (ret >= 0) { + *out_val = ret; + ret = 0; + } + + return ret; +} + +static bool susp_available(void) +{ + u32 type; + + /* + * At least one suspend type should be supported by the + * platform for the SBI SUSP extension to be usable. + */ + for (type = 0; type <= SBI_SUSP_SLEEP_TYPE_LAST; type++) { + if (sbi_system_suspend_supported(type)) + return true; + } + + return false; +} + +struct sbi_ecall_extension ecall_susp; + +static int sbi_ecall_susp_register_extensions(unsigned long extid, unsigned long *out_val) +{ + if (!susp_available()) { + *out_val = 0; + return 0; + } + + *out_val = 1; + return 0; +} + +struct sbi_ecall_extension ecall_susp = { + .extid_start = SBI_EXT_SUSP, + .extid_end = SBI_EXT_SUSP, + .probe = sbi_ecall_susp_register_extensions, + .handle = sbi_ecall_susp_handler, +}; diff --git a/opensbi/lib/sbi/sbi_hsm.c b/opensbi/lib/sbi/sbi_hsm.c index 4662150e7..ae29f8698 100644 --- a/opensbi/lib/sbi/sbi_hsm.c +++ b/opensbi/lib/sbi/sbi_hsm.c @@ -36,8 +36,25 @@ struct sbi_hsm_data { unsigned long saved_mie; unsigned long saved_mip; }; +#define __sbi_hsm_hart_change_state(hdata, oldstate, newstate) \ +({ \ + long state = atomic_cmpxchg(&(hdata)->state, oldstate, newstate); \ + if (state != (oldstate)) \ + sbi_printf("%s: ERR: The hart is in invalid state [%lu]\n", \ + __func__, state); \ + state == (oldstate); \ +}) -static inline int __sbi_hsm_hart_get_state(u32 hartid) +int sbi_hsm_hart_change_state(struct sbi_scratch *scratch, long oldstate, + long newstate) +{ + struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch, + hart_data_offset); + + return __sbi_hsm_hart_change_state(hdata, oldstate, newstate); +} + +int __sbi_hsm_hart_get_state(u32 hartid) { struct sbi_hsm_data *hdata; struct sbi_scratch *scratch; @@ -322,7 +339,7 @@ static int __sbi_hsm_suspend_ret_default(struct sbi_scratch *scratch) return 0; } -static void __sbi_hsm_suspend_non_ret_save(struct sbi_scratch *scratch) +void __sbi_hsm_suspend_non_ret_save(struct sbi_scratch *scratch) { struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch, hart_data_offset); diff --git a/opensbi/lib/sbi/sbi_init.c b/opensbi/lib/sbi/sbi_init.c index 3f44a2b87..47ddb83db 100644 --- a/opensbi/lib/sbi/sbi_init.c +++ b/opensbi/lib/sbi/sbi_init.c @@ -58,6 +58,7 @@ static void sbi_boot_print_general(struct sbi_scratch *scratch) const struct sbi_timer_device *tdev; const struct sbi_console_device *cdev; const struct sbi_system_reset_device *srdev; + const struct sbi_system_suspend_device *susp_dev; const struct sbi_platform *plat = sbi_platform_ptr(scratch); if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS) @@ -85,6 +86,9 @@ static void sbi_boot_print_general(struct sbi_scratch *scratch) srdev = sbi_system_reset_get_device(); sbi_printf("Platform SysReset Device : %s\n", (srdev) ? srdev->name : "---"); + susp_dev = sbi_system_suspend_get_device(); + sbi_printf("Platform Suspend Device : %s\n", + (susp_dev) ? susp_dev->name : "---"); /* Firmware details */ sbi_printf("Firmware Base : 0x%lx\n", scratch->fw_start); diff --git a/opensbi/lib/sbi/sbi_system.c b/opensbi/lib/sbi/sbi_system.c index 8b457d635..f564568dc 100644 --- a/opensbi/lib/sbi/sbi_system.c +++ b/opensbi/lib/sbi/sbi_system.c @@ -72,3 +72,88 @@ void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason) /* If platform specific reset did not work then do sbi_exit() */ sbi_exit(scratch); } + +static const struct sbi_system_suspend_device *suspend_dev; + +const struct sbi_system_suspend_device *sbi_system_suspend_get_device(void) +{ + return suspend_dev; +} + +void sbi_system_suspend_set_device(struct sbi_system_suspend_device *dev) +{ + if (!dev || suspend_dev) + return; + + suspend_dev = dev; +} + +bool sbi_system_suspend_supported(u32 sleep_type) +{ + return suspend_dev && suspend_dev->system_suspend_check && + suspend_dev->system_suspend_check(sleep_type) == 0; +} + +int sbi_system_suspend(u32 sleep_type, ulong resume_addr, ulong opaque) +{ + const struct sbi_domain *dom = sbi_domain_thishart_ptr(); + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); + void (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr; + //unsigned int hartid = current_hartid(); + unsigned long prev_mode; + //unsigned long i, j; + int ret; + + if (!dom || !dom->system_suspend_allowed) + return SBI_EFAIL; + + if (!suspend_dev || !suspend_dev->system_suspend || + !suspend_dev->system_suspend_check) + return SBI_EFAIL; + + ret = suspend_dev->system_suspend_check(sleep_type); + if (ret != SBI_OK) + return ret; + + prev_mode = (csr_read(CSR_MSTATUS) & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT; + if (prev_mode != PRV_S && prev_mode != PRV_U) + return SBI_EFAIL; + + //FIX ME: hartindex to hart + //sbi_hartmask_for_each_hartindex(j, &dom->assigned_harts) { + // //i = sbi_hartindex_to_hartid(j); + // if (i == hartid) + // continue; + // if (__sbi_hsm_hart_get_state(i) != SBI_HSM_STATE_STOPPED) + // return SBI_ERR_DENIED; + //} + + if (!sbi_domain_check_addr(dom, resume_addr, prev_mode, + SBI_DOMAIN_EXECUTE)) + return SBI_EINVALID_ADDR; + + if (!sbi_hsm_hart_change_state(scratch, SBI_HSM_STATE_STARTED, + SBI_HSM_STATE_SUSPENDED)) + return SBI_EFAIL; + + /* Prepare for resume */ + scratch->next_mode = prev_mode; + scratch->next_addr = resume_addr; + scratch->next_arg1 = opaque; + + __sbi_hsm_suspend_non_ret_save(scratch); + + /* Suspend */ + ret = suspend_dev->system_suspend(sleep_type, scratch->warmboot_addr); + if (ret != SBI_OK) { + if (!sbi_hsm_hart_change_state(scratch, SBI_HSM_STATE_SUSPENDED, + SBI_HSM_STATE_STARTED)) + sbi_hart_hang(); + return ret; + } + + /* Resume */ + jump_warmboot(); + + __builtin_unreachable(); +} diff --git a/opensbi/lib/utils/fdt/fdt_domain.c b/opensbi/lib/utils/fdt/fdt_domain.c index 95c195d65..64043d06a 100644 --- a/opensbi/lib/utils/fdt/fdt_domain.c +++ b/opensbi/lib/utils/fdt/fdt_domain.c @@ -398,6 +398,13 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque) else dom->system_reset_allowed = FALSE; + /* Read "system-suspend-allowed" DT property */ + if (fdt_get_property(fdt, domain_offset, + "system-suspend-allowed", NULL)) + dom->system_suspend_allowed = TRUE; + else + dom->system_suspend_allowed = FALSE; + /* Find /cpus DT node */ cpus_offset = fdt_path_offset(fdt, "/cpus"); if (cpus_offset < 0) diff --git a/opensbi/platform/generic/cvitek_riscv.c b/opensbi/platform/generic/cvitek_riscv.c new file mode 100644 index 000000000..fc79b267f --- /dev/null +++ b/opensbi/platform/generic/cvitek_riscv.c @@ -0,0 +1,107 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +__asm__(".section .rodata\n" + ".global suspend_sram_entry\n" + ".global suspend_sram_end\n" + ".type suspend_sram_entry, @object\n" + ".type suspend_sram_end, @object\n" + ".align 4\n" + "suspend_sram_entry:\n" + ".incbin \"" STRINGIFY(PM_SRAM_BIN_PATH) "\"\n" + ".align 4\n" + "suspend_sram_end:\n" + ".text\n"); + +#define RTC_SRAM_FLAG_ADDR 0x05026ff8 +#ifdef CONFIG_CV180X +#define SUSPEND_SRAM_ENTRY 0x3C000000 +#endif +#ifdef CONFIG_CV181X +#define SUSPEND_SRAM_ENTRY 0xC030000 +#endif +#define memcpy sbi_memcpy + +static void rtc_latch_pinmux_settings(void) +{ + writel(0x2, (void *)0x50250ac); + writel(0x0, (void *)0x5027084); + //TODO +} + +static void rtc_power_saving_settings_for_suspend(void) +{ + //TODO +} + +static int cvitek_sbi_system_suspend_check(u32 sleep_type) +{ + return sleep_type == SBI_SUSP_SLEEP_TYPE_SUSPEND ? 0 : SBI_EINVAL; +} + +static int cvitek_sbi_system_suspend(u32 sleep_type, + unsigned long mmode_resume_addr) +{ + void (*suspend)(void) = (void *)SUSPEND_SRAM_ENTRY; + + if (sleep_type != SBI_SUSP_SLEEP_TYPE_SUSPEND) + return SBI_EINVAL; + + rtc_latch_pinmux_settings(); + rtc_power_saving_settings_for_suspend(); + + /* store warmboot entry for resume*/ + writel(mmode_resume_addr, (void *)RTC_SRAM_FLAG_ADDR); + writel(readl((void *)0x03002000) | 0x10, (void *)0x03002000); //enable TPU clock + memcpy((void *)SUSPEND_SRAM_ENTRY, suspend_sram_entry, suspend_sram_end - suspend_sram_entry); + + asm volatile("fence.i" ::: "memory"); + + asm volatile("fence rw,rw\n\t"); + + suspend(); + + wfi(); + + return SBI_OK; +} + +static struct sbi_system_suspend_device cvitek_sbi_suspend_device = { + .name = "cvi-suspend", + .system_suspend_check = cvitek_sbi_system_suspend_check, + .system_suspend = cvitek_sbi_system_suspend, +}; + +static int cvitek_riscv_early_init(bool cold_boot, const struct fdt_match *match) +{ + sbi_system_suspend_set_device(&cvitek_sbi_suspend_device); + + return 0; +} + +static const struct fdt_match cvitek_riscv_match[] = { + { .compatible = "cvitek,cv180x" }, + { .compatible = "cvitek,cv181x" } +}; + +const struct platform_override cvitek_riscv = { + .match_table = cvitek_riscv_match, + .early_init = cvitek_riscv_early_init, +}; diff --git a/opensbi/platform/generic/include/platform_override.h b/opensbi/platform/generic/include/platform_override.h index 4af87544f..ce1c3ae06 100644 --- a/opensbi/platform/generic/include/platform_override.h +++ b/opensbi/platform/generic/include/platform_override.h @@ -12,6 +12,11 @@ #include +extern const struct platform_override sifive_fu540; +extern const struct platform_override cvitek_riscv; +extern u8 suspend_sram_entry[]; +extern u8 suspend_sram_end[]; + struct platform_override { const struct fdt_match *match_table; u64 (*features)(const struct fdt_match *match); diff --git a/opensbi/platform/generic/objects.mk b/opensbi/platform/generic/objects.mk index d6c8a42d6..2a5b49491 100644 --- a/opensbi/platform/generic/objects.mk +++ b/opensbi/platform/generic/objects.mk @@ -9,3 +9,4 @@ platform-objs-y += platform.o platform-objs-y += sifive_fu540.o +platform-objs-y += cvitek_riscv.o diff --git a/opensbi/platform/generic/platform.c b/opensbi/platform/generic/platform.c index 9eeb731d0..1486cc207 100644 --- a/opensbi/platform/generic/platform.c +++ b/opensbi/platform/generic/platform.c @@ -22,10 +22,9 @@ #include #include -extern const struct platform_override sifive_fu540; - static const struct platform_override *special_platforms[] = { &sifive_fu540, + &cvitek_riscv, }; static const struct platform_override *generic_plat = NULL; diff --git a/opensbi/pm_default_cv180x.bin b/opensbi/pm_default_cv180x.bin new file mode 100755 index 0000000000000000000000000000000000000000..f17a91740bd9fc69bde9ebc1e9d031e73b7dcced GIT binary patch literal 1808 zcmXxi(MwZN9KiA8+}*vdDXZPs9`3`nJ8};T_AuBUgodnb4}iJeP1|d>H)8hPc;Dvv{X^}ll@iKATXtw4y3!v9W~{Wjd$)ZMyXBA; zWV!Bl3E^`+?Dol1J2R=te4{na?%y7sjJKb?i#BwVhrWx-_@F8H7pX`^e&+R#U@{dkqz3o2AlhVfhc8@jWkj7V2 zJ-hep&P|78IqRa=xisNaoEy@GJ7VLoU0-&;du^=C?yr{kAIj0eDa5h%cB}`zsA2#$ z)G>%53}XV5n87UO(8N3zu!tqBU=?dv#|fOqS)9iPF5?4S!^ij(pJNkW;&1$eqT}DY zInje&R55@W>KMcjhB1OsjAH_mn87UO(8N3zu!I#H#wymZjuSYIvpA2!!ThM8jzJ8e z{oxd0hZ7a_pchpPpoT&s9~JbV7gY?PhB_uNi5bjd4o%Es0gEWQ=m!<_pchpPpoTgI zF@#}^U=-t+z$9ici#aqgj|D7Z2`e~^RjlC%j$$2!oB2^e4|-9>0BWdX5JMQo2u3lE z{g}WcW-yC6G%=3_EMf^OIE+=S;RueRIKlj=pa;FEVgNPNF^Cb2VjTN1fl16@7ISFg K_g7DLj@DmxN3Nm( literal 0 HcmV?d00001 diff --git a/opensbi/pm_default_cv181x.bin b/opensbi/pm_default_cv181x.bin new file mode 100755 index 0000000000000000000000000000000000000000..1484dbfe3713b97c2e23418e825ab8456f0736ba GIT binary patch literal 1800 zcmXZa&ubGw6u|Lmn$2!&DyvyZ4tvTLk$uzG(mdEA!3CV z0xfN&6${OwP?T1L7O_P^+#JMTIrJasp{UeDwecX-OZ@>--N^UBybm+*c=LwoI_3Fx z_UpiBJ1rD*L(Z71vgLTq@kY!!n;P6cfAm+sYNv#<)RtZPho1Du;dwi)?cZ-7$8Nc# zC0VZfJwo_A1ARVuc5gm4lW(-S~ z)XDt^&dn{CWV`F4-@P*JR@`r-3x{I!&X?EbmfZW>7M)N!$&JqD|K5u#Y8XHr4Gdxk z!tM~{v@CiP}=h(!T_zVA_=;9sGiz;du zKphPXVhF<+!6?Qtfl16@7ISD}9t&8)3XWkFYgor=oWliNMB!q7RM5a6hS2$Nig3b> z3VKmR4Fjm7kf=umy{Mvw0o2jJ1STlMJ!