• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Copyright (c) 2006 Simtec Electronics
4 //	Ben Dooks <ben@simtec.co.uk>
5 //
6 // http://armlinux.simtec.co.uk/.
7 
8 #include <linux/kernel.h>
9 #include <linux/types.h>
10 #include <linux/interrupt.h>
11 #include <linux/list.h>
12 #include <linux/timer.h>
13 #include <linux/init.h>
14 #include <linux/device.h>
15 #include <linux/syscore_ops.h>
16 #include <linux/platform_device.h>
17 #include <linux/io.h>
18 
19 #include <asm/cacheflush.h>
20 #include <asm/irq.h>
21 
22 #include <mach/irqs.h>
23 #include "regs-gpio.h"
24 
25 #include "cpu.h"
26 #include "pm.h"
27 #include "wakeup-mask.h"
28 
29 #include "regs-dsc-s3c24xx.h"
30 #include "s3c2412-power.h"
31 
32 extern void s3c2412_sleep_enter(void);
33 
s3c2412_cpu_suspend(unsigned long arg)34 static int s3c2412_cpu_suspend(unsigned long arg)
35 {
36 	unsigned long tmp;
37 
38 	/* set our standby method to sleep */
39 
40 	tmp = __raw_readl(S3C2412_PWRCFG);
41 	tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
42 	__raw_writel(tmp, S3C2412_PWRCFG);
43 
44 	s3c2412_sleep_enter();
45 
46 	pr_info("Failed to suspend the system\n");
47 	return 1; /* Aborting suspend */
48 }
49 
50 /* mapping of interrupts to parts of the wakeup mask */
51 static const struct samsung_wakeup_mask wake_irqs[] = {
52 	{ .irq = IRQ_RTC,	.bit = S3C2412_PWRCFG_RTC_MASKIRQ, },
53 };
54 
s3c2412_pm_prepare(void)55 static void s3c2412_pm_prepare(void)
56 {
57 	samsung_sync_wakemask(S3C2412_PWRCFG,
58 			      wake_irqs, ARRAY_SIZE(wake_irqs));
59 }
60 
s3c2412_pm_add(struct device * dev,struct subsys_interface * sif)61 static int s3c2412_pm_add(struct device *dev, struct subsys_interface *sif)
62 {
63 	pm_cpu_prep = s3c2412_pm_prepare;
64 	pm_cpu_sleep = s3c2412_cpu_suspend;
65 
66 	return 0;
67 }
68 
69 static struct sleep_save s3c2412_sleep[] = {
70 	SAVE_ITEM(S3C2412_DSC0),
71 	SAVE_ITEM(S3C2412_DSC1),
72 	SAVE_ITEM(S3C2413_GPJDAT),
73 	SAVE_ITEM(S3C2413_GPJCON),
74 	SAVE_ITEM(S3C2413_GPJUP),
75 
76 	/* save the PWRCFG to get back to original sleep method */
77 
78 	SAVE_ITEM(S3C2412_PWRCFG),
79 
80 	/* save the sleep configuration anyway, just in case these
81 	 * get damaged during wakeup */
82 
83 	SAVE_ITEM(S3C2412_GPBSLPCON),
84 	SAVE_ITEM(S3C2412_GPCSLPCON),
85 	SAVE_ITEM(S3C2412_GPDSLPCON),
86 	SAVE_ITEM(S3C2412_GPFSLPCON),
87 	SAVE_ITEM(S3C2412_GPGSLPCON),
88 	SAVE_ITEM(S3C2412_GPHSLPCON),
89 	SAVE_ITEM(S3C2413_GPJSLPCON),
90 };
91 
92 static struct subsys_interface s3c2412_pm_interface = {
93 	.name		= "s3c2412_pm",
94 	.subsys		= &s3c2412_subsys,
95 	.add_dev	= s3c2412_pm_add,
96 };
97 
s3c2412_pm_init(void)98 static __init int s3c2412_pm_init(void)
99 {
100 	return subsys_interface_register(&s3c2412_pm_interface);
101 }
102 
103 arch_initcall(s3c2412_pm_init);
104 
s3c2412_pm_suspend(void)105 static int s3c2412_pm_suspend(void)
106 {
107 	s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
108 	return 0;
109 }
110 
s3c2412_pm_resume(void)111 static void s3c2412_pm_resume(void)
112 {
113 	unsigned long tmp;
114 
115 	tmp = __raw_readl(S3C2412_PWRCFG);
116 	tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
117 	tmp |=  S3C2412_PWRCFG_STANDBYWFI_IDLE;
118 	__raw_writel(tmp, S3C2412_PWRCFG);
119 
120 	s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
121 }
122 
123 struct syscore_ops s3c2412_pm_syscore_ops = {
124 	.suspend	= s3c2412_pm_suspend,
125 	.resume		= s3c2412_pm_resume,
126 };
127