^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) // Copyright (c) 2010 Samsung Electronics Co., Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) // http://www.samsung.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) // S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/syscore_ops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/cacheflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "regs-s3c2443-clock.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "cpu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "pm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "s3c2412-power.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #ifdef CONFIG_PM_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern void s3c2412_sleep_enter(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static int s3c2416_cpu_suspend(unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* enable wakeup sources regardless of battery state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /* set the mode as sleep, 2BED represents "Go to BED" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) __raw_writel(0x2BED, S3C2443_PWRMODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) s3c2412_sleep_enter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) pr_info("Failed to suspend the system\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return 1; /* Aborting suspend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static void s3c2416_pm_prepare(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * write the magic value u-boot uses to check for resume into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * the INFORM0 register, and ensure INFORM1 is set to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * correct address to resume from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) __raw_writel(0x2BED, S3C2412_INFORM0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) __raw_writel(__pa_symbol(s3c_cpu_resume), S3C2412_INFORM1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) pm_cpu_prep = s3c2416_pm_prepare;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) pm_cpu_sleep = s3c2416_cpu_suspend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static struct subsys_interface s3c2416_pm_interface = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .name = "s3c2416_pm",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) .subsys = &s3c2416_subsys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .add_dev = s3c2416_pm_add,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static __init int s3c2416_pm_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return subsys_interface_register(&s3c2416_pm_interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) arch_initcall(s3c2416_pm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static void s3c2416_pm_resume(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* unset the return-from-sleep amd inform flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) __raw_writel(0x0, S3C2443_PWRMODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) __raw_writel(0x0, S3C2412_INFORM0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __raw_writel(0x0, S3C2412_INFORM1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct syscore_ops s3c2416_pm_syscore_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .resume = s3c2416_pm_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };