1 From 825154a75730a9505750384cda1dc47c6edb3a1d Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Fri, 4 Apr 2008 11:36:10 +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
8 - include/linux/pcf50606.h (struct pmu_voltage_rail, enum pmu_event, pmu_cb):
10 - include/linux/pcf50633.h (struct pmu_voltage_rail, enum pmu_event, pmu_cb):
13 Signed off-by: Werner Almesberger <werner@openmoko.org>
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
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 {
33 u_int8_t dcdc1, dcdc2;
34 @@ -573,6 +574,30 @@ static void pcf50606_work(struct work_struct *work)
36 DEBUGPC("Oh crap PMU IRQ register read failed %d\n", ret);
38 + if (!pcf->coldplug_done) {
39 + DEBUGPC("PMU Coldplug init\n");
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);
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;
54 + pcf->pdata->cb(&pcf->client.dev,
55 + PCF50606_FEAT_MBC, PMU_EVT_INSERT);
58 + pcf->coldplug_done = 1;
62 dev_dbg(&pcf->client.dev, "INT1=0x%02x INT2=0x%02x INT3=0x%02x:",
63 pcfirq[0], pcfirq[1], pcfirq[2]);
65 @@ -1642,7 +1667,8 @@ static int pcf50606_detect(struct i2c_adapter *adapter, int address, int kind)
66 pm_power_off = &pcf50606_go_standby;
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);
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
80 #ifndef _LINUX_PCF50606_H
81 #define _LINUX_PCF50606_H
83 +#include <linux/pcf506xx.h>
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,
91 pcf50606_charge_fast(struct pcf50606_data *pcf, int on);
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 {
111 -typedef int pmu_cb(struct device *dev, unsigned int feature,
112 - enum pmu_event event);
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
121 #ifndef _LINUX_PCF50633_H
122 #define _LINUX_PCF50633_H
124 +#include <linux/pcf506xx.h>
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);
132 pcf50633_charge_enable(struct pcf50633_data *pcf, int on);
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 {
139 - unsigned int flags;
150 - PMU_EVT_USB_INSERT,
151 - PMU_EVT_USB_REMOVE,
155 -typedef int pmu_cb(struct device *dev, unsigned int feature,
156 - enum pmu_event event);
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
163 index 0000000..33be73e
165 +++ b/include/linux/pcf506xx.h
167 +#ifndef _LINUX_PCF506XX_H
168 +#define _LINUX_PCF506XX_H
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 {
175 + unsigned int flags;
186 +#ifdef CONFIG_SENSORS_PCF50633
187 + PMU_EVT_USB_INSERT,
188 + PMU_EVT_USB_REMOVE,
193 +typedef int pmu_cb(struct device *dev, unsigned int feature,
194 + enum pmu_event event);
197 +#endif /* !_LINUX_PCF506XX_H */