diff options
-rw-r--r-- | arch/arm/plat-samsung/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/plat-samsung/include/plat/pm-common.h | 26 | ||||
-rw-r--r-- | arch/arm/plat-samsung/include/plat/pm.h | 25 | ||||
-rw-r--r-- | arch/arm/plat-samsung/pm-common.c | 75 | ||||
-rw-r--r-- | arch/arm/plat-samsung/pm.c | 56 |
5 files changed, 102 insertions, 81 deletions
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile index ba30a16b3ca8..25c826ed3b65 100644 --- a/arch/arm/plat-samsung/Makefile +++ b/arch/arm/plat-samsung/Makefile | |||
@@ -47,6 +47,7 @@ obj-$(CONFIG_SAMSUNG_DMADEV) += dma-ops.o | |||
47 | 47 | ||
48 | # PM support | 48 | # PM support |
49 | 49 | ||
50 | obj-$(CONFIG_PM_SLEEP) += pm-common.o | ||
50 | obj-$(CONFIG_SAMSUNG_PM) += pm.o | 51 | obj-$(CONFIG_SAMSUNG_PM) += pm.o |
51 | obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o | 52 | obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o |
52 | obj-$(CONFIG_SAMSUNG_PM_CHECK) += pm-check.o | 53 | obj-$(CONFIG_SAMSUNG_PM_CHECK) += pm-check.o |
diff --git a/arch/arm/plat-samsung/include/plat/pm-common.h b/arch/arm/plat-samsung/include/plat/pm-common.h index f72974a762bf..741723eb8cd7 100644 --- a/arch/arm/plat-samsung/include/plat/pm-common.h +++ b/arch/arm/plat-samsung/include/plat/pm-common.h | |||
@@ -13,6 +13,32 @@ | |||
13 | #ifndef __PLAT_SAMSUNG_PM_COMMON_H | 13 | #ifndef __PLAT_SAMSUNG_PM_COMMON_H |
14 | #define __PLAT_SAMSUNG_PM_COMMON_H __FILE__ | 14 | #define __PLAT_SAMSUNG_PM_COMMON_H __FILE__ |
15 | 15 | ||
16 | #include <linux/irq.h> | ||
17 | |||
18 | /* sleep save info */ | ||
19 | |||
20 | /** | ||
21 | * struct sleep_save - save information for shared peripherals. | ||
22 | * @reg: Pointer to the register to save. | ||
23 | * @val: Holder for the value saved from reg. | ||
24 | * | ||
25 | * This describes a list of registers which is used by the pm core and | ||
26 | * other subsystem to save and restore register values over suspend. | ||
27 | */ | ||
28 | struct sleep_save { | ||
29 | void __iomem *reg; | ||
30 | unsigned long val; | ||
31 | }; | ||
32 | |||
33 | #define SAVE_ITEM(x) \ | ||
34 | { .reg = (x) } | ||
35 | |||
36 | /* helper functions to save/restore lists of registers. */ | ||
37 | |||
38 | extern void s3c_pm_do_save(struct sleep_save *ptr, int count); | ||
39 | extern void s3c_pm_do_restore(const struct sleep_save *ptr, int count); | ||
40 | extern void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count); | ||
41 | |||
16 | /* PM debug functions */ | 42 | /* PM debug functions */ |
17 | 43 | ||
18 | /** | 44 | /** |
diff --git a/arch/arm/plat-samsung/include/plat/pm.h b/arch/arm/plat-samsung/include/plat/pm.h index 2e04396eb3f3..4099e8d6f5f9 100644 --- a/arch/arm/plat-samsung/include/plat/pm.h +++ b/arch/arm/plat-samsung/include/plat/pm.h | |||
@@ -15,7 +15,6 @@ | |||
15 | * management | 15 | * management |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/irq.h> | ||
19 | #include <plat/pm-common.h> | 18 | #include <plat/pm-common.h> |
20 | 19 | ||
21 | struct device; | 20 | struct device; |
@@ -59,30 +58,6 @@ extern unsigned long s3c_pm_flags; | |||
59 | 58 | ||
60 | extern int s3c2410_cpu_suspend(unsigned long); | 59 | extern int s3c2410_cpu_suspend(unsigned long); |
61 | 60 | ||
62 | /* sleep save info */ | ||
63 | |||
64 | /** | ||
65 | * struct sleep_save - save information for shared peripherals. | ||
66 | * @reg: Pointer to the register to save. | ||
67 | * @val: Holder for the value saved from reg. | ||
68 | * | ||
69 | * This describes a list of registers which is used by the pm core and | ||
70 | * other subsystem to save and restore register values over suspend. | ||
71 | */ | ||
72 | struct sleep_save { | ||
73 | void __iomem *reg; | ||
74 | unsigned long val; | ||
75 | }; | ||
76 | |||
77 | #define SAVE_ITEM(x) \ | ||
78 | { .reg = (x) } | ||
79 | |||
80 | /* helper functions to save/restore lists of registers. */ | ||
81 | |||
82 | extern void s3c_pm_do_save(struct sleep_save *ptr, int count); | ||
83 | extern void s3c_pm_do_restore(const struct sleep_save *ptr, int count); | ||
84 | extern void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count); | ||
85 | |||
86 | #ifdef CONFIG_SAMSUNG_PM | 61 | #ifdef CONFIG_SAMSUNG_PM |
87 | extern int s3c_irq_wake(struct irq_data *data, unsigned int state); | 62 | extern int s3c_irq_wake(struct irq_data *data, unsigned int state); |
88 | extern int s3c_irqext_wake(struct irq_data *data, unsigned int state); | 63 | extern int s3c_irqext_wake(struct irq_data *data, unsigned int state); |
diff --git a/arch/arm/plat-samsung/pm-common.c b/arch/arm/plat-samsung/pm-common.c new file mode 100644 index 000000000000..515cd53372bd --- /dev/null +++ b/arch/arm/plat-samsung/pm-common.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2013 Samsung Electronics Co., Ltd. | ||
3 | * Tomasz Figa <t.figa@samsung.com> | ||
4 | * Copyright (C) 2008 Openmoko, Inc. | ||
5 | * Copyright (C) 2004-2008 Simtec Electronics | ||
6 | * Ben Dooks <ben@simtec.co.uk> | ||
7 | * http://armlinux.simtec.co.uk/ | ||
8 | * | ||
9 | * Samsung common power management helper functions. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/io.h> | ||
17 | #include <linux/kernel.h> | ||
18 | |||
19 | #include <plat/pm-common.h> | ||
20 | |||
21 | /* helper functions to save and restore register state */ | ||
22 | |||
23 | /** | ||
24 | * s3c_pm_do_save() - save a set of registers for restoration on resume. | ||
25 | * @ptr: Pointer to an array of registers. | ||
26 | * @count: Size of the ptr array. | ||
27 | * | ||
28 | * Run through the list of registers given, saving their contents in the | ||
29 | * array for later restoration when we wakeup. | ||
30 | */ | ||
31 | void s3c_pm_do_save(struct sleep_save *ptr, int count) | ||
32 | { | ||
33 | for (; count > 0; count--, ptr++) { | ||
34 | ptr->val = __raw_readl(ptr->reg); | ||
35 | S3C_PMDBG("saved %p value %08lx\n", ptr->reg, ptr->val); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * s3c_pm_do_restore() - restore register values from the save list. | ||
41 | * @ptr: Pointer to an array of registers. | ||
42 | * @count: Size of the ptr array. | ||
43 | * | ||
44 | * Restore the register values saved from s3c_pm_do_save(). | ||
45 | * | ||
46 | * Note, we do not use S3C_PMDBG() in here, as the system may not have | ||
47 | * restore the UARTs state yet | ||
48 | */ | ||
49 | |||
50 | void s3c_pm_do_restore(const struct sleep_save *ptr, int count) | ||
51 | { | ||
52 | for (; count > 0; count--, ptr++) { | ||
53 | pr_debug("restore %p (restore %08lx, was %08x)\n", | ||
54 | ptr->reg, ptr->val, __raw_readl(ptr->reg)); | ||
55 | |||
56 | __raw_writel(ptr->val, ptr->reg); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * s3c_pm_do_restore_core() - early restore register values from save list. | ||
62 | * | ||
63 | * This is similar to s3c_pm_do_restore() except we try and minimise the | ||
64 | * side effects of the function in case registers that hardware might need | ||
65 | * to work has been restored. | ||
66 | * | ||
67 | * WARNING: Do not put any debug in here that may effect memory or use | ||
68 | * peripherals, as things may be changing! | ||
69 | */ | ||
70 | |||
71 | void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count) | ||
72 | { | ||
73 | for (; count > 0; count--, ptr++) | ||
74 | __raw_writel(ptr->val, ptr->reg); | ||
75 | } | ||
diff --git a/arch/arm/plat-samsung/pm.c b/arch/arm/plat-samsung/pm.c index 3d523c90202a..c08bc51201fc 100644 --- a/arch/arm/plat-samsung/pm.c +++ b/arch/arm/plat-samsung/pm.c | |||
@@ -66,62 +66,6 @@ int s3c_irqext_wake(struct irq_data *data, unsigned int state) | |||
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | /* helper functions to save and restore register state */ | ||
70 | |||
71 | /** | ||
72 | * s3c_pm_do_save() - save a set of registers for restoration on resume. | ||
73 | * @ptr: Pointer to an array of registers. | ||
74 | * @count: Size of the ptr array. | ||
75 | * | ||
76 | * Run through the list of registers given, saving their contents in the | ||
77 | * array for later restoration when we wakeup. | ||
78 | */ | ||
79 | void s3c_pm_do_save(struct sleep_save *ptr, int count) | ||
80 | { | ||
81 | for (; count > 0; count--, ptr++) { | ||
82 | ptr->val = __raw_readl(ptr->reg); | ||
83 | S3C_PMDBG("saved %p value %08lx\n", ptr->reg, ptr->val); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * s3c_pm_do_restore() - restore register values from the save list. | ||
89 | * @ptr: Pointer to an array of registers. | ||
90 | * @count: Size of the ptr array. | ||
91 | * | ||
92 | * Restore the register values saved from s3c_pm_do_save(). | ||
93 | * | ||
94 | * Note, we do not use S3C_PMDBG() in here, as the system may not have | ||
95 | * restore the UARTs state yet | ||
96 | */ | ||
97 | |||
98 | void s3c_pm_do_restore(const struct sleep_save *ptr, int count) | ||
99 | { | ||
100 | for (; count > 0; count--, ptr++) { | ||
101 | printk(KERN_DEBUG "restore %p (restore %08lx, was %08x)\n", | ||
102 | ptr->reg, ptr->val, __raw_readl(ptr->reg)); | ||
103 | |||
104 | __raw_writel(ptr->val, ptr->reg); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * s3c_pm_do_restore_core() - early restore register values from save list. | ||
110 | * | ||
111 | * This is similar to s3c_pm_do_restore() except we try and minimise the | ||
112 | * side effects of the function in case registers that hardware might need | ||
113 | * to work has been restored. | ||
114 | * | ||
115 | * WARNING: Do not put any debug in here that may effect memory or use | ||
116 | * peripherals, as things may be changing! | ||
117 | */ | ||
118 | |||
119 | void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count) | ||
120 | { | ||
121 | for (; count > 0; count--, ptr++) | ||
122 | __raw_writel(ptr->val, ptr->reg); | ||
123 | } | ||
124 | |||
125 | /* s3c2410_pm_show_resume_irqs | 69 | /* s3c2410_pm_show_resume_irqs |
126 | * | 70 | * |
127 | * print any IRQs asserted at resume time (ie, we woke from) | 71 | * print any IRQs asserted at resume time (ie, we woke from) |