summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@wdc.com>2019-01-23 03:50:50 +0300
committerAnup Patel <anup@brainfault.org>2019-02-08 06:48:46 +0300
commitf9b033e57769bf24fc13293afdd43c1979527615 (patch)
tree7dd04479271d59a5b9bdf486c893edd82e5a2c08 /platform
parentf4cf6da7ff2d97f74129a6f4f333991af596111e (diff)
downloadopensbi-f9b033e57769bf24fc13293afdd43c1979527615.tar.xz
platform: clint: Allow running on 32-bit systems
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/common/sys/clint.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/platform/common/sys/clint.c b/platform/common/sys/clint.c
index 78ea118..ee79a54 100644
--- a/platform/common/sys/clint.c
+++ b/platform/common/sys/clint.c
@@ -87,7 +87,15 @@ static volatile u64 *clint_time_cmp;
u64 clint_timer_value(void)
{
+#if __riscv_xlen == 64
return readq_relaxed(clint_time_val);
+#else
+ u64 tmp;
+ tmp = readl_relaxed((void *)clint_time_val + 0x04);
+ tmp <<= 32;
+ tmp |= readl_relaxed(clint_time_val);
+ return tmp;
+#endif
}
void clint_timer_event_stop(void)
@@ -98,7 +106,12 @@ void clint_timer_event_stop(void)
return;
/* Clear CLINT Time Compare */
+#if __riscv_xlen == 64
writeq_relaxed(-1ULL, &clint_time_cmp[target_hart]);
+#else
+ writel_relaxed(-1UL, &clint_time_cmp[target_hart]);
+ writel_relaxed(-1UL, (void *)(&clint_time_cmp[target_hart]) + 0x04);
+#endif
}
void clint_timer_event_start(u64 next_event)
@@ -109,7 +122,13 @@ void clint_timer_event_start(u64 next_event)
return;
/* Program CLINT Time Compare */
+#if __riscv_xlen == 64
writeq_relaxed(next_event, &clint_time_cmp[target_hart]);
+#else
+ u32 mask = -1UL;
+ writel_relaxed(next_event & mask, &clint_time_cmp[target_hart]);
+ writel_relaxed(next_event >> 32, (void *)(&clint_time_cmp[target_hart]) + 0x04);
+#endif
}
int clint_warm_timer_init(void)
@@ -121,7 +140,12 @@ int clint_warm_timer_init(void)
return -1;
/* Clear CLINT Time Compare */
+#if __riscv_xlen == 64
writeq_relaxed(-1ULL, &clint_time_cmp[target_hart]);
+#else
+ writel_relaxed(-1UL, &clint_time_cmp[target_hart]);
+ writel_relaxed(-1UL, (void *)(&clint_time_cmp[target_hart]) + 0x04);
+#endif
return 0;
}