From: "Florian Fainelli" <f.fainelli@gmail.com>
To: lorenzo.pieralisi@arm.com
Cc: Florian Fainelli <f.fainelli@gmail.com>,
nico@linaro.org, devicetree-discuss@lists.ozlabs.org,
rob.herring@calxeda.com, grant.likely@linaro.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] ARM: kernel: get cpu clock rate from cpu clock node first
Date: Thu, 20 Jun 2013 15:39:04 +0100 [thread overview]
Message-ID: <1371739146-32639-2-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1371739146-32639-1-git-send-email-f.fainelli@gmail.com>
The current topology code will only attempt to parse a "clock-frequency"
property for a given CPU node. Some platforms such as the ecx-2000
provide a clock node. Change the logic to first look for a clock node,
and if we fail, fallback to parsing a "clock-frequency" property. To
avoid unnecessary casting, change rate from u32 to unsigned long, and
introduce the "prop" variable to hold the contents of the
"clock-frequency" property.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
arch/arm/kernel/topology.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index c5a5954..8f340a1 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -21,6 +21,7 @@
#include <linux/of.h>
#include <linux/sched.h>
#include <linux/slab.h>
+#include <linux/clk.h>
#include <asm/cputype.h>
#include <asm/topology.h>
@@ -104,7 +105,9 @@ static void __init parse_dt_topology(void)
cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT);
while ((cn = of_find_node_by_type(cn, "cpu"))) {
- const u32 *rate, *reg;
+ const u32 *prop, *reg;
+ unsigned long rate;
+ struct clk *cpu_clk;
int len;
if (cpu >= num_possible_cpus())
@@ -117,11 +120,17 @@ static void __init parse_dt_topology(void)
if (cpu_eff->compatible == NULL)
continue;
- rate = of_get_property(cn, "clock-frequency", &len);
- if (!rate || len != 4) {
- pr_err("%s missing clock-frequency property\n",
- cn->full_name);
- continue;
+ cpu_clk = of_clk_get(cn, 0);
+ if (IS_ERR(cpu_clk)) {
+ prop = of_get_property(cn, "clock-frequency", &len);
+ if (!prop || len != 4) {
+ pr_err("%s missing clock-frequency property\n",
+ cn->full_name);
+ continue;
+ }
+ rate = be32_to_cpup(prop);
+ } else {
+ rate = clk_get_rate(cpu_clk);
}
reg = of_get_property(cn, "reg", &len);
@@ -130,7 +139,7 @@ static void __init parse_dt_topology(void)
continue;
}
- capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
+ capacity = (rate >> 20) * cpu_eff->efficiency;
/* Save min capacity of the system */
if (capacity < min_capacity)
--
1.8.1.2
next prev parent reply other threads:[~2013-06-20 14:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 14:39 [PATCH 0/3] ARM: kernel: minor topology/DT clock fixes Florian Fainelli
2013-06-20 14:39 ` Florian Fainelli [this message]
[not found] ` <1371739146-32639-2-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-06-21 9:35 ` [PATCH 1/3] ARM: kernel: get cpu clock rate from cpu clock node first Lorenzo Pieralisi
2013-06-21 9:42 ` Florian Fainelli
2013-06-20 14:39 ` [PATCH 2/3] ARM: kernel: downgrade missing clock-frequency from error to warning Florian Fainelli
2013-06-20 14:39 ` [PATCH 3/3] ARM: kernel: document ARM CPUs clocks and clock-frequency properties Florian Fainelli
[not found] ` <1371739146-32639-4-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-06-21 9:30 ` Lorenzo Pieralisi
2013-06-21 9:54 ` Florian Fainelli
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=1371739146-32639-2-git-send-email-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=nico@linaro.org \
--cc=rob.herring@calxeda.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 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).