devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo-l0cyMroinI0@public.gmane.org>
To: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org,
	paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org,
	mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org,
	sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 01/30] clk: ti: add ti_clk_get helper API
Date: Mon, 11 Apr 2016 11:18:52 +0300	[thread overview]
Message-ID: <1460362761-4842-2-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1460362761-4842-1-git-send-email-t-kristo-l0cyMroinI0@public.gmane.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 <t-kristo-l0cyMroinI0@public.gmane.org>
---
 drivers/clk/ti/clk.c   |   35 +++++++++++++++++++++++++++++------
 include/linux/clk/ti.h |    2 ++
 2 files changed, 31 insertions(+), 6 deletions(-)

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
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-04-11  8:18 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-11  8:18 [PATCH 00/30] ARM: OMAP2+: hwmod module clock type support Tero Kristo
2016-04-11  8:18 ` [PATCH 02/30] clk: ti: dpll: use ti_clk_get to fetch ref/bypass clocks Tero Kristo
2016-04-11  8:18 ` [PATCH 04/30] ARM: OMAP2+: hwmod: use new ti_clk_get API to search for clock handles Tero Kristo
2016-04-11  8:18 ` [PATCH 05/30] ARM: OMAP2+: clock: use the new ti_clk_get for fetching clocks Tero Kristo
2016-04-11  8:18 ` [PATCH 06/30] clk: ti: omap2: transition to usage of ti_clk_get Tero Kristo
2016-04-11  8:18 ` [PATCH 08/30] clk: ti: omap3: " Tero Kristo
2016-04-11  8:19 ` [PATCH 09/30] clk: ti: am43xx: " Tero Kristo
2016-04-11  8:19 ` [PATCH 12/30] clk: ti: dra7: " Tero Kristo
2016-04-11  8:19 ` [PATCH 16/30] clk: ti: mux: export mux clock APIs locally Tero Kristo
2016-04-11  8:19 ` [PATCH 18/30] clk: ti: add support for omap4 module clocks Tero Kristo
2016-04-11  8:19 ` [PATCH 19/30] ARM: dts: omap4: add hwmod " Tero Kristo
2016-04-11  8:19 ` [PATCH 20/30] ARM: OMAP2+: clockdomain: add usecounting support to autoidle APIs Tero Kristo
2016-04-11  8:19 ` [PATCH 22/30] ARM: AM33xx: fix module_wait_ready without clkctrl register Tero Kristo
     [not found] ` <1460362761-4842-1-git-send-email-t-kristo-l0cyMroinI0@public.gmane.org>
2016-04-11  8:18   ` Tero Kristo [this message]
2016-04-11  8:18   ` [PATCH 03/30] ARM: OMAP2+: omap_device: create clock alias purely from DT data Tero Kristo
2016-04-11  8:18   ` [PATCH 07/30] clk: ti: am33xx: transition to usage of ti_clk_get Tero Kristo
2016-04-11  8:19   ` [PATCH 10/30] clk: ti: omap4: " Tero Kristo
2016-04-11  8:19   ` [PATCH 11/30] clk: ti: omap5: " Tero Kristo
2016-04-11  8:19   ` [PATCH 13/30] clk: ti: dm814x: " Tero Kristo
2016-04-11  8:19   ` [PATCH 14/30] clk: ti: dm816x: cleanup any unnecessary clock aliases Tero Kristo
2016-04-11  8:19   ` [PATCH 15/30] clk: ti: remove un-used definitions from public clk_hw_omap struct Tero Kristo
2016-04-11  8:19   ` [PATCH 17/30] dt-bindings: clk: ti: Document module clock type Tero Kristo
2016-04-11  8:19   ` [PATCH 21/30] ARM: OMAP4: hwmod_data: use module clocks from DT Tero Kristo
2016-04-11  8:19   ` [PATCH 23/30] ARM: dts: am33xx: add hwmod module clocks Tero Kristo
2016-04-11 17:40   ` [PATCH 00/30] ARM: OMAP2+: hwmod module clock type support Tony Lindgren
2016-04-12 13:55     ` Tero Kristo
2016-04-12 16:42       ` Tony Lindgren
2016-04-11  8:19 ` [PATCH 24/30] ARM: dts: am43xx: add hwmod module clocks Tero Kristo
2016-04-11  8:19 ` [PATCH 25/30] clk: ti: am33xx: fix init time clock setup Tero Kristo
2016-04-11  8:19 ` [PATCH 26/30] ARM: AMx3xx: hwmod_data: use module clocks from DT Tero Kristo
2016-04-11  8:19 ` [PATCH 27/30] ARM: dts: omap5: add hwmod module clocks Tero Kristo
2016-04-11  8:19 ` [PATCH 28/30] ARM: OMAP5: hwmod_data: use module clocks from DT Tero Kristo
2016-04-11  8:19 ` [PATCH 29/30] ARM: dts: dra7: add hwmod module clocks Tero Kristo
2016-04-11  8:19 ` [PATCH 30/30] ARM: DRA7: hwmod_data: use module clocks from DT Tero Kristo
2016-04-12 14:58 ` [PATCH 00/30] ARM: OMAP2+: hwmod module clock type support Rob Herring
2016-04-12 15:58   ` Tony Lindgren
2016-04-13  6:59     ` Tero Kristo
2016-04-13 15:49       ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460362761-4842-2-git-send-email-t-kristo@ti.com \
    --to=t-kristo-l0cymroini0@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
    --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org \
    --cc=sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).