xref: /openbmc/linux/arch/arm/mach-shmobile/suspend.c (revision 3eb66e91a25497065c5322b1268cbc3953642227)
1*e2f2594bSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
2c3dada18SMagnus Damm /*
3c3dada18SMagnus Damm  * Suspend-to-RAM support code for SH-Mobile ARM
4c3dada18SMagnus Damm  *
5c3dada18SMagnus Damm  *  Copyright (C) 2011 Magnus Damm
6c3dada18SMagnus Damm  */
7c3dada18SMagnus Damm 
8c3dada18SMagnus Damm #include <linux/pm.h>
9c3dada18SMagnus Damm #include <linux/suspend.h>
10c3dada18SMagnus Damm #include <linux/module.h>
11c3dada18SMagnus Damm #include <linux/err.h>
12f7b861b7SThomas Gleixner #include <linux/cpu.h>
13f7b861b7SThomas Gleixner 
14c3dada18SMagnus Damm #include <asm/io.h>
159f97da78SDavid Howells #include <asm/system_misc.h>
16c3dada18SMagnus Damm 
172e41e5feSGeert Uytterhoeven #include "common.h"
182e41e5feSGeert Uytterhoeven 
shmobile_suspend_default_enter(suspend_state_t suspend_state)19c3dada18SMagnus Damm static int shmobile_suspend_default_enter(suspend_state_t suspend_state)
20c3dada18SMagnus Damm {
21c3dada18SMagnus Damm 	cpu_do_idle();
22c3dada18SMagnus Damm 	return 0;
23c3dada18SMagnus Damm }
24c3dada18SMagnus Damm 
shmobile_suspend_begin(suspend_state_t state)25c3dada18SMagnus Damm static int shmobile_suspend_begin(suspend_state_t state)
26c3dada18SMagnus Damm {
27f7b861b7SThomas Gleixner 	cpu_idle_poll_ctrl(true);
28c3dada18SMagnus Damm 	return 0;
29c3dada18SMagnus Damm }
30c3dada18SMagnus Damm 
shmobile_suspend_end(void)31c3dada18SMagnus Damm static void shmobile_suspend_end(void)
32c3dada18SMagnus Damm {
33f7b861b7SThomas Gleixner 	cpu_idle_poll_ctrl(false);
34c3dada18SMagnus Damm }
35c3dada18SMagnus Damm 
36c3dada18SMagnus Damm struct platform_suspend_ops shmobile_suspend_ops = {
37c3dada18SMagnus Damm 	.begin		= shmobile_suspend_begin,
38c3dada18SMagnus Damm 	.end		= shmobile_suspend_end,
39c3dada18SMagnus Damm 	.enter		= shmobile_suspend_default_enter,
40c3dada18SMagnus Damm 	.valid		= suspend_valid_only_mem,
41c3dada18SMagnus Damm };
42c3dada18SMagnus Damm 
shmobile_suspend_init(void)4321cc1b7eSShawn Guo int __init shmobile_suspend_init(void)
44c3dada18SMagnus Damm {
45c3dada18SMagnus Damm 	suspend_set_ops(&shmobile_suspend_ops);
46c3dada18SMagnus Damm 	return 0;
47c3dada18SMagnus Damm }
48