aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mfd/pcf50633
diff options
context:
space:
mode:
authorBalaji Rao <balajirrao@openmoko.org>2009-01-08 19:49:01 -0500
committerSamuel Ortiz <samuel@sortiz.org>2009-01-10 19:34:23 -0500
commitf52046b14b1e1a8a02ae48d0c69d39c5e204644f (patch)
treeb0d6e1ae2c839fe415adcaf054233a73011b69d7 /include/linux/mfd/pcf50633
parentc59765042f53a79a7a65585042ff463b69cb248c (diff)
mfd: PCF50633 core driver
This patch implements the core of the PCF50633 driver. This core driver has generic register read/write functions and does interrupt management for its sub devices. Signed-off-by: Balaji Rao <balajirrao@openmoko.org> Cc: Andy Green <andy@openmoko.com> Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
Diffstat (limited to 'include/linux/mfd/pcf50633')
-rw-r--r--include/linux/mfd/pcf50633/core.h218
1 files changed, 218 insertions, 0 deletions
diff --git a/include/linux/mfd/pcf50633/core.h b/include/linux/mfd/pcf50633/core.h
new file mode 100644
index 000000000000..4455b212d75a
--- /dev/null
+++ b/include/linux/mfd/pcf50633/core.h
@@ -0,0 +1,218 @@
1/*
2 * core.h -- Core driver for NXP PCF50633
3 *
4 * (C) 2006-2008 by Openmoko, Inc.
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#ifndef __LINUX_MFD_PCF50633_CORE_H
14#define __LINUX_MFD_PCF50633_CORE_H
15
16#include <linux/i2c.h>
17#include <linux/workqueue.h>
18#include <linux/regulator/driver.h>
19#include <linux/regulator/machine.h>
20#include <linux/power_supply.h>
21
22struct pcf50633;
23
24#define PCF50633_NUM_REGULATORS 11
25
26struct pcf50633_platform_data {
27 struct regulator_init_data reg_init_data[PCF50633_NUM_REGULATORS];
28
29 char **batteries;
30 int num_batteries;
31
32 /* Callbacks */
33 void (*probe_done)(struct pcf50633 *);
34 void (*mbc_event_callback)(struct pcf50633 *, int);
35 void (*regulator_registered)(struct pcf50633 *, int);
36 void (*force_shutdown)(struct pcf50633 *);
37
38 u8 resumers[5];
39};
40
41struct pcf50633_subdev_pdata {
42 struct pcf50633 *pcf;
43};
44
45struct pcf50633_irq {
46 void (*handler) (int, void *);
47 void *data;
48};
49
50int pcf50633_register_irq(struct pcf50633 *pcf, int irq,
51 void (*handler) (int, void *), void *data);
52int pcf50633_free_irq(struct pcf50633 *pcf, int irq);
53
54int pcf50633_irq_mask(struct pcf50633 *pcf, int irq);
55int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq);
56int pcf50633_irq_mask_get(struct pcf50633 *pcf, int irq);
57
58int pcf50633_read_block(struct pcf50633 *, u8 reg,
59 int nr_regs, u8 *data);
60int pcf50633_write_block(struct pcf50633 *pcf, u8 reg,
61 int nr_regs, u8 *data);
62u8 pcf50633_reg_read(struct pcf50633 *, u8 reg);
63int pcf50633_reg_write(struct pcf50633 *pcf, u8 reg, u8 val);
64
65int pcf50633_reg_set_bit_mask(struct pcf50633 *pcf, u8 reg, u8 mask, u8 val);
66int pcf50633_reg_clear_bits(struct pcf50633 *pcf, u8 reg, u8 bits);
67
68/* Interrupt registers */
69
70#define PCF50633_REG_INT1 0x02
71#define PCF50633_REG_INT2 0x03
72#define PCF50633_REG_INT3 0x04
73#define PCF50633_REG_INT4 0x05
74#define PCF50633_REG_INT5 0x06
75
76#define PCF50633_REG_INT1M 0x07
77#define PCF50633_REG_INT2M 0x08
78#define PCF50633_REG_INT3M 0x09
79#define PCF50633_REG_INT4M 0x0a
80#define PCF50633_REG_INT5M 0x0b
81
82enum {
83 /* Chip IRQs */
84 PCF50633_IRQ_ADPINS,
85 PCF50633_IRQ_ADPREM,
86 PCF50633_IRQ_USBINS,
87 PCF50633_IRQ_USBREM,
88 PCF50633_IRQ_RESERVED1,
89 PCF50633_IRQ_RESERVED2,
90 PCF50633_IRQ_ALARM,
91 PCF50633_IRQ_SECOND,
92 PCF50633_IRQ_ONKEYR,
93 PCF50633_IRQ_ONKEYF,
94 PCF50633_IRQ_EXTON1R,
95 PCF50633_IRQ_EXTON1F,
96 PCF50633_IRQ_EXTON2R,
97 PCF50633_IRQ_EXTON2F,
98 PCF50633_IRQ_EXTON3R,
99 PCF50633_IRQ_EXTON3F,
100 PCF50633_IRQ_BATFULL,
101 PCF50633_IRQ_CHGHALT,
102 PCF50633_IRQ_THLIMON,
103 PCF50633_IRQ_THLIMOFF,
104 PCF50633_IRQ_USBLIMON,
105 PCF50633_IRQ_USBLIMOFF,
106 PCF50633_IRQ_ADCRDY,
107 PCF50633_IRQ_ONKEY1S,
108 PCF50633_IRQ_LOWSYS,
109 PCF50633_IRQ_LOWBAT,
110 PCF50633_IRQ_HIGHTMP,
111 PCF50633_IRQ_AUTOPWRFAIL,
112 PCF50633_IRQ_DWN1PWRFAIL,
113 PCF50633_IRQ_DWN2PWRFAIL,
114 PCF50633_IRQ_LEDPWRFAIL,
115 PCF50633_IRQ_LEDOVP,
116 PCF50633_IRQ_LDO1PWRFAIL,
117 PCF50633_IRQ_LDO2PWRFAIL,
118 PCF50633_IRQ_LDO3PWRFAIL,
119 PCF50633_IRQ_LDO4PWRFAIL,
120 PCF50633_IRQ_LDO5PWRFAIL,
121 PCF50633_IRQ_LDO6PWRFAIL,
122 PCF50633_IRQ_HCLDOPWRFAIL,
123 PCF50633_IRQ_HCLDOOVL,
124
125 /* Always last */
126 PCF50633_NUM_IRQ,
127};
128
129struct pcf50633 {
130 struct device *dev;
131 struct i2c_client *i2c_client;
132
133 struct pcf50633_platform_data *pdata;
134 int irq;
135 struct pcf50633_irq irq_handler[PCF50633_NUM_IRQ];
136 struct work_struct irq_work;
137 struct mutex lock;
138
139 u8 mask_regs[5];
140
141 u8 suspend_irq_masks[5];
142 u8 resume_reason[5];
143 int is_suspended;
144
145 int onkey1s_held;
146
147 struct platform_device *rtc_pdev;
148 struct platform_device *mbc_pdev;
149 struct platform_device *adc_pdev;
150 struct platform_device *input_pdev;
151 struct platform_device *regulator_pdev[PCF50633_NUM_REGULATORS];
152};
153
154enum pcf50633_reg_int1 {
155 PCF50633_INT1_ADPINS = 0x01, /* Adapter inserted */
156 PCF50633_INT1_ADPREM = 0x02, /* Adapter removed */
157 PCF50633_INT1_USBINS = 0x04, /* USB inserted */
158 PCF50633_INT1_USBREM = 0x08, /* USB removed */
159 /* reserved */
160 PCF50633_INT1_ALARM = 0x40, /* RTC alarm time is reached */
161 PCF50633_INT1_SECOND = 0x80, /* RTC periodic second interrupt */
162};
163
164enum pcf50633_reg_int2 {
165 PCF50633_INT2_ONKEYR = 0x01, /* ONKEY rising edge */
166 PCF50633_INT2_ONKEYF = 0x02, /* ONKEY falling edge */
167 PCF50633_INT2_EXTON1R = 0x04, /* EXTON1 rising edge */
168 PCF50633_INT2_EXTON1F = 0x08, /* EXTON1 falling edge */
169 PCF50633_INT2_EXTON2R = 0x10, /* EXTON2 rising edge */
170 PCF50633_INT2_EXTON2F = 0x20, /* EXTON2 falling edge */
171 PCF50633_INT2_EXTON3R = 0x40, /* EXTON3 rising edge */
172 PCF50633_INT2_EXTON3F = 0x80, /* EXTON3 falling edge */
173};
174
175enum pcf50633_reg_int3 {
176 PCF50633_INT3_BATFULL = 0x01, /* Battery full */
177 PCF50633_INT3_CHGHALT = 0x02, /* Charger halt */
178 PCF50633_INT3_THLIMON = 0x04,
179 PCF50633_INT3_THLIMOFF = 0x08,
180 PCF50633_INT3_USBLIMON = 0x10,
181 PCF50633_INT3_USBLIMOFF = 0x20,
182 PCF50633_INT3_ADCRDY = 0x40, /* ADC result ready */
183 PCF50633_INT3_ONKEY1S = 0x80, /* ONKEY pressed 1 second */
184};
185
186enum pcf50633_reg_int4 {
187 PCF50633_INT4_LOWSYS = 0x01,
188 PCF50633_INT4_LOWBAT = 0x02,
189 PCF50633_INT4_HIGHTMP = 0x04,
190 PCF50633_INT4_AUTOPWRFAIL = 0x08,
191 PCF50633_INT4_DWN1PWRFAIL = 0x10,
192 PCF50633_INT4_DWN2PWRFAIL = 0x20,
193 PCF50633_INT4_LEDPWRFAIL = 0x40,
194 PCF50633_INT4_LEDOVP = 0x80,
195};
196
197enum pcf50633_reg_int5 {
198 PCF50633_INT5_LDO1PWRFAIL = 0x01,
199 PCF50633_INT5_LDO2PWRFAIL = 0x02,
200 PCF50633_INT5_LDO3PWRFAIL = 0x04,
201 PCF50633_INT5_LDO4PWRFAIL = 0x08,
202 PCF50633_INT5_LDO5PWRFAIL = 0x10,
203 PCF50633_INT5_LDO6PWRFAIL = 0x20,
204 PCF50633_INT5_HCLDOPWRFAIL = 0x40,
205 PCF50633_INT5_HCLDOOVL = 0x80,
206};
207
208/* misc. registers */
209#define PCF50633_REG_OOCSHDWN 0x0c
210
211/* LED registers */
212#define PCF50633_REG_LEDOUT 0x28
213#define PCF50633_REG_LEDENA 0x29
214#define PCF50633_REG_LEDCTL 0x2a
215#define PCF50633_REG_LEDDIM 0x2b
216
217#endif
218