forked from Mirrors/opensbi
		
	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 <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
		@@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,8 +12,6 @@
 | 
			
		||||
 | 
			
		||||
#include <sbi/sbi_types.h>
 | 
			
		||||
 | 
			
		||||
void __noreturn sbi_system_reboot(u32 type);
 | 
			
		||||
 | 
			
		||||
void __noreturn sbi_system_shutdown(u32 type);
 | 
			
		||||
void __noreturn sbi_system_reset(u32 platform_reset_type);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user