diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-06-07 06:00:35 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-06-11 08:54:10 +0200 |
commit | 758b6304c598a574c4aba8fe7cd9b7a15719057c (patch) | |
tree | 47ac4252e41552b87bf557ba35f228a7b4c53035 /arch/arm/include | |
parent | 2073d937faf2116c466f55d7c8e32ea2c80a1a01 (diff) | |
download | barebox-758b6304c598a574c4aba8fe7cd9b7a15719057c.tar.gz barebox-758b6304c598a574c4aba8fe7cd9b7a15719057c.tar.xz |
clocksource: armv8-timer: Convert explicit assembly into helpers
Move inline assembly related to querying and counter value as well as
getting and setting counter frequency register into asm/system.h as
well as converting it inot helper functions. This is done to make the
code availible to other parts of the system.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/include')
-rw-r--r-- | arch/arm/include/asm/system.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h index 57c76186b4..5cf828ea36 100644 --- a/arch/arm/include/asm/system.h +++ b/arch/arm/include/asm/system.h @@ -77,6 +77,30 @@ static inline unsigned long read_mpidr(void) return val; } + +static inline void set_cntfrq(unsigned long cntfrq) +{ + asm volatile("msr cntfrq_el0, %0" : : "r" (cntfrq) : "memory"); +} + +static inline unsigned long get_cntfrq(void) +{ + unsigned long cntfrq; + + asm volatile("mrs %0, cntfrq_el0" : "=r" (cntfrq)); + return cntfrq; +} + +static inline unsigned long get_cntpct(void) +{ + unsigned long cntpct; + + isb(); + asm volatile("mrs %0, cntpct_el0" : "=r" (cntpct)); + + return cntpct; +} + #endif static inline unsigned int get_cr(void) { |