Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

CLOCKSOURCE: mips-gic: Allow GIC clock to be specified in device-tree

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/

authored by

Andrew Bresticker and committed by
Ralf Baechle
5b4e8453 615eb603

+14 -1
+5
Documentation/devicetree/bindings/interrupt-controller/mips-gic.txt
··· 27 27 Required properties for timer sub-node: 28 28 - compatible : Should be "mti,gic-timer". 29 29 - interrupts : Interrupt for the GIC local timer. 30 + 31 + Optional properties for timer sub-node: 32 + - clocks : GIC timer operating clock. 30 33 - clock-frequency : Clock frequency at which the GIC timers operate. 34 + 35 + Note that one of clocks or clock-frequency must be specified. 31 36 32 37 Example: 33 38
+9 -1
drivers/clocksource/mips-gic-timer.c
··· 5 5 * 6 6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. 7 7 */ 8 + #include <linux/clk.h> 8 9 #include <linux/clockchips.h> 9 10 #include <linux/cpu.h> 10 11 #include <linux/init.h> ··· 150 149 151 150 static void __init gic_clocksource_of_init(struct device_node *node) 152 151 { 152 + struct clk *clk; 153 + 153 154 if (WARN_ON(!gic_present || !node->parent || 154 155 !of_device_is_compatible(node->parent, "mti,gic"))) 155 156 return; 156 157 157 - if (of_property_read_u32(node, "clock-frequency", &gic_frequency)) { 158 + clk = of_clk_get(node, 0); 159 + if (!IS_ERR(clk)) { 160 + gic_frequency = clk_get_rate(clk); 161 + clk_put(clk); 162 + } else if (of_property_read_u32(node, "clock-frequency", 163 + &gic_frequency)) { 158 164 pr_err("GIC frequency not specified.\n"); 159 165 return; 160 166 }