summaryrefslogtreecommitdiff
path: root/recipes/linux/linux-2.6.27/ts72xx/0029-EP93xx-Power-Management-Routines.patch
blob: 846a510b1a5e5f799bd2de9a88acb6a6ef03a36b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
From 6637a098eabb13d068c66e83e5bb0954a5266486 Mon Sep 17 00:00:00 2001
From: Matthieu Crapet <mcrapet@gmail.com>
Date: Sun, 4 Jan 2009 14:36:38 +0100
Subject: [PATCH] EP93xx Power Management Routines
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 arch/arm/mach-ep93xx/Makefile                   |    3 +
 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |    1 +
 arch/arm/mach-ep93xx/pm.c                       |   77 +++++++++++++++++++++++
 3 files changed, 81 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-ep93xx/pm.c

diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
index bbf8f9a..2f65745 100644
--- a/arch/arm/mach-ep93xx/Makefile
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -17,3 +17,6 @@ obj-$(CONFIG_MACH_GESBC9312)	+= gesbc9312.o
 obj-$(CONFIG_MACH_MICRO9)	+= micro9.o
 obj-$(CONFIG_MACH_TS72XX)	+= ts72xx.o
 obj-$(CONFIG_MACH_TS72XX_SBCINFO)	+= ts72xx_sbcinfo.o
+
+# Power Management
+obj-$(CONFIG_PM) += pm.o
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
index c0a8a95..f5218de 100644
--- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
@@ -135,6 +135,7 @@
 #define EP93XX_SYSCON_CLOCK_SET2	EP93XX_SYSCON_REG(0x24)
 #define EP93XX_SYSCON_DEVICE_CONFIG	EP93XX_SYSCON_REG(0x80)
 #define EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE	0x00800000
+#define EP93XX_SYSCON_DEVICE_CONFIG_SHENA	0x00000001
 #define EP93XX_SYSCON_SWLOCK		EP93XX_SYSCON_REG(0xc0)
 #define EP93XX_SYSCON_CHIPID		EP93XX_SYSCON_REG(0x94)
 
diff --git a/arch/arm/mach-ep93xx/pm.c b/arch/arm/mach-ep93xx/pm.c
new file mode 100644
index 0000000..0c4ba53
--- /dev/null
+++ b/arch/arm/mach-ep93xx/pm.c
@@ -0,0 +1,77 @@
+/*
+ *  arch/arm/mach-ep93xx/pm.c
+ *
+ *  EP93xx Power Management Routines
+ *
+ *  Based on pm.c from Andre Renaud, Bluewater Systems Ltd.
+ *
+ *  (c) Copyright 2008  Matthieu Crapet <mcrapet@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version
+ *  2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/suspend.h>
+#include <linux/sched.h>
+#include <linux/proc_fs.h>
+#include <linux/interrupt.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+#include <mach/hardware.h>
+
+
+static inline void ep93xx_standby(void)
+{
+  u32 v;
+  v = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG);
+  v |= EP93XX_SYSCON_DEVICE_CONFIG_SHENA;
+  __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
+  __raw_writel(v, EP93XX_SYSCON_DEVICE_CONFIG);
+
+  v = __raw_readl(EP93XX_SYSCON_STANDBY);
+
+  asm("nop; nop; nop; nop; nop");
+}
+
+static inline void ep93xx_resume(void)
+{
+  u32 v;
+
+  v = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG);
+  v &= ~EP93XX_SYSCON_DEVICE_CONFIG_SHENA;
+  __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
+  __raw_writel(v, EP93XX_SYSCON_DEVICE_CONFIG);
+}
+
+static int suspend_ep93xx_enter(suspend_state_t state)
+{
+  switch (state) {
+    case PM_SUSPEND_STANDBY:
+    case PM_SUSPEND_MEM:
+      ep93xx_standby(); /* go zzz */
+      ep93xx_resume();
+  }
+  return 0;
+}
+
+static int suspend_ep93xx_valid(suspend_state_t state)
+{
+  return (state == PM_SUSPEND_STANDBY) ||
+    (state == PM_SUSPEND_MEM);
+}
+
+
+static struct platform_suspend_ops ep93xx_suspend_ops = {
+  .enter	= suspend_ep93xx_enter,
+  .valid	= suspend_ep93xx_valid,
+};
+
+static int __init ep93xx_pm_init(void)
+{
+  pr_info("ep93xx: Power Management\n");
+  suspend_set_ops(&ep93xx_suspend_ops);
+  return 0;
+}
+__initcall(ep93xx_pm_init);
-- 
1.6.0.4