summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-11-24 09:29:05 +0300
committerAnup Patel <anup@brainfault.org>2020-12-01 14:40:31 +0300
commit5c429ae2133e1a82b81403146a3e38e2b4b8350e (patch)
tree09b02a0042a7ba5697e2f44082d08d05db147b3f /platform
parentda074796df871f6323d052f123b7668d390980dc (diff)
downloadopensbi-5c429ae2133e1a82b81403146a3e38e2b4b8350e.tar.xz
lib: sbi: Improve system reset platform operations
To implement the SBI SRST extension, we need two platform operations for system reset: 1) system_reset_check() - This operation will check whether given reset type and reason are supported by the platform 2) system_reset() - This operation will do the actual platform system reset and it will not return if reset type and reason are supported by the platform This patch updates system reset related code everywhere as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/generic/include/platform_override.h5
-rw-r--r--platform/generic/platform.c23
-rw-r--r--platform/nuclei/ux600/platform.c9
-rw-r--r--platform/template/platform.c12
-rw-r--r--platform/thead/c910/platform.c9
5 files changed, 46 insertions, 12 deletions
diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h
index 8a53cdf..77a90d6 100644
--- a/platform/generic/include/platform_override.h
+++ b/platform/generic/include/platform_override.h
@@ -20,7 +20,10 @@ struct platform_override {
int (*final_init)(bool cold_boot, const struct fdt_match *match);
void (*early_exit)(const struct fdt_match *match);
void (*final_exit)(const struct fdt_match *match);
- int (*system_reset)(u32 reset_type, const struct fdt_match *match);
+ int (*system_reset_check)(u32 reset_type, u32 reset_reason,
+ const struct fdt_match *match);
+ void (*system_reset)(u32 reset_type, u32 reset_reason,
+ const struct fdt_match *match);
int (*fdt_fixup)(void *fdt, const struct fdt_match *match);
};
diff --git a/platform/generic/platform.c b/platform/generic/platform.c
index d902e71..abb696a 100644
--- a/platform/generic/platform.c
+++ b/platform/generic/platform.c
@@ -177,12 +177,24 @@ static u64 generic_tlbr_flush_limit(void)
return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT;
}
-static int generic_system_reset(u32 reset_type)
+static int generic_system_reset_check(u32 reset_type, u32 reset_reason)
{
- if (generic_plat && generic_plat->system_reset)
- return generic_plat->system_reset(reset_type,
- generic_plat_match);
- return fdt_system_reset(reset_type);
+ if (generic_plat && generic_plat->system_reset_check)
+ return generic_plat->system_reset_check(reset_type,
+ reset_reason,
+ generic_plat_match);
+ return fdt_system_reset_check(reset_type, reset_reason);
+}
+
+static void generic_system_reset(u32 reset_type, u32 reset_reason)
+{
+ if (generic_plat && generic_plat->system_reset) {
+ generic_plat->system_reset(reset_type, reset_reason,
+ generic_plat_match);
+ return;
+ }
+
+ fdt_system_reset(reset_type, reset_reason);
}
const struct sbi_platform_operations platform_ops = {
@@ -205,6 +217,7 @@ const struct sbi_platform_operations platform_ops = {
.timer_event_start = fdt_timer_event_start,
.timer_init = fdt_timer_init,
.timer_exit = fdt_timer_exit,
+ .system_reset_check = generic_system_reset_check,
.system_reset = generic_system_reset,
};
diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c
index ba6803e..d0a45a2 100644
--- a/platform/nuclei/ux600/platform.c
+++ b/platform/nuclei/ux600/platform.c
@@ -186,13 +186,17 @@ static int ux600_timer_init(bool cold_boot)
return clint_warm_timer_init();
}
-static int ux600_system_reset(u32 type)
+static int ux600_system_reset_check(u32 type, u32 reason)
+{
+ return 1;
+}
+
+static void ux600_system_reset(u32 type, u32 reason)
{
/* Reset system using MSFTRST register in Nuclei Timer. */
writel(UX600_NUCLEI_TIMER_MSFTRST_KEY, (void *)(UX600_NUCLEI_TIMER_ADDR
+ UX600_NUCLEI_TIMER_MSFTRST_OFS));
while(1);
- return 0;
}
const struct sbi_platform_operations platform_ops = {
@@ -209,6 +213,7 @@ const struct sbi_platform_operations platform_ops = {
.timer_event_stop = clint_timer_event_stop,
.timer_event_start = clint_timer_event_start,
.timer_init = ux600_timer_init,
+ .system_reset_check = ux600_system_reset_check,
.system_reset = ux600_system_reset
};
diff --git a/platform/template/platform.c b/platform/template/platform.c
index 9cd750e..758e95f 100644
--- a/platform/template/platform.c
+++ b/platform/template/platform.c
@@ -178,14 +178,21 @@ static void platform_timer_event_stop(void)
}
/*
- * Reset the platform.
+ * Check reset type and reason supported by the platform.
*/
-static int platform_system_reset(u32 type)
+static int platform_system_reset_check(u32 type, u32 reason)
{
return 0;
}
/*
+ * Reset the platform.
+ */
+static void platform_system_reset(u32 type, u32 reason)
+{
+}
+
+/*
* Platform descriptor.
*/
const struct sbi_platform_operations platform_ops = {
@@ -202,6 +209,7 @@ const struct sbi_platform_operations platform_ops = {
.timer_event_stop = platform_timer_event_stop,
.timer_event_start = platform_timer_event_start,
.timer_init = platform_timer_init,
+ .system_reset_check = platform_system_reset_check,
.system_reset = platform_system_reset
};
const struct sbi_platform platform = {
diff --git a/platform/thead/c910/platform.c b/platform/thead/c910/platform.c
index df7658a..dfa484a 100644
--- a/platform/thead/c910/platform.c
+++ b/platform/thead/c910/platform.c
@@ -108,10 +108,14 @@ static int c910_timer_init(bool cold_boot)
return clint_warm_timer_init();
}
-static int c910_system_reset(u32 type)
+static int c910_system_reset_check(u32 type, u32 reason)
+{
+ return 1;
+}
+
+static void c910_system_reset(u32 type, u32 reason)
{
asm volatile ("ebreak");
- return 0;
}
int c910_hart_start(u32 hartid, ulong saddr)
@@ -135,6 +139,7 @@ const struct sbi_platform_operations platform_ops = {
.timer_init = c910_timer_init,
.timer_event_start = clint_timer_event_start,
+ .system_reset_check = c910_system_reset_check,
.system_reset = c910_system_reset,
.hart_start = c910_hart_start,