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:
		@@ -15,6 +15,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>
 | 
			
		||||
@@ -104,10 +105,32 @@ static u32 ux600_get_clk_freq(void)
 | 
			
		||||
	return cpu_freq;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct sbi_system_reset_device ux600_reset = {
 | 
			
		||||
	.name = "nuclei_ux600_reset",
 | 
			
		||||
	.system_reset_check = ux600_system_reset_check,
 | 
			
		||||
	.system_reset = ux600_system_reset
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int ux600_early_init(bool cold_boot)
 | 
			
		||||
{
 | 
			
		||||
	u32 regval;
 | 
			
		||||
 | 
			
		||||
	if (cold_boot)
 | 
			
		||||
		sbi_system_reset_set_device(&ux600_reset);
 | 
			
		||||
 | 
			
		||||
	/* Measure CPU Frequency using Timer */
 | 
			
		||||
	ux600_clk_freq = ux600_get_clk_freq();
 | 
			
		||||
 | 
			
		||||
@@ -186,19 +209,6 @@ static int ux600_timer_init(bool cold_boot)
 | 
			
		||||
	return clint_warm_timer_init();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const struct sbi_platform_operations platform_ops = {
 | 
			
		||||
	.early_init		= ux600_early_init,
 | 
			
		||||
	.final_init		= ux600_final_init,
 | 
			
		||||
@@ -206,8 +216,6 @@ const struct sbi_platform_operations platform_ops = {
 | 
			
		||||
	.irqchip_init		= ux600_irqchip_init,
 | 
			
		||||
	.ipi_init		= ux600_ipi_init,
 | 
			
		||||
	.timer_init		= ux600_timer_init,
 | 
			
		||||
	.system_reset_check	= ux600_system_reset_check,
 | 
			
		||||
	.system_reset		= ux600_system_reset
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const struct sbi_platform platform = {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user