Compare commits
2 Commits
v4.1.6
...
cv18xx-v4.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
631feca478 | ||
|
|
12c8046c42 |
32
Makefile
32
Makefile
@@ -143,20 +143,6 @@ deps-y+=$(libsbi-objs-path-y:.o=.dep)
|
|||||||
deps-y+=$(libsbiutils-objs-path-y:.o=.dep)
|
deps-y+=$(libsbiutils-objs-path-y:.o=.dep)
|
||||||
deps-y+=$(firmware-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
|
# Setup platform ABI, ISA and Code Model
|
||||||
ifndef PLATFORM_RISCV_ABI
|
ifndef PLATFORM_RISCV_ABI
|
||||||
ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1)
|
ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1)
|
||||||
@@ -217,6 +203,17 @@ GENFLAGS += $(libsbiutils-genflags-y)
|
|||||||
GENFLAGS += $(platform-genflags-y)
|
GENFLAGS += $(platform-genflags-y)
|
||||||
GENFLAGS += $(firmware-genflags-y)
|
GENFLAGS += $(firmware-genflags-y)
|
||||||
|
|
||||||
|
define add_define
|
||||||
|
GENFLAGS += -D$(1)$(if $(value $(1)),=$(value $(1)),)
|
||||||
|
endef
|
||||||
|
|
||||||
|
ifeq (${CONFIG_SKIP_UBOOT},y)
|
||||||
|
$(eval $(call add_define,CONFIG_SKIP_UBOOT))
|
||||||
|
endif
|
||||||
|
ifeq (${CONFIG_SKIP_UBOOT_DEBUG},y)
|
||||||
|
$(eval $(call add_define,CONFIG_SKIP_UBOOT_DEBUG))
|
||||||
|
endif
|
||||||
|
|
||||||
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2
|
CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2
|
||||||
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
||||||
CFLAGS += -mno-save-restore -mstrict-align
|
CFLAGS += -mno-save-restore -mstrict-align
|
||||||
@@ -226,13 +223,6 @@ CFLAGS += $(GENFLAGS)
|
|||||||
CFLAGS += $(platform-cflags-y)
|
CFLAGS += $(platform-cflags-y)
|
||||||
CFLAGS += -fno-pie -no-pie
|
CFLAGS += -fno-pie -no-pie
|
||||||
CFLAGS += $(firmware-cflags-y)
|
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 += $(GENFLAGS)
|
||||||
CPPFLAGS += $(platform-cppflags-y)
|
CPPFLAGS += $(platform-cppflags-y)
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ has following details:
|
|||||||
* **next_mode** - Privilege mode of the next booting stage for this
|
* **next_mode** - Privilege mode of the next booting stage for this
|
||||||
domain. This can be either S-mode or U-mode.
|
domain. This can be either S-mode or U-mode.
|
||||||
* **system_reset_allowed** - Is domain allowed to reset the system?
|
* **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
|
The memory regions represented by **regions** in **struct sbi_domain** have
|
||||||
following additional constraints to align with RISC-V PMP requirements:
|
following additional constraints to align with RISC-V PMP requirements:
|
||||||
@@ -92,7 +91,6 @@ following manner:
|
|||||||
* **next_mode** - Next booting stage mode in coldboot HART scratch space
|
* **next_mode** - Next booting stage mode in coldboot HART scratch space
|
||||||
is the next mode for the ROOT domain
|
is the next mode for the ROOT domain
|
||||||
* **system_reset_allowed** - The ROOT domain is allowed to reset the system
|
* **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
|
Domain Effects
|
||||||
--------------
|
--------------
|
||||||
@@ -189,8 +187,6 @@ The DT properties of a domain instance DT node are as follows:
|
|||||||
stage mode of coldboot HART** is used as default value.
|
stage mode of coldboot HART** is used as default value.
|
||||||
* **system-reset-allowed** (Optional) - A boolean flag representing
|
* **system-reset-allowed** (Optional) - A boolean flag representing
|
||||||
whether the domain instance is allowed to do system reset.
|
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
|
### Assigning HART To Domain Instance
|
||||||
|
|
||||||
@@ -256,7 +252,6 @@ be done:
|
|||||||
next-addr = <0x0 0x80100000>;
|
next-addr = <0x0 0x80100000>;
|
||||||
next-mode = <0x0>;
|
next-mode = <0x0>;
|
||||||
system-reset-allowed;
|
system-reset-allowed;
|
||||||
system-suspend-allowed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
udomain: untrusted-domain {
|
udomain: untrusted-domain {
|
||||||
|
|||||||
@@ -78,8 +78,6 @@ struct sbi_domain {
|
|||||||
unsigned long next_mode;
|
unsigned long next_mode;
|
||||||
/** Is domain allowed to reset the system */
|
/** Is domain allowed to reset the system */
|
||||||
bool system_reset_allowed;
|
bool system_reset_allowed;
|
||||||
/** Is domain allowed to suspend the system */
|
|
||||||
bool system_suspend_allowed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The root domain instance */
|
/** The root domain instance */
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ extern struct sbi_ecall_extension ecall_ipi;
|
|||||||
extern struct sbi_ecall_extension ecall_vendor;
|
extern struct sbi_ecall_extension ecall_vendor;
|
||||||
extern struct sbi_ecall_extension ecall_hsm;
|
extern struct sbi_ecall_extension ecall_hsm;
|
||||||
extern struct sbi_ecall_extension ecall_srst;
|
extern struct sbi_ecall_extension ecall_srst;
|
||||||
extern struct sbi_ecall_extension ecall_susp;
|
|
||||||
|
|
||||||
u16 sbi_ecall_version_major(void);
|
u16 sbi_ecall_version_major(void);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#define SBI_EXT_RFENCE 0x52464E43
|
#define SBI_EXT_RFENCE 0x52464E43
|
||||||
#define SBI_EXT_HSM 0x48534D
|
#define SBI_EXT_HSM 0x48534D
|
||||||
#define SBI_EXT_SRST 0x53525354
|
#define SBI_EXT_SRST 0x53525354
|
||||||
#define SBI_EXT_SUSP 0x53555350
|
|
||||||
|
|
||||||
/* SBI function IDs for BASE extension*/
|
/* SBI function IDs for BASE extension*/
|
||||||
#define SBI_EXT_BASE_GET_SPEC_VERSION 0x0
|
#define SBI_EXT_BASE_GET_SPEC_VERSION 0x0
|
||||||
@@ -38,9 +37,6 @@
|
|||||||
#define SBI_EXT_BASE_GET_MVENDORID 0x4
|
#define SBI_EXT_BASE_GET_MVENDORID 0x4
|
||||||
#define SBI_EXT_BASE_GET_MARCHID 0x5
|
#define SBI_EXT_BASE_GET_MARCHID 0x5
|
||||||
#define SBI_EXT_BASE_GET_MIMPID 0x6
|
#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*/
|
/* SBI function IDs for TIME extension*/
|
||||||
#define SBI_EXT_TIME_SET_TIMER 0x0
|
#define SBI_EXT_TIME_SET_TIMER 0x0
|
||||||
@@ -112,13 +108,6 @@
|
|||||||
#define SBI_ERR_INVALID_ADDRESS -5
|
#define SBI_ERR_INVALID_ADDRESS -5
|
||||||
#define SBI_ERR_ALREADY_AVAILABLE -6
|
#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
|
#define SBI_LAST_ERR SBI_ERR_ALREADY_AVAILABLE
|
||||||
|
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|||||||
@@ -57,13 +57,9 @@ void sbi_hsm_hart_resume_start(struct sbi_scratch *scratch);
|
|||||||
void sbi_hsm_hart_resume_finish(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,
|
int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
|
||||||
ulong raddr, ulong rmode, ulong priv);
|
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_get_state(const struct sbi_domain *dom, u32 hartid);
|
||||||
int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
|
int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
|
||||||
ulong hbase, ulong *out_hmask);
|
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);
|
void sbi_hsm_prepare_next_jump(struct sbi_scratch *scratch, u32 hartid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,30 +32,4 @@ bool sbi_system_reset_supported(u32 reset_type, u32 reset_reason);
|
|||||||
|
|
||||||
void __noreturn sbi_system_reset(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
|
#endif
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ libsbi-objs-y += sbi_ecall_hsm.o
|
|||||||
libsbi-objs-y += sbi_ecall_legacy.o
|
libsbi-objs-y += sbi_ecall_legacy.o
|
||||||
libsbi-objs-y += sbi_ecall_replace.o
|
libsbi-objs-y += sbi_ecall_replace.o
|
||||||
libsbi-objs-y += sbi_ecall_vendor.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_emulate_csr.o
|
||||||
libsbi-objs-y += sbi_fifo.o
|
libsbi-objs-y += sbi_fifo.o
|
||||||
libsbi-objs-y += sbi_hart.o
|
libsbi-objs-y += sbi_hart.o
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ struct sbi_domain root = {
|
|||||||
.possible_harts = &root_hmask,
|
.possible_harts = &root_hmask,
|
||||||
.regions = root_memregs,
|
.regions = root_memregs,
|
||||||
.system_reset_allowed = TRUE,
|
.system_reset_allowed = TRUE,
|
||||||
.system_suspend_allowed = TRUE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartid)
|
bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartid)
|
||||||
@@ -384,8 +383,6 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)
|
|||||||
|
|
||||||
sbi_printf("Domain%d SysReset %s: %s\n",
|
sbi_printf("Domain%d SysReset %s: %s\n",
|
||||||
dom->index, suffix, (dom->system_reset_allowed) ? "yes" : "no");
|
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)
|
void sbi_domain_dump_all(const char *suffix)
|
||||||
|
|||||||
@@ -168,9 +168,6 @@ int sbi_ecall_init(void)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
ret = sbi_ecall_register_extension(&ecall_vendor);
|
ret = sbi_ecall_register_extension(&ecall_vendor);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
ret = sbi_ecall_register_extension(&ecall_susp);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <sbi/sbi_trap.h>
|
#include <sbi/sbi_trap.h>
|
||||||
#include <sbi/sbi_version.h>
|
#include <sbi/sbi_version.h>
|
||||||
#include <sbi/riscv_asm.h>
|
#include <sbi/riscv_asm.h>
|
||||||
#include <sbi/riscv_io.h>
|
|
||||||
|
|
||||||
static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val)
|
static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val)
|
||||||
{
|
{
|
||||||
@@ -33,41 +32,6 @@ static int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val)
|
|||||||
return 0;
|
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,
|
static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid,
|
||||||
const struct sbi_trap_regs *regs,
|
const struct sbi_trap_regs *regs,
|
||||||
unsigned long *out_val,
|
unsigned long *out_val,
|
||||||
@@ -101,16 +65,6 @@ static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid,
|
|||||||
case SBI_EXT_BASE_PROBE_EXT:
|
case SBI_EXT_BASE_PROBE_EXT:
|
||||||
ret = sbi_ecall_base_probe(regs->a0, out_val);
|
ret = sbi_ecall_base_probe(regs->a0, out_val);
|
||||||
break;
|
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:
|
default:
|
||||||
ret = SBI_ENOTSUPP;
|
ret = SBI_ENOTSUPP;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
// SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
#include <sbi/sbi_ecall.h>
|
|
||||||
#include <sbi/sbi_ecall_interface.h>
|
|
||||||
#include <sbi/sbi_error.h>
|
|
||||||
#include <sbi/sbi_trap.h>
|
|
||||||
#include <sbi/sbi_system.h>
|
|
||||||
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
@@ -21,10 +21,19 @@
|
|||||||
#include <sbi/sbi_platform.h>
|
#include <sbi/sbi_platform.h>
|
||||||
#include <sbi/sbi_string.h>
|
#include <sbi/sbi_string.h>
|
||||||
#include <sbi/sbi_trap.h>
|
#include <sbi/sbi_trap.h>
|
||||||
|
#include <sbi/sbi_timer.h>
|
||||||
|
|
||||||
extern void __sbi_expected_trap(void);
|
extern void __sbi_expected_trap(void);
|
||||||
extern void __sbi_expected_trap_hext(void);
|
extern void __sbi_expected_trap_hext(void);
|
||||||
|
|
||||||
|
|
||||||
|
// Frequency of ARM arch timer and RISC-V rdtime
|
||||||
|
#define SYS_COUNTER_FREQ_IN_SECOND 25000000
|
||||||
|
#define TIME_RECORDS_ADDR ( 0x0E000000 + 0x10) // 0x0E000010
|
||||||
|
#define TIME_RECORDS_FIELD_KERNEL_START (TIME_RECORDS_ADDR + 0x16)
|
||||||
|
|
||||||
|
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||||
|
|
||||||
void (*sbi_hart_expected_trap)(void) = &__sbi_expected_trap;
|
void (*sbi_hart_expected_trap)(void) = &__sbi_expected_trap;
|
||||||
|
|
||||||
struct hart_features {
|
struct hart_features {
|
||||||
@@ -469,6 +478,15 @@ void __attribute__((noreturn)) sbi_hart_hang(void)
|
|||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_time()
|
||||||
|
{
|
||||||
|
unsigned long long boot_us = 0;
|
||||||
|
|
||||||
|
boot_us = sbi_timer_value() / (SYS_COUNTER_FREQ_IN_SECOND / 1000000 );
|
||||||
|
|
||||||
|
return DIV_ROUND_UP(boot_us, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
void __attribute__((noreturn))
|
void __attribute__((noreturn))
|
||||||
sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
|
sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
|
||||||
unsigned long next_addr, unsigned long next_mode,
|
unsigned long next_addr, unsigned long next_mode,
|
||||||
@@ -531,6 +549,8 @@ sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*(volatile uint16_t*)TIME_RECORDS_FIELD_KERNEL_START = get_time();
|
||||||
|
|
||||||
register unsigned long a0 asm("a0") = arg0;
|
register unsigned long a0 asm("a0") = arg0;
|
||||||
register unsigned long a1 asm("a1") = arg1;
|
register unsigned long a1 asm("a1") = arg1;
|
||||||
__asm__ __volatile__("mret" : : "r"(a0), "r"(a1));
|
__asm__ __volatile__("mret" : : "r"(a0), "r"(a1));
|
||||||
|
|||||||
@@ -36,25 +36,8 @@ struct sbi_hsm_data {
|
|||||||
unsigned long saved_mie;
|
unsigned long saved_mie;
|
||||||
unsigned long saved_mip;
|
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); \
|
|
||||||
})
|
|
||||||
|
|
||||||
int sbi_hsm_hart_change_state(struct sbi_scratch *scratch, long oldstate,
|
static inline int __sbi_hsm_hart_get_state(u32 hartid)
|
||||||
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_hsm_data *hdata;
|
||||||
struct sbi_scratch *scratch;
|
struct sbi_scratch *scratch;
|
||||||
@@ -339,7 +322,7 @@ static int __sbi_hsm_suspend_ret_default(struct sbi_scratch *scratch)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __sbi_hsm_suspend_non_ret_save(struct sbi_scratch *scratch)
|
static void __sbi_hsm_suspend_non_ret_save(struct sbi_scratch *scratch)
|
||||||
{
|
{
|
||||||
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
|
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
|
||||||
hart_data_offset);
|
hart_data_offset);
|
||||||
|
|||||||
@@ -35,116 +35,6 @@
|
|||||||
" | |\n" \
|
" | |\n" \
|
||||||
" |_|\n\n"
|
" |_|\n\n"
|
||||||
|
|
||||||
static void sbi_boot_print_banner(struct sbi_scratch *scratch)
|
|
||||||
{
|
|
||||||
if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef OPENSBI_VERSION_GIT
|
|
||||||
sbi_printf("\nOpenSBI %s\n", OPENSBI_VERSION_GIT);
|
|
||||||
#else
|
|
||||||
sbi_printf("\nOpenSBI v%d.%d\n", OPENSBI_VERSION_MAJOR,
|
|
||||||
OPENSBI_VERSION_MINOR);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sbi_printf(BANNER);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sbi_boot_print_general(struct sbi_scratch *scratch)
|
|
||||||
{
|
|
||||||
char str[128];
|
|
||||||
const struct sbi_hsm_device *hdev;
|
|
||||||
const struct sbi_ipi_device *idev;
|
|
||||||
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)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Platform details */
|
|
||||||
sbi_printf("Platform Name : %s\n",
|
|
||||||
sbi_platform_name(plat));
|
|
||||||
sbi_platform_get_features_str(plat, str, sizeof(str));
|
|
||||||
sbi_printf("Platform Features : %s\n", str);
|
|
||||||
sbi_printf("Platform HART Count : %u\n",
|
|
||||||
sbi_platform_hart_count(plat));
|
|
||||||
idev = sbi_ipi_get_device();
|
|
||||||
sbi_printf("Platform IPI Device : %s\n",
|
|
||||||
(idev) ? idev->name : "---");
|
|
||||||
tdev = sbi_timer_get_device();
|
|
||||||
sbi_printf("Platform Timer Device : %s\n",
|
|
||||||
(tdev) ? tdev->name : "---");
|
|
||||||
cdev = sbi_console_get_device();
|
|
||||||
sbi_printf("Platform Console Device : %s\n",
|
|
||||||
(cdev) ? cdev->name : "---");
|
|
||||||
hdev = sbi_hsm_get_device();
|
|
||||||
sbi_printf("Platform HSM Device : %s\n",
|
|
||||||
(hdev) ? hdev->name : "---");
|
|
||||||
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);
|
|
||||||
sbi_printf("Firmware Size : %d KB\n",
|
|
||||||
(u32)(scratch->fw_size / 1024));
|
|
||||||
|
|
||||||
/* SBI details */
|
|
||||||
sbi_printf("Runtime SBI Version : %d.%d\n",
|
|
||||||
sbi_ecall_version_major(), sbi_ecall_version_minor());
|
|
||||||
sbi_printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sbi_boot_print_domains(struct sbi_scratch *scratch)
|
|
||||||
{
|
|
||||||
if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Domain details */
|
|
||||||
sbi_domain_dump_all(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sbi_boot_print_hart(struct sbi_scratch *scratch, u32 hartid)
|
|
||||||
{
|
|
||||||
int xlen;
|
|
||||||
char str[128];
|
|
||||||
const struct sbi_domain *dom = sbi_domain_thishart_ptr();
|
|
||||||
|
|
||||||
if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Determine MISA XLEN and MISA string */
|
|
||||||
xlen = misa_xlen();
|
|
||||||
if (xlen < 1) {
|
|
||||||
sbi_printf("Error %d getting MISA XLEN\n", xlen);
|
|
||||||
sbi_hart_hang();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Boot HART details */
|
|
||||||
sbi_printf("Boot HART ID : %u\n", hartid);
|
|
||||||
sbi_printf("Boot HART Domain : %s\n", dom->name);
|
|
||||||
misa_string(xlen, str, sizeof(str));
|
|
||||||
sbi_printf("Boot HART ISA : %s\n", str);
|
|
||||||
sbi_hart_get_features_str(scratch, str, sizeof(str));
|
|
||||||
sbi_printf("Boot HART Features : %s\n", str);
|
|
||||||
sbi_printf("Boot HART PMP Count : %d\n",
|
|
||||||
sbi_hart_pmp_count(scratch));
|
|
||||||
sbi_printf("Boot HART PMP Granularity : %lu\n",
|
|
||||||
sbi_hart_pmp_granularity(scratch));
|
|
||||||
sbi_printf("Boot HART PMP Address Bits: %d\n",
|
|
||||||
sbi_hart_pmp_addrbits(scratch));
|
|
||||||
sbi_printf("Boot HART MHPM Count : %d\n",
|
|
||||||
sbi_hart_mhpm_count(scratch));
|
|
||||||
sbi_printf("Boot HART MHPM Count : %d\n",
|
|
||||||
sbi_hart_mhpm_count(scratch));
|
|
||||||
sbi_hart_delegation_dump(scratch, "Boot HART ", " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
static spinlock_t coldboot_lock = SPIN_LOCK_INITIALIZER;
|
static spinlock_t coldboot_lock = SPIN_LOCK_INITIALIZER;
|
||||||
static struct sbi_hartmask coldboot_wait_hmask = { 0 };
|
static struct sbi_hartmask coldboot_wait_hmask = { 0 };
|
||||||
@@ -221,11 +111,14 @@ static void wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
|
|
||||||
static unsigned long init_count_offset;
|
static unsigned long init_count_offset;
|
||||||
|
|
||||||
|
#ifdef CONFIG_SKIP_UBOOT
|
||||||
|
extern void generic_fdt_fixup_chosen(void);
|
||||||
|
#endif
|
||||||
static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
unsigned long *init_count;
|
unsigned long *init_count;
|
||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
// const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||||
|
|
||||||
/* Note: This has to be first thing in coldboot init sequence */
|
/* Note: This has to be first thing in coldboot init sequence */
|
||||||
rc = sbi_scratch_init(scratch);
|
rc = sbi_scratch_init(scratch);
|
||||||
@@ -246,32 +139,32 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
if (rc)
|
if (rc)
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
|
|
||||||
rc = sbi_platform_early_init(plat, TRUE);
|
// rc = sbi_platform_early_init(plat, TRUE);
|
||||||
if (rc)
|
// if (rc)
|
||||||
sbi_hart_hang();
|
// sbi_hart_hang();
|
||||||
|
|
||||||
rc = sbi_hart_init(scratch, TRUE);
|
rc = sbi_hart_init(scratch, TRUE);
|
||||||
if (rc)
|
if (rc)
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
|
|
||||||
|
#if defined(CONFIG_SKIP_UBOOT_DEBUG)
|
||||||
rc = sbi_console_init(scratch);
|
rc = sbi_console_init(scratch);
|
||||||
if (rc)
|
if (rc)
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
|
#endif
|
||||||
|
|
||||||
sbi_boot_print_banner(scratch);
|
// rc = sbi_platform_irqchip_init(plat, TRUE);
|
||||||
|
// if (rc) {
|
||||||
|
// sbi_printf("%s: platform irqchip init failed (error %d)\n",
|
||||||
|
// __func__, rc);
|
||||||
|
// sbi_hart_hang();
|
||||||
|
// }
|
||||||
|
|
||||||
rc = sbi_platform_irqchip_init(plat, TRUE);
|
// rc = sbi_ipi_init(scratch, TRUE);
|
||||||
if (rc) {
|
// if (rc) {
|
||||||
sbi_printf("%s: platform irqchip init failed (error %d)\n",
|
// sbi_printf("%s: ipi init failed (error %d)\n", __func__, rc);
|
||||||
__func__, rc);
|
// sbi_hart_hang();
|
||||||
sbi_hart_hang();
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
rc = sbi_ipi_init(scratch, TRUE);
|
|
||||||
if (rc) {
|
|
||||||
sbi_printf("%s: ipi init failed (error %d)\n", __func__, rc);
|
|
||||||
sbi_hart_hang();
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = sbi_tlb_init(scratch, TRUE);
|
rc = sbi_tlb_init(scratch, TRUE);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
@@ -291,8 +184,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
}
|
}
|
||||||
|
|
||||||
sbi_boot_print_general(scratch);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: Finalize domains after HSM initialization so that we
|
* Note: Finalize domains after HSM initialization so that we
|
||||||
* can startup non-root domains.
|
* can startup non-root domains.
|
||||||
@@ -306,8 +197,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
}
|
}
|
||||||
|
|
||||||
sbi_boot_print_domains(scratch);
|
|
||||||
|
|
||||||
rc = sbi_hart_pmp_configure(scratch);
|
rc = sbi_hart_pmp_configure(scratch);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
sbi_printf("%s: PMP configure failed (error %d)\n",
|
sbi_printf("%s: PMP configure failed (error %d)\n",
|
||||||
@@ -319,14 +208,15 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
* Note: Platform final initialization should be last so that
|
* Note: Platform final initialization should be last so that
|
||||||
* it sees correct domain assignment and PMP configuration.
|
* it sees correct domain assignment and PMP configuration.
|
||||||
*/
|
*/
|
||||||
rc = sbi_platform_final_init(plat, TRUE);
|
// rc = sbi_platform_final_init(plat, TRUE);
|
||||||
if (rc) {
|
// if (rc) {
|
||||||
sbi_printf("%s: platform final init failed (error %d)\n",
|
// sbi_printf("%s: platform final init failed (error %d)\n",
|
||||||
__func__, rc);
|
// __func__, rc);
|
||||||
sbi_hart_hang();
|
// sbi_hart_hang();
|
||||||
}
|
// }
|
||||||
|
#ifdef CONFIG_SKIP_UBOOT
|
||||||
sbi_boot_print_hart(scratch, hartid);
|
generic_fdt_fixup_chosen();
|
||||||
|
#endif
|
||||||
|
|
||||||
wake_coldboot_harts(scratch, hartid);
|
wake_coldboot_harts(scratch, hartid);
|
||||||
|
|
||||||
|
|||||||
@@ -72,88 +72,3 @@ void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason)
|
|||||||
/* If platform specific reset did not work then do sbi_exit() */
|
/* If platform specific reset did not work then do sbi_exit() */
|
||||||
sbi_exit(scratch);
|
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();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -398,13 +398,6 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)
|
|||||||
else
|
else
|
||||||
dom->system_reset_allowed = FALSE;
|
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 */
|
/* Find /cpus DT node */
|
||||||
cpus_offset = fdt_path_offset(fdt, "/cpus");
|
cpus_offset = fdt_path_offset(fdt, "/cpus");
|
||||||
if (cpus_offset < 0)
|
if (cpus_offset < 0)
|
||||||
|
|||||||
@@ -17,6 +17,43 @@
|
|||||||
#include <sbi_utils/fdt/fdt_fixup.h>
|
#include <sbi_utils/fdt/fdt_fixup.h>
|
||||||
#include <sbi_utils/fdt/fdt_helper.h>
|
#include <sbi_utils/fdt/fdt_helper.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_SKIP_UBOOT
|
||||||
|
#include "cvipart.h"
|
||||||
|
|
||||||
|
/* config root */
|
||||||
|
#ifdef CONFIG_NAND_SUPPORT
|
||||||
|
#ifdef CONFIG_SKIP_RAMDISK
|
||||||
|
#define ROOTARGS "ubi.mtd=ROOTFS ubi.block=0,0 root=/dev/ubiblock0_0 rootfstype=squashfs"
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define ROOTARGS "ubi.mtd=ROOTFS ubi.block=0,0"
|
||||||
|
#endif /* CONFIG_SKIP_RAMDISK */
|
||||||
|
#else
|
||||||
|
#define ROOTARGS "rootfstype=squashfs rootwait ro root=" ROOTFS_DEV
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* BOOTARGS */
|
||||||
|
#define PARTS PART_LAYOUT
|
||||||
|
|
||||||
|
/* config loglevel */
|
||||||
|
#if defined(CONFIG_BUILD_FOR_DEBUG)
|
||||||
|
#define CONSOLE_LOGLEVEL " loglevel=9 \0"
|
||||||
|
#define EARLYCON_RELEASE " "
|
||||||
|
#elif defined(CONFIG_SKIP_UBOOT_DEBUG)
|
||||||
|
#define CONSOLE_LOGLEVEL " loglevel=9 \0"
|
||||||
|
#define EARLYCON_RELEASE " release "
|
||||||
|
#else
|
||||||
|
#define CONSOLE_LOGLEVEL " loglevel=0 \0"
|
||||||
|
#define EARLYCON_RELEASE " release "
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define CVI_BOOTAGRS \
|
||||||
|
PARTS " " \
|
||||||
|
ROOTARGS " " \
|
||||||
|
"console=ttyS0,115200 earlycon=sbi riscv.fwsz=0x80000" CONSOLE_LOGLEVEL
|
||||||
|
#endif
|
||||||
|
|
||||||
void fdt_cpu_fixup(void *fdt)
|
void fdt_cpu_fixup(void *fdt)
|
||||||
{
|
{
|
||||||
struct sbi_domain *dom = sbi_domain_thishart_ptr();
|
struct sbi_domain *dom = sbi_domain_thishart_ptr();
|
||||||
@@ -265,4 +302,19 @@ void fdt_fixups(void *fdt)
|
|||||||
fdt_reserved_memory_fixup(fdt);
|
fdt_reserved_memory_fixup(fdt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SKIP_UBOOT
|
||||||
|
void generic_fdt_fixup_chosen(void)
|
||||||
|
{
|
||||||
|
void *fdt;
|
||||||
|
int nodeoffset;
|
||||||
|
char *str; /* used to set string properties */
|
||||||
|
|
||||||
|
fdt = sbi_scratch_thishart_arg1_ptr();
|
||||||
|
|
||||||
|
nodeoffset = fdt_path_offset(fdt, "/chosen");
|
||||||
|
|
||||||
|
// str = "mtdparts=10000000.cvi-spif:512K(fip),1792K(2nd),3072K(jump),384K(PQ),64K(PARAM),64K(PARAM_BAK),64K(ENV),64K(ENV_BAK),2048K(ROOTFS),4096K(DATA) rootwait ro root=/dev/mtdblock8 rootfstype=squashfs console=ttyS0,115200 earlycon=sbi riscv.fwsz=0x80000 loglevel=9";
|
||||||
|
str = CVI_BOOTAGRS;
|
||||||
|
fdt_setprop(fdt, nodeoffset, "bootargs", str, strlen(str) + 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
#define CLINT_TIMER_MAX_NR 16
|
#define CLINT_TIMER_MAX_NR 16
|
||||||
|
|
||||||
static unsigned long clint_timer_count = 0;
|
static unsigned long clint_timer_count = 0;
|
||||||
static struct clint_data clint_timer[CLINT_TIMER_MAX_NR];
|
static struct clint_data clint_timer[CLINT_TIMER_MAX_NR] = {
|
||||||
|
{.addr = 0x74000000, .first_hartid = 0, .hart_count = 1, .has_64bit_mmio = 0, },
|
||||||
|
};
|
||||||
|
|
||||||
static int timer_clint_cold_init(void *fdt, int nodeoff,
|
static int timer_clint_cold_init(void *fdt, int nodeoff,
|
||||||
const struct fdt_match *match)
|
const struct fdt_match *match)
|
||||||
@@ -29,9 +31,11 @@ static int timer_clint_cold_init(void *fdt, int nodeoff,
|
|||||||
if (1 < clint_timer_count)
|
if (1 < clint_timer_count)
|
||||||
ctmaster = &clint_timer[0];
|
ctmaster = &clint_timer[0];
|
||||||
|
|
||||||
rc = fdt_parse_clint_node(fdt, nodeoff, TRUE, ct);
|
if (clint_timer_count != 1) {
|
||||||
if (rc)
|
rc = fdt_parse_clint_node(fdt, nodeoff, TRUE, ct);
|
||||||
return rc;
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
return clint_cold_timer_init(ct, ctmaster);
|
return clint_cold_timer_init(ct, ctmaster);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ else
|
|||||||
FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x200000)))
|
FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x200000)))
|
||||||
endif
|
endif
|
||||||
#set FDT_ADDR 0xB0000000
|
#set FDT_ADDR 0xB0000000
|
||||||
FW_JUMP_FDT_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x30000000)))
|
FW_JUMP_FDT_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x80000)))
|
||||||
FW_PAYLOAD=y
|
FW_PAYLOAD=y
|
||||||
ifeq ($(PLATFORM_RISCV_XLEN), 32)
|
ifeq ($(PLATFORM_RISCV_XLEN), 32)
|
||||||
# This needs to be 4MB aligned for 32-bit system
|
# This needs to be 4MB aligned for 32-bit system
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 Western Digital Corporation or its affiliates.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Anup Patel <anup.patel@wdc.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <platform_override.h>
|
|
||||||
#include <sbi_utils/fdt/fdt_helper.h>
|
|
||||||
#include <sbi_utils/fdt/fdt_fixup.h>
|
|
||||||
#include <sbi/sbi_system.h>
|
|
||||||
#include <sbi/sbi_ecall_interface.h>
|
|
||||||
#include <sbi/sbi_string.h>
|
|
||||||
#include <sbi/sbi_types.h>
|
|
||||||
#include <sbi/sbi_error.h>
|
|
||||||
#include <sbi/riscv_asm.h>
|
|
||||||
#include <sbi/riscv_io.h>
|
|
||||||
|
|
||||||
__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,
|
|
||||||
};
|
|
||||||
@@ -12,11 +12,6 @@
|
|||||||
|
|
||||||
#include <sbi/sbi_types.h>
|
#include <sbi/sbi_types.h>
|
||||||
|
|
||||||
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 {
|
struct platform_override {
|
||||||
const struct fdt_match *match_table;
|
const struct fdt_match *match_table;
|
||||||
u64 (*features)(const struct fdt_match *match);
|
u64 (*features)(const struct fdt_match *match);
|
||||||
|
|||||||
@@ -9,4 +9,3 @@
|
|||||||
|
|
||||||
platform-objs-y += platform.o
|
platform-objs-y += platform.o
|
||||||
platform-objs-y += sifive_fu540.o
|
platform-objs-y += sifive_fu540.o
|
||||||
platform-objs-y += cvitek_riscv.o
|
|
||||||
|
|||||||
@@ -22,9 +22,10 @@
|
|||||||
#include <sbi_utils/ipi/fdt_ipi.h>
|
#include <sbi_utils/ipi/fdt_ipi.h>
|
||||||
#include <sbi_utils/reset/fdt_reset.h>
|
#include <sbi_utils/reset/fdt_reset.h>
|
||||||
|
|
||||||
|
extern const struct platform_override sifive_fu540;
|
||||||
|
|
||||||
static const struct platform_override *special_platforms[] = {
|
static const struct platform_override *special_platforms[] = {
|
||||||
&sifive_fu540,
|
&sifive_fu540,
|
||||||
&cvitek_riscv,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct platform_override *generic_plat = NULL;
|
static const struct platform_override *generic_plat = NULL;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user