From d9778f7ef961310958539716f524ec9cfaa81551 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Duje=20Mihanovi=C4=87?= Date: Thu, 26 Dec 2024 13:41:50 +0100 Subject: [PATCH] refactor timer_init --- board/samsung/coreprimevelte/coreprimevelte.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/board/samsung/coreprimevelte/coreprimevelte.c b/board/samsung/coreprimevelte/coreprimevelte.c index 7a8fe71eff..170566df74 100644 --- a/board/samsung/coreprimevelte/coreprimevelte.c +++ b/board/samsung/coreprimevelte/coreprimevelte.c @@ -1,15 +1,28 @@ -#include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* Timer constants */ +#define APBC_COUNTER_CLK_SEL 0xd4015064 +#define COUNTER_BASE 0xd4101000 +#define COUNTER_EN BIT(0) +#define COUNTER_HALT_ON_DEBUG BIT(1) int timer_init(void) { - u32 tmp = readl(0xd4015064); + u32 tmp = readl(APBC_COUNTER_CLK_SEL); + if ((tmp >> 16) != 0x319) return -1; - writel(tmp | 1, 0xd4015064); - writel(3, 0xd4101000); + /* Set timer frequency to 26MHz */ + writel(tmp | 1, APBC_COUNTER_CLK_SEL); + writel(COUNTER_EN | COUNTER_HALT_ON_DEBUG, COUNTER_BASE); + + gd->arch.timer_rate_hz = 26000000; + return 0; } -- 2.39.5