Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // Copyright (c) 2010 Samsung Electronics Co., Ltd.
0004 //      http://www.samsung.com
0005 //
0006 // S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
0007 
0008 #include <linux/device.h>
0009 #include <linux/syscore_ops.h>
0010 #include <linux/io.h>
0011 
0012 #include <asm/cacheflush.h>
0013 
0014 #include "regs-s3c2443-clock.h"
0015 
0016 #include "cpu.h"
0017 #include "pm.h"
0018 
0019 #include "s3c2412-power.h"
0020 
0021 #ifdef CONFIG_PM_SLEEP
0022 extern void s3c2412_sleep_enter(void);
0023 
0024 static int s3c2416_cpu_suspend(unsigned long arg)
0025 {
0026     /* enable wakeup sources regardless of battery state */
0027     __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
0028 
0029     /* set the mode as sleep, 2BED represents "Go to BED" */
0030     __raw_writel(0x2BED, S3C2443_PWRMODE);
0031 
0032     s3c2412_sleep_enter();
0033 
0034     pr_info("Failed to suspend the system\n");
0035     return 1; /* Aborting suspend */
0036 }
0037 
0038 static void s3c2416_pm_prepare(void)
0039 {
0040     /*
0041      * write the magic value u-boot uses to check for resume into
0042      * the INFORM0 register, and ensure INFORM1 is set to the
0043      * correct address to resume from.
0044      */
0045     __raw_writel(0x2BED, S3C2412_INFORM0);
0046     __raw_writel(__pa_symbol(s3c_cpu_resume), S3C2412_INFORM1);
0047 }
0048 
0049 static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif)
0050 {
0051     pm_cpu_prep = s3c2416_pm_prepare;
0052     pm_cpu_sleep = s3c2416_cpu_suspend;
0053 
0054     return 0;
0055 }
0056 
0057 static struct subsys_interface s3c2416_pm_interface = {
0058     .name       = "s3c2416_pm",
0059     .subsys     = &s3c2416_subsys,
0060     .add_dev    = s3c2416_pm_add,
0061 };
0062 
0063 static __init int s3c2416_pm_init(void)
0064 {
0065     return subsys_interface_register(&s3c2416_pm_interface);
0066 }
0067 
0068 arch_initcall(s3c2416_pm_init);
0069 #endif
0070 
0071 static void s3c2416_pm_resume(void)
0072 {
0073     /* unset the return-from-sleep amd inform flags */
0074     __raw_writel(0x0, S3C2443_PWRMODE);
0075     __raw_writel(0x0, S3C2412_INFORM0);
0076     __raw_writel(0x0, S3C2412_INFORM1);
0077 }
0078 
0079 struct syscore_ops s3c2416_pm_syscore_ops = {
0080     .resume     = s3c2416_pm_resume,
0081 };