2017-12-26 03:54:32 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
//
|
|
|
|
// Copyright (c) 2006 Simtec Electronics
|
|
|
|
// Ben Dooks <ben@simtec.co.uk>
|
|
|
|
//
|
|
|
|
// http://armlinux.simtec.co.uk/.
|
2006-09-22 22:42:18 +08:00
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/init.h>
|
2011-12-22 08:01:38 +08:00
|
|
|
#include <linux/device.h>
|
2011-04-23 04:03:21 +08:00
|
|
|
#include <linux/syscore_ops.h>
|
2006-09-22 22:42:18 +08:00
|
|
|
#include <linux/platform_device.h>
|
2008-09-06 19:10:45 +08:00
|
|
|
#include <linux/io.h>
|
2006-09-22 22:42:18 +08:00
|
|
|
|
2009-04-28 17:06:00 +08:00
|
|
|
#include <asm/cacheflush.h>
|
2006-09-22 22:42:18 +08:00
|
|
|
#include <asm/irq.h>
|
|
|
|
|
2013-01-03 06:01:09 +08:00
|
|
|
#include <mach/hardware.h>
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/regs-gpio.h>
|
2006-09-22 22:42:18 +08:00
|
|
|
|
2008-10-08 05:26:09 +08:00
|
|
|
#include <plat/cpu.h>
|
|
|
|
#include <plat/pm.h>
|
2013-02-13 02:09:10 +08:00
|
|
|
#include <plat/wakeup-mask.h>
|
2006-09-22 22:42:18 +08:00
|
|
|
|
2013-01-03 06:01:09 +08:00
|
|
|
#include "regs-dsc.h"
|
2013-02-02 13:49:35 +08:00
|
|
|
#include "s3c2412-power.h"
|
2013-01-03 06:01:09 +08:00
|
|
|
|
2007-12-23 10:09:34 +08:00
|
|
|
extern void s3c2412_sleep_enter(void);
|
|
|
|
|
2011-07-02 16:54:01 +08:00
|
|
|
static int s3c2412_cpu_suspend(unsigned long arg)
|
2006-09-22 22:42:18 +08:00
|
|
|
{
|
|
|
|
unsigned long tmp;
|
|
|
|
|
|
|
|
/* set our standby method to sleep */
|
|
|
|
|
|
|
|
tmp = __raw_readl(S3C2412_PWRCFG);
|
|
|
|
tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
|
|
|
|
__raw_writel(tmp, S3C2412_PWRCFG);
|
|
|
|
|
2007-12-23 10:09:34 +08:00
|
|
|
s3c2412_sleep_enter();
|
2011-07-02 16:54:01 +08:00
|
|
|
|
2013-01-26 02:40:19 +08:00
|
|
|
pr_info("Failed to suspend the system\n");
|
|
|
|
return 1; /* Aborting suspend */
|
2006-09-22 22:42:18 +08:00
|
|
|
}
|
|
|
|
|
2013-02-13 02:09:10 +08:00
|
|
|
/* mapping of interrupts to parts of the wakeup mask */
|
2016-12-10 21:47:37 +08:00
|
|
|
static const struct samsung_wakeup_mask wake_irqs[] = {
|
2013-02-13 02:09:10 +08:00
|
|
|
{ .irq = IRQ_RTC, .bit = S3C2412_PWRCFG_RTC_MASKIRQ, },
|
|
|
|
};
|
|
|
|
|
2006-09-22 22:42:18 +08:00
|
|
|
static void s3c2412_pm_prepare(void)
|
|
|
|
{
|
2013-02-13 02:09:10 +08:00
|
|
|
samsung_sync_wakemask(S3C2412_PWRCFG,
|
|
|
|
wake_irqs, ARRAY_SIZE(wake_irqs));
|
2006-09-22 22:42:18 +08:00
|
|
|
}
|
|
|
|
|
2012-01-27 14:35:25 +08:00
|
|
|
static int s3c2412_pm_add(struct device *dev, struct subsys_interface *sif)
|
2006-09-22 22:42:18 +08:00
|
|
|
{
|
|
|
|
pm_cpu_prep = s3c2412_pm_prepare;
|
|
|
|
pm_cpu_sleep = s3c2412_cpu_suspend;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sleep_save s3c2412_sleep[] = {
|
|
|
|
SAVE_ITEM(S3C2412_DSC0),
|
|
|
|
SAVE_ITEM(S3C2412_DSC1),
|
|
|
|
SAVE_ITEM(S3C2413_GPJDAT),
|
|
|
|
SAVE_ITEM(S3C2413_GPJCON),
|
|
|
|
SAVE_ITEM(S3C2413_GPJUP),
|
|
|
|
|
|
|
|
/* save the PWRCFG to get back to original sleep method */
|
|
|
|
|
|
|
|
SAVE_ITEM(S3C2412_PWRCFG),
|
|
|
|
|
|
|
|
/* save the sleep configuration anyway, just in case these
|
|
|
|
* get damaged during wakeup */
|
|
|
|
|
|
|
|
SAVE_ITEM(S3C2412_GPBSLPCON),
|
|
|
|
SAVE_ITEM(S3C2412_GPCSLPCON),
|
|
|
|
SAVE_ITEM(S3C2412_GPDSLPCON),
|
|
|
|
SAVE_ITEM(S3C2412_GPFSLPCON),
|
|
|
|
SAVE_ITEM(S3C2412_GPGSLPCON),
|
|
|
|
SAVE_ITEM(S3C2412_GPHSLPCON),
|
|
|
|
SAVE_ITEM(S3C2413_GPJSLPCON),
|
|
|
|
};
|
|
|
|
|
2011-12-22 08:01:38 +08:00
|
|
|
static struct subsys_interface s3c2412_pm_interface = {
|
|
|
|
.name = "s3c2412_pm",
|
|
|
|
.subsys = &s3c2412_subsys,
|
|
|
|
.add_dev = s3c2412_pm_add,
|
2011-04-23 04:03:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static __init int s3c2412_pm_init(void)
|
|
|
|
{
|
2012-01-06 15:08:09 +08:00
|
|
|
return subsys_interface_register(&s3c2412_pm_interface);
|
2011-04-23 04:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
arch_initcall(s3c2412_pm_init);
|
|
|
|
|
|
|
|
static int s3c2412_pm_suspend(void)
|
2006-09-22 22:42:18 +08:00
|
|
|
{
|
2008-12-12 08:24:06 +08:00
|
|
|
s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
|
2006-09-22 22:42:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-23 04:03:21 +08:00
|
|
|
static void s3c2412_pm_resume(void)
|
2006-09-22 22:42:18 +08:00
|
|
|
{
|
|
|
|
unsigned long tmp;
|
|
|
|
|
|
|
|
tmp = __raw_readl(S3C2412_PWRCFG);
|
|
|
|
tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
|
|
|
|
tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
|
|
|
|
__raw_writel(tmp, S3C2412_PWRCFG);
|
|
|
|
|
2008-12-12 08:24:06 +08:00
|
|
|
s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
|
2006-09-22 22:42:18 +08:00
|
|
|
}
|
|
|
|
|
2011-04-23 04:03:21 +08:00
|
|
|
struct syscore_ops s3c2412_pm_syscore_ops = {
|
2006-09-22 22:42:18 +08:00
|
|
|
.suspend = s3c2412_pm_suspend,
|
|
|
|
.resume = s3c2412_pm_resume,
|
|
|
|
};
|