From 3fd99912a6b0bab74caaa9991f4a7d698b61cba8 Mon Sep 17 00:00:00 2001 From: sophgo-forum-service Date: Thu, 6 Jun 2024 15:17:01 +0800 Subject: [PATCH] opensbi: weekly rls 2024.06.6 -2da720, Add rst/unrst/reset c906l ecall. Change-Id: Id1b2de0c5cb4607d46fd4397a78e77109790cc49 --- include/sbi/sbi_ecall_interface.h | 3 ++ lib/sbi/sbi_ecall_base.c | 46 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/sbi/sbi_ecall_interface.h b/include/sbi/sbi_ecall_interface.h index 559a33e7..743a21f0 100644 --- a/include/sbi/sbi_ecall_interface.h +++ b/include/sbi/sbi_ecall_interface.h @@ -37,6 +37,9 @@ #define SBI_EXT_BASE_GET_MVENDORID 0x4 #define SBI_EXT_BASE_GET_MARCHID 0x5 #define SBI_EXT_BASE_GET_MIMPID 0x6 +#define SBI_EXT_BASE_RESET_C906L 0x7 +#define SBI_EXT_BASE_RST_C906L 0x8 +#define SBI_EXT_BASE_UNRST_C906L 0x9 /* SBI function IDs for TIME extension*/ #define SBI_EXT_TIME_SET_TIMER 0x0 diff --git a/lib/sbi/sbi_ecall_base.c b/lib/sbi/sbi_ecall_base.c index 786d2ac6..910f4108 100644 --- a/lib/sbi/sbi_ecall_base.c +++ b/lib/sbi/sbi_ecall_base.c @@ -14,6 +14,7 @@ #include #include #include +#include static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val) { @@ -32,6 +33,41 @@ static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val) return 0; } +#define SEC_SYS_BASE (0x020B0000) +static int sbi_ecall_base_rst_c906l(void) +{ + unsigned int value; + + value = readl((void *)0x3003024); + writel((value & (~(1 << 6))), (void *)0x3003024); + + return 0; +} + +static int sbi_ecall_base_unrst_c906l(const unsigned long address) +{ + unsigned int value; + + value = readl((void *)SEC_SYS_BASE + 0x04); + writel((value | (1 << 13)), (void *)SEC_SYS_BASE + 0x04); + writel(address, (void *)SEC_SYS_BASE + 0x20); + writel((address >> 32), (void *)SEC_SYS_BASE + 0x24); + + value = readl((void *)0x3003024); + writel((value | (1 << 6)), (void *)0x3003024); + + return 0; +} + +static int sbi_ecall_base_reset_c906l(const unsigned long address) +{ + sbi_ecall_base_rst_c906l(); + + sbi_ecall_base_unrst_c906l(address); + + return 0; +} + static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid, const struct sbi_trap_regs *regs, unsigned long *out_val, @@ -65,6 +101,16 @@ static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid, case SBI_EXT_BASE_PROBE_EXT: ret = sbi_ecall_base_probe(regs->a0, out_val); break; + case SBI_EXT_BASE_RESET_C906L: + ret = sbi_ecall_base_reset_c906l(regs->a0); + *out_val = regs->a0; + break; + case SBI_EXT_BASE_RST_C906L: + ret = sbi_ecall_base_rst_c906l(); + break; + case SBI_EXT_BASE_UNRST_C906L: + ret = sbi_ecall_base_unrst_c906l(regs->a0); + break; default: ret = SBI_ENOTSUPP; }