From patchwork Mon Apr 11 08:18:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 65469 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp1332032lbl; Mon, 11 Apr 2016 01:22:32 -0700 (PDT) X-Received: by 10.66.132.37 with SMTP id or5mr31170659pab.144.1460362925628; Mon, 11 Apr 2016 01:22:05 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a22si2161726pfj.116.2016.04.11.01.22.05; Mon, 11 Apr 2016 01:22:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753901AbcDKIWD (ORCPT + 3 others); Mon, 11 Apr 2016 04:22:03 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:32949 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753006AbcDKIU3 (ORCPT ); Mon, 11 Apr 2016 04:20:29 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u3B8JQiP023554; Mon, 11 Apr 2016 03:19:26 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u3B8JQiW019328; Mon, 11 Apr 2016 03:19:26 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Mon, 11 Apr 2016 03:19:26 -0500 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u3B8JL5x024976; Mon, 11 Apr 2016 03:19:24 -0500 From: Tero Kristo To: , , , , CC: , , Subject: [PATCH 01/30] clk: ti: add ti_clk_get helper API Date: Mon, 11 Apr 2016 11:18:52 +0300 Message-ID: <1460362761-4842-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1460362761-4842-1-git-send-email-t-kristo@ti.com> References: <1460362761-4842-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The API can be used to fetch directly DT clocks based on name. Using this new API allows getting rid of most of the DT_CLK() entries under drivers/clk/ti. Signed-off-by: Tero Kristo --- drivers/clk/ti/clk.c | 35 +++++++++++++++++++++++++++++------ include/linux/clk/ti.h | 2 ++ 2 files changed, 31 insertions(+), 6 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 5fcf247..3dcf97e 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -68,6 +68,33 @@ static u32 clk_memmap_readl(void __iomem *reg) } /** + * ti_clk_get - lookup a TI clock handle + * @name: clock to find + * + * Searches for a TI clock handle. Will first attempt to search for a + * clock based on a DT node name, but if this fails, will revert to + * looking up a clock alias. Returns the pointer to the clock handle, + * or ERR_PTR in failure. + */ +struct clk *ti_clk_get(const char *name) +{ + struct of_phandle_args clkspec; + struct device_node *node; + struct clk *clk; + + if (of_have_populated_dt()) { + node = of_find_node_by_name(NULL, name); + clkspec.np = node; + clk = of_clk_get_from_provider(&clkspec); + + if (!IS_ERR(clk)) + return clk; + } + + return clk_get(NULL, name); +} + +/** * ti_clk_setup_ll_ops - setup low level clock operations * @ops: low level clock ops descriptor * @@ -102,14 +129,10 @@ int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops) void __init ti_dt_clocks_register(struct ti_dt_clk oclks[]) { struct ti_dt_clk *c; - struct device_node *node; struct clk *clk; - struct of_phandle_args clkspec; for (c = oclks; c->node_name != NULL; c++) { - node = of_find_node_by_name(NULL, c->node_name); - clkspec.np = node; - clk = of_clk_get_from_provider(&clkspec); + clk = ti_clk_get(c->node_name); if (!IS_ERR(clk)) { c->lk.clk = clk; @@ -446,7 +469,7 @@ void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks) int i; for (i = 0; i < num_clocks; i++) { - init_clk = clk_get(NULL, clk_names[i]); + init_clk = ti_clk_get(clk_names[i]); if (WARN(IS_ERR(init_clk), "could not find init clock %s\n", clk_names[i])) continue; diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h index dc5164a..210e946 100644 --- a/include/linux/clk/ti.h +++ b/include/linux/clk/ti.h @@ -292,6 +292,8 @@ struct ti_clk_features { void ti_clk_setup_features(struct ti_clk_features *features); const struct ti_clk_features *ti_clk_get_features(void); +struct clk *ti_clk_get(const char *name); + extern const struct clk_hw_omap_ops clkhwops_omap2xxx_dpll; #ifdef CONFIG_ATAGS