Skip to contentSkip to conversation

86xx: suspend support

PATCH In review Anton Vorontsov 2 participants 4 messages Jun 6, 2008 – Jul 15, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 86xx: suspend support

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).

---
 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
arch/powerpc/Kconfig +1 -1
index 2cde4e3..c45c71e 100644
@@ -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
arch/powerpc/platforms/86xx/Makefile +1 -0
index 1b9b4a9..a8557df 100644
@@ -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
arch/powerpc/platforms/86xx/mpc86xx_suspend.c new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
1.5.5.1
#1 lore raw

Ugh...

This should be From: Jason Jin <[email protected]>, since I've made only few small cleanups, the code itself is almost intact.

Quoted 141 lines · Anton Vorontsov

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).

---
 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
arch/powerpc/Kconfig +1 -1
index 2cde4e3..c45c71e 100644
@@ -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
arch/powerpc/platforms/86xx/Makefile +1 -0
index 1b9b4a9..a8557df 100644
@@ -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
arch/powerpc/platforms/86xx/mpc86xx_suspend.c new file +92 -0
new file mode 100644
index 0000000..ce13e4c
@@ -0,0 +1,92 @@
+/*
+ * MPC86xx suspend (standby) support
+ *
+ * Copyright (C) 2008 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author: Jason Jin <[email protected]>
+ *
+ * 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);
Signature · 1 line
1.5.5.1
Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#2 lore raw
In reply to Anton Vorontsov
Quoted 9 lines · Anton Vorontsov

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).

Quoted 7 lines

---

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

#3 lore raw
Quoted 22 lines · Kumar Gala
Quoted 11 lines · Anton Vorontsov

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).

Quoted 7 lines

---

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

Quoted 2 lines

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.

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2