lib: sbi: Improve system reset platform operations

To implement the SBI SRST extension, we need two platform operations
for system reset:
1) system_reset_check() - This operation will check whether given
   reset type and reason are supported by the platform
2) system_reset() - This operation will do the actual platform
   system reset and it will not return if reset type and reason
   are supported by the platform

This patch updates system reset related code everywhere as-per above.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
Anup Patel
2020-11-24 11:59:05 +05:30
committed by Anup Patel
parent da074796df
commit 5c429ae213
17 changed files with 137 additions and 36 deletions

View File

@@ -20,7 +20,10 @@ struct platform_override {
int (*final_init)(bool cold_boot, const struct fdt_match *match);
void (*early_exit)(const struct fdt_match *match);
void (*final_exit)(const struct fdt_match *match);
int (*system_reset)(u32 reset_type, const struct fdt_match *match);
int (*system_reset_check)(u32 reset_type, u32 reset_reason,
const struct fdt_match *match);
void (*system_reset)(u32 reset_type, u32 reset_reason,
const struct fdt_match *match);
int (*fdt_fixup)(void *fdt, const struct fdt_match *match);
};

View File

@@ -177,12 +177,24 @@ static u64 generic_tlbr_flush_limit(void)
return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT;
}
static int generic_system_reset(u32 reset_type)
static int generic_system_reset_check(u32 reset_type, u32 reset_reason)
{
if (generic_plat && generic_plat->system_reset)
return generic_plat->system_reset(reset_type,
generic_plat_match);
return fdt_system_reset(reset_type);
if (generic_plat && generic_plat->system_reset_check)
return generic_plat->system_reset_check(reset_type,
reset_reason,
generic_plat_match);
return fdt_system_reset_check(reset_type, reset_reason);
}
static void generic_system_reset(u32 reset_type, u32 reset_reason)
{
if (generic_plat && generic_plat->system_reset) {
generic_plat->system_reset(reset_type, reset_reason,
generic_plat_match);
return;
}
fdt_system_reset(reset_type, reset_reason);
}
const struct sbi_platform_operations platform_ops = {
@@ -205,6 +217,7 @@ const struct sbi_platform_operations platform_ops = {
.timer_event_start = fdt_timer_event_start,
.timer_init = fdt_timer_init,
.timer_exit = fdt_timer_exit,
.system_reset_check = generic_system_reset_check,
.system_reset = generic_system_reset,
};

View File

@@ -186,13 +186,17 @@ static int ux600_timer_init(bool cold_boot)
return clint_warm_timer_init();
}
static int ux600_system_reset(u32 type)
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);
return 0;
}
const struct sbi_platform_operations platform_ops = {
@@ -209,6 +213,7 @@ const struct sbi_platform_operations platform_ops = {
.timer_event_stop = clint_timer_event_stop,
.timer_event_start = clint_timer_event_start,
.timer_init = ux600_timer_init,
.system_reset_check = ux600_system_reset_check,
.system_reset = ux600_system_reset
};

View File

@@ -178,13 +178,20 @@ static void platform_timer_event_stop(void)
}
/*
* Reset the platform.
* Check reset type and reason supported by the platform.
*/
static int platform_system_reset(u32 type)
static int platform_system_reset_check(u32 type, u32 reason)
{
return 0;
}
/*
* Reset the platform.
*/
static void platform_system_reset(u32 type, u32 reason)
{
}
/*
* Platform descriptor.
*/
@@ -202,6 +209,7 @@ const struct sbi_platform_operations platform_ops = {
.timer_event_stop = platform_timer_event_stop,
.timer_event_start = platform_timer_event_start,
.timer_init = platform_timer_init,
.system_reset_check = platform_system_reset_check,
.system_reset = platform_system_reset
};
const struct sbi_platform platform = {

View File

@@ -108,10 +108,14 @@ static int c910_timer_init(bool cold_boot)
return clint_warm_timer_init();
}
static int c910_system_reset(u32 type)
static int c910_system_reset_check(u32 type, u32 reason)
{
return 1;
}
static void c910_system_reset(u32 type, u32 reason)
{
asm volatile ("ebreak");
return 0;
}
int c910_hart_start(u32 hartid, ulong saddr)
@@ -135,6 +139,7 @@ const struct sbi_platform_operations platform_ops = {
.timer_init = c910_timer_init,
.timer_event_start = clint_timer_event_start,
.system_reset_check = c910_system_reset_check,
.system_reset = c910_system_reset,
.hart_start = c910_hart_start,