aboutsummaryrefslogtreecommitdiff
path: root/linux/3.1.6/0010-n30-Add-PDA-power-supply-status-on-Acer-n30-n35.patch
blob: 73881401cce6b72b39eef1c290a6a18bfedd23e5 (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
From e98e470136f0910a64bed8a77c067e6976dd23de Mon Sep 17 00:00:00 2001
From: Jiri Pinkava <jiri.pinkava@vscht.cz>
Date: Mon, 24 May 2010 10:08:47 +0200
Subject: [PATCH 10/14] n30: Add PDA power supply status on Acer n30 / n35

Signed-off-by: Jiri Pinkava <jiri.pinkava@vscht.cz>
---
 arch/arm/mach-s3c2410/mach-n30.c |   53 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c
index 36ed810..9c0e5b8 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c2410/mach-n30.c
@@ -23,6 +23,7 @@
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
+#include <linux/pda_power.h>
 #include <linux/platform_device.h>
 #include <linux/pwm_backlight.h>
 #include <linux/serial_core.h>
@@ -185,6 +186,56 @@ static struct s3c2410_ts_mach_info n30_ts_cfg __initdata = {
 	.cfg_gpio = s3c24xx_ts_cfg_gpio,
 };
 
+/* It would be possible to register GPG1 as interrupt resource EINT9
+ * with the pda_power code, but since GPC7 cannot have an interrupt
+ * connected to it, the pda_power driver will use polling anyway.  In
+ * addition to that, since the USB driver already requests EINT9, the
+ * request_irq in pda_power fails.  So don't do that. */
+
+/*
+static struct resource n30_power_resource[] = {
+	{
+		.name = "usb",
+		.start = IRQ_EINT9,
+		.end   = IRQ_EINT9,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+*/
+
+static int n30_is_ac_online(void)
+{
+	return gpio_get_value(S3C2410_GPC(7));
+}
+
+static int n30_is_usb_online(void)
+{
+	return gpio_get_value(S3C2410_GPG(1));
+}
+
+static char *n30_power_supplied_to[] = {
+	"battery",
+};
+
+static struct pda_power_pdata n30_power_pdata = {
+	.is_ac_online = n30_is_ac_online,
+	.is_usb_online = n30_is_usb_online,
+	.supplied_to = n30_power_supplied_to,
+	.num_supplicants = ARRAY_SIZE(n30_power_supplied_to),
+};
+
+static struct platform_device n30_power = {
+	.name		= "pda-power",
+	.id		= -1,
+	.dev		= {
+		.platform_data	= &n30_power_pdata,
+	},
+/*
+	.num_resources	= ARRAY_SIZE(n30_power_resource),
+	.resource	= n30_power_resource,
+*/
+};
+
 static struct platform_device n30_battery = {
 	.name		= "n30-battery",
 	.id		= -1,
@@ -545,6 +596,7 @@ static struct platform_device *n30_devices[] __initdata = {
 	&s3c_device_adc,
 	&s3c_device_ts,
 	&n30_battery,
+	&n30_power,
 	&n30_button_device,
 	&n30_blue_led,
 	&n30_warning_led,
@@ -569,6 +621,7 @@ static struct platform_device *n35_devices[] __initdata = {
 	&n35_button_device,
 	&n35_blue_led,
 	&n35_warning_led,
+	&n30_power,
 };
 
 static struct s3c2410_platform_i2c __initdata n30_i2ccfg = {
-- 
1.7.3.1