blob: 9a2f05e279d4803fa333c0ef8afd2ee141028bbc [file] [log] [blame]
Krzysztof Kozlowski84b21702017-12-25 20:54:32 +01001// SPDX-License-Identifier: GPL-2.0
2//
3// Copyright (c) 2010 Samsung Electronics Co., Ltd.
4// http://www.samsung.com
5//
6// S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +09007
Kay Sievers4a858cf2011-12-21 16:01:38 -08008#include <linux/device.h>
Rafael J. Wysockibb072c32011-04-22 22:03:21 +02009#include <linux/syscore_ops.h>
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090010#include <linux/io.h>
11
12#include <asm/cacheflush.h>
13
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090014#include <mach/regs-s3c2443-clock.h>
15
16#include <plat/cpu.h>
17#include <plat/pm.h>
18
Kukjin Kim14cce0e2013-02-01 21:49:35 -080019#include "s3c2412-power.h"
20
Arnd Bergmann4f506da2015-02-27 05:50:22 +090021#ifdef CONFIG_PM_SLEEP
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090022extern void s3c2412_sleep_enter(void);
23
Russell King29cb3cd2011-07-02 09:54:01 +010024static int s3c2416_cpu_suspend(unsigned long arg)
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090025{
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090026 /* enable wakeup sources regardless of battery state */
27 __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
28
29 /* set the mode as sleep, 2BED represents "Go to BED" */
30 __raw_writel(0x2BED, S3C2443_PWRMODE);
31
32 s3c2412_sleep_enter();
Russell King29cb3cd2011-07-02 09:54:01 +010033
Abhilash Kesavand3fcacf52013-01-25 10:40:19 -080034 pr_info("Failed to suspend the system\n");
35 return 1; /* Aborting suspend */
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090036}
37
38static void s3c2416_pm_prepare(void)
39{
40 /*
41 * write the magic value u-boot uses to check for resume into
42 * the INFORM0 register, and ensure INFORM1 is set to the
43 * correct address to resume from.
44 */
45 __raw_writel(0x2BED, S3C2412_INFORM0);
Florian Fainelli64fc2a92017-01-15 03:59:29 +010046 __raw_writel(__pa_symbol(s3c_cpu_resume), S3C2412_INFORM1);
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090047}
48
Heiko Stuebner04511a62012-01-27 15:35:25 +090049static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif)
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090050{
51 pm_cpu_prep = s3c2416_pm_prepare;
52 pm_cpu_sleep = s3c2416_cpu_suspend;
53
54 return 0;
55}
56
Kay Sievers4a858cf2011-12-21 16:01:38 -080057static struct subsys_interface s3c2416_pm_interface = {
58 .name = "s3c2416_pm",
59 .subsys = &s3c2416_subsys,
60 .add_dev = s3c2416_pm_add,
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090061};
62
63static __init int s3c2416_pm_init(void)
64{
Kay Sievers4a858cf2011-12-21 16:01:38 -080065 return subsys_interface_register(&s3c2416_pm_interface);
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090066}
67
68arch_initcall(s3c2416_pm_init);
Arnd Bergmann4f506da2015-02-27 05:50:22 +090069#endif
Rafael J. Wysockibb072c32011-04-22 22:03:21 +020070
71static void s3c2416_pm_resume(void)
72{
73 /* unset the return-from-sleep amd inform flags */
74 __raw_writel(0x0, S3C2443_PWRMODE);
75 __raw_writel(0x0, S3C2412_INFORM0);
76 __raw_writel(0x0, S3C2412_INFORM1);
77}
78
79struct syscore_ops s3c2416_pm_syscore_ops = {
80 .resume = s3c2416_pm_resume,
81};