CLOCKSOURCE: mips-gic: Allow GIC clock to be specified in device-tree
authorAndrew Bresticker <abrestic@chromium.org>
Tue, 24 Feb 2015 02:28:34 +0000 (18:28 -0800)
committerRalf Baechle <ralf@linux-mips.org>
Wed, 1 Apr 2015 15:22:11 +0000 (17:22 +0200)
As an alternative to the "clock-frequency" property, allow the GIC
timer operating clock to be specified in the device-tree instead.
This is useful on systems which use common clock or where the GIC
is not fixed to a particular frequency and is instead, for example,
derived from the CPU clock.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: Kumar Gala <galak@codeaurora.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: devicetree@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/9309/

Documentation/devicetree/bindings/interrupt-controller/mips-gic.txt
drivers/clocksource/mips-gic-timer.c

index 5a65478e5d40dd050d943d3b419088e615925e1b..aae4c384ee1f2047836876ef8e1ff609e3a5770e 100644 (file)
@@ -27,8 +27,13 @@ Optional properties:
 Required properties for timer sub-node:
 - compatible : Should be "mti,gic-timer".
 - interrupts : Interrupt for the GIC local timer.
+
+Optional properties for timer sub-node:
+- clocks : GIC timer operating clock.
 - clock-frequency : Clock frequency at which the GIC timers operate.
 
+Note that one of clocks or clock-frequency must be specified.
+
 Example:
 
        gic: interrupt-controller@1bdc0000 {
index 16adbc1fa4c1a662bd858c992a218acd8ce206c1..b81ed1a5342d90ca7481dd48c0bf928da5bcc6e7 100644 (file)
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
  */
+#include <linux/clk.h>
 #include <linux/clockchips.h>
 #include <linux/cpu.h>
 #include <linux/init.h>
@@ -149,11 +150,18 @@ void __init gic_clocksource_init(unsigned int frequency)
 
 static void __init gic_clocksource_of_init(struct device_node *node)
 {
+       struct clk *clk;
+
        if (WARN_ON(!gic_present || !node->parent ||
                    !of_device_is_compatible(node->parent, "mti,gic")))
                return;
 
-       if (of_property_read_u32(node, "clock-frequency", &gic_frequency)) {
+       clk = of_clk_get(node, 0);
+       if (!IS_ERR(clk)) {
+               gic_frequency = clk_get_rate(clk);
+               clk_put(clk);
+       } else if (of_property_read_u32(node, "clock-frequency",
+                                       &gic_frequency)) {
                pr_err("GIC frequency not specified.\n");
                return;
        }