Skip to content

Commit

Permalink
platform: implement K210 system reset
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Damien Le Moal <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
  • Loading branch information
xypron authored and avpatel committed Mar 3, 2021
1 parent 234ed8e commit ec5274b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
19 changes: 19 additions & 0 deletions platform/kendryte/k210/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions platform/kendryte/k210/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */

0 comments on commit ec5274b

Please sign in to comment.