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: 9207885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 65D776089F for ; Thu, 30 Jun 2016 14:14:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5848528489 for ; Thu, 30 Jun 2016 14:14:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 423DA285E6; Thu, 30 Jun 2016 14:14:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3379285E6 for ; Thu, 30 Jun 2016 14:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932073AbcF3OO1 (ORCPT ); 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;