public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru•mvista.com>
To: Kumar Gala <galak@kernel•crashing.org>
Cc: Scott Wood <scottwood@freescale•com>,
	linuxppc-dev@ozlabs•org, Timur Tabi <timur@freescale•com>,
	Jason Jin <Jason.jin@freescale•com>
Subject: [PATCH 1/2] [POWERPC] 86xx: suspend support
Date: Fri, 6 Jun 2008 23:24:43 +0400	[thread overview]
Message-ID: <20080606192443.GA20132@polina.dev.rtsoft.ru> (raw)

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

             reply	other threads:[~2008-06-06 19:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06 19:24 Anton Vorontsov [this message]
2008-06-06 19:36 ` [PATCH 1/2] [POWERPC] 86xx: suspend support Anton Vorontsov
2008-07-15 16:16 ` Kumar Gala
2008-07-15 16:49   ` Anton Vorontsov

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=20080606192443.GA20132@polina.dev.rtsoft.ru \
    --to=avorontsov@ru$(echo .)mvista.com \
    --cc=Jason.jin@freescale$(echo .)com \
    --cc=galak@kernel$(echo .)crashing.org \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=scottwood@freescale$(echo .)com \
    --cc=timur@freescale$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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