microblaze: Add support for CCF
[firefly-linux-kernel-4.4.55.git] / arch / microblaze / kernel / cpu / cpuinfo.c
index c9203b1007aad889a1cb742448b27397ccd83be9..ce1cfed731eac77f57f8fd9dde77004d2fdb61ca 100644 (file)
@@ -8,6 +8,7 @@
  * for more details.
  */
 
+#include <linux/clk.h>
 #include <linux/init.h>
 #include <asm/cpuinfo.h>
 #include <asm/pvr.h>
@@ -68,11 +69,10 @@ const struct family_string_key family_string_lookup[] = {
 };
 
 struct cpuinfo cpuinfo;
+static struct device_node *cpu;
 
 void __init setup_cpuinfo(void)
 {
-       struct device_node *cpu = NULL;
-
        cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu");
        if (!cpu)
                pr_err("You don't have cpu!!!\n");
@@ -102,3 +102,22 @@ void __init setup_cpuinfo(void)
                pr_warn("%s: Stream instructions enabled"
                        " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__);
 }
+
+void __init setup_cpuinfo_clk(void)
+{
+       struct clk *clk;
+
+       clk = of_clk_get(cpu, 0);
+       if (IS_ERR(clk)) {
+               pr_err("ERROR: CPU CCF input clock not found\n");
+               /* take timebase-frequency from DTS */
+               cpuinfo.cpu_clock_freq = fcpu(cpu, "timebase-frequency");
+       } else {
+               cpuinfo.cpu_clock_freq = clk_get_rate(clk);
+       }
+
+       if (!cpuinfo.cpu_clock_freq) {
+               pr_err("ERROR: CPU clock frequency not setup\n");
+               BUG();
+       }
+}