* [PATCH 1/2] [POWERPC] 86xx: suspend support
@ 2008-06-06 19:24 Anton Vorontsov
2008-06-06 19:36 ` Anton Vorontsov
2008-07-15 16:16 ` Kumar Gala
0 siblings, 2 replies; 4+ messages in thread
From: Anton Vorontsov @ 2008-06-06 19:24 UTC (permalink / raw)
To: Kumar Gala; +Cc: Scott Wood, linuxppc-dev, Timur Tabi, Jason Jin
This patch adds suspend (standby, not suspend-to-ram) support for MPC86xx
processors.
In standby mode MPC86xx is able to wakeup only upon external interrupts
(including sreset).
Signed-off-by: Scott Wood <scottwood@freescale•com>
Signed-off-by: Jason Jin <Jason.jin@freescale•com>
Signed-off-by: Anton Vorontsov <avorontsov@ru•mvista.com>
---
arch/powerpc/Kconfig | 2 +-
arch/powerpc/platforms/86xx/Makefile | 1 +
arch/powerpc/platforms/86xx/mpc86xx_suspend.c | 92 +++++++++++++++++++++++++
3 files changed, 94 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/platforms/86xx/mpc86xx_suspend.c
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 2cde4e3..c45c71e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -192,7 +192,7 @@ config ARCH_HIBERNATION_POSSIBLE
config ARCH_SUSPEND_POSSIBLE
def_bool y
- depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200
+ depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200 || PPC_86xx
config PPC_DCR_NATIVE
bool
diff --git a/arch/powerpc/platforms/86xx/Makefile b/arch/powerpc/platforms/86xx/Makefile
index 1b9b4a9..a8557df 100644
--- a/arch/powerpc/platforms/86xx/Makefile
+++ b/arch/powerpc/platforms/86xx/Makefile
@@ -3,6 +3,7 @@
#
obj-$(CONFIG_SMP) += mpc86xx_smp.o
+obj-$(CONFIG_SUSPEND) += mpc86xx_suspend.o
obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o
obj-$(CONFIG_SBC8641D) += sbc8641d.o
obj-$(CONFIG_MPC8610_HPCD) += mpc8610_hpcd.o
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_suspend.c b/arch/powerpc/platforms/86xx/mpc86xx_suspend.c
new file mode 100644
index 0000000..ce13e4c
--- /dev/null
+++ b/arch/powerpc/platforms/86xx/mpc86xx_suspend.c
@@ -0,0 +1,92 @@
+/*
+ * MPC86xx suspend (standby) support
+ *
+ * Copyright (C) 2008 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author: Jason Jin <jason.jin@freescale•com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/suspend.h>
+#include <linux/of.h>
+#include <linux/io.h>
+#include <asm/prom.h>
+#include <asm/reg.h>
+#include <asm/mpc6xx.h>
+
+#define PMCSR_DEVSLEEP 0x00020000
+
+struct mpc86xx_pmc {
+ __be32 devdisr;
+ __be32 devdisr2;
+ __be32 reserve1;
+ __be32 reserve2;
+ __be32 powmgtcsr;
+};
+
+static struct mpc86xx_pmc __iomem *pmc_regs_86xx;
+
+static int mpc86xx_suspend_enter(suspend_state_t state)
+{
+ u32 tmp;
+
+ /* Disable power management. */
+ tmp = mfmsr();
+ mtmsr(tmp & ~MSR_POW);
+
+ /* Enable sleep mode, disable others. */
+ tmp = mfspr(SPRN_HID0);
+ mtspr(SPRN_HID0, (tmp & ~(HID0_DOZE | HID0_NAP)) | HID0_SLEEP);
+ asm("sync");
+
+ /* Device power down. */
+ setbits32(&pmc_regs_86xx->powmgtcsr, PMCSR_DEVSLEEP);
+
+ /* 86xx did not support deep sleep, let it enter standby mode. */
+ mpc6xx_enter_standby();
+
+ clrbits32(&pmc_regs_86xx->powmgtcsr, PMCSR_DEVSLEEP);
+
+ return 0;
+}
+
+static int mpc86xx_suspend_valid(suspend_state_t state)
+{
+ if (state == PM_SUSPEND_STANDBY)
+ return 1;
+ return 0;
+}
+
+static struct platform_suspend_ops mpc86xx_suspend_ops = {
+ .valid = mpc86xx_suspend_valid,
+ .enter = mpc86xx_suspend_enter,
+};
+
+static int __init mpc86xx_pmc_init(void)
+{
+ void __iomem *guts;
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts");
+ if (!np) {
+ np = of_find_compatible_node(NULL, NULL, "fsl,mpc8641-guts");
+ if (!np)
+ return -ENODEV;
+ }
+
+ guts = of_iomap(np, 0);
+ of_node_put(np);
+ if (!guts)
+ return -ENOMEM;
+
+ pmc_regs_86xx = guts + 0x70;
+
+ suspend_set_ops(&mpc86xx_suspend_ops);
+ return 0;
+}
+module_init(mpc86xx_pmc_init);
--
1.5.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] [POWERPC] 86xx: suspend support
2008-06-06 19:24 [PATCH 1/2] [POWERPC] 86xx: suspend support Anton Vorontsov
@ 2008-06-06 19:36 ` Anton Vorontsov
2008-07-15 16:16 ` Kumar Gala
1 sibling, 0 replies; 4+ messages in thread
From: Anton Vorontsov @ 2008-06-06 19:36 UTC (permalink / raw)
To: Kumar Gala; +Cc: Scott Wood, linuxppc-dev, Timur Tabi, Jason Jin
Ugh...
This should be From: Jason Jin <Jason.jin@freescale•com>, since
I've made only few small cleanups, the code itself is almost intact.
On Fri, Jun 06, 2008 at 11:24:43PM +0400, Anton Vorontsov wrote:
> This patch adds suspend (standby, not suspend-to-ram) support for MPC86xx
> processors.
>
> In standby mode MPC86xx is able to wakeup only upon external interrupts
> (including sreset).
>
> Signed-off-by: Scott Wood <scottwood@freescale•com>
> Signed-off-by: Jason Jin <Jason.jin@freescale•com>
> Signed-off-by: Anton Vorontsov <avorontsov@ru•mvista.com>
> ---
> arch/powerpc/Kconfig | 2 +-
> arch/powerpc/platforms/86xx/Makefile | 1 +
> arch/powerpc/platforms/86xx/mpc86xx_suspend.c | 92 +++++++++++++++++++++++++
> 3 files changed, 94 insertions(+), 1 deletions(-)
> create mode 100644 arch/powerpc/platforms/86xx/mpc86xx_suspend.c
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 2cde4e3..c45c71e 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -192,7 +192,7 @@ config ARCH_HIBERNATION_POSSIBLE
>
> config ARCH_SUSPEND_POSSIBLE
> def_bool y
> - depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200
> + depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200 || PPC_86xx
>
> config PPC_DCR_NATIVE
> bool
> diff --git a/arch/powerpc/platforms/86xx/Makefile b/arch/powerpc/platforms/86xx/Makefile
> index 1b9b4a9..a8557df 100644
> --- a/arch/powerpc/platforms/86xx/Makefile
> +++ b/arch/powerpc/platforms/86xx/Makefile
> @@ -3,6 +3,7 @@
> #
>
> obj-$(CONFIG_SMP) += mpc86xx_smp.o
> +obj-$(CONFIG_SUSPEND) += mpc86xx_suspend.o
> obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o
> obj-$(CONFIG_SBC8641D) += sbc8641d.o
> obj-$(CONFIG_MPC8610_HPCD) += mpc8610_hpcd.o
> diff --git a/arch/powerpc/platforms/86xx/mpc86xx_suspend.c b/arch/powerpc/platforms/86xx/mpc86xx_suspend.c
> new file mode 100644
> index 0000000..ce13e4c
> --- /dev/null
> +++ b/arch/powerpc/platforms/86xx/mpc86xx_suspend.c
> @@ -0,0 +1,92 @@
> +/*
> + * MPC86xx suspend (standby) support
> + *
> + * Copyright (C) 2008 Freescale Semiconductor, Inc. All rights reserved.
> + *
> + * Author: Jason Jin <jason.jin@freescale•com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/types.h>
> +#include <linux/suspend.h>
> +#include <linux/of.h>
> +#include <linux/io.h>
> +#include <asm/prom.h>
> +#include <asm/reg.h>
> +#include <asm/mpc6xx.h>
> +
> +#define PMCSR_DEVSLEEP 0x00020000
> +
> +struct mpc86xx_pmc {
> + __be32 devdisr;
> + __be32 devdisr2;
> + __be32 reserve1;
> + __be32 reserve2;
> + __be32 powmgtcsr;
> +};
> +
> +static struct mpc86xx_pmc __iomem *pmc_regs_86xx;
> +
> +static int mpc86xx_suspend_enter(suspend_state_t state)
> +{
> + u32 tmp;
> +
> + /* Disable power management. */
> + tmp = mfmsr();
> + mtmsr(tmp & ~MSR_POW);
> +
> + /* Enable sleep mode, disable others. */
> + tmp = mfspr(SPRN_HID0);
> + mtspr(SPRN_HID0, (tmp & ~(HID0_DOZE | HID0_NAP)) | HID0_SLEEP);
> + asm("sync");
> +
> + /* Device power down. */
> + setbits32(&pmc_regs_86xx->powmgtcsr, PMCSR_DEVSLEEP);
> +
> + /* 86xx did not support deep sleep, let it enter standby mode. */
> + mpc6xx_enter_standby();
> +
> + clrbits32(&pmc_regs_86xx->powmgtcsr, PMCSR_DEVSLEEP);
> +
> + return 0;
> +}
> +
> +static int mpc86xx_suspend_valid(suspend_state_t state)
> +{
> + if (state == PM_SUSPEND_STANDBY)
> + return 1;
> + return 0;
> +}
> +
> +static struct platform_suspend_ops mpc86xx_suspend_ops = {
> + .valid = mpc86xx_suspend_valid,
> + .enter = mpc86xx_suspend_enter,
> +};
> +
> +static int __init mpc86xx_pmc_init(void)
> +{
> + void __iomem *guts;
> + struct device_node *np;
> +
> + np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts");
> + if (!np) {
> + np = of_find_compatible_node(NULL, NULL, "fsl,mpc8641-guts");
> + if (!np)
> + return -ENODEV;
> + }
> +
> + guts = of_iomap(np, 0);
> + of_node_put(np);
> + if (!guts)
> + return -ENOMEM;
> +
> + pmc_regs_86xx = guts + 0x70;
> +
> + suspend_set_ops(&mpc86xx_suspend_ops);
> + return 0;
> +}
> +module_init(mpc86xx_pmc_init);
> --
> 1.5.5.1
--
Anton Vorontsov
email: cbouatmailru@gmail•com
irc://irc.freenode.net/bd2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] [POWERPC] 86xx: suspend support
2008-06-06 19:24 [PATCH 1/2] [POWERPC] 86xx: suspend support Anton Vorontsov
2008-06-06 19:36 ` Anton Vorontsov
@ 2008-07-15 16:16 ` Kumar Gala
2008-07-15 16:49 ` Anton Vorontsov
1 sibling, 1 reply; 4+ messages in thread
From: Kumar Gala @ 2008-07-15 16:16 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: Scott Wood, linuxppc-dev, Timur Tabi, Jason Jin
On Jun 6, 2008, at 2:24 PM, Anton Vorontsov wrote:
> This patch adds suspend (standby, not suspend-to-ram) support for
> MPC86xx
> processors.
>
> In standby mode MPC86xx is able to wakeup only upon external
> interrupts
> (including sreset).
>
> Signed-off-by: Scott Wood <scottwood@freescale•com>
> Signed-off-by: Jason Jin <Jason.jin@freescale•com>
> Signed-off-by: Anton Vorontsov <avorontsov@ru•mvista.com>
> ---
> arch/powerpc/Kconfig | 2 +-
> arch/powerpc/platforms/86xx/Makefile | 1 +
> arch/powerpc/platforms/86xx/mpc86xx_suspend.c | 92 ++++++++++++++++
> +++++++++
> 3 files changed, 94 insertions(+), 1 deletions(-)
> create mode 100644 arch/powerpc/platforms/86xx/mpc86xx_suspend.c
I'd like to understand how much PM support these patches really add w/
regards to the work Scott's done for 83xx PM.
- k
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] [POWERPC] 86xx: suspend support
2008-07-15 16:16 ` Kumar Gala
@ 2008-07-15 16:49 ` Anton Vorontsov
0 siblings, 0 replies; 4+ messages in thread
From: Anton Vorontsov @ 2008-07-15 16:49 UTC (permalink / raw)
To: Kumar Gala; +Cc: Scott Wood, linuxppc-dev, Timur Tabi, Jason Jin
On Tue, Jul 15, 2008 at 11:16:14AM -0500, Kumar Gala wrote:
>
> On Jun 6, 2008, at 2:24 PM, Anton Vorontsov wrote:
>
>> This patch adds suspend (standby, not suspend-to-ram) support for
>> MPC86xx
>> processors.
>>
>> In standby mode MPC86xx is able to wakeup only upon external
>> interrupts
>> (including sreset).
>>
>> Signed-off-by: Scott Wood <scottwood@freescale•com>
>> Signed-off-by: Jason Jin <Jason.jin@freescale•com>
>> Signed-off-by: Anton Vorontsov <avorontsov@ru•mvista.com>
>> ---
>> arch/powerpc/Kconfig | 2 +-
>> arch/powerpc/platforms/86xx/Makefile | 1 +
>> arch/powerpc/platforms/86xx/mpc86xx_suspend.c | 92 ++++++++++++++++
>> +++++++++
>> 3 files changed, 94 insertions(+), 1 deletions(-)
>> create mode 100644 arch/powerpc/platforms/86xx/mpc86xx_suspend.c
>
> I'd like to understand how much PM support these patches really add w/
> regards to the work Scott's done for 83xx PM.
This support provides "sleep" mode, i.e. almost all internal core
functions are off, some peripherals could be turned off, but sysclk
must be preserved. Upon wakeup CPU continues execution where it was
put to sleep. This is also called standby mode.
This patch does not implement "deep sleep" (suspend-to-ram) mode yet.
Deep sleep can save more power: CPU can be turned off completely (except
SDRAM -- it must still receive refresh cycles).
But deep sleep is also more tricky to implement.. During deep sleep CPU
losing all track of execution and state, thus upon wakeup CPU starts
execution of the firmware, so the firmware should be also aware of deep
sleep capability.
--
Anton Vorontsov
email: cbouatmailru@gmail•com
irc://irc.freenode.net/bd2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-07-15 16:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-06 19:24 [PATCH 1/2] [POWERPC] 86xx: suspend support Anton Vorontsov
2008-06-06 19:36 ` Anton Vorontsov
2008-07-15 16:16 ` Kumar Gala
2008-07-15 16:49 ` Anton Vorontsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox