| Abhilash Kesavan | 6436b6a | 2010-10-20 19:43:35 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c2416/pm.c | 
|  | 2 | * | 
|  | 3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | 
|  | 4 | *		http://www.samsung.com | 
|  | 5 | * | 
|  | 6 | * S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support) | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or modify | 
|  | 9 | * it under the terms of the GNU General Public License version 2 as | 
|  | 10 | * published by the Free Software Foundation. | 
|  | 11 | */ | 
|  | 12 |  | 
| Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 13 | #include <linux/device.h> | 
| Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 14 | #include <linux/syscore_ops.h> | 
| Abhilash Kesavan | 6436b6a | 2010-10-20 19:43:35 +0900 | [diff] [blame] | 15 | #include <linux/io.h> | 
|  | 16 |  | 
|  | 17 | #include <asm/cacheflush.h> | 
|  | 18 |  | 
|  | 19 | #include <mach/regs-power.h> | 
|  | 20 | #include <mach/regs-s3c2443-clock.h> | 
|  | 21 |  | 
|  | 22 | #include <plat/cpu.h> | 
|  | 23 | #include <plat/pm.h> | 
|  | 24 |  | 
|  | 25 | extern void s3c2412_sleep_enter(void); | 
|  | 26 |  | 
| Russell King | 29cb3cd | 2011-07-02 09:54:01 +0100 | [diff] [blame] | 27 | static int s3c2416_cpu_suspend(unsigned long arg) | 
| Abhilash Kesavan | 6436b6a | 2010-10-20 19:43:35 +0900 | [diff] [blame] | 28 | { | 
| Abhilash Kesavan | 6436b6a | 2010-10-20 19:43:35 +0900 | [diff] [blame] | 29 | /* enable wakeup sources regardless of battery state */ | 
|  | 30 | __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG); | 
|  | 31 |  | 
|  | 32 | /* set the mode as sleep, 2BED represents "Go to BED" */ | 
|  | 33 | __raw_writel(0x2BED, S3C2443_PWRMODE); | 
|  | 34 |  | 
|  | 35 | s3c2412_sleep_enter(); | 
| Russell King | 29cb3cd | 2011-07-02 09:54:01 +0100 | [diff] [blame] | 36 |  | 
|  | 37 | panic("sleep resumed to originator?"); | 
| Abhilash Kesavan | 6436b6a | 2010-10-20 19:43:35 +0900 | [diff] [blame] | 38 | } | 
|  | 39 |  | 
|  | 40 | static void s3c2416_pm_prepare(void) | 
|  | 41 | { | 
|  | 42 | /* | 
|  | 43 | * write the magic value u-boot uses to check for resume into | 
|  | 44 | * the INFORM0 register, and ensure INFORM1 is set to the | 
|  | 45 | * correct address to resume from. | 
|  | 46 | */ | 
|  | 47 | __raw_writel(0x2BED, S3C2412_INFORM0); | 
|  | 48 | __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1); | 
|  | 49 | } | 
|  | 50 |  | 
| Heiko Stuebner | 04511a6 | 2012-01-27 15:35:25 +0900 | [diff] [blame] | 51 | static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif) | 
| Abhilash Kesavan | 6436b6a | 2010-10-20 19:43:35 +0900 | [diff] [blame] | 52 | { | 
|  | 53 | pm_cpu_prep = s3c2416_pm_prepare; | 
|  | 54 | pm_cpu_sleep = s3c2416_cpu_suspend; | 
|  | 55 |  | 
|  | 56 | return 0; | 
|  | 57 | } | 
|  | 58 |  | 
| Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 59 | static struct subsys_interface s3c2416_pm_interface = { | 
|  | 60 | .name		= "s3c2416_pm", | 
|  | 61 | .subsys		= &s3c2416_subsys, | 
|  | 62 | .add_dev	= s3c2416_pm_add, | 
| Abhilash Kesavan | 6436b6a | 2010-10-20 19:43:35 +0900 | [diff] [blame] | 63 | }; | 
|  | 64 |  | 
|  | 65 | static __init int s3c2416_pm_init(void) | 
|  | 66 | { | 
| Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 67 | return subsys_interface_register(&s3c2416_pm_interface); | 
| Abhilash Kesavan | 6436b6a | 2010-10-20 19:43:35 +0900 | [diff] [blame] | 68 | } | 
|  | 69 |  | 
|  | 70 | arch_initcall(s3c2416_pm_init); | 
| Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 71 |  | 
|  | 72 |  | 
|  | 73 | static void s3c2416_pm_resume(void) | 
|  | 74 | { | 
|  | 75 | /* unset the return-from-sleep amd inform flags */ | 
|  | 76 | __raw_writel(0x0, S3C2443_PWRMODE); | 
|  | 77 | __raw_writel(0x0, S3C2412_INFORM0); | 
|  | 78 | __raw_writel(0x0, S3C2412_INFORM1); | 
|  | 79 | } | 
|  | 80 |  | 
|  | 81 | struct syscore_ops s3c2416_pm_syscore_ops = { | 
|  | 82 | .resume		= s3c2416_pm_resume, | 
|  | 83 | }; |