opensbi: weekly rls 2024.06.6

-2da720, Add rst/unrst/reset c906l ecall.

Change-Id: Id1b2de0c5cb4607d46fd4397a78e77109790cc49
This commit is contained in:
sophgo-forum-service
2024-06-06 15:17:01 +08:00
committed by carbon
parent 7f009500c5
commit d4cb5e934f
2 changed files with 49 additions and 0 deletions

View File

@ -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

View File

@ -14,6 +14,7 @@
#include <sbi/sbi_trap.h>
#include <sbi/sbi_version.h>
#include <sbi/riscv_asm.h>
#include <sbi/riscv_io.h>
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;
}