All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: <linux-omap@vger.kernel.org>, <linux-clk@vger.kernel.org>,
	<tony@atomide.com>, <paul@pwsan.com>, <sboyd@codeaurora.org>,
	<mturquette@baylibre.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Subject: [PATCHv3 2/7] clk: ti: add clkdev get helper
Date: Thu, 30 Jun 2016 17:13:33 +0300	[thread overview]
Message-ID: <1467296018-25086-3-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1467296018-25086-1-git-send-email-t-kristo@ti.com>

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 <t-kristo@ti.com>
---
 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;
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Tero Kristo <t-kristo@ti.com>
To: linux-omap@vger.kernel.org, linux-clk@vger.kernel.org,
	tony@atomide.com, paul@pwsan.com, sboyd@codeaurora.org,
	mturquette@baylibre.com
Cc: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 2/7] clk: ti: add clkdev get helper
Date: Thu, 30 Jun 2016 17:13:33 +0300	[thread overview]
Message-ID: <1467296018-25086-3-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1467296018-25086-1-git-send-email-t-kristo@ti.com>

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 <t-kristo@ti.com>
---
 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;
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 2/7] clk: ti: add clkdev get helper
Date: Thu, 30 Jun 2016 17:13:33 +0300	[thread overview]
Message-ID: <1467296018-25086-3-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1467296018-25086-1-git-send-email-t-kristo@ti.com>

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 <t-kristo@ti.com>
---
 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;
-- 
1.9.1

  parent reply	other threads:[~2016-06-30 14:13 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30 14:13 [PATCHv3 0/7] clk: ti add support for hwmod clk type Tero Kristo
2016-06-30 14:13 ` Tero Kristo
2016-06-30 14:13 ` Tero Kristo
2016-06-30 14:13 ` [PATCHv3 1/7] clkdev: add helper registration API Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13 ` Tero Kristo [this message]
2016-06-30 14:13   ` [PATCHv3 2/7] clk: ti: add clkdev get helper Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-07-12 10:22   ` Russell King - ARM Linux
2016-07-12 10:22     ` Russell King - ARM Linux
2016-07-12 15:18     ` Tero Kristo
2016-07-12 15:18       ` Tero Kristo
2016-07-12 15:18       ` Tero Kristo
2016-07-12 15:34       ` Russell King - ARM Linux
2016-07-12 15:34         ` Russell King - ARM Linux
2016-07-12 15:49         ` Tero Kristo
2016-07-12 15:49           ` Tero Kristo
2016-07-12 15:49           ` Tero Kristo
2016-07-12 17:40           ` Michael Turquette
2016-07-12 17:40             ` Michael Turquette
2016-07-12 17:40             ` Michael Turquette
2016-06-30 14:13 ` [PATCHv3 3/7] clk: ti: remove un-used definitions from public clk_hw_omap struct Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13 ` [PATCHv3 4/7] clk: ti: mux: export mux clock APIs locally Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13 ` [PATCHv3 5/7] clk: ti: am33xx: fix timer3/6 init time setup for module clocks Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13 ` [PATCHv3 6/7] dt-bindings: clk: ti: Document module clock type Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13 ` [PATCHv3 7/7] clk: ti: add support for omap4 module clocks Tero Kristo
2016-06-30 14:13   ` Tero Kristo
2016-06-30 14:13   ` Tero Kristo

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=1467296018-25086-3-git-send-email-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=paul@pwsan.com \
    --cc=sboyd@codeaurora.org \
    --cc=tony@atomide.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.