diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-02-26 09:25:10 +0000 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-03-03 08:39:10 +0530 |
commit | ec5274b04ce1433778af8aed2d583e6d85b8a702 (patch) | |
tree | 44632fdc0104ea30a4c7941c55b5dab661762961 /platform | |
parent | 234ed8e427f4d92903123199f6590d144e0d9351 (diff) | |
download | opensbi-ec5274b04ce1433778af8aed2d583e6d85b8a702.zip opensbi-ec5274b04ce1433778af8aed2d583e6d85b8a702.tar.gz opensbi-ec5274b04ce1433778af8aed2d583e6d85b8a702.tar.bz2 |
platform: implement K210 system reset
Implement rebooting the K210 via the system reset extension.
All reset types are treated in the same way.
A request for shutdown results in a reboot.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'platform')
-rw-r--r-- | platform/kendryte/k210/platform.c | 19 | ||||
-rw-r--r-- | platform/kendryte/k210/platform.h | 9 |
2 files changed, 28 insertions, 0 deletions
diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 944b388..0c50af5 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -129,6 +129,22 @@ 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 = { .final_init = k210_final_init, @@ -142,6 +158,9 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = clint_ipi_send, .ipi_clear = clint_ipi_clear, + .system_reset_check = k210_system_reset_check, + .system_reset = k210_system_reset, + .timer_init = k210_timer_init, .timer_value = clint_timer_value, .timer_event_stop = clint_timer_event_stop, diff --git a/platform/kendryte/k210/platform.h b/platform/kendryte/k210/platform.h index 5269bc4..e425faf 100644 --- a/platform/kendryte/k210/platform.h +++ b/platform/kendryte/k210/platform.h @@ -27,10 +27,19 @@ /* Registers */ #define K210_PLL0 0x08 #define K210_CLKSEL0 0x20 +#define K210_RESET 0x30 + +/* Register bit masks */ +#define K210_RESET_MASK 0x01 static inline u32 k210_read_sysreg(u32 reg) { return readl((volatile void *)(K210_SYSCTL_BASE_ADDR + reg)); } +static inline void k210_write_sysreg(u32 val, u32 reg) +{ + writel(val, (volatile void *)(K210_SYSCTL_BASE_ADDR + reg)); +} + #endif /* _K210_PLATFORM_H_ */ |