summaryrefslogtreecommitdiff
path: root/packages/linux/linux-rp-2.6.21/sharpsl_pm-r1.patch
blob: 9e7632fe0a949b55971365a622d8638ef5f69da4 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
Index: linux-2.6.21/arch/arm/common/sharpsl_pm.c
===================================================================
--- linux-2.6.21.orig/arch/arm/common/sharpsl_pm.c	2007-07-03 21:42:09.000000000 +0200
+++ linux-2.6.21/arch/arm/common/sharpsl_pm.c	2007-07-03 21:42:57.000000000 +0200
@@ -28,10 +28,8 @@
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/irq.h>
-#include <asm/arch/pm.h>
-#include <asm/arch/pxa-regs.h>
-#include <asm/arch/sharpsl.h>
 #include <asm/hardware/sharpsl_pm.h>
+#include "sharpsl_pm.h"
 
 /*
  * Constants
@@ -153,7 +151,7 @@
 		sharpsl_pm.battstat.mainbat_percent = percent;
 	}
 
-	dev_dbg(sharpsl_pm.dev, "Battery: voltage: %d, status: %d, percentage: %d, time: %d\n", voltage,
+	dev_dbg(sharpsl_pm.dev, "Battery: voltage: %d, status: %d, percentage: %d, time: %ld\n", voltage,
 			sharpsl_pm.battstat.mainbat_status, sharpsl_pm.battstat.mainbat_percent, jiffies);
 
 	/* If battery is low. limit backlight intensity to save power. */
@@ -504,7 +502,7 @@
 
 static void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state)
 {
-	dev_dbg(sharpsl_pm.dev, "Time is: %08x\n",RCNR);
+	dev_dbg(sharpsl_pm.dev, "Time is: %08lx\n",RCNR);
 
 	dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG);
 	/* not charging and AC-IN! */
@@ -518,28 +516,28 @@
 
 	sharpsl_pm.machinfo->presuspend();
 
-	PEDR = 0xffffffff; /* clear it */
+	clear_pedr_on_pxa();
 
 	sharpsl_pm.flags &= ~SHARPSL_ALARM_ACTIVE;
 	if ((sharpsl_pm.charge_mode == CHRG_ON) && ((alarm_enable && ((alarm_time - RCNR) > (SHARPSL_BATCHK_TIME_SUSPEND + 30))) || !alarm_enable)) {
-		RTSR &= RTSR_ALE;
+		enable_alarm_irq();
 		RTAR = RCNR + SHARPSL_BATCHK_TIME_SUSPEND;
-		dev_dbg(sharpsl_pm.dev, "Charging alarm at: %08x\n",RTAR);
+		dev_dbg(sharpsl_pm.dev, "Charging alarm at: %08lx\n",RTAR);
 		sharpsl_pm.flags |= SHARPSL_ALARM_ACTIVE;
 	} else if (alarm_enable) {
-		RTSR &= RTSR_ALE;
+		enable_alarm_irq();
 		RTAR = alarm_time;
-		dev_dbg(sharpsl_pm.dev, "User alarm at: %08x\n",RTAR);
+		dev_dbg(sharpsl_pm.dev, "User alarm at: %08lx\n",RTAR);
 	} else {
 		dev_dbg(sharpsl_pm.dev, "No alarms set.\n");
 		RTAR = 0;
 	}
 
-	pxa_pm_enter(state);
+	sharpsl_pm_enter(state);
 
 	sharpsl_pm.machinfo->postsuspend();
 
-	dev_dbg(sharpsl_pm.dev, "Corgi woken up from suspend: %08x\n",PEDR);
+	dev_dbg(sharpsl_pm.dev, "Corgi woken up from suspend: %08x\n",pedr_on_pxa());
 }
 
 static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state)
@@ -572,7 +570,7 @@
 static int corgi_pxa_pm_enter(suspend_state_t state)
 {
 	unsigned long alarm_time = RTAR;
-	unsigned int alarm_status = ((RTSR & RTSR_ALE) != 0);
+	unsigned int alarm_status = get_alarm_status();
 
 	dev_dbg(sharpsl_pm.dev, "SharpSL suspending for first time.\n");
 
@@ -633,7 +631,7 @@
 	}
 
 	temp = get_select_val(buff);
-	dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT));
+	dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %ld\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT));
 
 	if ((acin && (temp < sharpsl_pm.machinfo->fatal_acin_volt)) ||
 			(!acin && (temp < sharpsl_pm.machinfo->fatal_noacin_volt)))
@@ -782,9 +780,9 @@
 
 static struct pm_ops sharpsl_pm_ops = {
 	.pm_disk_mode	= PM_DISK_FIRMWARE,
-	.prepare	= pxa_pm_prepare,
+	.prepare	= sharpsl_pm_prepare,
 	.enter		= corgi_pxa_pm_enter,
-	.finish		= pxa_pm_finish,
+	.finish		= sharpsl_pm_finish,
 };
 
 static int __init sharpsl_pm_probe(struct platform_device *pdev)
@@ -813,7 +811,7 @@
 	apm_get_power_status = sharpsl_apm_get_power_status;
 
 	pm_set_ops(&sharpsl_pm_ops);
-
+	printk(KERN_DEBUG "sharpsl register pm_ops\n");
 	mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250));
 
 	return 0;
Index: linux-2.6.21/arch/arm/common/sharpsl_pm.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.21/arch/arm/common/sharpsl_pm.h	2007-07-03 21:42:26.000000000 +0200
@@ -0,0 +1,78 @@
+
+#ifdef CONFIG_ARCH_PXA
+#	include <asm/arch/pm.h>
+#	include <asm/arch/pxa-regs.h>
+#	include <asm/arch/sharpsl.h>
+static inline void clear_pedr_on_pxa(void)
+{
+	PEDR = 0xffffffff; /* clear it */
+}
+
+static inline void enable_alarm_irq(void)
+{
+	RTSR &= RTSR_ALE;
+}
+
+static inline int pedr_on_pxa(void)
+{
+	return PEDR;
+}
+
+static inline int get_alarm_status(void)
+{
+	return ((RTSR & RTSR_ALE) != 0);
+}
+
+static inline int sharpsl_pm_enter(suspend_state_t state)
+{
+	return pxa_pm_enter(state);
+}
+static inline int sharpsl_pm_prepare(suspend_state_t state)
+{
+	return pxa_pm_prepare(state);
+}
+
+int sharpsl_pm_finish(suspend_state_t state)
+{
+	return pxa_pm_finish(state);
+}
+#endif
+
+#ifdef CONFIG_ARCH_SA1100
+#	include <asm/arch/SA-1100.h>
+extern int sa11x0_pm_enter(suspend_state_t state);
+
+static inline void clear_pedr_on_pxa(void) {}
+static inline void enable_alarm_irq(void) {}
+static inline int pedr_on_pxa(void)
+{
+	return GPLR;
+}
+
+static inline int get_alarm_status(void)
+{
+	return 1;
+}
+
+static inline int  sharpsl_pm_enter(suspend_state_t state)
+{
+	return  sa11x0_pm_enter(state);
+}
+
+static inline int sharpsl_pm_prepare(suspend_state_t state)
+{
+	switch (state) {
+		case PM_SUSPEND_MEM:
+		case PM_SUSPEND_STANDBY:
+			return 0;
+		default:
+			return -EINVAL;
+	}
+}
+
+int sharpsl_pm_finish(suspend_state_t state)
+{
+	return 0;
+}
+#endif
+
Index: linux-2.6.21/arch/arm/mach-sa1100/pm.c
===================================================================
--- linux-2.6.21.orig/arch/arm/mach-sa1100/pm.c	2007-04-26 05:08:32.000000000 +0200
+++ linux-2.6.21/arch/arm/mach-sa1100/pm.c	2007-07-03 21:42:26.000000000 +0200
@@ -54,7 +54,7 @@
 };
 
 
-static int sa11x0_pm_enter(suspend_state_t state)
+int sa11x0_pm_enter(suspend_state_t state)
 {
 	unsigned long gpio, sleep_save[SLEEP_SAVE_SIZE];
 	struct timespec delta, rtc;
@@ -128,6 +128,7 @@
 
 	return 0;
 }
+EXPORT_SYMBOL(sa1x00_pm_enter);
 
 unsigned long sleep_phys_sp(void *sp)
 {