From patchwork Fri Jun 8 07:35:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ike Panhc X-Patchwork-Id: 163723 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id D7432B72C5 for ; Fri, 8 Jun 2012 17:35:35 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SctjE-0008PK-Cz; Fri, 08 Jun 2012 07:35:28 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SctjC-0008Oc-Ak for kernel-team@lists.ubuntu.com; Fri, 08 Jun 2012 07:35:26 +0000 Received: from [210.242.151.101] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SctjB-0003PI-OB for kernel-team@lists.ubuntu.com; Fri, 08 Jun 2012 07:35:26 +0000 From: Ike Panhc To: kernel-team@lists.ubuntu.com Subject: [PATCH 04/10] UBUNTU: SAUCE: dt/clock: add function to get parent clock name Date: Fri, 8 Jun 2012 15:35:22 +0800 Message-Id: <1339140922-10301-1-git-send-email-ike.pan@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1339140847-10159-1-git-send-email-ike.pan@canonical.com> References: <1339140847-10159-1-git-send-email-ike.pan@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Rob Herring BugLink: http://launchpad.net/bugs/1008345 Signed-off-by: Rob Herring Signed-off-by: Ike Panhc --- drivers/of/clock.c | 26 +++++++++++++++++++++++++- include/linux/of_clk.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/of/clock.c b/drivers/of/clock.c index 7546c94..d6c41d3 100644 --- a/drivers/of/clock.c +++ b/drivers/of/clock.c @@ -128,6 +128,30 @@ struct clk *of_clk_get(struct device_node *np, int index) return clk; } +const char *of_clk_get_parent_name(struct device_node *np, int index) +{ + struct of_phandle_args clkspec; + const char *clk_name; + int rc; + + if (index < 0) + return NULL; + + rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, + &clkspec); + if (rc) + return NULL; + + if (of_property_read_string_index(clkspec.np, "clock-output-names", + clkspec.args_count ? clkspec.args[0] : 0, + &clk_name) < 0) + clk_name = clkspec.np->name; + + of_node_put(clkspec.np); + return clk_name; +} + + /** * of_clk_get_by_name() - Parse and lookup a clock referenced by a device node * @np: pointer to clock consumer node @@ -210,4 +234,4 @@ void __init of_fixed_clk_setup(struct device_node *node) clk = clk_register_fixed_rate(NULL, clk_name, NULL, CLK_IS_ROOT, rate); if (clk) of_clk_add_provider(node, NULL, clk); -} \ No newline at end of file +} diff --git a/include/linux/of_clk.h b/include/linux/of_clk.h index 02ecc98..6a07071 100644 --- a/include/linux/of_clk.h +++ b/include/linux/of_clk.h @@ -22,6 +22,8 @@ void of_clk_del_provider(struct device_node *np); struct clk *of_clk_get(struct device_node *np, int index); struct clk *of_clk_get_by_name(struct device_node *np, const char *name); +const char *of_clk_get_parent_name(struct device_node *np, int index); + void of_clk_init(const struct of_device_id *matches); extern void of_fixed_clk_setup(struct device_node *np);