forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 ea08eeccae9297f7aabd2ef7f0c2517ac4549acc
kernel/arch/arm/mach-s5pv210/pm.c
....@@ -13,14 +13,55 @@
1313 #include <linux/suspend.h>
1414 #include <linux/syscore_ops.h>
1515 #include <linux/io.h>
16
+#include <linux/soc/samsung/s3c-pm.h>
1617
1718 #include <asm/cacheflush.h>
1819 #include <asm/suspend.h>
1920
20
-#include <plat/pm-common.h>
21
-
2221 #include "common.h"
2322 #include "regs-clock.h"
23
+
24
+/* helper functions to save and restore register state */
25
+struct sleep_save {
26
+ void __iomem *reg;
27
+ unsigned long val;
28
+};
29
+
30
+#define SAVE_ITEM(x) \
31
+ { .reg = (x) }
32
+
33
+/**
34
+ * s3c_pm_do_save() - save a set of registers for restoration on resume.
35
+ * @ptr: Pointer to an array of registers.
36
+ * @count: Size of the ptr array.
37
+ *
38
+ * Run through the list of registers given, saving their contents in the
39
+ * array for later restoration when we wakeup.
40
+ */
41
+static void s3c_pm_do_save(struct sleep_save *ptr, int count)
42
+{
43
+ for (; count > 0; count--, ptr++) {
44
+ ptr->val = readl_relaxed(ptr->reg);
45
+ S3C_PMDBG("saved %p value %08lx\n", ptr->reg, ptr->val);
46
+ }
47
+}
48
+
49
+/**
50
+ * s3c_pm_do_restore() - restore register values from the save list.
51
+ * @ptr: Pointer to an array of registers.
52
+ * @count: Size of the ptr array.
53
+ *
54
+ * Restore the register values saved from s3c_pm_do_save().
55
+ *
56
+ * WARNING: Do not put any debug in here that may effect memory or use
57
+ * peripherals, as things may be changing!
58
+*/
59
+
60
+static void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count)
61
+{
62
+ for (; count > 0; count--, ptr++)
63
+ writel_relaxed(ptr->val, ptr->reg);
64
+}
2465
2566 static struct sleep_save s5pv210_core_save[] = {
2667 /* Clock ETC */
....@@ -31,6 +72,11 @@
3172 * VIC wake-up support (TODO)
3273 */
3374 static u32 s5pv210_irqwake_intmask = 0xffffffff;
75
+
76
+static u32 s5pv210_read_eint_wakeup_mask(void)
77
+{
78
+ return __raw_readl(S5P_EINT_WAKEUP_MASK);
79
+}
3480
3581 /*
3682 * Suspend helpers.
....@@ -59,8 +105,10 @@
59105 {
60106 unsigned int tmp;
61107
62
- /* Set wake-up mask registers */
63
- __raw_writel(exynos_get_eint_wake_mask(), S5P_EINT_WAKEUP_MASK);
108
+ /*
109
+ * Set wake-up mask registers
110
+ * S5P_EINT_WAKEUP_MASK is set by pinctrl driver in late suspend.
111
+ */
64112 __raw_writel(s5pv210_irqwake_intmask, S5P_WAKEUP_MASK);
65113
66114 /* ensure at least INFORM0 has the resume address */
....@@ -89,23 +137,22 @@
89137 */
90138 static int s5pv210_suspend_enter(suspend_state_t state)
91139 {
140
+ u32 eint_wakeup_mask = s5pv210_read_eint_wakeup_mask();
92141 int ret;
93
-
94
- s3c_pm_debug_init();
95142
96143 S3C_PMDBG("%s: suspending the system...\n", __func__);
97144
98145 S3C_PMDBG("%s: wakeup masks: %08x,%08x\n", __func__,
99
- s5pv210_irqwake_intmask, exynos_get_eint_wake_mask());
146
+ s5pv210_irqwake_intmask, eint_wakeup_mask);
100147
101148 if (s5pv210_irqwake_intmask == -1U
102
- && exynos_get_eint_wake_mask() == -1U) {
149
+ && eint_wakeup_mask == -1U) {
103150 pr_err("%s: No wake-up sources!\n", __func__);
104151 pr_err("%s: Aborting sleep\n", __func__);
105152 return -EINVAL;
106153 }
107154
108
- s3c_pm_save_uarts();
155
+ s3c_pm_save_uarts(false);
109156 s5pv210_pm_prepare();
110157 flush_cache_all();
111158 s3c_pm_check_store();
....@@ -114,7 +161,7 @@
114161 if (ret)
115162 return ret;
116163
117
- s3c_pm_restore_uarts();
164
+ s3c_pm_restore_uarts(false);
118165
119166 S3C_PMDBG("%s: wakeup stat: %08x\n", __func__,
120167 __raw_readl(S5P_WAKEUP_STAT));