@@ -16,6 +16,10 @@ struct suspend_context {
unsigned long envcfg;
unsigned long tvec;
unsigned long ie;
+#if __riscv_xlen < 64
+ unsigned long stimecmph;
+#endif
+ unsigned long stimecmp;
#ifdef CONFIG_MMU
unsigned long satp;
#endif
@@ -19,6 +19,12 @@ void suspend_save_csrs(struct suspend_context *context)
context->tvec = csr_read(CSR_TVEC);
context->ie = csr_read(CSR_IE);
+ if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SSTC)) {
+ context->stimecmp = csr_read(CSR_STIMECMP);
+#if __riscv_xlen < 64
+ context->stimecmph = csr_read(CSR_STIMECMPH);
+#endif
+ }
/*
* No need to save/restore IP CSR (i.e. MIP or SIP) because:
*
@@ -42,6 +48,13 @@ void suspend_restore_csrs(struct suspend_context *context)
csr_write(CSR_TVEC, context->tvec);
csr_write(CSR_IE, context->ie);
+ if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SSTC)) {
+ csr_write(CSR_STIMECMP, context->stimecmp);
+#if __riscv_xlen < 64
+ csr_write(CSR_STIMECMPH, context->stimecmph);
+#endif
+ }
+
#ifdef CONFIG_MMU
csr_write(CSR_SATP, context->satp);
#endif
If the HW support the SSTC extension, we should save and restore the stimecmp register while cpu non retention suspend. Signed-off-by: Nick Hu <nick.hu@sifive.com> --- arch/riscv/include/asm/suspend.h | 4 ++++ arch/riscv/kernel/suspend.c | 13 +++++++++++++ 2 files changed, 17 insertions(+)