1 /* linux/arch/arm/mach-s5pv210/pm.c
3 * Copyright (c) 2010-2014 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
6 * S5PV210 - Power Management support
8 * Based on arch/arm/mach-s3c2410/pm.c
9 * Copyright (c) 2006 Simtec Electronics
10 * Ben Dooks <ben@simtec.co.uk>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
17 #include <linux/init.h>
18 #include <linux/suspend.h>
19 #include <linux/syscore_ops.h>
22 #include <asm/cacheflush.h>
23 #include <asm/suspend.h>
25 #include <plat/pm-common.h>
27 #include <mach/regs-clock.h>
31 static struct sleep_save s5pv210_core_save[] = {
33 SAVE_ITEM(S5P_MDNIE_SEL),
37 * VIC wake-up support (TODO)
39 static u32 s5pv210_irqwake_intmask = 0xffffffff;
44 static int s5pv210_cpu_suspend(unsigned long arg)
48 /* issue the standby signal into the pm unit. Note, we
49 * issue a write-buffer drain just in case */
56 "mcr p15, 0, %0, c7, c10, 5\n\t"
57 "mcr p15, 0, %0, c7, c10, 4\n\t"
60 pr_info("Failed to suspend the system\n");
61 return 1; /* Aborting suspend */
64 static void s5pv210_pm_prepare(void)
68 /* Set wake-up mask registers */
69 __raw_writel(exynos_get_eint_wake_mask(), S5P_EINT_WAKEUP_MASK);
70 __raw_writel(s5pv210_irqwake_intmask, S5P_WAKEUP_MASK);
72 /* ensure at least INFORM0 has the resume address */
73 __raw_writel(virt_to_phys(s5pv210_cpu_resume), S5P_INFORM0);
75 tmp = __raw_readl(S5P_SLEEP_CFG);
76 tmp &= ~(S5P_SLEEP_CFG_OSC_EN | S5P_SLEEP_CFG_USBOSC_EN);
77 __raw_writel(tmp, S5P_SLEEP_CFG);
79 /* WFI for SLEEP mode configuration by SYSCON */
80 tmp = __raw_readl(S5P_PWR_CFG);
81 tmp &= S5P_CFG_WFI_CLEAN;
82 tmp |= S5P_CFG_WFI_SLEEP;
83 __raw_writel(tmp, S5P_PWR_CFG);
85 /* SYSCON interrupt handling disable */
86 tmp = __raw_readl(S5P_OTHERS);
87 tmp |= S5P_OTHER_SYSC_INTOFF;
88 __raw_writel(tmp, S5P_OTHERS);
90 s3c_pm_do_save(s5pv210_core_save, ARRAY_SIZE(s5pv210_core_save));
96 static int s5pv210_suspend_enter(suspend_state_t state)
102 S3C_PMDBG("%s: suspending the system...\n", __func__);
104 S3C_PMDBG("%s: wakeup masks: %08x,%08x\n", __func__,
105 s5pv210_irqwake_intmask, exynos_get_eint_wake_mask());
107 if (s5pv210_irqwake_intmask == -1U
108 && exynos_get_eint_wake_mask() == -1U) {
109 pr_err("%s: No wake-up sources!\n", __func__);
110 pr_err("%s: Aborting sleep\n", __func__);
115 s5pv210_pm_prepare();
117 s3c_pm_check_store();
119 ret = cpu_suspend(0, s5pv210_cpu_suspend);
123 s3c_pm_restore_uarts();
125 S3C_PMDBG("%s: wakeup stat: %08x\n", __func__,
126 __raw_readl(S5P_WAKEUP_STAT));
128 s3c_pm_check_restore();
130 S3C_PMDBG("%s: resuming the system...\n", __func__);
135 static int s5pv210_suspend_prepare(void)
137 s3c_pm_check_prepare();
142 static void s5pv210_suspend_finish(void)
144 s3c_pm_check_cleanup();
147 static const struct platform_suspend_ops s5pv210_suspend_ops = {
148 .enter = s5pv210_suspend_enter,
149 .prepare = s5pv210_suspend_prepare,
150 .finish = s5pv210_suspend_finish,
151 .valid = suspend_valid_only_mem,
155 * Syscore operations used to delay restore of certain registers.
157 static void s5pv210_pm_resume(void)
161 tmp = __raw_readl(S5P_OTHERS);
162 tmp |= (S5P_OTHERS_RET_IO | S5P_OTHERS_RET_CF |\
163 S5P_OTHERS_RET_MMC | S5P_OTHERS_RET_UART);
164 __raw_writel(tmp , S5P_OTHERS);
166 s3c_pm_do_restore_core(s5pv210_core_save, ARRAY_SIZE(s5pv210_core_save));
169 static struct syscore_ops s5pv210_pm_syscore_ops = {
170 .resume = s5pv210_pm_resume,
174 * Initialization entry point.
176 void __init s5pv210_pm_init(void)
178 register_syscore_ops(&s5pv210_pm_syscore_ops);
179 suspend_set_ops(&s5pv210_suspend_ops);