summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2017-03-03 13:34:01 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-09 07:36:15 +0100
commit6bc48eabbfe78906ac2b7fa8e12cc9b0608c76bd (patch)
treef33412aab697a989397b0152ab4256ada4a138ee
parent92c1033036a0f1d65fb71e7c04cfb9393d31aa1c (diff)
downloadbarebox-6bc48eabbfe78906ac2b7fa8e12cc9b0608c76bd.tar.gz
clocksource: allow to have multiple device from clock source
use the one with the most priority. We can not select the clocksource at user level. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/clock.c11
-rw-r--r--include/clock.h3
2 files changed, 13 insertions, 1 deletions
diff --git a/common/clock.c b/common/clock.c
index 2c5dd91..1090b60 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -213,6 +213,17 @@ EXPORT_SYMBOL(mdelay_non_interruptible);
int init_clock(struct clocksource *cs)
{
+ if (current_clock && cs->priority <= current_clock->priority)
+ return 0;
+
+ if (cs->init) {
+ int ret;
+
+ ret = cs->init(cs);
+ if (ret)
+ return ret;
+ }
+
current_clock = cs;
time_beginning = get_time_ns();
diff --git a/include/clock.h b/include/clock.h
index d65e404..5f2f53a 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -12,7 +12,8 @@ struct clocksource {
uint64_t (*read)(void);
uint64_t cycle_last;
uint64_t mask;
-
+ int priority;
+ int (*init)(struct clocksource*);
};
static inline uint32_t cyc2ns(struct clocksource *cs, uint64_t cycles)