[ar71xx] create firmware image for the Ubiquiti LS-SR71 board
[openwrt/svn-archive/archive.git] / target / linux / s3c24xx / patches-2.6.26 / 1034-pcf506xx.patch.patch
1 From 4ced79a6699eb5828c71b5438826fb44e3b41997 Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Wed, 16 Jul 2008 14:46:56 +0100
4 Subject: [PATCH] pcf506xx.patch
5 Moved shared PMU code from pcf50606.h and pcf50633.h (which prevented inclusion
6 of both at the same time) to pcf506xx.h
7
8 - include/linux/pcf50606.h (struct pmu_voltage_rail, enum pmu_event, pmu_cb):
9 moved to pcf506xx.h
10 - include/linux/pcf50633.h (struct pmu_voltage_rail, enum pmu_event, pmu_cb):
11 moved to pcf506xx.h
12
13 Signed off-by: Werner Almesberger <werner@openmoko.org>
14 ---
15 drivers/i2c/chips/pcf50606.c | 28 +++++++++++++++++++++++++++-
16 include/linux/pcf50606.h | 23 +++--------------------
17 include/linux/pcf50633.h | 27 +++------------------------
18 include/linux/pcf506xx.h | 31 +++++++++++++++++++++++++++++++
19 4 files changed, 64 insertions(+), 45 deletions(-)
20 create mode 100644 include/linux/pcf506xx.h
21
22 diff --git a/drivers/i2c/chips/pcf50606.c b/drivers/i2c/chips/pcf50606.c
23 index 6626c68..b530583 100644
24 --- a/drivers/i2c/chips/pcf50606.c
25 +++ b/drivers/i2c/chips/pcf50606.c
26 @@ -102,6 +102,7 @@ struct pcf50606_data {
27 int allow_close;
28 int onkey_seconds;
29 int irq;
30 + int coldplug_done;
31 #ifdef CONFIG_PM
32 struct {
33 u_int8_t dcdc1, dcdc2;
34 @@ -573,6 +574,30 @@ static void pcf50606_work(struct work_struct *work)
35 if (ret != 3)
36 DEBUGPC("Oh crap PMU IRQ register read failed %d\n", ret);
37
38 + if (!pcf->coldplug_done) {
39 + DEBUGPC("PMU Coldplug init\n");
40 +
41 + /* we used SECOND to kick ourselves started -- turn it off */
42 + pcfirq[0] &= ~PCF50606_INT1_SECOND;
43 + reg_set_bit_mask(pcf, PCF50606_REG_INT1M, PCF50606_INT1_SECOND,
44 + PCF50606_INT1_SECOND);
45 +
46 + /* coldplug the USB if present */
47 + if (__reg_read(pcf, PCF50606_REG_OOCS) & PCF50606_OOCS_EXTON) {
48 + /* Charger inserted */
49 + DEBUGPC("COLD CHGINS ");
50 + input_report_key(pcf->input_dev, KEY_BATTERY, 1);
51 + apm_queue_event(APM_POWER_STATUS_CHANGE);
52 + pcf->flags |= PCF50606_F_CHG_PRESENT;
53 + if (pcf->pdata->cb)
54 + pcf->pdata->cb(&pcf->client.dev,
55 + PCF50606_FEAT_MBC, PMU_EVT_INSERT);
56 + }
57 +
58 + pcf->coldplug_done = 1;
59 + }
60 +
61 +
62 dev_dbg(&pcf->client.dev, "INT1=0x%02x INT2=0x%02x INT3=0x%02x:",
63 pcfirq[0], pcfirq[1], pcfirq[2]);
64
65 @@ -1642,7 +1667,8 @@ static int pcf50606_detect(struct i2c_adapter *adapter, int address, int kind)
66 pm_power_off = &pcf50606_go_standby;
67
68 /* configure interrupt mask */
69 - reg_write(data, PCF50606_REG_INT1M, PCF50606_INT1_SECOND);
70 + /* we don't mask SECOND here, because we want one to do coldplug with */
71 + reg_write(data, PCF50606_REG_INT1M, 0x00);
72 reg_write(data, PCF50606_REG_INT2M, 0x00);
73 reg_write(data, PCF50606_REG_INT3M, PCF50606_INT3_TSCPRES);
74
75 diff --git a/include/linux/pcf50606.h b/include/linux/pcf50606.h
76 index bc98e47..167328f 100644
77 --- a/include/linux/pcf50606.h
78 +++ b/include/linux/pcf50606.h
79 @@ -1,6 +1,9 @@
80 #ifndef _LINUX_PCF50606_H
81 #define _LINUX_PCF50606_H
82
83 +#include <linux/pcf506xx.h>
84 +
85 +
86 /* public in-kernel pcf50606 api */
87 enum pcf50606_regulator_id {
88 PCF50606_REGULATOR_DCD,
89 @@ -48,26 +51,6 @@ pcf50606_onoff_set(struct pcf50606_data *pcf,
90 extern void
91 pcf50606_charge_fast(struct pcf50606_data *pcf, int on);
92
93 -#define PMU_VRAIL_F_SUSPEND_ON 0x00000001 /* Remains on during suspend */
94 -#define PMU_VRAIL_F_UNUSED 0x00000002 /* This rail is not used */
95 -struct pmu_voltage_rail {
96 - char *name;
97 - unsigned int flags;
98 - struct {
99 - unsigned int init;
100 - unsigned int max;
101 - } voltage;
102 -};
103 -
104 -enum pmu_event {
105 - PMU_EVT_NONE,
106 - PMU_EVT_INSERT,
107 - PMU_EVT_REMOVE,
108 - __NUM_PMU_EVTS
109 -};
110 -
111 -typedef int pmu_cb(struct device *dev, unsigned int feature,
112 - enum pmu_event event);
113
114 #define PCF50606_FEAT_EXTON 0x00000001 /* not yet supported */
115 #define PCF50606_FEAT_MBC 0x00000002
116 diff --git a/include/linux/pcf50633.h b/include/linux/pcf50633.h
117 index 5f32004..bf50fe4 100644
118 --- a/include/linux/pcf50633.h
119 +++ b/include/linux/pcf50633.h
120 @@ -1,6 +1,9 @@
121 #ifndef _LINUX_PCF50633_H
122 #define _LINUX_PCF50633_H
123
124 +#include <linux/pcf506xx.h>
125 +
126 +
127 /* public in-kernel pcf50633 api */
128 enum pcf50633_regulator_id {
129 PCF50633_REGULATOR_AUTO,
130 @@ -57,30 +60,6 @@ pcf50633_usb_curlim_set(struct pcf50633_data *pcf, int ma);
131 extern void
132 pcf50633_charge_enable(struct pcf50633_data *pcf, int on);
133
134 -/* FIXME: sharded with pcf50606 */
135 -#define PMU_VRAIL_F_SUSPEND_ON 0x00000001 /* Remains on during suspend */
136 -#define PMU_VRAIL_F_UNUSED 0x00000002 /* This rail is not used */
137 -struct pmu_voltage_rail {
138 - char *name;
139 - unsigned int flags;
140 - struct {
141 - unsigned int init;
142 - unsigned int max;
143 - } voltage;
144 -};
145 -
146 -enum pmu_event {
147 - PMU_EVT_NONE,
148 - PMU_EVT_INSERT,
149 - PMU_EVT_REMOVE,
150 - PMU_EVT_USB_INSERT,
151 - PMU_EVT_USB_REMOVE,
152 - __NUM_PMU_EVTS
153 -};
154 -
155 -typedef int pmu_cb(struct device *dev, unsigned int feature,
156 - enum pmu_event event);
157 -
158 #define PCF50633_FEAT_EXTON 0x00000001 /* not yet supported */
159 #define PCF50633_FEAT_MBC 0x00000002
160 #define PCF50633_FEAT_BBC 0x00000004 /* not yet supported */
161 diff --git a/include/linux/pcf506xx.h b/include/linux/pcf506xx.h
162 new file mode 100644
163 index 0000000..33be73e
164 --- /dev/null
165 +++ b/include/linux/pcf506xx.h
166 @@ -0,0 +1,31 @@
167 +#ifndef _LINUX_PCF506XX_H
168 +#define _LINUX_PCF506XX_H
169 +
170 +
171 +#define PMU_VRAIL_F_SUSPEND_ON 0x00000001 /* Remains on during suspend */
172 +#define PMU_VRAIL_F_UNUSED 0x00000002 /* This rail is not used */
173 +struct pmu_voltage_rail {
174 + char *name;
175 + unsigned int flags;
176 + struct {
177 + unsigned int init;
178 + unsigned int max;
179 + } voltage;
180 +};
181 +
182 +enum pmu_event {
183 + PMU_EVT_NONE,
184 + PMU_EVT_INSERT,
185 + PMU_EVT_REMOVE,
186 +#ifdef CONFIG_SENSORS_PCF50633
187 + PMU_EVT_USB_INSERT,
188 + PMU_EVT_USB_REMOVE,
189 +#endif
190 + __NUM_PMU_EVTS
191 +};
192 +
193 +typedef int pmu_cb(struct device *dev, unsigned int feature,
194 + enum pmu_event event);
195 +
196 +
197 +#endif /* !_LINUX_PCF506XX_H */
198 --
199 1.5.6.3
200