diff options
| author | Andrew Jones <ajones@ventanamicro.com> | 2023-02-27 11:31:06 +0100 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2023-02-27 19:50:51 +0530 |
| commit | 5ccebf0a7ec79d0bbef36d6dcdc2717f25d40767 (patch) | |
| tree | 71c3f8bcaacef745452db2f8c7032913b72e05c3 /lib | |
| parent | 37558dccbedbb571150630a910547a93d7ec8822 (diff) | |
| download | opensbi-5ccebf0a7ec79d0bbef36d6dcdc2717f25d40767.zip opensbi-5ccebf0a7ec79d0bbef36d6dcdc2717f25d40767.tar.gz opensbi-5ccebf0a7ec79d0bbef36d6dcdc2717f25d40767.tar.bz2 | |
platform: generic: Add system suspend test
When the system-suspend-test property is present in the domain config
node as shown below, implement system suspend with a simple 5 second
delay followed by a WFI. This allows testing system suspend when the
low-level firmware doesn't support it.
/ {
chosen {
opensbi-domains {
compatible = "opensbi,domain,config";
system-suspend-test;
};
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sbi/sbi_system.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c index 7fa5ea8..6933915 100644 --- a/lib/sbi/sbi_system.c +++ b/lib/sbi/sbi_system.c @@ -17,6 +17,7 @@ #include <sbi/sbi_system.h> #include <sbi/sbi_ipi.h> #include <sbi/sbi_init.h> +#include <sbi/sbi_timer.h> static SBI_LIST_HEAD(reset_devices_list); @@ -108,6 +109,36 @@ void sbi_system_suspend_set_device(struct sbi_system_suspend_device *dev) suspend_dev = dev; } +static int sbi_system_suspend_test_check(u32 sleep_type) +{ + return sleep_type == SBI_SUSP_SLEEP_TYPE_SUSPEND; +} + +static int sbi_system_suspend_test_suspend(u32 sleep_type, + unsigned long mmode_resume_addr) +{ + if (sleep_type != SBI_SUSP_SLEEP_TYPE_SUSPEND) + return SBI_EINVAL; + + sbi_timer_mdelay(5000); + + /* Wait for interrupt */ + wfi(); + + return SBI_OK; +} + +static struct sbi_system_suspend_device sbi_system_suspend_test = { + .name = "system-suspend-test", + .system_suspend_check = sbi_system_suspend_test_check, + .system_suspend = sbi_system_suspend_test_suspend, +}; + +void sbi_system_suspend_test_enable(void) +{ + sbi_system_suspend_set_device(&sbi_system_suspend_test); +} + bool sbi_system_suspend_supported(u32 sleep_type) { return suspend_dev && suspend_dev->system_suspend_check && |
