summaryrefslogtreecommitdiff
path: root/include/sbi
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-04-21 19:34:17 +0300
committerAnup Patel <anup@brainfault.org>2021-04-28 14:30:49 +0300
commit559a8f1d3be3210d4903c0db54c2d36e2f8d6ad4 (patch)
tree5a646e54241cfef96ccca4a5a8cc29ee68d77acf /include/sbi
parent068ca086af2312d56efe51a724d78d84e1339ab4 (diff)
downloadopensbi-559a8f1d3be3210d4903c0db54c2d36e2f8d6ad4.tar.xz
lib: sbi: Simplify timer platform operations
Instead of having timer_value(), timer_event_start(), and timer_event_stop() callbacks in platform operations, it will be much simpler for timer driver to directly register these operations as device to the sbi_timer implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'include/sbi')
-rw-r--r--include/sbi/sbi_platform.h58
-rw-r--r--include/sbi/sbi_timer.h21
2 files changed, 25 insertions, 54 deletions
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index 0d18ef2..a2084c1 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -51,14 +51,12 @@ struct sbi_trap_regs;
/** Possible feature flags of a platform */
enum sbi_platform_features {
- /** Platform has timer value */
- SBI_PLATFORM_HAS_TIMER_VALUE = (1 << 0),
/** Platform has HART hotplug support */
- SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 1),
+ SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 0),
/** Platform has fault delegation support */
- SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 2),
+ SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 1),
/** Platform has custom secondary hart booting support */
- SBI_PLATFORM_HAS_HART_SECONDARY_BOOT = (1 << 3),
+ SBI_PLATFORM_HAS_HART_SECONDARY_BOOT = (1 << 2),
/** Last index of Platform features*/
SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_HART_SECONDARY_BOOT,
@@ -66,7 +64,7 @@ enum sbi_platform_features {
/** Default feature set for a platform */
#define SBI_PLATFORM_DEFAULT_FEATURES \
- (SBI_PLATFORM_HAS_TIMER_VALUE | SBI_PLATFORM_HAS_MFAULTS_DELEGATION)
+ (SBI_PLATFORM_HAS_MFAULTS_DELEGATION)
/** Platform functions */
struct sbi_platform_operations {
@@ -115,12 +113,6 @@ struct sbi_platform_operations {
/** Get tlb flush limit value **/
u64 (*get_tlbr_flush_limit)(void);
- /** Get platform timer value */
- u64 (*timer_value)(void);
- /** Start platform timer event for current HART */
- void (*timer_event_start)(u64 next_event);
- /** Stop platform timer event for current HART */
- void (*timer_event_stop)(void);
/** Initialize platform timer for current HART */
int (*timer_init)(bool cold_boot);
/** Exit platform timer for current HART */
@@ -210,9 +202,6 @@ struct sbi_platform {
#define sbi_platform_ops(__p) \
((const struct sbi_platform_operations *)(__p)->platform_ops_addr)
-/** Check whether the platform supports timer value */
-#define sbi_platform_has_timer_value(__p) \
- ((__p)->features & SBI_PLATFORM_HAS_TIMER_VALUE)
/** Check whether the platform supports HART hotplug */
#define sbi_platform_has_hart_hotplug(__p) \
((__p)->features & SBI_PLATFORM_HAS_HART_HOTPLUG)
@@ -587,45 +576,6 @@ static inline void sbi_platform_ipi_exit(const struct sbi_platform *plat)
}
/**
- * Get platform timer value
- *
- * @param plat pointer to struct sbi_platform
- *
- * @return 64-bit timer value
- */
-static inline u64 sbi_platform_timer_value(const struct sbi_platform *plat)
-{
- if (plat && sbi_platform_ops(plat)->timer_value)
- return sbi_platform_ops(plat)->timer_value();
- return 0;
-}
-
-/**
- * Start platform timer event for current HART
- *
- * @param plat pointer to struct struct sbi_platform
- * @param next_event timer value when timer event will happen
- */
-static inline void
-sbi_platform_timer_event_start(const struct sbi_platform *plat, u64 next_event)
-{
- if (plat && sbi_platform_ops(plat)->timer_event_start)
- sbi_platform_ops(plat)->timer_event_start(next_event);
-}
-
-/**
- * Stop platform timer event for current HART
- *
- * @param plat pointer to struct sbi_platform
- */
-static inline void
-sbi_platform_timer_event_stop(const struct sbi_platform *plat)
-{
- if (plat && sbi_platform_ops(plat)->timer_event_stop)
- sbi_platform_ops(plat)->timer_event_stop();
-}
-
-/**
* Initialize the platform timer for current HART
*
* @param plat pointer to struct sbi_platform
diff --git a/include/sbi/sbi_timer.h b/include/sbi/sbi_timer.h
index 87bbdbf..1ba6da0 100644
--- a/include/sbi/sbi_timer.h
+++ b/include/sbi/sbi_timer.h
@@ -12,6 +12,21 @@
#include <sbi/sbi_types.h>
+/** Timer hardware device */
+struct sbi_timer_device {
+ /** Name of the timer operations */
+ char name[32];
+
+ /** Get free-running timer value */
+ u64 (*timer_value)(void);
+
+ /** Start timer event for current HART */
+ void (*timer_event_start)(u64 next_event);
+
+ /** Stop timer event for current HART */
+ void (*timer_event_stop)(void);
+};
+
struct sbi_scratch;
/** Get timer value for current HART */
@@ -35,6 +50,12 @@ void sbi_timer_event_start(u64 next_event);
/** Process timer event for current HART */
void sbi_timer_process(void);
+/** Get current timer device */
+const struct sbi_timer_device *sbi_timer_get_device(void);
+
+/** Register timer device */
+void sbi_timer_set_device(const struct sbi_timer_device *dev);
+
/* Initialize timer */
int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot);