summaryrefslogtreecommitdiff
path: root/arch/riscv/lib
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv/lib')
-rw-r--r--arch/riscv/lib/reset.c2
-rw-r--r--arch/riscv/lib/sifive_clint.c16
2 files changed, 12 insertions, 6 deletions
diff --git a/arch/riscv/lib/reset.c b/arch/riscv/lib/reset.c
index 6008bbe78e..8779c619cc 100644
--- a/arch/riscv/lib/reset.c
+++ b/arch/riscv/lib/reset.c
@@ -7,7 +7,6 @@
#include <command.h>
#include <hang.h>
-#ifndef CONFIG_SYSRESET
int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
printf("resetting ...\n");
@@ -17,4 +16,3 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
return 0;
}
-#endif
diff --git a/arch/riscv/lib/sifive_clint.c b/arch/riscv/lib/sifive_clint.c
index 78fc6c868d..b9a2c649cc 100644
--- a/arch/riscv/lib/sifive_clint.c
+++ b/arch/riscv/lib/sifive_clint.c
@@ -26,6 +26,9 @@ DECLARE_GLOBAL_DATA_PTR;
int riscv_get_time(u64 *time)
{
+ /* ensure timer register base has a sane value */
+ riscv_init_ipi();
+
*time = readq((void __iomem *)MTIME_REG(gd->arch.clint));
return 0;
@@ -33,6 +36,9 @@ int riscv_get_time(u64 *time)
int riscv_set_timecmp(int hart, u64 cmp)
{
+ /* ensure timer register base has a sane value */
+ riscv_init_ipi();
+
writeq(cmp, (void __iomem *)MTIMECMP_REG(gd->arch.clint, hart));
return 0;
@@ -40,11 +46,13 @@ int riscv_set_timecmp(int hart, u64 cmp)
int riscv_init_ipi(void)
{
- long *ret = syscon_get_first_range(RISCV_SYSCON_CLINT);
+ if (!gd->arch.clint) {
+ long *ret = syscon_get_first_range(RISCV_SYSCON_CLINT);
- if (IS_ERR(ret))
- return PTR_ERR(ret);
- gd->arch.clint = ret;
+ if (IS_ERR(ret))
+ return PTR_ERR(ret);
+ gd->arch.clint = ret;
+ }
return 0;
}