From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Russell King <linux@arm.linux.org.uk>, Arnd Bergmann <arnd@arndb.de>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Rob Herring <robh+dt@kernel.org>, Nicolas Pitre <nico@linaro.org>,
Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: [PATCH 1/2] ARM: topology: Use a clock if possible to get the CPU frequency
Date: Wed, 21 May 2014 21:33:15 +0200 [thread overview]
Message-ID: <1400700796-5763-2-git-send-email-maxime.ripard@free-electrons.com> (raw)
In-Reply-To: <1400700796-5763-1-git-send-email-maxime.ripard@free-electrons.com>
The Cortex-A7 and Cortex-A15 based SoCs need a clock-frequency property in the
topology code.
Allow to use a clock to provide the same information.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
arch/arm/kernel/topology.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index 0bc94b1fd1ae..2885993ccf53 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -11,6 +11,7 @@
* for more details.
*/
+#include <linux/clk.h>
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <linux/export.h>
@@ -100,8 +101,8 @@ static void __init parse_dt_topology(void)
__cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT);
for_each_possible_cpu(cpu) {
- const u32 *rate;
- int len;
+ struct clk *clk;
+ u32 rate = 0;
/* too early to use cpu->of_node */
cn = of_get_cpu_node(cpu, NULL);
@@ -117,14 +118,23 @@ 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);
+ clk = of_clk_get(cn, 0);
+ if (!IS_ERR(clk)) {
+ rate = clk_get_rate(clk);
+ } else {
+ if (of_property_read_u32(cn, "clock-frequency", &rate)) {
+ pr_err("%s missing clocks or clock-frequency properties\n",
+ cn->full_name);
+ continue;
+ }
+ }
+
+ if (!rate) {
+ pr_err("%s invalid CPU frequency", cn->full_name);
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.9.3
next prev parent reply other threads:[~2014-05-21 19:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-21 19:33 [PATCH 0/2] ARM: topology: Allow to set the frequency through a clock Maxime Ripard
2014-05-21 19:33 ` Maxime Ripard [this message]
2014-05-21 19:33 ` [PATCH 2/2] ARM: sunxi: Add clocks node to the CPU nodes Maxime Ripard
2014-06-10 11:47 ` [PATCH 0/2] ARM: topology: Allow to set the frequency through a clock Maxime Ripard
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=1400700796-5763-2-git-send-email-maxime.ripard@free-electrons.com \
--to=maxime.ripard@free-electrons.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=nico@linaro.org \
--cc=robh+dt@kernel.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®