forked from Mirrors/opensbi
		
	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>
This commit is contained in:
		@@ -12,6 +12,7 @@
 | 
			
		||||
#include <sbi/sbi_console.h>
 | 
			
		||||
#include <sbi/sbi_const.h>
 | 
			
		||||
#include <sbi/sbi_platform.h>
 | 
			
		||||
#include <sbi/sbi_system.h>
 | 
			
		||||
#include <sbi_utils/fdt/fdt_fixup.h>
 | 
			
		||||
#include <sbi_utils/irqchip/plic.h>
 | 
			
		||||
#include <sbi_utils/serial/sifive-uart.h>
 | 
			
		||||
@@ -68,6 +69,36 @@ static u32 k210_get_clk_freq(void)
 | 
			
		||||
	return pll0_freq / div;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int k210_system_reset_check(u32 type, u32 reason)
 | 
			
		||||
{
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void k210_system_reset(u32 type, u32 reason)
 | 
			
		||||
{
 | 
			
		||||
	u32 val;
 | 
			
		||||
 | 
			
		||||
	val = k210_read_sysreg(K210_RESET);
 | 
			
		||||
	val |= K210_RESET_MASK;
 | 
			
		||||
	k210_write_sysreg(val, K210_RESET);
 | 
			
		||||
 | 
			
		||||
	while (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct sbi_system_reset_device k210_reset = {
 | 
			
		||||
	.name = "kendryte_k210_reset",
 | 
			
		||||
	.system_reset_check = k210_system_reset_check,
 | 
			
		||||
	.system_reset = k210_system_reset
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int k210_early_init(bool cold_boot)
 | 
			
		||||
{
 | 
			
		||||
	if (cold_boot)
 | 
			
		||||
		sbi_system_reset_set_device(&k210_reset);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int k210_final_init(bool cold_boot)
 | 
			
		||||
{
 | 
			
		||||
	void *fdt;
 | 
			
		||||
@@ -129,23 +160,9 @@ static int k210_timer_init(bool cold_boot)
 | 
			
		||||
	return clint_warm_timer_init();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int k210_system_reset_check(u32 type, u32 reason)
 | 
			
		||||
{
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void k210_system_reset(u32 type, u32 reason)
 | 
			
		||||
{
 | 
			
		||||
	u32 val;
 | 
			
		||||
 | 
			
		||||
	val = k210_read_sysreg(K210_RESET);
 | 
			
		||||
	val |= K210_RESET_MASK;
 | 
			
		||||
	k210_write_sysreg(val, K210_RESET);
 | 
			
		||||
 | 
			
		||||
	while (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const struct sbi_platform_operations platform_ops = {
 | 
			
		||||
	.early_init	= k210_early_init,
 | 
			
		||||
 | 
			
		||||
	.final_init	= k210_final_init,
 | 
			
		||||
 | 
			
		||||
	.console_init	= k210_console_init,
 | 
			
		||||
@@ -154,9 +171,6 @@ const struct sbi_platform_operations platform_ops = {
 | 
			
		||||
 | 
			
		||||
	.ipi_init  = k210_ipi_init,
 | 
			
		||||
 | 
			
		||||
	.system_reset_check	= k210_system_reset_check,
 | 
			
		||||
	.system_reset		= k210_system_reset,
 | 
			
		||||
 | 
			
		||||
	.timer_init	   = k210_timer_init,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user