summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Dongsheng <dongsheng.wang@freescale.com>2014-04-25 05:28:18 (GMT)
committerJose Rivera <German.Rivera@freescale.com>2014-04-29 14:11:25 (GMT)
commitacf2570649581aa9b12a1afcb73215c439ab33c8 (patch)
tree538b6977aa5b63d5d9046d3e90929f3f08eefe9f
parent22642f20535811b5bf40a3f3323fd4e5719a162d (diff)
downloadlinux-fsl-qoriq-acf2570649581aa9b12a1afcb73215c439ab33c8.tar.xz
fsl/pm: add api to get suspend state which is STANDBY or MEM
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> Change-Id: Ibd369079f6f0777854d88d7e1af21f455eaf909e Reviewed-on: http://git.am.freescale.net:8181/11530 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Yang Li <LeoLi@freescale.com> Reviewed-by: Jose Rivera <German.Rivera@freescale.com>
-rw-r--r--arch/powerpc/include/asm/fsl_pm.h6
-rw-r--r--arch/powerpc/kernel/Makefile1
-rw-r--r--arch/powerpc/kernel/fsl_pm.c26
-rw-r--r--arch/powerpc/platforms/85xx/qoriq_pm.c5
-rw-r--r--arch/powerpc/sysdev/fsl_pmc.c15
5 files changed, 51 insertions, 2 deletions
diff --git a/arch/powerpc/include/asm/fsl_pm.h b/arch/powerpc/include/asm/fsl_pm.h
index d06adaa..bcdc018 100644
--- a/arch/powerpc/include/asm/fsl_pm.h
+++ b/arch/powerpc/include/asm/fsl_pm.h
@@ -13,6 +13,8 @@
#ifdef __KERNEL__
#ifndef __ASSEMBLY__
+#include <linux/suspend.h>
+
#define E500_PM_PH10 1
#define E500_PM_PH15 2
#define E500_PM_PH20 3
@@ -47,6 +49,10 @@ extern int fsl_enter_epu_deepsleep(void);
extern void fsl_dp_enter_low(void __iomem *ccsr_base, void __iomem *dcsr_base,
void __iomem *pld_base, int pld_flag);
extern void fsl_booke_deep_sleep_resume(void);
+
+void set_pm_suspend_state(suspend_state_t state);
+suspend_state_t pm_suspend_state(void);
+
#endif /* __ASSEMBLY__ */
#define T1040QDS_TETRA_FLAG 1
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index ca9a2a9..c326675 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_EEH) += eeh.o eeh_pe.o eeh_dev.o eeh_cache.o \
obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
obj-$(CONFIG_FA_DUMP) += fadump.o
+obj-$(CONFIG_FSL_SOC) += fsl_pm.o
ifeq ($(CONFIG_PPC32),y)
obj-$(CONFIG_E500) += idle_e500.o
endif
diff --git a/arch/powerpc/kernel/fsl_pm.c b/arch/powerpc/kernel/fsl_pm.c
new file mode 100644
index 0000000..1d19b85
--- /dev/null
+++ b/arch/powerpc/kernel/fsl_pm.c
@@ -0,0 +1,26 @@
+/*
+ * Freescale 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/fsl_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/platforms/85xx/qoriq_pm.c b/arch/powerpc/platforms/85xx/qoriq_pm.c
index 4578a63..9f656e9 100644
--- a/arch/powerpc/platforms/85xx/qoriq_pm.c
+++ b/arch/powerpc/platforms/85xx/qoriq_pm.c
@@ -79,12 +79,15 @@ static int qoriq_suspend_enter(suspend_state_t state)
static int qoriq_suspend_valid(suspend_state_t state)
{
+ set_pm_suspend_state(state);
+
if (state == PM_SUSPEND_STANDBY && (sleep_modes & FSL_SLEEP))
return 1;
if (state == PM_SUSPEND_MEM && (sleep_modes & FSL_DEEP_SLEEP))
return 1;
+ set_pm_suspend_state(PM_SUSPEND_ON);
return 0;
}
@@ -100,6 +103,7 @@ static int qoriq_suspend_begin(suspend_state_t state)
static void qoriq_suspend_end(void)
{
+ set_pm_suspend_state(PM_SUSPEND_ON);
fsl_dp_iounmap();
}
@@ -128,6 +132,7 @@ static int __init qoriq_suspend_init(void)
}
suspend_set_ops(&qoriq_suspend_ops);
+ set_pm_suspend_state(PM_SUSPEND_ON);
return 0;
}
diff --git a/arch/powerpc/sysdev/fsl_pmc.c b/arch/powerpc/sysdev/fsl_pmc.c
index 61dba33..e56edfa 100644
--- a/arch/powerpc/sysdev/fsl_pmc.c
+++ b/arch/powerpc/sysdev/fsl_pmc.c
@@ -21,6 +21,7 @@
#include <linux/device.h>
#include <linux/of_platform.h>
#include <linux/pm.h>
+#include <asm/fsl_pm.h>
#include <asm/switch_to.h>
#include <asm/cacheflush.h>
@@ -163,16 +164,25 @@ static int pmc_suspend_enter(suspend_state_t state)
static int pmc_suspend_valid(suspend_state_t state)
{
+ set_pm_suspend_state(state);
+
if (((pmc_flag & PMC_SLEEP) && (state == PM_SUSPEND_STANDBY)) ||
((pmc_flag & PMC_DEEP_SLEEP) && (state == PM_SUSPEND_MEM)))
return 1;
- else
- return 0;
+
+ set_pm_suspend_state(PM_SUSPEND_ON);
+ return 0;
+}
+
+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 *pdev)
@@ -191,6 +201,7 @@ static int pmc_probe(struct platform_device *pdev)
pmc_flag |= PMC_DEEP_SLEEP | PMC_LOSSLESS;
suspend_set_ops(&pmc_suspend_ops);
+ set_pm_suspend_state(PM_SUSPEND_ON);
pr_info("Freescale PMC driver\n");
return 0;