1 /* linux/arch/arm/mach-s3c2410/s3c2412-pm.c
3 * Copyright (c) 2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/.
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.
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>
19 #include <linux/sysdev.h>
20 #include <linux/platform_device.h>
22 #include <asm/hardware.h>
26 #include <asm/arch/regs-power.h>
27 #include <asm/arch/regs-gpioj.h>
28 #include <asm/arch/regs-gpio.h>
29 #include <asm/arch/regs-dsc.h>
36 static void s3c2412_cpu_suspend(void)
40 /* set our standby method to sleep */
42 tmp = __raw_readl(S3C2412_PWRCFG);
43 tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
44 __raw_writel(tmp, S3C2412_PWRCFG);
46 /* issue the standby signal into the pm unit. Note, we
47 * issue a write-buffer drain just in case */
54 "mcr p15, 0, %0, c7, c10, 4\n\t"
55 "mcr p15, 0, %0, c7, c0, 4" :: "r" (tmp));
57 /* we should never get past here */
59 panic("sleep resumed to originator?");
62 static void s3c2412_pm_prepare(void)
66 static int s3c2412_pm_add(struct sys_device *sysdev)
68 pm_cpu_prep = s3c2412_pm_prepare;
69 pm_cpu_sleep = s3c2412_cpu_suspend;
74 static 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),
81 /* save the PWRCFG to get back to original sleep method */
83 SAVE_ITEM(S3C2412_PWRCFG),
85 /* save the sleep configuration anyway, just in case these
86 * get damaged during wakeup */
88 SAVE_ITEM(S3C2412_GPBSLPCON),
89 SAVE_ITEM(S3C2412_GPCSLPCON),
90 SAVE_ITEM(S3C2412_GPDSLPCON),
91 SAVE_ITEM(S3C2412_GPESLPCON),
92 SAVE_ITEM(S3C2412_GPFSLPCON),
93 SAVE_ITEM(S3C2412_GPGSLPCON),
94 SAVE_ITEM(S3C2412_GPHSLPCON),
95 SAVE_ITEM(S3C2413_GPJSLPCON),
98 static int s3c2412_pm_suspend(struct sys_device *dev, pm_message_t state)
100 s3c2410_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
104 static int s3c2412_pm_resume(struct sys_device *dev)
108 tmp = __raw_readl(S3C2412_PWRCFG);
109 tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
110 tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
111 __raw_writel(tmp, S3C2412_PWRCFG);
113 s3c2410_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
117 static struct sysdev_driver s3c2412_pm_driver = {
118 .add = s3c2412_pm_add,
119 .suspend = s3c2412_pm_suspend,
120 .resume = s3c2412_pm_resume,
123 static __init int s3c2412_pm_init(void)
125 return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver);
128 arch_initcall(s3c2412_pm_init);