summaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2013-03-11 13:26:34 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2013-03-11 22:17:42 +0100
commit9d9375e6f41a015fedcb17f890a16455f6aca7e6 (patch)
tree021b9ec8bd4f75d53471ee02f26aaf83691229e5 /drivers/clocksource
parent5976f09410de9173847070c97b3060453015d419 (diff)
downloadbarebox-9d9375e6f41a015fedcb17f890a16455f6aca7e6.tar.gz
barebox-9d9375e6f41a015fedcb17f890a16455f6aca7e6.tar.xz
ARM: clps711x: Add clocksource driver
This patch adds clocksource driver for CLPS711X targets and adds support to platform to use this new driver. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/Kconfig4
-rw-r--r--drivers/clocksource/Makefile1
-rw-r--r--drivers/clocksource/clps711x.c61
3 files changed, 66 insertions, 0 deletions
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 3f27cf2430..9f3558b6e4 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -10,6 +10,10 @@ config CLOCKSOURCE_BCM2835
bool
depends on ARCH_BCM2835
+config CLOCKSOURCE_CLPS711X
+ bool
+ depends on ARCH_CLPS711X
+
config CLOCKSOURCE_NOMADIK
bool
depends on ARM
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index b0bc8bd7d2..d919881fb8 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -1,4 +1,5 @@
obj-$(CONFIG_AMBA_SP804) += amba-sp804.o
obj-$(CONFIG_ARM_SMP_TWD) += arm_smp_twd.o
obj-$(CONFIG_CLOCKSOURCE_BCM2835) += bcm2835.o
+obj-$(CONFIG_CLOCKSOURCE_CLPS711X) += clps711x.o
obj-$(CONFIG_CLOCKSOURCE_NOMADIK) += nomadik.o
diff --git a/drivers/clocksource/clps711x.c b/drivers/clocksource/clps711x.c
new file mode 100644
index 0000000000..8c379d39ec
--- /dev/null
+++ b/drivers/clocksource/clps711x.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 Alexander Shiyan <shc_work@mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <clock.h>
+#include <io.h>
+#include <init.h>
+
+#include <linux/clk.h>
+#include <linux/err.h>
+
+static __iomem void *clps711x_timer_base;
+
+static uint64_t clps711x_cs_read(void)
+{
+ return ~readw(clps711x_timer_base);
+}
+
+static struct clocksource clps711x_cs = {
+ .read = clps711x_cs_read,
+ .mask = CLOCKSOURCE_MASK(16),
+};
+
+static int clps711x_cs_probe(struct device_d *dev)
+{
+ u32 rate;
+ struct clk *timer_clk;
+
+ timer_clk = clk_get(dev, NULL);
+ if (IS_ERR(timer_clk))
+ return PTR_ERR(timer_clk);
+
+ rate = clk_get_rate(timer_clk);
+ clps711x_timer_base = dev_request_mem_region(dev, 0);
+ if (!clps711x_timer_base) {
+ clk_put(timer_clk);
+ return -ENOENT;
+ }
+
+ clocks_calc_mult_shift(&clps711x_cs.mult, &clps711x_cs.shift, rate,
+ NSEC_PER_SEC, 10);
+
+ return init_clock(&clps711x_cs);
+}
+
+static struct driver_d clps711x_cs_driver = {
+ .name = "clps711x-cs",
+ .probe = clps711x_cs_probe,
+};
+
+static __init int clps711x_cs_init(void)
+{
+ return platform_driver_register(&clps711x_cs_driver);
+}
+coredevice_initcall(clps711x_cs_init);