aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/plat-samsung/Makefile1
-rw-r--r--arch/arm/plat-samsung/include/plat/pm-common.h26
-rw-r--r--arch/arm/plat-samsung/include/plat/pm.h25
-rw-r--r--arch/arm/plat-samsung/pm-common.c75
-rw-r--r--arch/arm/plat-samsung/pm.c56
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
50obj-$(CONFIG_PM_SLEEP) += pm-common.o
50obj-$(CONFIG_SAMSUNG_PM) += pm.o 51obj-$(CONFIG_SAMSUNG_PM) += pm.o
51obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o 52obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o
52obj-$(CONFIG_SAMSUNG_PM_CHECK) += pm-check.o 53obj-$(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 */
28struct 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
38extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
39extern void s3c_pm_do_restore(const struct sleep_save *ptr, int count);
40extern 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
21struct device; 20struct device;
@@ -59,30 +58,6 @@ extern unsigned long s3c_pm_flags;
59 58
60extern int s3c2410_cpu_suspend(unsigned long); 59extern 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 */
72struct 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
82extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
83extern void s3c_pm_do_restore(const struct sleep_save *ptr, int count);
84extern void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count);
85
86#ifdef CONFIG_SAMSUNG_PM 61#ifdef CONFIG_SAMSUNG_PM
87extern int s3c_irq_wake(struct irq_data *data, unsigned int state); 62extern int s3c_irq_wake(struct irq_data *data, unsigned int state);
88extern int s3c_irqext_wake(struct irq_data *data, unsigned int state); 63extern 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 */
31void 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
50void 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
71void 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 */
79void 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
98void 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
119void 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)