diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-06-07 06:00:34 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-06-11 08:54:10 +0200 |
commit | 2073d937faf2116c466f55d7c8e32ea2c80a1a01 (patch) | |
tree | 059b17ccf5578375615c7a9a380d0374b151669d /arch/arm/include | |
parent | ecf3ca14097474a43a6936fc0a50389cf991f13d (diff) | |
download | barebox-2073d937faf2116c466f55d7c8e32ea2c80a1a01.tar.gz barebox-2073d937faf2116c466f55d7c8e32ea2c80a1a01.tar.xz |
ARM: Add constants and helpers for system counter interface
Add constants and helpers for system counter interface as can be found
in section "I1.3 Generic Timer registers" of "ARM Architecture
Reference Manual ARMv8, for ARMv8-A architecture"
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/syscounter.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/arm/include/asm/syscounter.h b/arch/arm/include/asm/syscounter.h new file mode 100644 index 0000000000..a644cfaad6 --- /dev/null +++ b/arch/arm/include/asm/syscounter.h @@ -0,0 +1,24 @@ +#ifndef _ASM_SYSCNT_H_ +#define _ASM_SYSCNT_H_ + +#include <io.h> + +#define SYSCNT_CNTCR 0x0000 +#define SYSCNT_CNTCR_EN BIT(0) +#define SYSCNT_CNTCR_HDBG BIT(1) +#define SYSCNT_CNTCR_FCREQ(n) BIT(8 + (n)) + +#define SYSCNT_CNTFID(n) (0x0020 + 4 * (n)) + +static inline void syscnt_enable(void __iomem *syscnt) +{ + writel(SYSCNT_CNTCR_EN | SYSCNT_CNTCR_HDBG | SYSCNT_CNTCR_FCREQ(0), + syscnt + SYSCNT_CNTCR); +} + +static inline u32 syscnt_get_cntfrq(void __iomem *syscnt) +{ + return readl(syscnt + SYSCNT_CNTFID(0)); +} + +#endif
\ No newline at end of file |