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> |
| 19 | #include <linux/sysdev.h> |
| 20 | #include <linux/platform_device.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 21 | #include <linux/io.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 22 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 23 | #include <mach/hardware.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 24 | #include <asm/irq.h> |
| 25 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/regs-power.h> |
| 27 | #include <mach/regs-gpioj.h> |
| 28 | #include <mach/regs-gpio.h> |
| 29 | #include <mach/regs-dsc.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 30 | |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 31 | #include <plat/cpu.h> |
| 32 | #include <plat/pm.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 33 | |
Ben Dooks | d5120ae | 2008-10-07 23:09:51 +0100 | [diff] [blame] | 34 | #include <plat/s3c2412.h> |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 35 | |
Ben Dooks | 3323495 | 2007-12-23 03:09:34 +0100 | [diff] [blame] | 36 | extern void s3c2412_sleep_enter(void); |
| 37 | |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 38 | static void s3c2412_cpu_suspend(void) |
| 39 | { |
| 40 | unsigned long tmp; |
| 41 | |
| 42 | /* set our standby method to sleep */ |
| 43 | |
| 44 | tmp = __raw_readl(S3C2412_PWRCFG); |
| 45 | tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP; |
| 46 | __raw_writel(tmp, S3C2412_PWRCFG); |
| 47 | |
Ben Dooks | 3323495 | 2007-12-23 03:09:34 +0100 | [diff] [blame] | 48 | s3c2412_sleep_enter(); |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | static void s3c2412_pm_prepare(void) |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | static int s3c2412_pm_add(struct sys_device *sysdev) |
| 56 | { |
| 57 | pm_cpu_prep = s3c2412_pm_prepare; |
| 58 | pm_cpu_sleep = s3c2412_cpu_suspend; |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | static struct sleep_save s3c2412_sleep[] = { |
| 64 | SAVE_ITEM(S3C2412_DSC0), |
| 65 | SAVE_ITEM(S3C2412_DSC1), |
| 66 | SAVE_ITEM(S3C2413_GPJDAT), |
| 67 | SAVE_ITEM(S3C2413_GPJCON), |
| 68 | SAVE_ITEM(S3C2413_GPJUP), |
| 69 | |
| 70 | /* save the PWRCFG to get back to original sleep method */ |
| 71 | |
| 72 | SAVE_ITEM(S3C2412_PWRCFG), |
| 73 | |
| 74 | /* save the sleep configuration anyway, just in case these |
| 75 | * get damaged during wakeup */ |
| 76 | |
| 77 | SAVE_ITEM(S3C2412_GPBSLPCON), |
| 78 | SAVE_ITEM(S3C2412_GPCSLPCON), |
| 79 | SAVE_ITEM(S3C2412_GPDSLPCON), |
Ben Dooks | 4b053e7 | 2006-09-22 15:42:18 +0100 | [diff] [blame] | 80 | SAVE_ITEM(S3C2412_GPFSLPCON), |
| 81 | SAVE_ITEM(S3C2412_GPGSLPCON), |
| 82 | SAVE_ITEM(S3C2412_GPHSLPCON), |
| 83 | SAVE_ITEM(S3C2413_GPJSLPCON), |
| 84 | }; |
| 85 | |
| 86 | static int s3c2412_pm_suspend(struct sys_device *dev, pm_message_t state) |
| 87 | { |
| 88 | s3c2410_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | static int s3c2412_pm_resume(struct sys_device *dev) |
| 93 | { |
| 94 | unsigned long tmp; |
| 95 | |
| 96 | tmp = __raw_readl(S3C2412_PWRCFG); |
| 97 | tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK; |
| 98 | tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE; |
| 99 | __raw_writel(tmp, S3C2412_PWRCFG); |
| 100 | |
| 101 | s3c2410_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); |
| 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | static struct sysdev_driver s3c2412_pm_driver = { |
| 106 | .add = s3c2412_pm_add, |
| 107 | .suspend = s3c2412_pm_suspend, |
| 108 | .resume = s3c2412_pm_resume, |
| 109 | }; |
| 110 | |
| 111 | static __init int s3c2412_pm_init(void) |
| 112 | { |
| 113 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver); |
| 114 | } |
| 115 | |
| 116 | arch_initcall(s3c2412_pm_init); |