diff options
author | Antony Pavlov <antonynpavlov@gmail.com> | 2014-12-02 03:03:28 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-12-17 12:15:11 +0100 |
commit | fbb3be384548b1ded9ebcc4a4b45ff57bd2f38a1 (patch) | |
tree | 16a452bed34cb2adaac0fca3efda7bb3b13a2be6 /common/clock.c | |
parent | 704f59fe652bfca0d649390956530cb3ae43db24 (diff) | |
download | barebox-fbb3be384548b1ded9ebcc4a4b45ff57bd2f38a1.tar.gz barebox-fbb3be384548b1ded9ebcc4a4b45ff57bd2f38a1.tar.xz |
clock: incorporate dummy clocksource into core clock code
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/clock.c')
-rw-r--r-- | common/clock.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/common/clock.c b/common/clock.c index 2ee81da8e7..35c9e6cbb8 100644 --- a/common/clock.c +++ b/common/clock.c @@ -22,6 +22,7 @@ */ #include <common.h> +#include <init.h> #include <asm-generic/div64.h> #include <clock.h> #include <poller.h> @@ -35,6 +36,16 @@ static uint64_t time_ns; */ uint64_t time_beginning; +static int dummy_csrc_warn(void) +{ + if (!current_clock) { + pr_warn("Warning: Using dummy clocksource\n"); + } + + return 0; +} +late_initcall(dummy_csrc_warn); + /** * get_time_ns - get current timestamp in nanoseconds */ @@ -44,8 +55,13 @@ uint64_t get_time_ns(void) uint64_t cycle_now, cycle_delta; uint64_t ns_offset; - if (!cs) - return 0; + if (!cs) { + static uint64_t dummy_counter; + + dummy_counter += CONFIG_CLOCKSOURCE_DUMMY_RATE; + + return dummy_counter; + } /* read clocksource: */ cycle_now = cs->read() & cs->mask; |