diff options
author | Anup Patel <anup.patel@wdc.com> | 2021-04-22 11:53:32 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-04-28 17:25:00 +0530 |
commit | 043d088e3964ec64b091f739e2282f53f7d264fb (patch) | |
tree | e5ec82451c097df3f3416ec077752527d81107a7 /platform | |
parent | dc39c7b630a607b96c25f8ea50f0bb1af619928a (diff) |
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>
Diffstat (limited to 'platform')
-rw-r--r-- | platform/generic/include/platform_override.h | 4 | ||||
-rw-r--r-- | platform/generic/platform.c | 22 | ||||
-rw-r--r-- | platform/kendryte/k210/platform.c | 52 | ||||
-rw-r--r-- | platform/nuclei/ux600/platform.c | 38 | ||||
-rw-r--r-- | platform/template/platform.c | 19 |
5 files changed, 57 insertions, 78 deletions
diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h index 77a90d6..4af8754 100644 --- a/platform/generic/include/platform_override.h +++ b/platform/generic/include/platform_override.h @@ -20,10 +20,6 @@ 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_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); }; diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 4ae8b88..da0c1af 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -184,26 +184,6 @@ static u64 generic_tlbr_flush_limit(void) return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT; } -static int generic_system_reset_check(u32 reset_type, u32 reset_reason) -{ - 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 = { .early_init = generic_early_init, .final_init = generic_final_init, @@ -218,8 +198,6 @@ const struct sbi_platform_operations platform_ops = { .get_tlbr_flush_limit = generic_tlbr_flush_limit, .timer_init = fdt_timer_init, .timer_exit = fdt_timer_exit, - .system_reset_check = generic_system_reset_check, - .system_reset = generic_system_reset, }; struct sbi_platform platform = { diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 4b89939..66a0392 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -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, }; diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index ac81d03..5414316 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -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 = { diff --git a/platform/template/platform.c b/platform/template/platform.c index 04334b2..d407fd5 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -116,21 +116,6 @@ static int platform_timer_init(bool cold_boot) } /* - * Check reset type and reason supported by the platform. - */ -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. */ const struct sbi_platform_operations platform_ops = { @@ -139,9 +124,7 @@ const struct sbi_platform_operations platform_ops = { .console_init = platform_console_init, .irqchip_init = platform_irqchip_init, .ipi_init = platform_ipi_init, - .timer_init = platform_timer_init, - .system_reset_check = platform_system_reset_check, - .system_reset = platform_system_reset + .timer_init = platform_timer_init }; const struct sbi_platform platform = { .opensbi_version = OPENSBI_VERSION, |