summaryrefslogtreecommitdiffstats
path: root/arch/mips/xilfpga/time.c
diff options
context:
space:
mode:
authorZubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>2015-10-26 12:30:56 +0100
committerRalf Baechle <ralf@linux-mips.org>2015-11-11 08:38:44 +0100
commit9937f5fff889bde488c5ffd238dcb49e9b9cc7b7 (patch)
tree2ac3a86bd0914a3b264ade99152f73c052a1cb2e /arch/mips/xilfpga/time.c
parentMIPS: xilfpga: Add xilfpga device tree files. (diff)
downloadlinux-9937f5fff889bde488c5ffd238dcb49e9b9cc7b7.tar.xz
linux-9937f5fff889bde488c5ffd238dcb49e9b9cc7b7.zip
MIPS: xilfpga: Add mipsfpga platform code
The xilfpga platform will be DT only. Add required platform code. DT files have already been added separately. Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> Cc: robh+dt@kernel.org Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Cc: devicetree@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/11364/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/xilfpga/time.c')
-rw-r--r--arch/mips/xilfpga/time.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/arch/mips/xilfpga/time.c b/arch/mips/xilfpga/time.c
new file mode 100644
index 000000000000..a1c0fc8893e8
--- /dev/null
+++ b/arch/mips/xilfpga/time.c
@@ -0,0 +1,41 @@
+/*
+ * Xilfpga clocksource/timer setup
+ *
+ * Copyright (C) 2015 Imagination Technologies
+ * Author: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/clocksource.h>
+#include <linux/of.h>
+
+#include <asm/time.h>
+
+void __init plat_time_init(void)
+{
+ struct device_node *np;
+ struct clk *clk;
+
+ of_clk_init(NULL);
+ clocksource_of_init();
+
+ np = of_get_cpu_node(0, NULL);
+ if (!np) {
+ pr_err("Failed to get CPU node\n");
+ return;
+ }
+
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk)) {
+ pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
+ return;
+ }
+
+ mips_hpt_frequency = clk_get_rate(clk) / 2;
+ clk_put(clk);
+}