From: Gregory CLEMENT <gregory.clement@free-electrons.com>
To: Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
linux-arm-kernel@lists.infradead.org,
Mike Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@codeaurora.org>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Daniel Lezcano <daniel.lezcano@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
linux-pm@vger.kernel.org,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Boris BREZILLON <boris.brezillon@free-electrons.com>,
Lior Amsalem <alior@marvell.com>,
Tawfik Bayouk <tawfik@marvell.com>,
Nadav Haklai <nadavh@marvell.com>
Subject: [PATCH RFC 4/5] ARM: mvebu: Armada 38x: Add dynamic frequency scaling support in pmsu
Date: Fri, 3 Jul 2015 08:11:56 +0200 [thread overview]
Message-ID: <1435903917-20486-5-git-send-email-gregory.clement@free-electrons.com> (raw)
In-Reply-To: <1435903917-20486-1-git-send-email-gregory.clement@free-electrons.com>
This commit add the last missing piece of code enabling dynamic
frequency scaling support for Armada 38x.
The main difference with Armada XP is that the Cortex A9 CPU
frequencies of the Armada 38x SoCs are not independent. Even if a SoC
contains a single CPU, some specific initialization has to be done at
pmsu level: this unit must not wait for the second CPU when the
frequency is modified.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm/mach-mvebu/pmsu.c | 67 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 61 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c
index f19be0ac0068..a2ced0b7fa0a 100644
--- a/arch/arm/mach-mvebu/pmsu.c
+++ b/arch/arm/mach-mvebu/pmsu.c
@@ -352,6 +352,13 @@ void mvebu_v7_pmsu_idle_exit(void)
/* cancel ask HW to power down the L2 Cache if possible */
reg = readl(pmsu_mp_base + PMSU_CTL_CFG(hw_cpu));
reg &= ~PMSU_CTL_CFG_L2_PWDDN;
+
+ /*
+ * When exiting from idle state such as cpuidle or hotplug,
+ * Enable PMU wait for the CPU to enter WFI when doing DFS
+ * by setting CPUx Frequency ID to 1
+ */
+ reg |= 1 << PMSU_CTL_CFG_CPU0_FRQ_ID_SFT;
writel(reg, pmsu_mp_base + PMSU_CTL_CFG(hw_cpu));
/* cancel Enable wakeup events and mask interrupts */
@@ -586,6 +593,38 @@ int armada_xp_pmsu_dfs_request(int cpu)
return 0;
}
+void mvebu_v7_pmsu_disable_dfs_cpu(int hw_cpu)
+{
+ u32 reg;
+
+ if (pmsu_mp_base == NULL)
+ return;
+ /*
+ * Disable PMU wait for the CPU to enter WFI when doing DFS
+ * by setting CPUx Frequency ID to 0
+ */
+ reg = readl(pmsu_mp_base + PMSU_CTL_CFG(hw_cpu));
+ reg &= ~(PMSU_CTL_CFG_CPU0_FRQ_ID_MSK << PMSU_CTL_CFG_CPU0_FRQ_ID_SFT);
+ writel(reg, pmsu_mp_base + PMSU_CTL_CFG(hw_cpu));
+}
+
+int armada_38x_pmsu_dfs_request(int cpu)
+{
+ /*
+ * Protect CPU DFS from changing the number of online cpus number during
+ * frequency transition by temporarily disable cpu hotplug
+ */
+ cpu_hotplug_disable();
+
+ /* Trigger the DFS on all the CPUs */
+ on_each_cpu(mvebu_pmsu_dfs_request_local,
+ NULL, false);
+
+ cpu_hotplug_enable();
+
+ return 0;
+}
+
int mvebu_pmsu_dfs_request(int cpu)
{
return mvebu_pmsu_dfs_request_ptr(cpu);
@@ -595,15 +634,19 @@ struct cpufreq_dt_platform_data armada_xp_cpufreq_dt_pd = {
.independent_clocks = true,
};
+struct cpufreq_dt_platform_data armada_38x_cpufreq_dt_pd = {
+ .independent_clocks = false,
+};
+
static int __init mvebu_pmsu_cpufreq_init(void)
{
struct device_node *np;
struct resource res;
int ret, cpu;
- if (!of_machine_is_compatible("marvell,armadaxp"))
+ if (!of_machine_is_compatible("marvell,armadaxp") &&
+ !of_machine_is_compatible("marvell,armada380"))
return 0;
-
/*
* In order to have proper cpufreq handling, we need to ensure
* that the Device Tree description of the CPU clock includes
@@ -648,6 +691,8 @@ static int __init mvebu_pmsu_cpufreq_init(void)
return PTR_ERR(clk);
}
+ clk_prepare_enable(clk);
+
/*
* In case of a failure of dev_pm_opp_add(), we don't
* bother with cleaning up the registered OPP (there's
@@ -666,10 +711,20 @@ static int __init mvebu_pmsu_cpufreq_init(void)
return ret;
}
}
- mvebu_pmsu_dfs_request_ptr = armada_xp_pmsu_dfs_request;
- platform_device_register_data(NULL, "cpufreq-dt", -1,
- &armada_xp_cpufreq_dt_pd,
- sizeof(armada_xp_cpufreq_dt_pd));
+ if (of_machine_is_compatible("marvell,armada380")) {
+ if (num_online_cpus() == 1)
+ mvebu_v7_pmsu_disable_dfs_cpu(1);
+
+ mvebu_pmsu_dfs_request_ptr = armada_38x_pmsu_dfs_request;
+ platform_device_register_data(NULL, "cpufreq-dt", -1,
+ &armada_38x_cpufreq_dt_pd,
+ sizeof(armada_38x_cpufreq_dt_pd));
+ } else if (of_machine_is_compatible("marvell,armadaxp")) {
+ mvebu_pmsu_dfs_request_ptr = armada_xp_pmsu_dfs_request;
+ platform_device_register_data(NULL, "cpufreq-dt", -1,
+ &armada_xp_cpufreq_dt_pd,
+ sizeof(armada_xp_cpufreq_dt_pd));
+ }
return 0;
}
--
2.1.0
next prev parent reply other threads:[~2015-07-03 6:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 6:11 [PATCH RFC 0/5] cpufreq support for Marvell Armada 38x Gregory CLEMENT
2015-07-03 6:11 ` [PATCH RFC 1/5] clk: mvebu: Add Armada 38x support for clk-cpu Gregory CLEMENT
2015-07-03 13:54 ` Andrew Lunn
2015-07-03 6:11 ` [PATCH RFC 2/5] ARM: mvebu: Use shorter register definition in pmsu.c Gregory CLEMENT
2015-07-03 14:02 ` Andrew Lunn
2015-07-03 6:11 ` [PATCH RFC 3/5] ARM: mvebu: Made the dynamic frequency scaling support more generic Gregory CLEMENT
2015-07-03 6:11 ` Gregory CLEMENT [this message]
2015-07-03 6:11 ` [PATCH RFC 5/5] ARM: mvebu: Update Armada 38x DT for dynamic frequency scaling Gregory CLEMENT
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=1435903917-20486-5-git-send-email-gregory.clement@free-electrons.com \
--to=gregory.clement@free-electrons.com \
--cc=alior@marvell.com \
--cc=andrew@lunn.ch \
--cc=boris.brezillon@free-electrons.com \
--cc=daniel.lezcano@linaro.org \
--cc=ezequiel.garcia@free-electrons.com \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=mturquette@baylibre.com \
--cc=nadavh@marvell.com \
--cc=rjw@rjwysocki.net \
--cc=sboyd@codeaurora.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=tawfik@marvell.com \
--cc=thomas.petazzoni@free-electrons.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
all inboxes | Powered by JetHome®