From: Zhao Chenhui <chenhui.zhao@freescale.com>
To: <linuxppc-dev@lists.ozlabs.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH v2 09/15] powerpc/rcpm: add sleep feature for SoCs using RCPM
Date: Fri, 19 Apr 2013 18:47:42 +0800 [thread overview]
Message-ID: <1366368468-29143-9-git-send-email-chenhui.zhao@freescale.com> (raw)
In-Reply-To: <1366368468-29143-1-git-send-email-chenhui.zhao@freescale.com>
The SoCs which have a RCPM (Run Control/Power Management) module
support power management feature. This patch implements sleep feature.
In sleep mode, the clocks of cores and unused IP blocks will be
turned off. The IP blocks which are allowed to wake up the system
are still running.
Signed-off-by: Zhao Chenhui <chenhui.zhao@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
arch/powerpc/Kconfig | 4 +-
arch/powerpc/include/asm/fsl_guts.h | 1 +
arch/powerpc/platforms/85xx/Kconfig | 1 +
arch/powerpc/sysdev/Kconfig | 5 ++
arch/powerpc/sysdev/Makefile | 1 +
arch/powerpc/sysdev/fsl_rcpm.c | 101 +++++++++++++++++++++++++++++++++++
6 files changed, 111 insertions(+), 2 deletions(-)
create mode 100644 arch/powerpc/sysdev/fsl_rcpm.c
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b6851be..0ad6e30 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -220,7 +220,7 @@ config ARCH_HIBERNATION_POSSIBLE
config ARCH_SUSPEND_POSSIBLE
def_bool y
depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200 || PPC_83xx || \
- (PPC_85xx && !PPC_E500MC) || PPC_86xx || PPC_PSERIES \
+ FSL_SOC_BOOKE || PPC_86xx || PPC_PSERIES \
|| 44x || 40x
config PPC_DCR_NATIVE
@@ -694,7 +694,7 @@ config FSL_PCI
config FSL_PMC
bool
default y
- depends on SUSPEND && (PPC_85xx || PPC_86xx)
+ depends on SUSPEND && ((PPC_85xx && !PPC_E500MC) || PPC_86xx)
help
Freescale MPC85xx/MPC86xx power management controller support
(suspend/resume). For MPC83xx see platforms/83xx/suspend.c
diff --git a/arch/powerpc/include/asm/fsl_guts.h b/arch/powerpc/include/asm/fsl_guts.h
index 4eac1cf..b8a08d5 100644
--- a/arch/powerpc/include/asm/fsl_guts.h
+++ b/arch/powerpc/include/asm/fsl_guts.h
@@ -124,6 +124,7 @@ struct ccsr_rcpm {
u8 res0038[4];
__be32 cwdtdsr; /* 0x003c - Core watchdog detect status register */
__be32 powmgtcsr; /* 0x0040 - Power Mangement Control & Status Register */
+#define RCPM_POWMGTCSR_SLP 0x00020000
u8 res0044[12];
__be32 ippdexpcr; /* 0x0050 - IP Powerdown Exception Control Register */
u8 res0054[16];
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index 8f02b05..c0aa36e 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -8,6 +8,7 @@ menuconfig FSL_SOC_BOOKE
select FSL_PCI if PCI
select SERIAL_8250_EXTENDED if SERIAL_8250
select SERIAL_8250_SHARE_IRQ if SERIAL_8250
+ select FSL_CORENET_RCPM if SUSPEND && PPC_E500MC
default y
if FSL_SOC_BOOKE
diff --git a/arch/powerpc/sysdev/Kconfig b/arch/powerpc/sysdev/Kconfig
index a84fecf..6c22d91 100644
--- a/arch/powerpc/sysdev/Kconfig
+++ b/arch/powerpc/sysdev/Kconfig
@@ -33,3 +33,8 @@ config SCOM_DEBUGFS
config GE_FPGA
bool
default n
+
+config FSL_CORENET_RCPM
+ bool
+ help
+ This option enables support for RCPM (Run Control/Power Management).
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index b0a518e..f12b856 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
obj-$(CONFIG_FSL_SOC) += fsl_soc.o fsl_mpic_err.o
obj-$(CONFIG_FSL_PCI) += fsl_pci.o $(fsl-msi-obj-y)
obj-$(CONFIG_FSL_PMC) += fsl_pmc.o
+obj-$(CONFIG_FSL_CORENET_RCPM) += fsl_rcpm.o
obj-$(CONFIG_FSL_LBC) += fsl_lbc.o
obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
obj-$(CONFIG_FSL_GTM) += fsl_gtm.o
diff --git a/arch/powerpc/sysdev/fsl_rcpm.c b/arch/powerpc/sysdev/fsl_rcpm.c
new file mode 100644
index 0000000..fd789da
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_rcpm.c
@@ -0,0 +1,101 @@
+/*
+ * RCPM(Run Control/Power Management) support
+ *
+ * Copyright 2012-2013 Freescale Semiconductor Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/suspend.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/of_platform.h>
+
+#include <asm/io.h>
+#include <asm/cacheflush.h>
+#include <asm/fsl_guts.h>
+
+static struct ccsr_rcpm __iomem *rcpm_regs;
+
+static int rcpm_suspend_enter(suspend_state_t state)
+{
+ int ret = 0;
+
+ switch (state) {
+ case PM_SUSPEND_STANDBY:
+
+ flush_dcache_L1();
+ flush_backside_L2_cache();
+
+ setbits32(&rcpm_regs->powmgtcsr, RCPM_POWMGTCSR_SLP);
+
+ /* At this point, the device is in sleep mode. */
+
+ /* Upon resume, wait for SLP bit to be clear. */
+ ret = spin_event_timeout(
+ (in_be32(&rcpm_regs->powmgtcsr) & RCPM_POWMGTCSR_SLP) == 0,
+ 10000, 10);
+ if (!ret) {
+ pr_err("%s: timeout waiting for SLP bit to be cleared\n",
+ __func__);
+ ret = -EINVAL;
+ }
+ break;
+
+ default:
+ ret = -EINVAL;
+
+ }
+ return ret;
+}
+
+static int rcpm_suspend_valid(suspend_state_t state)
+{
+ if (state == PM_SUSPEND_STANDBY)
+ return 1;
+ else
+ return 0;
+}
+
+static const struct platform_suspend_ops rcpm_suspend_ops = {
+ .valid = rcpm_suspend_valid,
+ .enter = rcpm_suspend_enter,
+};
+
+static int rcpm_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+
+ rcpm_regs = of_iomap(np, 0);
+ if (!rcpm_regs)
+ return -ENOMEM;
+
+ suspend_set_ops(&rcpm_suspend_ops);
+
+ dev_info(&pdev->dev, "Freescale RCPM driver\n");
+ return 0;
+}
+
+static const struct of_device_id rcpm_ids[] = {
+ { .compatible = "fsl,qoriq-rcpm-1.0", },
+ { },
+};
+
+static struct platform_driver rcpm_driver = {
+ .driver = {
+ .name = "fsl-rcpm",
+ .of_match_table = rcpm_ids,
+ },
+ .probe = rcpm_probe,
+};
+
+static int __init rcpm_init(void)
+{
+ return platform_driver_register(&rcpm_driver);
+}
+
+device_initcall(rcpm_init);
--
1.7.3
next prev parent reply other threads:[~2013-04-19 10:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-19 10:47 [PATCH v2 01/15] powerpc/85xx: cache operations for Freescale SoCs based on BOOK3E Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 02/15] powerpc/85xx: add sleep and deep sleep support Zhao Chenhui
2013-04-23 23:53 ` Scott Wood
2013-04-28 10:20 ` Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 03/15] fsl_pmc: Add API to enable device as wakeup event source Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 04/15] pm: add power node to dts Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 05/15] fsl_pmc: update device bindings Zhao Chenhui
2013-06-03 22:43 ` Scott Wood
2013-04-19 10:47 ` [PATCH v2 06/15] powerpc/85xx: add support to JOG feature using cpufreq interface Zhao Chenhui
2013-04-22 3:25 ` Viresh Kumar
2013-04-22 10:56 ` Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 07/15] powerpc/85xx: add time base sync for SoCs based on e500mc/e5500 Zhao Chenhui
2013-04-23 23:58 ` Scott Wood
2013-04-19 10:47 ` [PATCH v2 08/15] powerpc/85xx: add cpu hotplug support for e500mc/e5500 Zhao Chenhui
2013-04-19 10:47 ` Zhao Chenhui [this message]
2013-04-19 10:47 ` [PATCH v2 10/15] powerpc/85xx: fix 64-bit support for cpu hotplug Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 11/15] powerpc/rcpm: add struct ccsr_rcpm_v2 Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 12/15] powerpc/85xx: add time base sync support for e6500 Zhao Chenhui
2013-04-24 0:04 ` Scott Wood
2013-04-24 11:29 ` Zhao Chenhui
2013-04-24 22:38 ` Scott Wood
2013-04-25 0:28 ` Zhao Chenhui
2013-04-26 0:07 ` Scott Wood
2013-04-28 9:56 ` Zhao Chenhui
2013-04-29 20:18 ` Scott Wood
2013-04-19 10:47 ` [PATCH v2 13/15] powerpc/85xx: add support for e6500 L1 cache operation Zhao Chenhui
2013-04-24 0:00 ` Scott Wood
2013-04-24 11:14 ` Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 14/15] powerpc/smp: add cpu hotplug support for e6500 Zhao Chenhui
2013-04-19 10:47 ` [PATCH v2 15/15] powerpc/rcpm: add sleep support for T4/B4 chips Zhao Chenhui
2013-04-23 9:53 ` [linuxppc-release] [PATCH v2 01/15] powerpc/85xx: cache operations for Freescale SoCs based on BOOK3E Zhao Chenhui
2013-04-23 23:46 ` Scott Wood
2013-04-24 11:08 ` Zhao Chenhui
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=1366368468-29143-9-git-send-email-chenhui.zhao@freescale.com \
--to=chenhui.zhao@freescale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).