From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fMg5M-0004Zo-BY for barebox@lists.infradead.org; Sat, 26 May 2018 20:47:45 +0000 Received: by mail-pl0-x243.google.com with SMTP id z9-v6so1666429plk.11 for ; Sat, 26 May 2018 13:46:34 -0700 (PDT) From: Andrey Smirnov Date: Sat, 26 May 2018 13:44:22 -0700 Message-Id: <20180526204451.16530-20-andrew.smirnov@gmail.com> In-Reply-To: <20180526204451.16530-1-andrew.smirnov@gmail.com> References: <20180526204451.16530-1-andrew.smirnov@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2 19/48] ARM: Add constants and helpers for system counter interface To: barebox@lists.infradead.org Cc: Andrey Smirnov 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 --- arch/arm/include/asm/syscounter.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 arch/arm/include/asm/syscounter.h diff --git a/arch/arm/include/asm/syscounter.h b/arch/arm/include/asm/syscounter.h new file mode 100644 index 000000000..a644cfaad --- /dev/null +++ b/arch/arm/include/asm/syscounter.h @@ -0,0 +1,24 @@ +#ifndef _ASM_SYSCNT_H_ +#define _ASM_SYSCNT_H_ + +#include + +#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 -- 2.17.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox