From patchwork Thu Jun 30 14:13:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 71246 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp417458qgy; Thu, 30 Jun 2016 07:14:34 -0700 (PDT) X-Received: by 10.98.112.196 with SMTP id l187mr21855456pfc.59.1467296073764; Thu, 30 Jun 2016 07:14:33 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e62si4650665pfe.193.2016.06.30.07.14.33; Thu, 30 Jun 2016 07:14:33 -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 S932073AbcF3OO1 (ORCPT + 3 others); Thu, 30 Jun 2016 10:14:27 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:39699 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752549AbcF3OOY (ORCPT ); Thu, 30 Jun 2016 10:14:24 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u5UECkCa017895; Thu, 30 Jun 2016 09:12:46 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5UEDwGF004450; Thu, 30 Jun 2016 09:13:58 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Thu, 30 Jun 2016 09:13:58 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5UEDnVW002253; Thu, 30 Jun 2016 09:13:56 -0500 From: Tero Kristo To: , , , , , CC: Subject: [PATCHv3 2/7] clk: ti: add clkdev get helper Date: Thu, 30 Jun 2016 17:13:33 +0300 Message-ID: <1467296018-25086-3-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467296018-25086-1-git-send-email-t-kristo@ti.com> References: <1467296018-25086-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 TI clocks can be found based on a simple query against the clock name, thus add a clkdev helper functionality for this. Using this new helper implementation allows getting rid of most of the DT_CLK() entries under drivers/clk/ti. Signed-off-by: Tero Kristo --- drivers/clk/ti/clk.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) -- 1.9.1 -- 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..17554c3 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -68,6 +68,36 @@ static u32 clk_memmap_readl(void __iomem *reg) } /** + * ti_clk_get - lookup a TI clock handle + * @dev_id: device to lookup clock for + * @con_id: connection ID to find + * + * Searches for a TI clock handle based on the DT node name. + * Returns the pointer to the clock handle, or ERR_PTR in failure. + */ +static struct clk *ti_clk_get(const char *dev_id, const char *con_id) +{ + struct of_phandle_args clkspec; + struct device_node *node; + struct clk *clk; + + /* Only check for cases of type clk_get_sys(NULL, "xyz") */ + if (dev_id || !con_id) + return ERR_PTR(-ENOENT); + + if (of_have_populated_dt()) { + node = of_find_node_by_name(NULL, con_id); + clkspec.np = node; + clk = of_clk_get_from_provider(&clkspec); + + if (!IS_ERR(clk)) + return clk; + } + + return ERR_PTR(-ENOENT); +} + +/** * ti_clk_setup_ll_ops - setup low level clock operations * @ops: low level clock ops descriptor * @@ -87,6 +117,8 @@ int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops) ops->clk_readl = clk_memmap_readl; ops->clk_writel = clk_memmap_writel; + clkdev_helper_register(ti_clk_get); + return 0; } @@ -102,14 +134,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(NULL, c->node_name); if (!IS_ERR(clk)) { c->lk.clk = clk;