From: Gregory CLEMENT <gregory.clement@free-electrons.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
linux-pm@vger.kernel.org, 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,
Lior Amsalem <alior@marvell.com>,
Tawfik Bayouk <tawfik@marvell.com>,
Nadav Haklai <nadavh@marvell.com>
Subject: [PATCH 13/16] cpuidle: mvebu: Move the description of the cpuidle states in the platform part
Date: Fri, 27 Jun 2014 15:22:54 +0200 [thread overview]
Message-ID: <1403875377-940-14-git-send-email-gregory.clement@free-electrons.com> (raw)
In-Reply-To: <1403875377-940-1-git-send-email-gregory.clement@free-electrons.com>
In order to prepare the add of new SoCs supports for this cpuidle
driver, this patch moves the description of the state in the platform
part. Indeed the number of the cpuidle state, and the value of the
flag used will vary depending of the SoC.
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm/mach-mvebu/pmsu.c | 32 +++++++++++++++++++++++--
drivers/cpuidle/cpuidle-mvebu-v7.c | 49 +++++++++++++-------------------------
include/linux/mvebu-v7-cpuidle.h | 24 +++++++++++++++++++
3 files changed, 70 insertions(+), 35 deletions(-)
create mode 100644 include/linux/mvebu-v7-cpuidle.h
diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c
index 00ebd5638633..9396839e162e 100644
--- a/arch/arm/mach-mvebu/pmsu.c
+++ b/arch/arm/mach-mvebu/pmsu.c
@@ -19,15 +19,18 @@
#define pr_fmt(fmt) "mvebu-pmsu: " fmt
#include <linux/cpu_pm.h>
+#include <linux/cpuidle.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/io.h>
#include <linux/mbus.h>
+#include <linux/mvebu-v7-cpuidle.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/resource.h>
#include <linux/smp.h>
#include <asm/cacheflush.h>
+#include <asm/cpuidle.h>
#include <asm/cp15.h>
#include <asm/smp_plat.h>
#include <asm/suspend.h>
@@ -299,17 +302,42 @@ static struct notifier_block mvebu_v7_cpu_pm_notifier = {
static bool (*mvebu_v7_cpu_idle_init)(void);
+static struct mvebu_v7_cpuidle armada_xp_cpuidle = {
+ .mvebu_v7_idle_driver = {
+ .name = "armada_xp_idle",
+ .states[0] = ARM_CPUIDLE_WFI_STATE,
+ .states[1] = {
+ .exit_latency = 10,
+ .power_usage = 50,
+ .target_residency = 100,
+ .flags = CPUIDLE_FLAG_TIME_VALID,
+ .name = "Idle",
+ .desc = "CPU power down",
+ },
+ .states[2] = {
+ .exit_latency = 100,
+ .power_usage = 5,
+ .target_residency = 1000,
+ .flags = CPUIDLE_FLAG_TIME_VALID |
+ MVEBU_V7_FLAG_DEEP_IDLE,
+ .name = "Deep idle",
+ .desc = "CPU and L2 Fabric power down",
+ },
+ .state_count = 3,
+ },
+ .mvebu_v7_cpu_suspend = armada_xp_370_cpu_suspend,
+};
+
static __init bool armada_xp_cpuidle_init(void)
{
struct device_node *np;
-
np = of_find_compatible_node(NULL, NULL, "marvell,coherency-fabric");
if (!np)
return false;
of_node_put(np);
mvebu_cpu_resume = armada_370_xp_cpu_resume;
- mvebu_v7_cpuidle_device.dev.platform_data = armada_xp_370_cpu_suspend;
+ mvebu_v7_cpuidle_device.dev.platform_data = &armada_xp_cpuidle;
return true;
}
diff --git a/drivers/cpuidle/cpuidle-mvebu-v7.c b/drivers/cpuidle/cpuidle-mvebu-v7.c
index 6066e0d9aabe..2fdc18797c0e 100644
--- a/drivers/cpuidle/cpuidle-mvebu-v7.c
+++ b/drivers/cpuidle/cpuidle-mvebu-v7.c
@@ -16,15 +16,12 @@
#include <linux/cpu_pm.h>
#include <linux/cpuidle.h>
#include <linux/module.h>
+#include <linux/mvebu-v7-cpuidle.h>
#include <linux/of.h>
#include <linux/suspend.h>
#include <linux/platform_device.h>
-#include <asm/cpuidle.h>
-#define MVEBU_V7_MAX_STATES 3
-#define MVEBU_V7_FLAG_DEEP_IDLE 0x10000
-
-static int (*mvebu_v7_cpu_suspend)(int);
+static struct mvebu_v7_cpuidle *pcpuidle;
static int mvebu_v7_enter_idle(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
@@ -32,12 +29,13 @@ static int mvebu_v7_enter_idle(struct cpuidle_device *dev,
{
int ret;
bool deepidle = false;
+
cpu_pm_enter();
if (drv->states[index].flags & MVEBU_V7_FLAG_DEEP_IDLE)
deepidle = true;
- ret = mvebu_v7_cpu_suspend(deepidle);
+ ret = pcpuidle->mvebu_v7_cpu_suspend(deepidle);
if (ret)
return ret;
@@ -46,36 +44,21 @@ static int mvebu_v7_enter_idle(struct cpuidle_device *dev,
return index;
}
-static struct cpuidle_driver mvebu_v7_idle_driver = {
- .name = "mvebu_v7_idle",
- .states[0] = ARM_CPUIDLE_WFI_STATE,
- .states[1] = {
- .enter = mvebu_v7_enter_idle,
- .exit_latency = 10,
- .power_usage = 50,
- .target_residency = 100,
- .flags = CPUIDLE_FLAG_TIME_VALID,
- .name = "Idle",
- .desc = "CPU power down",
- },
- .states[2] = {
- .enter = mvebu_v7_enter_idle,
- .exit_latency = 100,
- .power_usage = 5,
- .target_residency = 1000,
- .flags = CPUIDLE_FLAG_TIME_VALID |
- MVEBU_V7_FLAG_DEEP_IDLE,
- .name = "Deep idle",
- .desc = "CPU and L2 Fabric power down",
- },
- .state_count = MVEBU_V7_MAX_STATES,
-};
-
static int mvebu_v7_cpuidle_probe(struct platform_device *pdev)
{
+ int i;
+
+ pcpuidle = (void *)(pdev->dev.platform_data);
+
+ /*
+ * The first state is the ARM WFI state, so we don't have to
+ * provide an enter function
+ */
+ for (i = 1; i < pcpuidle->mvebu_v7_idle_driver.state_count; i++)
+ pcpuidle->mvebu_v7_idle_driver.states[i].enter =
+ mvebu_v7_enter_idle;
- mvebu_v7_cpu_suspend = (void *)(pdev->dev.platform_data);
- return cpuidle_register(&mvebu_v7_idle_driver, NULL);
+ return cpuidle_register(&pcpuidle->mvebu_v7_idle_driver, NULL);
}
static struct platform_driver mvebu_v7_cpuidle_plat_driver = {
diff --git a/include/linux/mvebu-v7-cpuidle.h b/include/linux/mvebu-v7-cpuidle.h
new file mode 100644
index 000000000000..28c8674292ad
--- /dev/null
+++ b/include/linux/mvebu-v7-cpuidle.h
@@ -0,0 +1,24 @@
+/*
+ * Marvell EBU cpuidle defintion
+ *
+ * Copyright (C) 2014 Marvell
+ *
+ * Gregory CLEMENT <gregory.clement@free-electrons.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ *
+ */
+
+#ifndef __LINUX_MVEBU_V7_CPUIDLE_H__
+#define __LINUX_MVEBU_V7_CPUIDLE_H__
+
+#define MVEBU_V7_FLAG_DEEP_IDLE 0x10000
+
+struct mvebu_v7_cpuidle {
+ struct cpuidle_driver mvebu_v7_idle_driver;
+ int (*mvebu_v7_cpu_suspend)(unsigned long);
+};
+
+#endif
--
1.8.1.2
next prev parent reply other threads:[~2014-06-27 13:24 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-27 13:22 [PATCH 00/16] CPU Idle for Armada 370 and Armada 38x Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 01/16] ARM: mvebu: Sort the headers of pmsu.c in alphabetic order Gregory CLEMENT
2014-06-30 12:16 ` Thomas Petazzoni
2014-07-02 22:57 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 02/16] ARM: mvebu: Add a common function for the boot address work around Gregory CLEMENT
2014-06-30 12:40 ` Thomas Petazzoni
2014-07-02 22:58 ` Gregory CLEMENT
2014-07-03 7:16 ` Thomas Petazzoni
2014-07-01 14:34 ` Thomas Petazzoni
2014-07-02 22:58 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 03/16] ARM: mvebu: Add function to export the physical address of the boot register Gregory CLEMENT
2014-06-27 14:14 ` Gregory CLEMENT
2014-06-30 12:46 ` Thomas Petazzoni
2014-07-03 8:39 ` Gregory CLEMENT
2014-07-03 9:25 ` Thomas Petazzoni
2014-07-03 10:07 ` Gregory CLEMENT
2014-07-01 11:46 ` Thomas Petazzoni
2014-07-01 15:02 ` Ezequiel Garcia
2014-06-27 13:22 ` [PATCH 04/16] ARM: mvebu: Use the common function for Armada 375 SMP workaround Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 05/16] ARM: mvebu: Add workaround for cpuidle support for Armada 370 Gregory CLEMENT
2014-06-30 12:50 ` Thomas Petazzoni
2014-07-03 8:44 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 06/16] ARM: mvebu: Rename the armada_370_xp into mvebu_v7 in pmsu.c file Gregory CLEMENT
2014-06-30 12:57 ` Thomas Petazzoni
2014-07-03 8:47 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 07/16] ARM: mvebu: Make the CPU idle initialization more generic Gregory CLEMENT
2014-06-27 14:15 ` Gregory CLEMENT
2014-06-28 14:56 ` Jason Cooper
2014-06-30 10:30 ` Gregory CLEMENT
2014-06-30 14:07 ` Thomas Petazzoni
2014-07-03 8:54 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 08/16] ARM: mvebu: Use a local variable to store the resume address Gregory CLEMENT
2014-06-30 15:09 ` Thomas Petazzoni
2014-07-03 9:24 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 09/16] ARM: mvebu: Make the snoop disable optional in mvebu_v7_pmsu_idle_prepare Gregory CLEMENT
2014-06-30 15:43 ` Thomas Petazzoni
2014-07-03 12:50 ` Gregory CLEMENT
2014-07-03 12:55 ` Thomas Petazzoni
2014-06-27 13:22 ` [PATCH 10/16] ARM: mvebu: Export the SCU address Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 11/16] ARM: mvebu: dts: Add CA9 MPcore SoC Controller node Gregory CLEMENT
2014-06-30 15:37 ` Thomas Petazzoni
2014-07-03 12:51 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 12/16] cpuidle: mvebu: Rename the driver from armada-370-xp to mvebu-v7 Gregory CLEMENT
2014-06-30 13:28 ` Thomas Petazzoni
2014-07-03 13:08 ` Gregory CLEMENT
2014-06-27 13:22 ` Gregory CLEMENT [this message]
2014-06-30 13:32 ` [PATCH 13/16] cpuidle: mvebu: Move the description of the cpuidle states in the platform part Thomas Petazzoni
2014-07-03 13:23 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 14/16] ARM: mvebu: Add CPU idle support for Armada 370 Gregory CLEMENT
2014-06-30 13:36 ` Thomas Petazzoni
2014-07-03 15:03 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 15/16] ARM: mvebu: Add CPU idle support for Armada 38x Gregory CLEMENT
2014-06-30 15:07 ` Thomas Petazzoni
2014-07-03 15:29 ` Gregory CLEMENT
2014-07-01 14:35 ` Thomas Petazzoni
2014-07-03 15:09 ` Gregory CLEMENT
2014-06-27 13:22 ` [PATCH 16/16] ARM: mvebu: defconfig: Enable CPU Idle support in mvebu_v7_defconfig Gregory CLEMENT
2014-06-30 15:45 ` [PATCH 00/16] CPU Idle for Armada 370 and Armada 38x Thomas Petazzoni
2014-06-30 15:51 ` Gregory CLEMENT
2014-07-01 14:38 ` Thomas Petazzoni
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=1403875377-940-14-git-send-email-gregory.clement@free-electrons.com \
--to=gregory.clement@free-electrons.com \
--cc=alior@marvell.com \
--cc=andrew@lunn.ch \
--cc=daniel.lezcano@linaro.org \
--cc=ezequiel.garcia@free-electrons.com \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=nadavh@marvell.com \
--cc=rjw@rjwysocki.net \
--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