From a9eac67ad019200e9a281a6fc10e394353a026f2 Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Fri, 24 Apr 2020 12:26:22 +0530 Subject: include: sbi_platform: Combine reboot and shutdown into one callback We can achieve shutdown, cold reboot, and warm reboot using just one sbi_platform callback so we combine system_reboot() and system_shutdown() callbacks into one system_reset() callback. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi/sbi_platform.h | 37 +++++++++++-------------------------- include/sbi/sbi_system.h | 4 +--- include/sbi_utils/sys/htif.h | 2 +- 3 files changed, 13 insertions(+), 30 deletions(-) (limited to 'include') diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index fc2913d..9eaf82e 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -146,10 +146,11 @@ struct sbi_platform_operations { */ int (*hart_stop)(void); - /** Reboot the platform */ - int (*system_reboot)(u32 type); - /** Shutdown or poweroff the platform */ - int (*system_shutdown)(u32 type); + /** Reset the platform */ +#define SBI_PLATFORM_RESET_SHUTDOWN 0 +#define SBI_PLATFORM_RESET_COLD 1 +#define SBI_PLATFORM_RESET_WARM 2 + int (*system_reset)(u32 reset_type); /** platform specific SBI extension implementation probe function */ int (*vendor_ext_check)(long extid); @@ -686,34 +687,18 @@ static inline void sbi_platform_timer_exit(const struct sbi_platform *plat) } /** - * Reboot the platform + * Reset the platform * * @param plat pointer to struct sbi_platform - * @param type type of reboot + * @param reset_type type of reset * * @return 0 on success and negative error code on failure */ -static inline int sbi_platform_system_reboot(const struct sbi_platform *plat, - u32 type) +static inline int sbi_platform_system_reset(const struct sbi_platform *plat, + u32 reset_type) { - if (plat && sbi_platform_ops(plat)->system_reboot) - return sbi_platform_ops(plat)->system_reboot(type); - return 0; -} - -/** - * Shutdown or poweroff the platform - * - * @param plat pointer to struct sbi_platform - * @param type type of shutdown or poweroff - * - * @return 0 on success and negative error code on failure - */ -static inline int sbi_platform_system_shutdown(const struct sbi_platform *plat, - u32 type) -{ - if (plat && sbi_platform_ops(plat)->system_shutdown) - return sbi_platform_ops(plat)->system_shutdown(type); + if (plat && sbi_platform_ops(plat)->system_reset) + return sbi_platform_ops(plat)->system_reset(reset_type); return 0; } diff --git a/include/sbi/sbi_system.h b/include/sbi/sbi_system.h index 8d9c18b..d44ef12 100644 --- a/include/sbi/sbi_system.h +++ b/include/sbi/sbi_system.h @@ -12,8 +12,6 @@ #include -void __noreturn sbi_system_reboot(u32 type); - -void __noreturn sbi_system_shutdown(u32 type); +void __noreturn sbi_system_reset(u32 platform_reset_type); #endif diff --git a/include/sbi_utils/sys/htif.h b/include/sbi_utils/sys/htif.h index 42903e8..7384b48 100644 --- a/include/sbi_utils/sys/htif.h +++ b/include/sbi_utils/sys/htif.h @@ -14,6 +14,6 @@ void htif_putc(char ch); int htif_getc(void); -int htif_system_down(u32 type); +int htif_system_reset(u32 type); #endif -- cgit v1.2.3