summaryrefslogtreecommitdiff
path: root/include/sbi_utils
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-05-20 08:31:57 +0300
committerAnup Patel <anup@brainfault.org>2021-06-24 07:08:47 +0300
commit4519e29c51315205119ce03ff0e5152def647ed5 (patch)
treed9e081487bb0a64209a23b73b4c9ad2159270ee9 /include/sbi_utils
parent11c345f14a3e3c67e688024094f72de4f92c87a4 (diff)
downloadopensbi-4519e29c51315205119ce03ff0e5152def647ed5.tar.xz
lib: utils/timer: Add ACLINT MTIMER library
We add common ACLINT MTIMER library similar to the CLINT library so that OpenSBI platforms can use it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'include/sbi_utils')
-rw-r--r--include/sbi_utils/timer/aclint_mtimer.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/sbi_utils/timer/aclint_mtimer.h b/include/sbi_utils/timer/aclint_mtimer.h
new file mode 100644
index 0000000..62aa086
--- /dev/null
+++ b/include/sbi_utils/timer/aclint_mtimer.h
@@ -0,0 +1,41 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ * Anup Patel <anup.patel@wdc.com>
+ */
+
+#ifndef __TIMER_ACLINT_MTIMER_H__
+#define __TIMER_ACLINT_MTIMER_H__
+
+#include <sbi/sbi_types.h>
+
+#define ACLINT_MTIMER_ALIGN 0x1000
+#define ACLINT_MTIMER_SIZE 0x8000
+#define ACLINT_MTIMER_MAX_HARTS 4095
+
+#define CLINT_MTIMER_OFFSET 0x4000
+
+struct aclint_mtimer_data {
+ /* Public details */
+ unsigned long addr;
+ unsigned long size;
+ u32 first_hartid;
+ u32 hart_count;
+ bool has_64bit_mmio;
+ /* Private details (initialized and used by ACLINT MTIMER library) */
+ struct aclint_mtimer_data *time_delta_reference;
+ unsigned long time_delta_computed;
+ u64 time_delta;
+ u64 (*time_rd)(volatile u64 *addr);
+ void (*time_wr)(bool timecmp, u64 value, volatile u64 *addr);
+};
+
+int aclint_mtimer_warm_init(void);
+
+int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
+ struct aclint_mtimer_data *reference);
+
+#endif