From patchwork Wed Apr 10 15:40:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Ruppert X-Patchwork-Id: 2422151 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 8319BDF2E5 for ; Wed, 10 Apr 2013 15:41:23 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UPx97-0005sj-R8; Wed, 10 Apr 2013 15:41:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UPx95-00089y-Cb; Wed, 10 Apr 2013 15:41:11 +0000 Received: from mail.abilis.ch ([195.70.19.74]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UPx91-00089X-W0 for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2013 15:41:09 +0000 Received: from vzimbra0.lan (vzimbra0.lan [10.41.22.42]) by mail.abilis.ch (8.13.8/8.13.8) with ESMTP id r3AFejAS028145; Wed, 10 Apr 2013 17:40:45 +0200 Received: from ab42.lan (ab42.lan [10.41.22.170]) by vzimbra0.lan (Postfix) with ESMTP id 904E7900FEA; Wed, 10 Apr 2013 17:40:45 +0200 (CEST) Received: by ab42.lan (Postfix, from userid 2100) id 8903915EA; Wed, 10 Apr 2013 17:40:45 +0200 (CEST) From: Christian Ruppert To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] clk: Add device tree binding to clk-fixed-factor Date: Wed, 10 Apr 2013 17:40:43 +0200 Message-Id: <1365608443-30350-1-git-send-email-christian.ruppert@abilis.com> X-Mailer: git-send-email 1.7.1 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on dmmail0.lan X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130410_114108_293399_5B687BA6 X-CRM114-Status: GOOD ( 13.42 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Mike Turquette , linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, Rob Herring , Grant Likely , Rob Landley , Christian Ruppert X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds a device tree binding for the simple fixed factor clock divider/multiplier of the common clock tree binding. Signed-off-by: Christian Ruppert --- .../bindings/clock/fixed-factor-clkdiv.txt | 24 +++++++++++++++ drivers/clk/clk-fixed-factor.c | 32 ++++++++++++++++++++ include/linux/clk-provider.h | 1 + 3 files changed, 57 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/fixed-factor-clkdiv.txt diff --git a/Documentation/devicetree/bindings/clock/fixed-factor-clkdiv.txt b/Documentation/devicetree/bindings/clock/fixed-factor-clkdiv.txt new file mode 100644 index 0000000..352bac4 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/fixed-factor-clkdiv.txt @@ -0,0 +1,24 @@ +Device Tree Clock bindings for plat-tb10x + +This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : shall be "fixed-factor-clkdiv" +- #clock-cells: from common clock binding; shall be set to 0 +- clocks: shall be the input parent clock phandle for the clock. +- clock-mult: defines the multiplication factor of the output clock frequency + wrt. the input clock frequency. +- clock-div: defines the division factor of the output clock frequency wrt. + the input clock frequency. + +Example: +cpu_clk: clkdiv_cpu { /* CPU clock derived from pll0. 1/2 of pll frequency */ + compatible = "fixed-factor-clkdiv"; + #clock-cells = <0>; + clocks = <&pll0>; + clock-mult = <1>; + clock-div = <2>; + clock-output-names = "cpu_clk"; +}; diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c index 1ef271e..85e45f1 100644 --- a/drivers/clk/clk-fixed-factor.c +++ b/drivers/clk/clk-fixed-factor.c @@ -11,6 +11,7 @@ #include #include #include +#include /* * DOC: basic fixed multiplier and divider clock that cannot gate @@ -96,3 +97,34 @@ struct clk *clk_register_fixed_factor(struct device *dev, const char *name, return clk; } + +#ifdef CONFIG_OF +/** + * of_fixed_factor_clkdiv_setup() - Set up simple fixed factor clock divider + */ +void of_fixed_factor_clkdiv_setup(struct device_node *node) +{ + struct clk *clk; + const char *clk_name = node->name; + const char *parent_name; + u32 mult, div; + + if (of_property_read_u32(node, "clock-mult", &mult)) + return; + + if (of_property_read_u32(node, "clock-div", &div)) + return; + + parent_name = of_clk_get_parent_name(node, 0); + + of_property_read_string(node, "clock-output-names", &clk_name); + + clk = clk_register_fixed_factor(NULL, clk_name, parent_name, 0, + mult, div); + if (!IS_ERR(clk)) + of_clk_add_provider(node, of_clk_src_simple_get, clk); +} +EXPORT_SYMBOL_GPL(of_fixed_factor_clkdiv_setup); +CLK_OF_DECLARE(fixed_clkdiv, "fixed-factor-clkdiv", + of_fixed_factor_clkdiv_setup); +#endif diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 7f197d7..d4937cf 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -184,6 +184,7 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name, unsigned long fixed_rate); void of_fixed_clk_setup(struct device_node *np); +void of_fixed_factor_clkdiv_setup(struct device_node *node); /** * struct clk_gate - gating clock