diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-12-11 19:24:06 -0500 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2009-03-08 08:23:51 -0400 |
commit | 6419711a164ba1304fa8fbb75ae9485455e04dcd (patch) | |
tree | 15fe79b0ffff33d253258b849f1b69ac4c2c3bbe /arch/arm/plat-s3c | |
parent | a3f66351b3cc89011e8a34068c245b413ce696d6 (diff) |
[ARM] S3C: Move PM support functions to common location
Start moving the PM code by moving all the common support functions
to a common location in arch/arm/plat-s3c. With the move we rename
the functions from s3cxxx_ to s3c_ to fit the new location.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s3c')
-rw-r--r-- | arch/arm/plat-s3c/Makefile | 4 | ||||
-rw-r--r-- | arch/arm/plat-s3c/include/plat/pm.h | 36 | ||||
-rw-r--r-- | arch/arm/plat-s3c/pm.c | 97 |
3 files changed, 134 insertions, 3 deletions
diff --git a/arch/arm/plat-s3c/Makefile b/arch/arm/plat-s3c/Makefile index 39195f972d5e..afd8d089ba16 100644 --- a/arch/arm/plat-s3c/Makefile +++ b/arch/arm/plat-s3c/Makefile | |||
@@ -18,6 +18,10 @@ obj-y += pwm-clock.o | |||
18 | obj-y += gpio.o | 18 | obj-y += gpio.o |
19 | obj-y += gpio-config.o | 19 | obj-y += gpio-config.o |
20 | 20 | ||
21 | # PM support | ||
22 | |||
23 | obj-$(CONFIG_PM) += pm.o | ||
24 | |||
21 | # devices | 25 | # devices |
22 | 26 | ||
23 | obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o | 27 | obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o |
diff --git a/arch/arm/plat-s3c/include/plat/pm.h b/arch/arm/plat-s3c/include/plat/pm.h index cc623667e48a..a1520997ab82 100644 --- a/arch/arm/plat-s3c/include/plat/pm.h +++ b/arch/arm/plat-s3c/include/plat/pm.h | |||
@@ -1,6 +1,7 @@ | |||
1 | /* linux/include/asm-arm/plat-s3c24xx/pm.h | 1 | /* linux/include/asm-arm/plat-s3c24xx/pm.h |
2 | * | 2 | * |
3 | * Copyright (c) 2004 Simtec Electronics | 3 | * Copyright (c) 2004 Simtec Electronics |
4 | * http://armlinux.simtec.co.uk/ | ||
4 | * Written by Ben Dooks, <ben@simtec.co.uk> | 5 | * Written by Ben Dooks, <ben@simtec.co.uk> |
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -49,10 +50,18 @@ extern int s3c2410_cpu_save(unsigned long *saveblk); | |||
49 | extern void s3c2410_cpu_suspend(void); | 50 | extern void s3c2410_cpu_suspend(void); |
50 | extern void s3c2410_cpu_resume(void); | 51 | extern void s3c2410_cpu_resume(void); |
51 | 52 | ||
52 | extern unsigned long s3c2410_sleep_save_phys; | 53 | extern unsigned long s3c_sleep_save_phys; |
53 | 54 | ||
54 | /* sleep save info */ | 55 | /* sleep save info */ |
55 | 56 | ||
57 | /** | ||
58 | * struct sleep_save - save information for shared peripherals. | ||
59 | * @reg: Pointer to the register to save. | ||
60 | * @val: Holder for the value saved from reg. | ||
61 | * | ||
62 | * This describes a list of registers which is used by the pm core and | ||
63 | * other subsystem to save and restore register values over suspend. | ||
64 | */ | ||
56 | struct sleep_save { | 65 | struct sleep_save { |
57 | void __iomem *reg; | 66 | void __iomem *reg; |
58 | unsigned long val; | 67 | unsigned long val; |
@@ -61,8 +70,11 @@ struct sleep_save { | |||
61 | #define SAVE_ITEM(x) \ | 70 | #define SAVE_ITEM(x) \ |
62 | { .reg = (x) } | 71 | { .reg = (x) } |
63 | 72 | ||
64 | extern void s3c2410_pm_do_save(struct sleep_save *ptr, int count); | 73 | /* helper functions to save/restore lists of registers. */ |
65 | extern void s3c2410_pm_do_restore(struct sleep_save *ptr, int count); | 74 | |
75 | extern void s3c_pm_do_save(struct sleep_save *ptr, int count); | ||
76 | extern void s3c_pm_do_restore(struct sleep_save *ptr, int count); | ||
77 | extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count); | ||
66 | 78 | ||
67 | #ifdef CONFIG_PM | 79 | #ifdef CONFIG_PM |
68 | extern int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state); | 80 | extern int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state); |
@@ -71,3 +83,21 @@ extern int s3c24xx_irq_resume(struct sys_device *dev); | |||
71 | #define s3c24xx_irq_suspend NULL | 83 | #define s3c24xx_irq_suspend NULL |
72 | #define s3c24xx_irq_resume NULL | 84 | #define s3c24xx_irq_resume NULL |
73 | #endif | 85 | #endif |
86 | |||
87 | /* PM debug functions */ | ||
88 | |||
89 | #ifdef CONFIG_S3C2410_PM_DEBUG | ||
90 | /** | ||
91 | * s3c_pm_dbg() - low level debug function for use in suspend/resume. | ||
92 | * @msg: The message to print. | ||
93 | * | ||
94 | * This function is used mainly to debug the resume process before the system | ||
95 | * can rely on printk/console output. It uses the low-level debugging output | ||
96 | * routine printascii() to do its work. | ||
97 | */ | ||
98 | extern void s3c_pm_dbg(const char *msg, ...); | ||
99 | |||
100 | #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt) | ||
101 | #else | ||
102 | #define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt) | ||
103 | #endif | ||
diff --git a/arch/arm/plat-s3c/pm.c b/arch/arm/plat-s3c/pm.c new file mode 100644 index 000000000000..122e9b91a7f4 --- /dev/null +++ b/arch/arm/plat-s3c/pm.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /* linux/arch/arm/plat-s3c/pm.c | ||
2 | * | ||
3 | * Copyright 2008 Openmoko, Inc. | ||
4 | * Copyright 2004,2006,2008 Simtec Electronics | ||
5 | * Ben Dooks <ben@simtec.co.uk> | ||
6 | * http://armlinux.simtec.co.uk/ | ||
7 | * | ||
8 | * S3C common power management (suspend to ram) support. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/init.h> | ||
16 | #include <linux/suspend.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/io.h> | ||
19 | |||
20 | #include <plat/pm.h> | ||
21 | |||
22 | /* for external use */ | ||
23 | |||
24 | unsigned long s3c_pm_flags; | ||
25 | |||
26 | #ifdef CONFIG_S3C2410_PM_DEBUG | ||
27 | extern void printascii(const char *); | ||
28 | |||
29 | void s3c_pm_dbg(const char *fmt, ...) | ||
30 | { | ||
31 | va_list va; | ||
32 | char buff[256]; | ||
33 | |||
34 | va_start(va, fmt); | ||
35 | vsprintf(buff, fmt, va); | ||
36 | va_end(va); | ||
37 | |||
38 | printascii(buff); | ||
39 | } | ||
40 | #endif /* CONFIG_S3C2410_PM_DEBUG */ | ||
41 | |||
42 | |||
43 | /* helper functions to save and restore register state */ | ||
44 | |||
45 | /** | ||
46 | * s3c_pm_do_save() - save a set of registers for restoration on resume. | ||
47 | * @ptr: Pointer to an array of registers. | ||
48 | * @count: Size of the ptr array. | ||
49 | * | ||
50 | * Run through the list of registers given, saving their contents in the | ||
51 | * array for later restoration when we wakeup. | ||
52 | */ | ||
53 | void s3c_pm_do_save(struct sleep_save *ptr, int count) | ||
54 | { | ||
55 | for (; count > 0; count--, ptr++) { | ||
56 | ptr->val = __raw_readl(ptr->reg); | ||
57 | S3C_PMDBG("saved %p value %08lx\n", ptr->reg, ptr->val); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * s3c_pm_do_restore() - restore register values from the save list. | ||
63 | * @ptr: Pointer to an array of registers. | ||
64 | * @count: Size of the ptr array. | ||
65 | * | ||
66 | * Restore the register values saved from s3c_pm_do_save(). | ||
67 | * | ||
68 | * Note, we do not use S3C_PMDBG() in here, as the system may not have | ||
69 | * restore the UARTs state yet | ||
70 | */ | ||
71 | |||
72 | void s3c_pm_do_restore(struct sleep_save *ptr, int count) | ||
73 | { | ||
74 | for (; count > 0; count--, ptr++) { | ||
75 | printk(KERN_DEBUG "restore %p (restore %08lx, was %08x)\n", | ||
76 | ptr->reg, ptr->val, __raw_readl(ptr->reg)); | ||
77 | |||
78 | __raw_writel(ptr->val, ptr->reg); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * s3c_pm_do_restore_core() - early restore register values from save list. | ||
84 | * | ||
85 | * This is similar to s3c_pm_do_restore() except we try and minimise the | ||
86 | * side effects of the function in case registers that hardware might need | ||
87 | * to work has been restored. | ||
88 | * | ||
89 | * WARNING: Do not put any debug in here that may effect memory or use | ||
90 | * peripherals, as things may be changing! | ||
91 | */ | ||
92 | |||
93 | void s3c_pm_do_restore_core(struct sleep_save *ptr, int count) | ||
94 | { | ||
95 | for (; count > 0; count--, ptr++) | ||
96 | __raw_writel(ptr->val, ptr->reg); | ||
97 | } | ||