clocksource: Sched clock source for Versatile Express
authorPawel Moll <pawel.moll@arm.com>
Wed, 16 Apr 2014 17:22:59 +0000 (18:22 +0100)
committerPawel Moll <pawel.moll@arm.com>
Thu, 15 May 2014 16:02:20 +0000 (17:02 +0100)
This patch adds a trival sched clock source using free
running, 24MHz clocked counter present in the ARM Ltd.
reference platforms (Versatile, RealView, Versatile
Express) System Registers block.

This code replaces the call in the VE machine code.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
arch/arm/mach-vexpress/v2m.c
drivers/clocksource/Kconfig
drivers/clocksource/Makefile
drivers/clocksource/versatile.c [new file with mode: 0644]

index 90f04c9..d8a9fd7 100644 (file)
@@ -418,8 +418,6 @@ void __init v2m_dt_init_early(void)
                        pr_warning("vexpress: DT HBI (%x) is not matching "
                                        "hardware (%x)!\n", dt_hbi, hbi);
        }
-
-       versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
 }
 
 
index 96918e1..2c27b02 100644 (file)
@@ -191,3 +191,14 @@ config EM_TIMER_STI
 
 config CLKSRC_QCOM
        bool
+
+config CLKSRC_VERSATILE
+       bool "ARM Versatile (Express) reference platforms clock source"
+       depends on GENERIC_SCHED_CLOCK
+       select CLKSRC_OF
+       default y if MFD_VEXPRESS_SYSREG
+       help
+         This option enables clock source based on free running
+         counter available in the "System Registers" block of
+         ARM Versatile, RealView and Versatile Express reference
+         platforms.
index 98cb6c5..6f25bdf 100644 (file)
@@ -39,3 +39,4 @@ obj-$(CONFIG_ARM_GLOBAL_TIMER)                += arm_global_timer.o
 obj-$(CONFIG_CLKSRC_METAG_GENERIC)     += metag_generic.o
 obj-$(CONFIG_ARCH_HAS_TICK_BROADCAST)  += dummy_timer.o
 obj-$(CONFIG_ARCH_KEYSTONE)            += timer-keystone.o
+obj-$(CONFIG_CLKSRC_VERSATILE)         += versatile.o
diff --git a/drivers/clocksource/versatile.c b/drivers/clocksource/versatile.c
new file mode 100644 (file)
index 0000000..e4c50ad
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Copyright (C) 2014 ARM Limited
+ */
+
+#include <linux/clocksource.h>
+#include <linux/io.h>
+#include <linux/of_address.h>
+#include <linux/sched_clock.h>
+
+#define SYS_24MHZ 0x05c
+
+static void __iomem *versatile_sys_24mhz;
+
+static u32 notrace versatile_sys_24mhz_read(void)
+{
+       return readl(versatile_sys_24mhz);
+}
+
+static void __init versatile_sched_clock_init(struct device_node *node)
+{
+       void __iomem *base = of_iomap(node, 0);
+
+       if (!base)
+               return;
+
+       versatile_sys_24mhz = base + SYS_24MHZ;
+
+       setup_sched_clock(versatile_sys_24mhz_read, 32, 24000000);
+}
+CLOCKSOURCE_OF_DECLARE(versatile, "arm,vexpress-sysreg",
+               versatile_sched_clock_init);