Ben Dooks | a21765a | 2007-02-11 18:31:01 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c2412/pm.c |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 2 | * |
| 3 | * Copyright (c) 2006 Simtec Electronics |
| 4 | * Ben Dooks <ben@simtec.co.uk> |
| 5 | * |
| 6 | * http://armlinux.simtec.co.uk/. |
| 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 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/list.h> |
| 17 | #include <linux/timer.h> |
| 18 | #include <linux/init.h> |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 19 | #include <linux/device.h> |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 20 | #include <linux/syscore_ops.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 21 | #include <linux/platform_device.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 22 | #include <linux/io.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 23 | |
Ben Dooks | dc8fc7e | 2009-04-28 10:06:00 +0100 | [diff] [blame] | 24 | #include <asm/cacheflush.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 25 | #include <asm/irq.h> |
| 26 | |
Kukjin Kim | b435378 | 2013-01-02 14:01:09 -0800 | [diff] [blame] | 27 | #include <mach/hardware.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/regs-gpio.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 29 | |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 30 | #include <plat/cpu.h> |
| 31 | #include <plat/pm.h> |
Ben Dooks | d5120ae | 2008-10-07 23:09:51 +0100 | [diff] [blame] | 32 | #include <plat/s3c2412.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 33 | |
Kukjin Kim | b435378 | 2013-01-02 14:01:09 -0800 | [diff] [blame] | 34 | #include "regs-dsc.h" |
Kukjin Kim | 14cce0e | 2013-02-01 21:49:35 -0800 | [diff] [blame^] | 35 | #include "s3c2412-power.h" |
Kukjin Kim | b435378 | 2013-01-02 14:01:09 -0800 | [diff] [blame] | 36 | |
Ben Dooks | 3323495 | 2007-12-23 03:09:34 +0100 | [diff] [blame] | 37 | extern void s3c2412_sleep_enter(void); |
| 38 | |
Russell King | 29cb3cd | 2011-07-02 09:54:01 +0100 | [diff] [blame] | 39 | static int s3c2412_cpu_suspend(unsigned long arg) |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 40 | { |
| 41 | unsigned long tmp; |
| 42 | |
| 43 | /* set our standby method to sleep */ |
| 44 | |
| 45 | tmp = __raw_readl(S3C2412_PWRCFG); |
| 46 | tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP; |
| 47 | __raw_writel(tmp, S3C2412_PWRCFG); |
| 48 | |
Ben Dooks | 3323495 | 2007-12-23 03:09:34 +0100 | [diff] [blame] | 49 | s3c2412_sleep_enter(); |
Russell King | 29cb3cd | 2011-07-02 09:54:01 +0100 | [diff] [blame] | 50 | |
| 51 | panic("sleep resumed to originator?"); |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | static void s3c2412_pm_prepare(void) |
| 55 | { |
| 56 | } |
| 57 | |
Heiko Stuebner | 04511a6 | 2012-01-27 15:35:25 +0900 | [diff] [blame] | 58 | static int s3c2412_pm_add(struct device *dev, struct subsys_interface *sif) |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 59 | { |
| 60 | pm_cpu_prep = s3c2412_pm_prepare; |
| 61 | pm_cpu_sleep = s3c2412_cpu_suspend; |
| 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static struct sleep_save s3c2412_sleep[] = { |
| 67 | SAVE_ITEM(S3C2412_DSC0), |
| 68 | SAVE_ITEM(S3C2412_DSC1), |
| 69 | SAVE_ITEM(S3C2413_GPJDAT), |
| 70 | SAVE_ITEM(S3C2413_GPJCON), |
| 71 | SAVE_ITEM(S3C2413_GPJUP), |
| 72 | |
| 73 | /* save the PWRCFG to get back to original sleep method */ |
| 74 | |
| 75 | SAVE_ITEM(S3C2412_PWRCFG), |
| 76 | |
| 77 | /* save the sleep configuration anyway, just in case these |
| 78 | * get damaged during wakeup */ |
| 79 | |
| 80 | SAVE_ITEM(S3C2412_GPBSLPCON), |
| 81 | SAVE_ITEM(S3C2412_GPCSLPCON), |
| 82 | SAVE_ITEM(S3C2412_GPDSLPCON), |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 83 | SAVE_ITEM(S3C2412_GPFSLPCON), |
| 84 | SAVE_ITEM(S3C2412_GPGSLPCON), |
| 85 | SAVE_ITEM(S3C2412_GPHSLPCON), |
| 86 | SAVE_ITEM(S3C2413_GPJSLPCON), |
| 87 | }; |
| 88 | |
Kay Sievers | 4a858cf | 2011-12-21 16:01:38 -0800 | [diff] [blame] | 89 | static struct subsys_interface s3c2412_pm_interface = { |
| 90 | .name = "s3c2412_pm", |
| 91 | .subsys = &s3c2412_subsys, |
| 92 | .add_dev = s3c2412_pm_add, |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | static __init int s3c2412_pm_init(void) |
| 96 | { |
Kukjin Kim | ea04018 | 2012-01-06 16:08:09 +0900 | [diff] [blame] | 97 | return subsys_interface_register(&s3c2412_pm_interface); |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | arch_initcall(s3c2412_pm_init); |
| 101 | |
| 102 | static int s3c2412_pm_suspend(void) |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 103 | { |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 104 | s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 105 | return 0; |
| 106 | } |
| 107 | |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 108 | static void s3c2412_pm_resume(void) |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 109 | { |
| 110 | unsigned long tmp; |
| 111 | |
| 112 | tmp = __raw_readl(S3C2412_PWRCFG); |
| 113 | tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK; |
| 114 | tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE; |
| 115 | __raw_writel(tmp, S3C2412_PWRCFG); |
| 116 | |
Ben Dooks | 6419711 | 2008-12-12 00:24:06 +0000 | [diff] [blame] | 117 | s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 118 | } |
| 119 | |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 120 | struct syscore_ops s3c2412_pm_syscore_ops = { |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 121 | .suspend = s3c2412_pm_suspend, |
| 122 | .resume = s3c2412_pm_resume, |
| 123 | }; |