| .. | .. |
|---|
| 13 | 13 | #include <linux/suspend.h> |
|---|
| 14 | 14 | #include <linux/syscore_ops.h> |
|---|
| 15 | 15 | #include <linux/io.h> |
|---|
| 16 | +#include <linux/soc/samsung/s3c-pm.h> |
|---|
| 16 | 17 | |
|---|
| 17 | 18 | #include <asm/cacheflush.h> |
|---|
| 18 | 19 | #include <asm/suspend.h> |
|---|
| 19 | 20 | |
|---|
| 20 | | -#include <plat/pm-common.h> |
|---|
| 21 | | - |
|---|
| 22 | 21 | #include "common.h" |
|---|
| 23 | 22 | #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 | +} |
|---|
| 24 | 65 | |
|---|
| 25 | 66 | static struct sleep_save s5pv210_core_save[] = { |
|---|
| 26 | 67 | /* Clock ETC */ |
|---|
| .. | .. |
|---|
| 31 | 72 | * VIC wake-up support (TODO) |
|---|
| 32 | 73 | */ |
|---|
| 33 | 74 | 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 | +} |
|---|
| 34 | 80 | |
|---|
| 35 | 81 | /* |
|---|
| 36 | 82 | * Suspend helpers. |
|---|
| .. | .. |
|---|
| 59 | 105 | { |
|---|
| 60 | 106 | unsigned int tmp; |
|---|
| 61 | 107 | |
|---|
| 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 | + */ |
|---|
| 64 | 112 | __raw_writel(s5pv210_irqwake_intmask, S5P_WAKEUP_MASK); |
|---|
| 65 | 113 | |
|---|
| 66 | 114 | /* ensure at least INFORM0 has the resume address */ |
|---|
| .. | .. |
|---|
| 89 | 137 | */ |
|---|
| 90 | 138 | static int s5pv210_suspend_enter(suspend_state_t state) |
|---|
| 91 | 139 | { |
|---|
| 140 | + u32 eint_wakeup_mask = s5pv210_read_eint_wakeup_mask(); |
|---|
| 92 | 141 | int ret; |
|---|
| 93 | | - |
|---|
| 94 | | - s3c_pm_debug_init(); |
|---|
| 95 | 142 | |
|---|
| 96 | 143 | S3C_PMDBG("%s: suspending the system...\n", __func__); |
|---|
| 97 | 144 | |
|---|
| 98 | 145 | 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); |
|---|
| 100 | 147 | |
|---|
| 101 | 148 | if (s5pv210_irqwake_intmask == -1U |
|---|
| 102 | | - && exynos_get_eint_wake_mask() == -1U) { |
|---|
| 149 | + && eint_wakeup_mask == -1U) { |
|---|
| 103 | 150 | pr_err("%s: No wake-up sources!\n", __func__); |
|---|
| 104 | 151 | pr_err("%s: Aborting sleep\n", __func__); |
|---|
| 105 | 152 | return -EINVAL; |
|---|
| 106 | 153 | } |
|---|
| 107 | 154 | |
|---|
| 108 | | - s3c_pm_save_uarts(); |
|---|
| 155 | + s3c_pm_save_uarts(false); |
|---|
| 109 | 156 | s5pv210_pm_prepare(); |
|---|
| 110 | 157 | flush_cache_all(); |
|---|
| 111 | 158 | s3c_pm_check_store(); |
|---|
| .. | .. |
|---|
| 114 | 161 | if (ret) |
|---|
| 115 | 162 | return ret; |
|---|
| 116 | 163 | |
|---|
| 117 | | - s3c_pm_restore_uarts(); |
|---|
| 164 | + s3c_pm_restore_uarts(false); |
|---|
| 118 | 165 | |
|---|
| 119 | 166 | S3C_PMDBG("%s: wakeup stat: %08x\n", __func__, |
|---|
| 120 | 167 | __raw_readl(S5P_WAKEUP_STAT)); |
|---|