2017-12-25 20:54:32 +01:00
// SPDX-License-Identifier: GPL-2.0
//
// Copyright (c) 2010 Samsung Electronics Co., Ltd.
// http://www.samsung.com
//
// S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
2010-10-20 19:43:35 +09:00
2011-12-21 16:01:38 -08:00
# include <linux/device.h>
2011-04-22 22:03:21 +02:00
# include <linux/syscore_ops.h>
2010-10-20 19:43:35 +09:00
# include <linux/io.h>
# include <asm/cacheflush.h>
# include <mach/regs-s3c2443-clock.h>
# include <plat/cpu.h>
# include <plat/pm.h>
2013-02-01 21:49:35 -08:00
# include "s3c2412-power.h"
2015-02-27 05:50:22 +09:00
# ifdef CONFIG_PM_SLEEP
2010-10-20 19:43:35 +09:00
extern void s3c2412_sleep_enter ( void ) ;
2011-07-02 09:54:01 +01:00
static int s3c2416_cpu_suspend ( unsigned long arg )
2010-10-20 19:43:35 +09:00
{
/* enable wakeup sources regardless of battery state */
__raw_writel ( S3C2443_PWRCFG_SLEEP , S3C2443_PWRCFG ) ;
/* set the mode as sleep, 2BED represents "Go to BED" */
__raw_writel ( 0x2BED , S3C2443_PWRMODE ) ;
s3c2412_sleep_enter ( ) ;
2011-07-02 09:54:01 +01:00
2013-01-25 10:40:19 -08:00
pr_info ( " Failed to suspend the system \n " ) ;
return 1 ; /* Aborting suspend */
2010-10-20 19:43:35 +09:00
}
static void s3c2416_pm_prepare ( void )
{
/*
* write the magic value u - boot uses to check for resume into
* the INFORM0 register , and ensure INFORM1 is set to the
* correct address to resume from .
*/
__raw_writel ( 0x2BED , S3C2412_INFORM0 ) ;
2017-01-15 03:59:29 +01:00
__raw_writel ( __pa_symbol ( s3c_cpu_resume ) , S3C2412_INFORM1 ) ;
2010-10-20 19:43:35 +09:00
}
2012-01-27 15:35:25 +09:00
static int s3c2416_pm_add ( struct device * dev , struct subsys_interface * sif )
2010-10-20 19:43:35 +09:00
{
pm_cpu_prep = s3c2416_pm_prepare ;
pm_cpu_sleep = s3c2416_cpu_suspend ;
return 0 ;
}
2011-12-21 16:01:38 -08:00
static struct subsys_interface s3c2416_pm_interface = {
. name = " s3c2416_pm " ,
. subsys = & s3c2416_subsys ,
. add_dev = s3c2416_pm_add ,
2011-04-22 22:03:21 +02:00
} ;
static __init int s3c2416_pm_init ( void )
2010-10-20 19:43:35 +09:00
{
2011-12-21 16:01:38 -08:00
return subsys_interface_register ( & s3c2416_pm_interface ) ;
2010-10-20 19:43:35 +09:00
}
2011-04-22 22:03:21 +02:00
arch_initcall ( s3c2416_pm_init ) ;
2015-02-27 05:50:22 +09:00
# endif
2011-04-22 22:03:21 +02:00
static void s3c2416_pm_resume ( void )
2010-10-20 19:43:35 +09:00
{
/* unset the return-from-sleep amd inform flags */
__raw_writel ( 0x0 , S3C2443_PWRMODE ) ;
__raw_writel ( 0x0 , S3C2412_INFORM0 ) ;
__raw_writel ( 0x0 , S3C2412_INFORM1 ) ;
}
2011-04-22 22:03:21 +02:00
struct syscore_ops s3c2416_pm_syscore_ops = {
2010-10-20 19:43:35 +09:00
. resume = s3c2416_pm_resume ,
} ;