From: Dongsheng Wang <dongsheng.wang@freescale.com>
To: <benh@kernel.crashing.org>, <scottwood@freescale.com>
Cc: linuxppc-dev@lists.ozlabs.org, chenhui.zhao@freescale.com,
jason.jin@freescale.com,
Wang Dongsheng <dongsheng.wang@freescale.com>
Subject: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
Date: Thu, 24 Apr 2014 14:11:48 +0800 [thread overview]
Message-ID: <1398319908-30166-1-git-send-email-dongsheng.wang@freescale.com> (raw)
From: Wang Dongsheng <dongsheng.wang@freescale.com>
Add set_pm_suspend_state & pm_suspend_state functions to set/get
suspend state. When system going to sleep or deep sleep, devices
can get the system suspend state(STANDBY/MEM) through pm_suspend_state
function and to handle different situations.
Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
---
*v2*
Move pm api from fsl platform to powerpc general framework.
diff --git a/arch/powerpc/include/asm/pm.h b/arch/powerpc/include/asm/pm.h
new file mode 100644
index 0000000..00ddbf1
--- /dev/null
+++ b/arch/powerpc/include/asm/pm.h
@@ -0,0 +1,26 @@
+/*
+ * asm/pm.h
+ *
+ * Definitions for any platform related flags or structures for
+ * Power Management.
+ *
+ * Author: Wang Dongsheng <dongsheng.wang@freescale.com>
+ *
+ * Copyright 2014 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.
+ */
+
+#ifndef _POWERPC_PM_H_
+#define _POWERPC_PM_H_
+#ifdef __KERNEL__
+#include <linux/suspend.h>
+
+extern void set_pm_suspend_state(suspend_state_t state);
+extern suspend_state_t pm_suspend_state(void);
+
+#endif /* __KERNEL__ */
+#endif /* _POWERPC_PM_H_ */
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index fcc9a89..2060145 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -28,7 +28,7 @@ endif
obj-y := cputable.o ptrace.o syscalls.o \
irq.o align.o signal_32.o pmc.o vdso.o \
- process.o systbl.o idle.o \
+ process.o systbl.o idle.o pm.o \
signal.o sysfs.o cacheinfo.o time.o \
prom.o traps.o setup-common.o \
udbg.o misc.o io.o dma.o \
diff --git a/arch/powerpc/kernel/pm.c b/arch/powerpc/kernel/pm.c
new file mode 100644
index 0000000..23d3c94
--- /dev/null
+++ b/arch/powerpc/kernel/pm.c
@@ -0,0 +1,26 @@
+/*
+ * PowerPC General Power Management Implementation
+ *
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ * Author: Wang Dongsheng <dongsheng.wang@freescale.com>
+ *
+ * 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/suspend.h>
+#include <asm/pm.h>
+
+static suspend_state_t pm_state;
+
+void set_pm_suspend_state(suspend_state_t state)
+{
+ pm_state = state;
+}
+
+suspend_state_t pm_suspend_state(void)
+{
+ return pm_state;
+}
diff --git a/arch/powerpc/sysdev/fsl_pmc.c b/arch/powerpc/sysdev/fsl_pmc.c
index 8cf4aa0..fd777ca 100644
--- a/arch/powerpc/sysdev/fsl_pmc.c
+++ b/arch/powerpc/sysdev/fsl_pmc.c
@@ -21,6 +21,8 @@
#include <linux/of_address.h>
#include <linux/of_platform.h>
+#include <asm/pm.h>
+
struct pmc_regs {
__be32 devdisr;
__be32 devdisr2;
@@ -52,12 +54,20 @@ static int pmc_suspend_valid(suspend_state_t state)
{
if (state != PM_SUSPEND_STANDBY)
return 0;
+
+ set_pm_suspend_state(state);
return 1;
}
+static void pmc_suspend_end(void)
+{
+ set_pm_suspend_state(PM_SUSPEND_ON);
+}
+
static const struct platform_suspend_ops pmc_suspend_ops = {
.valid = pmc_suspend_valid,
.enter = pmc_suspend_enter,
+ .end = pmc_suspend_end,
};
static int pmc_probe(struct platform_device *ofdev)
@@ -68,6 +78,7 @@ static int pmc_probe(struct platform_device *ofdev)
pmc_dev = &ofdev->dev;
suspend_set_ops(&pmc_suspend_ops);
+ set_pm_suspend_state(PM_SUSPEND_ON);
return 0;
}
--
1.8.5
next reply other threads:[~2014-04-24 6:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-24 6:11 Dongsheng Wang [this message]
2014-04-25 21:45 ` [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM Scott Wood
2014-04-28 5:53 ` Leo Li
2014-04-29 22:47 ` Scott Wood
2014-04-29 23:07 ` Rafael J. Wysocki
2014-05-09 9:33 ` Li Yang
2014-05-09 17:09 ` Scott Wood
2014-05-10 12:35 ` Li Yang
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=1398319908-30166-1-git-send-email-dongsheng.wang@freescale.com \
--to=dongsheng.wang@freescale.com \
--cc=benh@kernel.crashing.org \
--cc=chenhui.zhao@freescale.com \
--cc=jason.jin@freescale.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=scottwood@freescale.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;
as well as URLs for NNTP newsgroup(s).