Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756298AbbBEAxy (ORCPT ); Wed, 4 Feb 2015 19:53:54 -0500 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:61252 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756260AbbBEAxw (ORCPT ); Wed, 4 Feb 2015 19:53:52 -0500 X-IronPort-AV: E=Sophos;i="5.09,521,1418112000"; d="scan'208";a="56364571" From: Ray Jui To: Mike Turquette , Stephen Boyd , Matt Porter , Alex Elder , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Russell King , Arnd Bergmann CC: , , Scott Branden , Dmitry Torokhov , Anatol Pomazau , , , Ray Jui Subject: [PATCH v5 1/6] clk: add of_clk_get_parent_rate function Date: Wed, 4 Feb 2015 16:55:00 -0800 Message-ID: <1423097705-22939-2-git-send-email-rjui@broadcom.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1423097705-22939-1-git-send-email-rjui@broadcom.com> References: <1423097705-22939-1-git-send-email-rjui@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2553 Lines: 75 Sometimes a clock needs to know the rate of its parent before itself is registered to the framework. An example is that a PLL may need to initialize itself to a specific VCO frequency, before registering to the framework. The parent rate needs to be known, for PLL multipliers and divisors to be configured properly. Introduce helper function of_clk_get_parent_rate, which can be used to obtain the parent rate of a clock, given a device node and index. Signed-off-by: Ray Jui --- drivers/clk/clk.c | 17 +++++++++++++++++ include/linux/clk-provider.h | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d48ac71..e1893a2 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2581,6 +2581,23 @@ const char *of_clk_get_parent_name(struct device_node *np, int index) } EXPORT_SYMBOL_GPL(of_clk_get_parent_name); +unsigned long of_clk_get_parent_rate(struct device_node *np, int index) +{ + const char *parent_name; + struct clk *parent_clk; + + parent_name = of_clk_get_parent_name(np, index); + if (!parent_name) + return 0; + + parent_clk = __clk_lookup(parent_name); + if (!parent_clk) + return 0; + + return clk_get_rate(parent_clk); +} +EXPORT_SYMBOL_GPL(of_clk_get_parent_rate); + struct clock_provider { of_clk_init_cb_t clk_init_cb; struct device_node *np; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index d936409..e1e2d95 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -585,7 +585,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data); int of_clk_get_parent_count(struct device_node *np); const char *of_clk_get_parent_name(struct device_node *np, int index); - +unsigned long of_clk_get_parent_rate(struct device_node *np, int index); void of_clk_init(const struct of_device_id *matches); #else /* !CONFIG_OF */ @@ -614,6 +614,10 @@ static inline const char *of_clk_get_parent_name(struct device_node *np, { return NULL; } +static unsigned long of_clk_get_parent_rate(struct device_node *np, int index) +{ + return 0; +} #define of_clk_init(matches) \ { while (0); } #endif /* CONFIG_OF */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/