summaryrefslogtreecommitdiff
path: root/include
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 /include
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 'include')
-rw-r--r--include/sbi/sbi_platform.h40
-rw-r--r--include/sbi/sbi_system.h16
-rw-r--r--include/sbi_utils/reset/fdt_reset.h6
-rw-r--r--include/sbi_utils/sys/htif.h4
-rw-r--r--include/sbi_utils/sys/sifive_test.h4
5 files changed, 17 insertions, 53 deletions
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index 2756d73..921d39c 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -127,11 +127,6 @@ struct sbi_platform_operations {
*/
int (*hart_suspend)(u32 suspend_type, ulong raddr);
- /* Check whether reset type and reason supported by the platform */
- int (*system_reset_check)(u32 reset_type, u32 reset_reason);
- /** Reset the platform */
- void (*system_reset)(u32 reset_type, u32 reset_reason);
-
/** platform specific SBI extension implementation probe function */
int (*vendor_ext_check)(long extid);
/** platform specific SBI extension implementation provider */
@@ -573,41 +568,6 @@ static inline void sbi_platform_timer_exit(const struct sbi_platform *plat)
}
/**
- * Check whether reset type and reason supported by the platform
- *
- * @param plat pointer to struct sbi_platform
- * @param reset_type type of reset
- * @param reset_reason reason for reset
- *
- * @return 0 if reset type and reason not supported and 1 if supported
- */
-static inline int sbi_platform_system_reset_check(
- const struct sbi_platform *plat,
- u32 reset_type, u32 reset_reason)
-{
- if (plat && sbi_platform_ops(plat)->system_reset_check)
- return sbi_platform_ops(plat)->system_reset_check(reset_type,
- reset_reason);
- return 0;
-}
-
-/**
- * Reset the platform
- *
- * This function will not return for supported reset type and reset reason
- *
- * @param plat pointer to struct sbi_platform
- * @param reset_type type of reset
- * @param reset_reason reason for reset
- */
-static inline void sbi_platform_system_reset(const struct sbi_platform *plat,
- u32 reset_type, u32 reset_reason)
-{
- if (plat && sbi_platform_ops(plat)->system_reset)
- sbi_platform_ops(plat)->system_reset(reset_type, reset_reason);
-}
-
-/**
* Check if a vendor extension is implemented or not.
*
* @param plat pointer to struct sbi_platform
diff --git a/include/sbi/sbi_system.h b/include/sbi/sbi_system.h
index 34ba766..a9fa546 100644
--- a/include/sbi/sbi_system.h
+++ b/include/sbi/sbi_system.h
@@ -12,6 +12,22 @@
#include <sbi/sbi_types.h>
+/** System reset hardware device */
+struct sbi_system_reset_device {
+ /** Name of the system reset device */
+ char name[32];
+
+ /* Check whether reset type and reason supported by the device */
+ int (*system_reset_check)(u32 reset_type, u32 reset_reason);
+
+ /** Reset the system */
+ void (*system_reset)(u32 reset_type, u32 reset_reason);
+};
+
+const struct sbi_system_reset_device *sbi_system_reset_get_device(void);
+
+void sbi_system_reset_set_device(const struct sbi_system_reset_device *dev);
+
bool sbi_system_reset_supported(u32 reset_type, u32 reset_reason);
void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason);
diff --git a/include/sbi_utils/reset/fdt_reset.h b/include/sbi_utils/reset/fdt_reset.h
index cce441a..6d58697 100644
--- a/include/sbi_utils/reset/fdt_reset.h
+++ b/include/sbi_utils/reset/fdt_reset.h
@@ -15,14 +15,8 @@
struct fdt_reset {
const struct fdt_match *match_table;
int (*init)(void *fdt, int nodeoff, const struct fdt_match *match);
- int (*system_reset_check)(u32 reset_type, u32 reset_reason);
- void (*system_reset)(u32 reset_type, u32 reset_reason);
};
-int fdt_system_reset_check(u32 reset_type, u32 reset_reason);
-
-void fdt_system_reset(u32 reset_type, u32 reset_reason);
-
int fdt_reset_init(void);
#endif
diff --git a/include/sbi_utils/sys/htif.h b/include/sbi_utils/sys/htif.h
index 8073a44..9cc9634 100644
--- a/include/sbi_utils/sys/htif.h
+++ b/include/sbi_utils/sys/htif.h
@@ -12,8 +12,6 @@
int htif_serial_init(void);
-int htif_system_reset_check(u32 type, u32 reason);
-
-void htif_system_reset(u32 type, u32 reason);
+int htif_system_reset_init(void);
#endif
diff --git a/include/sbi_utils/sys/sifive_test.h b/include/sbi_utils/sys/sifive_test.h
index 958622e..0a09499 100644
--- a/include/sbi_utils/sys/sifive_test.h
+++ b/include/sbi_utils/sys/sifive_test.h
@@ -12,10 +12,6 @@
#include <sbi/sbi_types.h>
-int sifive_test_system_reset_check(u32 type, u32 reason);
-
-void sifive_test_system_reset(u32 type, u32 reason);
-
int sifive_test_init(unsigned long base);
#endif