From patchwork Mon Jun 13 19:04:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 69926 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1692798qgf; Mon, 13 Jun 2016 12:06:55 -0700 (PDT) X-Received: by 10.98.102.25 with SMTP id a25mr15303531pfc.65.1465844804868; Mon, 13 Jun 2016 12:06:44 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id s88si19090443pfa.225.2016.06.13.12.06.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jun 2016 12:06:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCXBE-0000H0-No; Mon, 13 Jun 2016 19:05:48 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCXB3-00007b-1a for linux-arm-kernel@lists.infradead.org; Mon, 13 Jun 2016 19:05:37 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id u5DJ4nBF031879; Mon, 13 Jun 2016 14:04:49 -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 u5DJ5CUu019430; Mon, 13 Jun 2016 14:05:12 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Mon, 13 Jun 2016 14:05:12 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5DJ56Sn004255; Mon, 13 Jun 2016 14:05:10 -0500 From: Tero Kristo To: , , , , Subject: [RESEND PATCHv2 01/28] clk: ti: add ti_clk_get helper API Date: Mon, 13 Jun 2016 22:04:35 +0300 Message-ID: <1465844702-12200-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465844702-12200-1-git-send-email-t-kristo@ti.com> References: <1465844702-12200-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160613_120537_174181_2214C227 X-CRM114-Status: GOOD ( 12.72 ) X-Spam-Score: -7.3 (-------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-7.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.153 listed in list.dnswl.org] 1.0 FSL_HELO_HOME No description available. -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [198.47.26.153 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 6110fe0..331b81b 100644 --- a/include/linux/clk/ti.h +++ b/include/linux/clk/ti.h @@ -294,6 +294,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