blob: d75f95e487ee6414eb7d02908bbdf5320475950a [file] [log] [blame]
Ben Dooksa21765a2007-02-11 18:31:01 +01001/* linux/arch/arm/mach-s3c2412/pm.c
Ben Dooks4b053e72006-09-22 15:42:18 +01002 *
3 * Copyright (c) 2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * http://armlinux.simtec.co.uk/.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/list.h>
17#include <linux/timer.h>
18#include <linux/init.h>
Kay Sievers4a858cf2011-12-21 16:01:38 -080019#include <linux/device.h>
Rafael J. Wysockibb072c32011-04-22 22:03:21 +020020#include <linux/syscore_ops.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010021#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010022#include <linux/io.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010023
Ben Dooksdc8fc7e2009-04-28 10:06:00 +010024#include <asm/cacheflush.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010025#include <asm/irq.h>
26
Kukjin Kimb4353782013-01-02 14:01:09 -080027#include <mach/hardware.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/regs-gpio.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010029
Ben Dooksa2b7ba92008-10-07 22:26:09 +010030#include <plat/cpu.h>
31#include <plat/pm.h>
Heiko Stuebner59295702013-02-12 10:09:10 -080032#include <plat/wakeup-mask.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010033
Kukjin Kimb4353782013-01-02 14:01:09 -080034#include "regs-dsc.h"
Kukjin Kim14cce0e2013-02-01 21:49:35 -080035#include "s3c2412-power.h"
Kukjin Kimb4353782013-01-02 14:01:09 -080036
Ben Dooks33234952007-12-23 03:09:34 +010037extern void s3c2412_sleep_enter(void);
38
Russell King29cb3cd2011-07-02 09:54:01 +010039static int s3c2412_cpu_suspend(unsigned long arg)
Ben Dooks4b053e72006-09-22 15:42:18 +010040{
41 unsigned long tmp;
42
43 /* set our standby method to sleep */
44
45 tmp = __raw_readl(S3C2412_PWRCFG);
46 tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
47 __raw_writel(tmp, S3C2412_PWRCFG);
48
Ben Dooks33234952007-12-23 03:09:34 +010049 s3c2412_sleep_enter();
Russell King29cb3cd2011-07-02 09:54:01 +010050
Abhilash Kesavand3fcacf2013-01-25 10:40:19 -080051 pr_info("Failed to suspend the system\n");
52 return 1; /* Aborting suspend */
Ben Dooks4b053e72006-09-22 15:42:18 +010053}
54
Heiko Stuebner59295702013-02-12 10:09:10 -080055/* mapping of interrupts to parts of the wakeup mask */
56static struct samsung_wakeup_mask wake_irqs[] = {
57 { .irq = IRQ_RTC, .bit = S3C2412_PWRCFG_RTC_MASKIRQ, },
58};
59
Ben Dooks4b053e72006-09-22 15:42:18 +010060static void s3c2412_pm_prepare(void)
61{
Heiko Stuebner59295702013-02-12 10:09:10 -080062 samsung_sync_wakemask(S3C2412_PWRCFG,
63 wake_irqs, ARRAY_SIZE(wake_irqs));
Ben Dooks4b053e72006-09-22 15:42:18 +010064}
65
Heiko Stuebner04511a62012-01-27 15:35:25 +090066static int s3c2412_pm_add(struct device *dev, struct subsys_interface *sif)
Ben Dooks4b053e72006-09-22 15:42:18 +010067{
68 pm_cpu_prep = s3c2412_pm_prepare;
69 pm_cpu_sleep = s3c2412_cpu_suspend;
70
71 return 0;
72}
73
74static struct sleep_save s3c2412_sleep[] = {
75 SAVE_ITEM(S3C2412_DSC0),
76 SAVE_ITEM(S3C2412_DSC1),
77 SAVE_ITEM(S3C2413_GPJDAT),
78 SAVE_ITEM(S3C2413_GPJCON),
79 SAVE_ITEM(S3C2413_GPJUP),
80
81 /* save the PWRCFG to get back to original sleep method */
82
83 SAVE_ITEM(S3C2412_PWRCFG),
84
85 /* save the sleep configuration anyway, just in case these
86 * get damaged during wakeup */
87
88 SAVE_ITEM(S3C2412_GPBSLPCON),
89 SAVE_ITEM(S3C2412_GPCSLPCON),
90 SAVE_ITEM(S3C2412_GPDSLPCON),
Ben Dooks4b053e72006-09-22 15:42:18 +010091 SAVE_ITEM(S3C2412_GPFSLPCON),
92 SAVE_ITEM(S3C2412_GPGSLPCON),
93 SAVE_ITEM(S3C2412_GPHSLPCON),
94 SAVE_ITEM(S3C2413_GPJSLPCON),
95};
96
Kay Sievers4a858cf2011-12-21 16:01:38 -080097static struct subsys_interface s3c2412_pm_interface = {
98 .name = "s3c2412_pm",
99 .subsys = &s3c2412_subsys,
100 .add_dev = s3c2412_pm_add,
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200101};
102
103static __init int s3c2412_pm_init(void)
104{
Kukjin Kimea040182012-01-06 16:08:09 +0900105 return subsys_interface_register(&s3c2412_pm_interface);
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200106}
107
108arch_initcall(s3c2412_pm_init);
109
110static int s3c2412_pm_suspend(void)
Ben Dooks4b053e72006-09-22 15:42:18 +0100111{
Ben Dooks64197112008-12-12 00:24:06 +0000112 s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
Ben Dooks4b053e72006-09-22 15:42:18 +0100113 return 0;
114}
115
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200116static void s3c2412_pm_resume(void)
Ben Dooks4b053e72006-09-22 15:42:18 +0100117{
118 unsigned long tmp;
119
120 tmp = __raw_readl(S3C2412_PWRCFG);
121 tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
122 tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
123 __raw_writel(tmp, S3C2412_PWRCFG);
124
Ben Dooks64197112008-12-12 00:24:06 +0000125 s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
Ben Dooks4b053e72006-09-22 15:42:18 +0100126}
127
Rafael J. Wysockibb072c32011-04-22 22:03:21 +0200128struct syscore_ops s3c2412_pm_syscore_ops = {
Ben Dooks4b053e72006-09-22 15:42:18 +0100129 .suspend = s3c2412_pm_suspend,
130 .resume = s3c2412_pm_resume,
131};