From: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jamie Iles <jamie-wmLquQDDieKakBO8gow8eQ@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: Re: Virtual devices (cpufreq etc) and DT
Date: Wed, 03 Aug 2011 11:29:16 -0500 [thread overview]
Message-ID: <4E39775C.4090305@gmail.com> (raw)
In-Reply-To: <20110803095019.GB2607-apL1N+EY0C9YtYNIL7UdTEEOCMrvLtNR@public.gmane.org>
On 08/03/2011 04:50 AM, Jamie Iles wrote:
> I'm trying to work out how our cpufreq driver fits in with device tree
> bindings. We have a simple driver that just takes a struct clk and
> calls clk_set_rate() on it. Is a node in the device tree the right way
> to do this as it isn't really a physical device? I have the PLL in the
> clocks group of the DT:
Sounds generically useful...
The OF clock bindings are not really completely finalized and work on
the OF clk code is basically blocked waiting on the common struct clk
infrastructure.
>
> clocks {
> ...
>
> arm_clk: clock@11 {
> compatible = "picochip,pc3x3-pll";
> reg = <0x800a0050 0x8>;
> picoxcell,min-freq = <140000000>;
> picoxcell,max-freq = <700000000>;
> ref-clock = <&ref_clk>, "ref";
> clock-outputs = "cpu";
> };
> };
>
This describes the clock output. You still need to describe the
connection which is what the cpufreq driver should get. For that you
need something like this:
cpu@0 {
compatible = "arm,cortex-a9";
reg = <0>;
cpu-clock = <&arm_clk>, "cpu";
};
cpu@1 {
compatible = "arm,cortex-a9";
cpu-clock = <&arm_clk>, "cpu";
};
Then look for the cpu node(s) and get it's clock.
> so I could reference that. The of clk interface also requires a struct
> device for getting the clk so I guess this is needed...
I ran into that problem as well. Making of_clk_get take a struct
device_node ptr instead of struct device fixes the problem. Here's a
patch that does that.
Rob
From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH] of/clk: use struct device_node for of_clk_get
In order to allow clock retrieval without having a struct device,
use the OF node pointer instead for of_clk_get.
Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
---
drivers/clk/clkdev.c | 3 ++-
drivers/of/clock.c | 12 +++++-------
include/linux/of_clk.h | 4 ++--
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 9252b4f..a8f1d29 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -89,7 +89,8 @@ struct clk *clk_get(struct device *dev, const char
*con_id)
const char *dev_id = dev ? dev_name(dev) : NULL;
struct clk *clk;
- clk = of_clk_get(dev, con_id);
+ if (dev)
+ clk = of_clk_get(dev->of_node, con_id);
if (clk && __clk_get(clk))
return clk;
diff --git a/drivers/of/clock.c b/drivers/of/clock.c
index 4a6eb0a..7c90994 100644
--- a/drivers/of/clock.c
+++ b/drivers/of/clock.c
@@ -89,7 +89,7 @@ static struct clk *__of_clk_get_from_provider(struct
device_node *np, const char
return clk;
}
-struct clk *of_clk_get(struct device *dev, const char *id)
+struct clk *of_clk_get(struct device_node *node, const char *id)
{
struct device_node *provnode;
u32 provhandle;
@@ -98,12 +98,10 @@ struct clk *of_clk_get(struct device *dev, const
char *id)
char prop_name[32]; /* 32 is max size of property name */
const void *prop;
- if (!dev)
- return NULL;
- dev_dbg(dev, "Looking up %s-clock from device tree\n", id);
+ pr_debug("Looking up %s-clock from device tree\n", id);
snprintf(prop_name, 32, "%s-clock", id ? id : "bus");
- prop = of_get_property(dev->of_node, prop_name, &sz);
+ prop = of_get_property(node, prop_name, &sz);
if (!prop || sz < 4)
return NULL;
@@ -122,12 +120,12 @@ struct clk *of_clk_get(struct device *dev, const
char *id)
provnode = of_find_node_by_phandle(provhandle);
if (!provnode) {
pr_warn("%s: %s property in node %s references invalid phandle",
- __func__, prop_name, dev->of_node->full_name);
+ __func__, prop_name, node->full_name);
return NULL;
}
clk = __of_clk_get_from_provider(provnode, prop);
if (clk)
- dev_dbg(dev, "Using clock from %s\n", provnode->full_name);
+ pr_debug("Using clock from %s\n", provnode->full_name);
of_node_put(provnode);
diff --git a/include/linux/of_clk.h b/include/linux/of_clk.h
index 71a29eb..848b1c27 100644
--- a/include/linux/of_clk.h
+++ b/include/linux/of_clk.h
@@ -23,12 +23,12 @@ void of_clk_del_provider(struct device_node *np,
void *data),
void *data);
-struct clk *of_clk_get(struct device *dev, const char *id);
+struct clk *of_clk_get(struct device_node *node, const char *id);
int of_clk_fixed_parse(void);
#else
-static inline struct clk *of_clk_get(struct device *dev, const char *id)
+struct clk *of_clk_get(struct device_node *node, const char *id)
{
return NULL;
}
--
1.7.4.1
next prev parent reply other threads:[~2011-08-03 16:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 9:50 Virtual devices (cpufreq etc) and DT Jamie Iles
[not found] ` <20110803095019.GB2607-apL1N+EY0C9YtYNIL7UdTEEOCMrvLtNR@public.gmane.org>
2011-08-03 16:29 ` Rob Herring [this message]
[not found] ` <4E39775C.4090305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-08-03 16:41 ` Jamie Iles
[not found] ` <20110803164128.GQ2607-apL1N+EY0C9YtYNIL7UdTEEOCMrvLtNR@public.gmane.org>
2011-08-03 16:54 ` Rob Herring
[not found] ` <4E397D29.4090500-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-08-04 9:54 ` Jamie Iles
2011-08-04 10:23 ` Jamie Iles
[not found] ` <20110804102321.GC2899-apL1N+EY0C9YtYNIL7UdTEEOCMrvLtNR@public.gmane.org>
2011-08-04 10:33 ` Grant Likely
[not found] ` <CACxGe6tq_fpcwVZPYvPTkoLkkU0c3KeuCR+-UQSCcZcAo9vOUA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-04 10:44 ` Jamie Iles
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=4E39775C.4090305@gmail.com \
--to=robherring2-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=jamie-wmLquQDDieKakBO8gow8eQ@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 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.