mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: <geert+renesas@glider.be>
Cc: <laurent.pinchart@ideasonboard.com>, <ulf.hansson@linaro.org>,
	<khilman@linaro.org>, <grant.likely@secretlab.ca>,
	<mturquette@linaro.org>, <tomasz.figa@gmail.com>,
	<ben.dooks@codethink.co.uk>, <horms@verge.net.au>,
	<magnus.damm@gmail.com>, <rjw@rjwysocki.net>,
	<linux-sh@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-omap@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	Grygorii Strashko <grygorii.strashko@ti.com>
Subject: [RFC PATCH 1/2] clk: of: introduce of_clk_get_from_set()
Date: Thu, 12 Jun 2014 19:53:42 +0300	[thread overview]
Message-ID: <1402592023-13416-2-git-send-email-grygorii.strashko@ti.com> (raw)
In-Reply-To: <1402592023-13416-1-git-send-email-grygorii.strashko@ti.com>

In many case it's useful to divide device's clocks into
few sets according to their designation.
- some clocks can be optional for the device
- some clocks can be managed by PM frameworks (like clock_ops for example)
  while some need to be managed by driver directly.

This patch introduces new API of_clk_get_from_set() which allows
the callers to specify additional prefix to be used together with
generic DT clocks list property name "clocks".

In the example bellow, the caller asks CLK framework to retrieve
clock from the clocks list "clkops-clocks" and not from "clocks":
DT:
	usb: usb@2680000 {
		compatible = "ti,keystone-dwc3";
		[...]
		clkops-clocks = <&clkusb>;

Code:
	clk = of_clk_get_from_set(np, "clkops", 0);

This changes will not affect on already existed code.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/clk/clkdev.c |   24 ++++++++++++++++++++++--
 include/linux/clk.h  |    7 +++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index f890b90..2308518 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -53,7 +53,8 @@ struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec)
 	return clk;
 }
 
-struct clk *of_clk_get(struct device_node *np, int index)
+static struct clk *of_clk_get_named(struct device_node *np,
+		const char *propname, int index)
 {
 	struct of_phandle_args clkspec;
 	struct clk *clk;
@@ -62,7 +63,7 @@ struct clk *of_clk_get(struct device_node *np, int index)
 	if (index < 0)
 		return ERR_PTR(-EINVAL);
 
-	rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
+	rc = of_parse_phandle_with_args(np, propname, "#clock-cells", index,
 					&clkspec);
 	if (rc)
 		return ERR_PTR(rc);
@@ -71,8 +72,27 @@ struct clk *of_clk_get(struct device_node *np, int index)
 	of_node_put(clkspec.np);
 	return clk;
 }
+
+struct clk *of_clk_get(struct device_node *np, int index)
+{
+	return of_clk_get_named(np, "clocks", index);
+}
 EXPORT_SYMBOL(of_clk_get);
 
+struct clk *of_clk_get_from_set(struct device_node *np,
+		const char *set_id, int index)
+{
+	char prop_name[32]; /* 32 is max size of property name */
+
+	if (set_id)
+		snprintf(prop_name, 32, "%s-clocks", set_id);
+	else
+		snprintf(prop_name, 32, "clocks");
+
+	return of_clk_get_named(np, prop_name, index);
+}
+EXPORT_SYMBOL(of_clk_get_from_set);
+
 /**
  * of_clk_get_by_name() - Parse and lookup a clock referenced by a device node
  * @np: pointer to clock consumer node
diff --git a/include/linux/clk.h b/include/linux/clk.h
index fb5e097..fc8865a 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -397,6 +397,8 @@ struct of_phandle_args;
 
 #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
 struct clk *of_clk_get(struct device_node *np, int index);
+struct clk *of_clk_get_from_set(struct device_node *np,
+		const char *set_id, int index);
 struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
 struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
 #else
@@ -409,6 +411,11 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np,
 {
 	return ERR_PTR(-ENOENT);
 }
+static inline struct clk *of_clk_get_from_set(struct device_node *np,
+					const char *set_id, int index)
+{
+	return ERR_PTR(-ENOENT);
+}
 #endif
 
 #endif
-- 
1.7.9.5


  reply	other threads:[~2014-06-12 16:06 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 10:13 [PATCH/RFC 0/4] of: Register clocks for Runtime PM with PM core Geert Uytterhoeven
2014-04-24 10:13 ` [PATCH/RFC 1/4] clk: Add CLK_RUNTIME_PM and clk_may_runtime_pm() Geert Uytterhoeven
2014-04-24 10:13 ` [PATCH/RFC 2/4] PM / clock_ops: Add pm_clk_add_clk() Geert Uytterhoeven
2014-04-24 10:13 ` [PATCH/RFC 3/4] of/clk: Register clocks suitable for Runtime PM with the PM core Geert Uytterhoeven
2014-04-24 13:11   ` Ulf Hansson
2014-04-24 14:09     ` Geert Uytterhoeven
2014-04-26  1:59     ` Tomasz Figa
2014-05-02  8:13       ` Ulf Hansson
2014-05-02 14:58         ` Geert Uytterhoeven
2014-05-06  7:58           ` Ulf Hansson
2014-04-30 21:23     ` Laurent Pinchart
2014-04-30 22:06       ` Geert Uytterhoeven
2014-04-25 23:44   ` Kevin Hilman
2014-04-29 13:16     ` Grant Likely
2014-04-30 21:25       ` Laurent Pinchart
2014-04-30 21:33         ` Ben Dooks
2014-04-30 21:54       ` Geert Uytterhoeven
2014-05-01  8:03         ` Grant Likely
2014-05-01 13:41           ` Geert Uytterhoeven
2014-05-01 13:56             ` Grant Likely
2014-05-01 14:46               ` Geert Uytterhoeven
2014-04-30 21:47     ` Geert Uytterhoeven
2014-05-02  8:56   ` Ulf Hansson
2014-05-02 14:35     ` Geert Uytterhoeven
2014-05-06  7:43       ` Ulf Hansson
2014-04-24 10:13 ` [PATCH/RFC 4/4] clk: shmobile: mstp: Set CLK_RUNTIME_PM flag Geert Uytterhoeven
2014-04-30 21:29 ` [PATCH/RFC 0/4] of: Register clocks for Runtime PM with PM core Laurent Pinchart
2014-04-30 22:17   ` Geert Uytterhoeven
2014-06-12 16:53 ` [RFC PATCH 0/2] use named clocks list to register clocks for PM clock domain Grygorii Strashko
2014-06-12 16:53   ` Grygorii Strashko [this message]
2014-06-12 16:53   ` [RFC PATCH 2/2] of/clk: use "clkops-clocks" to specify clocks handled by clock_ops domain Grygorii Strashko
2014-07-28 14:05     ` Grant Likely
2014-07-28 17:47       ` Grygorii Strashko
2014-07-29  5:52         ` Grant Likely
2014-07-30  0:06           ` Laurent Pinchart
2014-07-30 13:25             ` Grygorii Strashko
2014-12-12 17:40               ` Laurent Pinchart
2014-08-04 11:28             ` Geert Uytterhoeven
2014-08-04 15:21               ` Laurent Pinchart
2014-09-08 20:13             ` Kevin Hilman
2014-12-12 17:52               ` Laurent Pinchart

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=1402592023-13416-2-git-send-email-grygorii.strashko@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=ben.dooks@codethink.co.uk \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=grant.likely@secretlab.ca \
    --cc=horms@verge.net.au \
    --cc=khilman@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mturquette@linaro.org \
    --cc=rjw@rjwysocki.net \
    --cc=tomasz.figa@gmail.com \
    --cc=ulf.hansson@linaro.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

all inboxes | Powered by JetHome®