summaryrefslogtreecommitdiff
path: root/target/linux/s3c24xx/patches/0034-pcf506xx.patch.patch
blob: 0eeaf2fc612189a0134c253a02962129de490519 (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
From 4ced79a6699eb5828c71b5438826fb44e3b41997 Mon Sep 17 00:00:00 2001
From: mokopatches <mokopatches@openmoko.org>
Date: Wed, 16 Jul 2008 14:46:56 +0100
Subject: [PATCH] pcf506xx.patch
 Moved shared PMU code from pcf50606.h and pcf50633.h (which prevented inclusion
 of both at the same time) to pcf506xx.h

- include/linux/pcf50606.h (struct pmu_voltage_rail, enum pmu_event, pmu_cb):
  moved to pcf506xx.h
- include/linux/pcf50633.h (struct pmu_voltage_rail, enum pmu_event, pmu_cb):
  moved to pcf506xx.h

Signed off-by: Werner Almesberger <werner@openmoko.org>
---
 drivers/i2c/chips/pcf50606.c |   28 +++++++++++++++++++++++++++-
 include/linux/pcf50606.h     |   23 +++--------------------
 include/linux/pcf50633.h     |   27 +++------------------------
 include/linux/pcf506xx.h     |   31 +++++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+), 45 deletions(-)
 create mode 100644 include/linux/pcf506xx.h

diff --git a/drivers/i2c/chips/pcf50606.c b/drivers/i2c/chips/pcf50606.c
index 6626c68..b530583 100644
--- a/drivers/i2c/chips/pcf50606.c
+++ b/drivers/i2c/chips/pcf50606.c
@@ -102,6 +102,7 @@ struct pcf50606_data {
 	int allow_close;
 	int onkey_seconds;
 	int irq;
+	int coldplug_done;
 #ifdef CONFIG_PM
 	struct {
 		u_int8_t dcdc1, dcdc2;
@@ -573,6 +574,30 @@ static void pcf50606_work(struct work_struct *work)
 	if (ret != 3)
 		DEBUGPC("Oh crap PMU IRQ register read failed %d\n", ret);
 
+	if (!pcf->coldplug_done) {
+		DEBUGPC("PMU Coldplug init\n");
+
+		/* we used SECOND to kick ourselves started -- turn it off */
+		pcfirq[0] &= ~PCF50606_INT1_SECOND;
+		reg_set_bit_mask(pcf, PCF50606_REG_INT1M, PCF50606_INT1_SECOND,
+				 PCF50606_INT1_SECOND);
+
+		/* coldplug the USB if present */
+		if (__reg_read(pcf, PCF50606_REG_OOCS) & PCF50606_OOCS_EXTON) {
+			/* Charger inserted */
+			DEBUGPC("COLD CHGINS ");
+			input_report_key(pcf->input_dev, KEY_BATTERY, 1);
+			apm_queue_event(APM_POWER_STATUS_CHANGE);
+			pcf->flags |= PCF50606_F_CHG_PRESENT;
+			if (pcf->pdata->cb)
+				pcf->pdata->cb(&pcf->client.dev,
+					PCF50606_FEAT_MBC, PMU_EVT_INSERT);
+		}
+
+		pcf->coldplug_done = 1;
+	}
+
+
 	dev_dbg(&pcf->client.dev, "INT1=0x%02x INT2=0x%02x INT3=0x%02x:",
 		pcfirq[0], pcfirq[1], pcfirq[2]);
 
@@ -1642,7 +1667,8 @@ static int pcf50606_detect(struct i2c_adapter *adapter, int address, int kind)
 	pm_power_off = &pcf50606_go_standby;
 
 	/* configure interrupt mask */
-	reg_write(data, PCF50606_REG_INT1M, PCF50606_INT1_SECOND);
+	/* we don't mask SECOND here, because we want one to do coldplug with */
+	reg_write(data, PCF50606_REG_INT1M, 0x00);
 	reg_write(data, PCF50606_REG_INT2M, 0x00);
 	reg_write(data, PCF50606_REG_INT3M, PCF50606_INT3_TSCPRES);
 
diff --git a/include/linux/pcf50606.h b/include/linux/pcf50606.h
index bc98e47..167328f 100644
--- a/include/linux/pcf50606.h
+++ b/include/linux/pcf50606.h
@@ -1,6 +1,9 @@
 #ifndef _LINUX_PCF50606_H
 #define _LINUX_PCF50606_H
 
+#include <linux/pcf506xx.h>
+
+
 /* public in-kernel pcf50606 api */
 enum pcf50606_regulator_id {
 	PCF50606_REGULATOR_DCD,
@@ -48,26 +51,6 @@ pcf50606_onoff_set(struct pcf50606_data *pcf,
 extern void
 pcf50606_charge_fast(struct pcf50606_data *pcf, int on);
 
-#define PMU_VRAIL_F_SUSPEND_ON	0x00000001	/* Remains on during suspend */
-#define PMU_VRAIL_F_UNUSED	0x00000002	/* This rail is not used */
-struct pmu_voltage_rail {
-	char *name;
-	unsigned int flags;
-	struct {
-		unsigned int init;
-		unsigned int max;
-	} voltage;
-};
-
-enum pmu_event {
-	PMU_EVT_NONE,
-	PMU_EVT_INSERT,
-	PMU_EVT_REMOVE,
-	__NUM_PMU_EVTS
-};
-
-typedef int pmu_cb(struct device *dev, unsigned int feature,
-		   enum pmu_event event);
 
 #define PCF50606_FEAT_EXTON	0x00000001	/* not yet supported */
 #define PCF50606_FEAT_MBC	0x00000002
diff --git a/include/linux/pcf50633.h b/include/linux/pcf50633.h
index 5f32004..bf50fe4 100644
--- a/include/linux/pcf50633.h
+++ b/include/linux/pcf50633.h
@@ -1,6 +1,9 @@
 #ifndef _LINUX_PCF50633_H
 #define _LINUX_PCF50633_H
 
+#include <linux/pcf506xx.h>
+
+
 /* public in-kernel pcf50633 api */
 enum pcf50633_regulator_id {
 	PCF50633_REGULATOR_AUTO,
@@ -57,30 +60,6 @@ pcf50633_usb_curlim_set(struct pcf50633_data *pcf, int ma);
 extern void
 pcf50633_charge_enable(struct pcf50633_data *pcf, int on);
 
-/* FIXME: sharded with pcf50606 */
-#define PMU_VRAIL_F_SUSPEND_ON	0x00000001	/* Remains on during suspend */
-#define PMU_VRAIL_F_UNUSED	0x00000002	/* This rail is not used */
-struct pmu_voltage_rail {
-	char *name;
-	unsigned int flags;
-	struct {
-		unsigned int init;
-		unsigned int max;
-	} voltage;
-};
-
-enum pmu_event {
-	PMU_EVT_NONE,
-	PMU_EVT_INSERT,
-	PMU_EVT_REMOVE,
-	PMU_EVT_USB_INSERT,
-	PMU_EVT_USB_REMOVE,
-	__NUM_PMU_EVTS
-};
-
-typedef int pmu_cb(struct device *dev, unsigned int feature,
-		   enum pmu_event event);
-
 #define PCF50633_FEAT_EXTON	0x00000001	/* not yet supported */
 #define PCF50633_FEAT_MBC	0x00000002
 #define PCF50633_FEAT_BBC	0x00000004	/* not yet supported */
diff --git a/include/linux/pcf506xx.h b/include/linux/pcf506xx.h
new file mode 100644
index 0000000..33be73e
--- /dev/null
+++ b/include/linux/pcf506xx.h
@@ -0,0 +1,31 @@
+#ifndef _LINUX_PCF506XX_H
+#define _LINUX_PCF506XX_H
+
+
+#define PMU_VRAIL_F_SUSPEND_ON	0x00000001	/* Remains on during suspend */
+#define PMU_VRAIL_F_UNUSED	0x00000002	/* This rail is not used */
+struct pmu_voltage_rail {
+	char *name;
+	unsigned int flags;
+	struct {
+		unsigned int init;
+		unsigned int max;
+	} voltage;
+};
+
+enum pmu_event {
+	PMU_EVT_NONE,
+	PMU_EVT_INSERT,
+	PMU_EVT_REMOVE,
+#ifdef CONFIG_SENSORS_PCF50633
+	PMU_EVT_USB_INSERT,
+	PMU_EVT_USB_REMOVE,
+#endif
+	__NUM_PMU_EVTS
+};
+
+typedef int pmu_cb(struct device *dev, unsigned int feature,
+		   enum pmu_event event);
+
+
+#endif /* !_LINUX_PCF506XX_H */
-- 
1.5.6.3