[PATCH 11/12] ARM: versatile: Use existing clocksource driver

Sascha Hauer s.hauer at pengutronix.de
Tue May 2 02:14:18 PDT 2023


We already have a SP804 driver in drivers/clocksource/. Use that instead
of the open coded arch clocksource.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/Kconfig               |  2 ++
 arch/arm/mach-versatile/core.c | 60 ----------------------------------
 2 files changed, 2 insertions(+), 60 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ef3adbbe9d..1d2734975a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -275,6 +275,8 @@ config ARCH_VERSATILE
 	bool "ARM Versatile boards (ARM926EJ-S)"
 	depends on 32BIT
 	select GPIOLIB
+	select ARM_AMBA
+	select AMBA_SP804
 	select HAVE_CLK
 	select HAS_DEBUG_LL
 	select COMMON_CLK
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 74af8c0804..b0124b700c 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -35,69 +35,10 @@
 #include <linux/amba/bus.h>
 
 #include <io.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/armlinux.h>
 
 #include <mach/versatile/platform.h>
 
-
-/* 1Mhz / 256 */
-#define TIMER_FREQ (1000000/256)
-
-#define TIMER0_BASE (VERSATILE_TIMER0_1_BASE)
-#define TIMER1_BASE ((VERSATILE_TIMER0_1_BASE) + 0x20)
-#define TIMER2_BASE (VERSATILE_TIMER2_3_BASE)
-#define TIMER3_BASE ((VERSATILE_TIMER2_3_BASE) + 0x20)
-
-static uint64_t vpb_clocksource_read(void)
-{
-	return ~readl(TIMER0_BASE + TIMER_VALUE);
-}
-
-static struct clocksource vpb_cs = {
-	.read = vpb_clocksource_read,
-	.mask = CLOCKSOURCE_MASK(32),
-	.shift = 10,
-	.priority = 80,
-};
-
-/* From Linux v2.6.35
- * arch/arm/mach-versatile/core.c */
-static void versatile_timer_init (void)
-{
-	u32 val;
-
-	/*
-	 * set clock frequency:
-	 *      VERSATILE_REFCLK is 32KHz
-	 *      VERSATILE_TIMCLK is 1MHz
-	 */
-
-	val = readl(VERSATILE_SCTL_BASE);
-	val |= (VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel);
-	writel(val, VERSATILE_SCTL_BASE);
-
-	/*
-	 * Disable all timers, just to be sure.
-	 */
-
-	writel(0, TIMER0_BASE + TIMER_CTRL);
-	writel(0, TIMER1_BASE + TIMER_CTRL);
-	writel(0, TIMER2_BASE + TIMER_CTRL);
-	writel(0, TIMER3_BASE + TIMER_CTRL);
-
-	writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_DIV256,
-					TIMER0_BASE + TIMER_CTRL);
-}
-
-static int vpb_clocksource_init(void)
-{
-	versatile_timer_init();
-	vpb_cs.mult = clocksource_hz2mult(TIMER_FREQ, vpb_cs.shift);
-
-	return init_clock(&vpb_cs);
-}
-
 static void __noreturn versatile_reset_soc(struct restart_handler *rst)
 {
 	u32 val;
@@ -118,7 +59,6 @@ static int versatile_init(void)
 	    !of_machine_is_compatible("arm,versatile-ab"))
 		return 0;
 
-	vpb_clocksource_init();
 	restart_handler_register_fn("soc", versatile_reset_soc);
 	return 0;
 }
-- 
2.39.2




More information about the barebox mailing list