diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-11-07 14:57:16 +0530 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2015-06-22 14:06:56 +0530 |
commit | aa93e8ef98471277cfedacd68604bb28b5a35aa7 (patch) | |
tree | 40b78e1eb7d72320e33638bb6850d90fc57c02c2 /arch/arc/kernel/time.c | |
parent | b3210d141f5ec32d3b29d0cf4f33d922a739602f (diff) | |
download | linux-aa93e8ef98471277cfedacd68604bb28b5a35aa7.tar.gz linux-aa93e8ef98471277cfedacd68604bb28b5a35aa7.tar.bz2 linux-aa93e8ef98471277cfedacd68604bb28b5a35aa7.zip |
ARCv2: clocksource: Introduce 64bit local RTC counter
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/arc/kernel/time.c')
-rw-r--r-- | arch/arc/kernel/time.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/arch/arc/kernel/time.c b/arch/arc/kernel/time.c index 71493f75ae6b..da495478a40b 100644 --- a/arch/arc/kernel/time.c +++ b/arch/arc/kernel/time.c @@ -60,6 +60,54 @@ /********** Clock Source Device *********/ +#ifdef CONFIG_ARC_HAS_RTC + +#define AUX_RTC_CTRL 0x103 +#define AUX_RTC_LOW 0x104 +#define AUX_RTC_HIGH 0x105 + +int arc_counter_setup(void) +{ + write_aux_reg(AUX_RTC_CTRL, 1); + + /* Not usable in SMP */ + return !IS_ENABLED(CONFIG_SMP); +} + +static cycle_t arc_counter_read(struct clocksource *cs) +{ + unsigned long status; + union { +#ifdef CONFIG_CPU_BIG_ENDIAN + struct { u32 high, low; }; +#else + struct { u32 low, high; }; +#endif + cycle_t full; + } stamp; + + + __asm__ __volatile( + "1: \n" + " lr %0, [AUX_RTC_LOW] \n" + " lr %1, [AUX_RTC_HIGH] \n" + " lr %2, [AUX_RTC_CTRL] \n" + " bbit0.nt %2, 31, 1b \n" + : "=r" (stamp.low), "=r" (stamp.high), "=r" (status)); + + return stamp.full; +} + +static struct clocksource arc_counter = { + .name = "ARCv2 RTC", + .rating = 350, + .read = arc_counter_read, + .mask = CLOCKSOURCE_MASK(64), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +#else /* !CONFIG_ARC_HAS_RTC */ + /* * set 32bit TIMER1 to keep counting monotonically and wraparound */ @@ -86,6 +134,8 @@ static struct clocksource arc_counter = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; +#endif + /********** Clock Event Device *********/ /* |