summaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_system.c
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-04-22 09:23:32 +0300
committerAnup Patel <anup@brainfault.org>2021-04-28 14:55:00 +0300
commit043d088e3964ec64b091f739e2282f53f7d264fb (patch)
treee5ec82451c097df3f3416ec077752527d81107a7 /lib/sbi/sbi_system.c
parentdc39c7b630a607b96c25f8ea50f0bb1af619928a (diff)
downloadopensbi-043d088e3964ec64b091f739e2282f53f7d264fb.tar.xz
lib: sbi: Simplify system reset platform operations
Instead of having system_reset_check() and system_reset() callbacks in platform operations, it will be much simpler for reset driver to directly register these operations as a device to the sbi_system implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_system.c')
-rw-r--r--lib/sbi/sbi_system.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c
index 10915b4..479060b 100644
--- a/lib/sbi/sbi_system.c
+++ b/lib/sbi/sbi_system.c
@@ -18,10 +18,25 @@
#include <sbi/sbi_ipi.h>
#include <sbi/sbi_init.h>
+static const struct sbi_system_reset_device *reset_dev = NULL;
+
+const struct sbi_system_reset_device *sbi_system_reset_get_device(void)
+{
+ return reset_dev;
+}
+
+void sbi_system_reset_set_device(const struct sbi_system_reset_device *dev)
+{
+ if (!dev || reset_dev)
+ return;
+
+ reset_dev = dev;
+}
+
bool sbi_system_reset_supported(u32 reset_type, u32 reset_reason)
{
- if (sbi_platform_system_reset_check(sbi_platform_thishart_ptr(),
- reset_type, reset_reason))
+ if (reset_dev && reset_dev->system_reset_check &&
+ reset_dev->system_reset_check(reset_type, reset_reason))
return TRUE;
return FALSE;
@@ -47,9 +62,9 @@ void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason)
sbi_hsm_hart_stop(scratch, FALSE);
/* Platform specific reset if domain allowed system reset */
- if (dom->system_reset_allowed)
- sbi_platform_system_reset(sbi_platform_ptr(scratch),
- reset_type, reset_reason);
+ if (dom->system_reset_allowed &&
+ reset_dev && reset_dev->system_reset)
+ reset_dev->system_reset(reset_type, reset_reason);
/* If platform specific reset did not work then do sbi_exit() */
sbi_exit(scratch);