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
|
From 2dac0b9383e3939ce69b07aff70e8eae3b7fa561 Mon Sep 17 00:00:00 2001
From: Jiri Pinkava <jiri.pinkava@vscht.cz>
Date: Wed, 26 May 2010 23:00:56 +0200
Subject: [PATCH 13/14] n35: Acer n35 GPS power management
Signed-off-by: Jiri Pinkava <jiri.pinkava@vscht.cz>
---
arch/arm/mach-s3c2410/Makefile | 1 +
arch/arm/mach-s3c2410/mach-n30.c | 6 ++
arch/arm/mach-s3c2410/n35_gps.c | 148 ++++++++++++++++++++++++++++++++++++++
3 files changed, 155 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-s3c2410/n35_gps.c
diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
index 0d468e9..896baa4 100644
--- a/arch/arm/mach-s3c2410/Makefile
+++ b/arch/arm/mach-s3c2410/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_ARCH_H1940) += mach-h1940.o
obj-$(CONFIG_H1940BT) += h1940-bluetooth.o
obj-$(CONFIG_PM_H1940) += pm-h1940.o
obj-$(CONFIG_MACH_N30) += mach-n30.o
+obj-$(CONFIG_MACH_N35) += n35_gps.o
obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o
obj-$(CONFIG_MACH_OTOM) += mach-otom.o
obj-$(CONFIG_MACH_AML_M5900) += mach-amlm5900.o
diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c
index 34a7e9e..010d5aa 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c2410/mach-n30.c
@@ -631,6 +631,11 @@ static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = {
.set_power = n30_sdi_set_power,
};
+static struct platform_device n35_device_gps = {
+ .name = "n35-gps",
+ .id = -1,
+};
+
static struct platform_device *n30_devices[] __initdata = {
&s3c_device_lcd,
&s3c_device_wdt,
@@ -664,6 +669,7 @@ static struct platform_device *n35_devices[] __initdata = {
&s3c_device_ts,
&s3c_device_timer[0],
&n35_backlight,
+ &n35_device_gps,
&n35_lcd_powerdev,
&n30_battery,
&n35_button_device,
diff --git a/arch/arm/mach-s3c2410/n35_gps.c b/arch/arm/mach-s3c2410/n35_gps.c
new file mode 100644
index 0000000..41506e9
--- /dev/null
+++ b/arch/arm/mach-s3c2410/n35_gps.c
@@ -0,0 +1,148 @@
+/*
+ * arch/arm/mach-s3c2410/n35-gps.c
+ * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive for
+ * more details.
+ *
+ * Acer n35 GPS "driver"
+ * FIXME: Do proper up/down handling, now it only ses power on/off.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+//#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/gpio.h>
+
+#include <mach/regs-gpio.h>
+#include <mach/hardware.h>
+
+#define DRV_NAME "n35-gps"
+
+struct n35_gps_data {
+ int suspend_power_state;
+};
+
+static struct n35_gps_data n35_gps;
+
+static int gps_power_get(void)
+{
+ return !(gpio_get_value(S3C2410_GPB(4)) || \
+ gpio_get_value(S3C2410_GPG(11)));
+}
+
+static void gps_power_set(int power)
+{
+ gpio_set_value(S3C2410_GPB(4), power ? 0 : 1);
+ gpio_set_value(S3C2410_GPG(11), power ? 0 : 1);
+}
+
+static ssize_t gps_power_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ if (gps_power_get())
+ return sprintf(buf, "1\n");
+ return sprintf(buf, "0\n");
+}
+
+static ssize_t gps_power_store(struct device *pdev,
+ struct device_attribute *attr, const char *buf, size_t size)
+{
+ int power;
+
+ power = simple_strtoul(buf, NULL, 0);
+ gps_power_set(power);
+
+ return size;
+}
+
+static DEVICE_ATTR(gps_power, 0664, gps_power_show, gps_power_store);
+
+static int __devinit n35_gps_probe(struct platform_device *pdev)
+{
+ int ret;
+
+ ret = gpio_request(S3C2410_GPB(4), "Acer n35 GPS module power");
+ if (ret)
+ goto ret_err;
+
+ ret = gpio_request(S3C2410_GPG(11), "Acer n35 GPS antena power");
+ if (ret)
+ goto ret_err_gpg4;
+
+ s3c_gpio_cfgpin(S3C2410_GPB(4), S3C2410_GPIO_OUTPUT);
+ s3c_gpio_cfgpin(S3C2410_GPG(11), S3C2410_GPIO_OUTPUT);
+
+ gps_power_set(0);
+
+ ret = device_create_file(&pdev->dev, &dev_attr_gps_power);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to create GPS sysfs device\n");
+ goto ret_err_gpg11;
+ }
+
+ return 0;
+ret_err_gpg11:
+ gpio_free(S3C2410_GPG(11));
+ret_err_gpg4:
+ gpio_free(S3C2410_GPB(4));
+ret_err:
+ return ret;
+}
+
+static int n35_gps_remove(struct platform_device *pdev)
+{
+ gps_power_set(0);
+
+ gpio_free(S3C2410_GPG(11));
+ gpio_free(S3C2410_GPB(4));
+
+ device_remove_file(&pdev->dev, &dev_attr_gps_power);
+
+ return 0;
+}
+
+static int n35_gps_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ n35_gps.suspend_power_state = gps_power_get();
+ gps_power_set(0);
+ return 0;
+}
+
+static int n35_gps_resume(struct platform_device *pdev)
+{
+ gps_power_set(n35_gps.suspend_power_state);
+ return 0;
+}
+
+static struct platform_driver n35_gps_driver = {
+ .driver = {
+ .name = DRV_NAME,
+ },
+ .probe = n35_gps_probe,
+ .remove = n35_gps_remove,
+ .resume = n35_gps_resume,
+ .suspend = n35_gps_suspend,
+};
+
+
+static int __init n35_gps_init(void)
+{
+ return platform_driver_register(&n35_gps_driver);
+}
+
+static void __exit n35_gps_exit(void)
+{
+ platform_driver_unregister(&n35_gps_driver);
+}
+
+module_init(n35_gps_init);
+module_exit(n35_gps_exit);
+
+MODULE_AUTHOR("Jiri Pinkava <jiri.pinkava@vscht.cz>");
+MODULE_DESCRIPTION("Driver for the Acer n35 GPS");
+MODULE_LICENSE("GPL");
--
1.7.3.1
|