aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMyungJoo Ham <myungjoo.ham@samsung.com>2011-03-04 01:50:26 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2011-03-23 05:42:03 -0400
commit527e7e9a82ec95cdb8f694855004b3d262efd09f (patch)
tree5c58fb64d9efcf37c712b55c6ce993567483e2e3 /include
parentf77289ac25b0c81acbed6f9c17cb14809a04e18b (diff)
mfd: MAX8997/8966 support
MAX8997/MAX8966 chip is a multi-function device with I2C bussses. The chip includes PMIC, RTC, Fuel Gauge, MUIC, Haptic, Flash control, and Battery (charging) control. This patch is an initial release of a MAX8997/8966 driver that supports to enable the chip with its primary I2C bus that connects every device mentioned above except for Fuel Gauge, which uses another I2C bus. The fuel gauge is not supported by this mfd driver and is supported by a seperated driver of MAX17042 Fuel Gauge (yes, the fuel gauge part is compatible with MAX17042). Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mfd/max8997-private.h347
-rw-r--r--include/linux/mfd/max8997.h88
2 files changed, 435 insertions, 0 deletions
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
new file mode 100644
index 000000000000..93a9477e075f
--- /dev/null
+++ b/include/linux/mfd/max8997-private.h
@@ -0,0 +1,347 @@
1/*
2 * max8997.h - Voltage regulator driver for the Maxim 8997
3 *
4 * Copyright (C) 2010 Samsung Electrnoics
5 * MyungJoo Ham <myungjoo.ham@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef __LINUX_MFD_MAX8997_PRIV_H
23#define __LINUX_MFD_MAX8997_PRIV_H
24
25#include <linux/i2c.h>
26
27enum max8997_pmic_reg {
28 MAX8997_REG_PMIC_ID0 = 0x00,
29 MAX8997_REG_PMIC_ID1 = 0x01,
30 MAX8997_REG_INTSRC = 0x02,
31 MAX8997_REG_INT1 = 0x03,
32 MAX8997_REG_INT2 = 0x04,
33 MAX8997_REG_INT3 = 0x05,
34 MAX8997_REG_INT4 = 0x06,
35
36 MAX8997_REG_INT1MSK = 0x08,
37 MAX8997_REG_INT2MSK = 0x09,
38 MAX8997_REG_INT3MSK = 0x0a,
39 MAX8997_REG_INT4MSK = 0x0b,
40
41 MAX8997_REG_STATUS1 = 0x0d,
42 MAX8997_REG_STATUS2 = 0x0e,
43 MAX8997_REG_STATUS3 = 0x0f,
44 MAX8997_REG_STATUS4 = 0x10,
45
46 MAX8997_REG_MAINCON1 = 0x13,
47 MAX8997_REG_MAINCON2 = 0x14,
48 MAX8997_REG_BUCKRAMP = 0x15,
49
50 MAX8997_REG_BUCK1CTRL = 0x18,
51 MAX8997_REG_BUCK1DVS1 = 0x19,
52 MAX8997_REG_BUCK1DVS2 = 0x1a,
53 MAX8997_REG_BUCK1DVS3 = 0x1b,
54 MAX8997_REG_BUCK1DVS4 = 0x1c,
55 MAX8997_REG_BUCK1DVS5 = 0x1d,
56 MAX8997_REG_BUCK1DVS6 = 0x1e,
57 MAX8997_REG_BUCK1DVS7 = 0x1f,
58 MAX8997_REG_BUCK1DVS8 = 0x20,
59 MAX8997_REG_BUCK2CTRL = 0x21,
60 MAX8997_REG_BUCK2DVS1 = 0x22,
61 MAX8997_REG_BUCK2DVS2 = 0x23,
62 MAX8997_REG_BUCK2DVS3 = 0x24,
63 MAX8997_REG_BUCK2DVS4 = 0x25,
64 MAX8997_REG_BUCK2DVS5 = 0x26,
65 MAX8997_REG_BUCK2DVS6 = 0x27,
66 MAX8997_REG_BUCK2DVS7 = 0x28,
67 MAX8997_REG_BUCK2DVS8 = 0x29,
68 MAX8997_REG_BUCK3CTRL = 0x2a,
69 MAX8997_REG_BUCK3DVS = 0x2b,
70 MAX8997_REG_BUCK4CTRL = 0x2c,
71 MAX8997_REG_BUCK4DVS = 0x2d,
72 MAX8997_REG_BUCK5CTRL = 0x2e,
73 MAX8997_REG_BUCK5DVS1 = 0x2f,
74 MAX8997_REG_BUCK5DVS2 = 0x30,
75 MAX8997_REG_BUCK5DVS3 = 0x31,
76 MAX8997_REG_BUCK5DVS4 = 0x32,
77 MAX8997_REG_BUCK5DVS5 = 0x33,
78 MAX8997_REG_BUCK5DVS6 = 0x34,
79 MAX8997_REG_BUCK5DVS7 = 0x35,
80 MAX8997_REG_BUCK5DVS8 = 0x36,
81 MAX8997_REG_BUCK6CTRL = 0x37,
82 MAX8997_REG_BUCK6BPSKIPCTRL = 0x38,
83 MAX8997_REG_BUCK7CTRL = 0x39,
84 MAX8997_REG_BUCK7DVS = 0x3a,
85 MAX8997_REG_LDO1CTRL = 0x3b,
86 MAX8997_REG_LDO2CTRL = 0x3c,
87 MAX8997_REG_LDO3CTRL = 0x3d,
88 MAX8997_REG_LDO4CTRL = 0x3e,
89 MAX8997_REG_LDO5CTRL = 0x3f,
90 MAX8997_REG_LDO6CTRL = 0x40,
91 MAX8997_REG_LDO7CTRL = 0x41,
92 MAX8997_REG_LDO8CTRL = 0x42,
93 MAX8997_REG_LDO9CTRL = 0x43,
94 MAX8997_REG_LDO10CTRL = 0x44,
95 MAX8997_REG_LDO11CTRL = 0x45,
96 MAX8997_REG_LDO12CTRL = 0x46,
97 MAX8997_REG_LDO13CTRL = 0x47,
98 MAX8997_REG_LDO14CTRL = 0x48,
99 MAX8997_REG_LDO15CTRL = 0x49,
100 MAX8997_REG_LDO16CTRL = 0x4a,
101 MAX8997_REG_LDO17CTRL = 0x4b,
102 MAX8997_REG_LDO18CTRL = 0x4c,
103 MAX8997_REG_LDO21CTRL = 0x4d,
104
105 MAX8997_REG_MBCCTRL1 = 0x50,
106 MAX8997_REG_MBCCTRL2 = 0x51,
107 MAX8997_REG_MBCCTRL3 = 0x52,
108 MAX8997_REG_MBCCTRL4 = 0x53,
109 MAX8997_REG_MBCCTRL5 = 0x54,
110 MAX8997_REG_MBCCTRL6 = 0x55,
111 MAX8997_REG_OTPCGHCVS = 0x56,
112
113 MAX8997_REG_SAFEOUTCTRL = 0x5a,
114
115 MAX8997_REG_LBCNFG1 = 0x5e,
116 MAX8997_REG_LBCNFG2 = 0x5f,
117 MAX8997_REG_BBCCTRL = 0x60,
118
119 MAX8997_REG_FLASH1_CUR = 0x63, /* 0x63 ~ 0x6e for FLASH */
120 MAX8997_REG_FLASH2_CUR = 0x64,
121 MAX8997_REG_MOVIE_CUR = 0x65,
122 MAX8997_REG_GSMB_CUR = 0x66,
123 MAX8997_REG_BOOST_CNTL = 0x67,
124 MAX8997_REG_LEN_CNTL = 0x68,
125 MAX8997_REG_FLASH_CNTL = 0x69,
126 MAX8997_REG_WDT_CNTL = 0x6a,
127 MAX8997_REG_MAXFLASH1 = 0x6b,
128 MAX8997_REG_MAXFLASH2 = 0x6c,
129 MAX8997_REG_FLASHSTATUS = 0x6d,
130 MAX8997_REG_FLASHSTATUSMASK = 0x6e,
131
132 MAX8997_REG_GPIOCNTL1 = 0x70,
133 MAX8997_REG_GPIOCNTL2 = 0x71,
134 MAX8997_REG_GPIOCNTL3 = 0x72,
135 MAX8997_REG_GPIOCNTL4 = 0x73,
136 MAX8997_REG_GPIOCNTL5 = 0x74,
137 MAX8997_REG_GPIOCNTL6 = 0x75,
138 MAX8997_REG_GPIOCNTL7 = 0x76,
139 MAX8997_REG_GPIOCNTL8 = 0x77,
140 MAX8997_REG_GPIOCNTL9 = 0x78,
141 MAX8997_REG_GPIOCNTL10 = 0x79,
142 MAX8997_REG_GPIOCNTL11 = 0x7a,
143 MAX8997_REG_GPIOCNTL12 = 0x7b,
144
145 MAX8997_REG_LDO1CONFIG = 0x80,
146 MAX8997_REG_LDO2CONFIG = 0x81,
147 MAX8997_REG_LDO3CONFIG = 0x82,
148 MAX8997_REG_LDO4CONFIG = 0x83,
149 MAX8997_REG_LDO5CONFIG = 0x84,
150 MAX8997_REG_LDO6CONFIG = 0x85,
151 MAX8997_REG_LDO7CONFIG = 0x86,
152 MAX8997_REG_LDO8CONFIG = 0x87,
153 MAX8997_REG_LDO9CONFIG = 0x88,
154 MAX8997_REG_LDO10CONFIG = 0x89,
155 MAX8997_REG_LDO11CONFIG = 0x8a,
156 MAX8997_REG_LDO12CONFIG = 0x8b,
157 MAX8997_REG_LDO13CONFIG = 0x8c,
158 MAX8997_REG_LDO14CONFIG = 0x8d,
159 MAX8997_REG_LDO15CONFIG = 0x8e,
160 MAX8997_REG_LDO16CONFIG = 0x8f,
161 MAX8997_REG_LDO17CONFIG = 0x90,
162 MAX8997_REG_LDO18CONFIG = 0x91,
163 MAX8997_REG_LDO21CONFIG = 0x92,
164
165 MAX8997_REG_DVSOKTIMER1 = 0x97,
166 MAX8997_REG_DVSOKTIMER2 = 0x98,
167 MAX8997_REG_DVSOKTIMER4 = 0x99,
168 MAX8997_REG_DVSOKTIMER5 = 0x9a,
169
170 MAX8997_REG_PMIC_END = 0x9b,
171};
172
173enum max8997_muic_reg {
174 MAX8997_MUIC_REG_ID = 0x0,
175 MAX8997_MUIC_REG_INT1 = 0x1,
176 MAX8997_MUIC_REG_INT2 = 0x2,
177 MAX8997_MUIC_REG_INT3 = 0x3,
178 MAX8997_MUIC_REG_STATUS1 = 0x4,
179 MAX8997_MUIC_REG_STATUS2 = 0x5,
180 MAX8997_MUIC_REG_STATUS3 = 0x6,
181 MAX8997_MUIC_REG_INTMASK1 = 0x7,
182 MAX8997_MUIC_REG_INTMASK2 = 0x8,
183 MAX8997_MUIC_REG_INTMASK3 = 0x9,
184 MAX8997_MUIC_REG_CDETCTRL = 0xa,
185
186 MAX8997_MUIC_REG_CONTROL1 = 0xc,
187 MAX8997_MUIC_REG_CONTROL2 = 0xd,
188 MAX8997_MUIC_REG_CONTROL3 = 0xe,
189
190 MAX8997_MUIC_REG_END = 0xf,
191};
192
193enum max8997_haptic_reg {
194 MAX8997_HAPTIC_REG_GENERAL = 0x00,
195 MAX8997_HAPTIC_REG_CONF1 = 0x01,
196 MAX8997_HAPTIC_REG_CONF2 = 0x02,
197 MAX8997_HAPTIC_REG_DRVCONF = 0x03,
198 MAX8997_HAPTIC_REG_CYCLECONF1 = 0x04,
199 MAX8997_HAPTIC_REG_CYCLECONF2 = 0x05,
200 MAX8997_HAPTIC_REG_SIGCONF1 = 0x06,
201 MAX8997_HAPTIC_REG_SIGCONF2 = 0x07,
202 MAX8997_HAPTIC_REG_SIGCONF3 = 0x08,
203 MAX8997_HAPTIC_REG_SIGCONF4 = 0x09,
204 MAX8997_HAPTIC_REG_SIGDC1 = 0x0a,
205 MAX8997_HAPTIC_REG_SIGDC2 = 0x0b,
206 MAX8997_HAPTIC_REG_SIGPWMDC1 = 0x0c,
207 MAX8997_HAPTIC_REG_SIGPWMDC2 = 0x0d,
208 MAX8997_HAPTIC_REG_SIGPWMDC3 = 0x0e,
209 MAX8997_HAPTIC_REG_SIGPWMDC4 = 0x0f,
210 MAX8997_HAPTIC_REG_MTR_REV = 0x10,
211
212 MAX8997_HAPTIC_REG_END = 0x11,
213};
214
215/* slave addr = 0x0c: using "2nd part" of rev4 datasheet */
216enum max8997_rtc_reg {
217 MAX8997_RTC_CTRLMASK = 0x02,
218 MAX8997_RTC_CTRL = 0x03,
219 MAX8997_RTC_UPDATE1 = 0x04,
220 MAX8997_RTC_UPDATE2 = 0x05,
221 MAX8997_RTC_WTSR_SMPL = 0x06,
222
223 MAX8997_RTC_SEC = 0x10,
224 MAX8997_RTC_MIN = 0x11,
225 MAX8997_RTC_HOUR = 0x12,
226 MAX8997_RTC_DAY_OF_WEEK = 0x13,
227 MAX8997_RTC_MONTH = 0x14,
228 MAX8997_RTC_YEAR = 0x15,
229 MAX8997_RTC_DAY_OF_MONTH = 0x16,
230 MAX8997_RTC_ALARM1_SEC = 0x17,
231 MAX8997_RTC_ALARM1_MIN = 0x18,
232 MAX8997_RTC_ALARM1_HOUR = 0x19,
233 MAX8997_RTC_ALARM1_DAY_OF_WEEK = 0x1a,
234 MAX8997_RTC_ALARM1_MONTH = 0x1b,
235 MAX8997_RTC_ALARM1_YEAR = 0x1c,
236 MAX8997_RTC_ALARM1_DAY_OF_MONTH = 0x1d,
237 MAX8997_RTC_ALARM2_SEC = 0x1e,
238 MAX8997_RTC_ALARM2_MIN = 0x1f,
239 MAX8997_RTC_ALARM2_HOUR = 0x20,
240 MAX8997_RTC_ALARM2_DAY_OF_WEEK = 0x21,
241 MAX8997_RTC_ALARM2_MONTH = 0x22,
242 MAX8997_RTC_ALARM2_YEAR = 0x23,
243 MAX8997_RTC_ALARM2_DAY_OF_MONTH = 0x24,
244};
245
246enum max8997_irq_source {
247 PMIC_INT1 = 0,
248 PMIC_INT2,
249 PMIC_INT3,
250 PMIC_INT4,
251
252 FUEL_GAUGE, /* Ignored (MAX17042 driver handles) */
253
254 MUIC_INT1,
255 MUIC_INT2,
256 MUIC_INT3,
257
258 GPIO_LOW, /* Not implemented */
259 GPIO_HI, /* Not implemented */
260
261 FLASH_STATUS, /* Not implemented */
262
263 MAX8997_IRQ_GROUP_NR,
264};
265
266enum max8997_irq {
267 MAX8997_PMICIRQ_PWRONR,
268 MAX8997_PMICIRQ_PWRONF,
269 MAX8997_PMICIRQ_PWRON1SEC,
270 MAX8997_PMICIRQ_JIGONR,
271 MAX8997_PMICIRQ_JIGONF,
272 MAX8997_PMICIRQ_LOWBAT2,
273 MAX8997_PMICIRQ_LOWBAT1,
274
275 MAX8997_PMICIRQ_JIGR,
276 MAX8997_PMICIRQ_JIGF,
277 MAX8997_PMICIRQ_MR,
278 MAX8997_PMICIRQ_DVS1OK,
279 MAX8997_PMICIRQ_DVS2OK,
280 MAX8997_PMICIRQ_DVS3OK,
281 MAX8997_PMICIRQ_DVS4OK,
282
283 MAX8997_PMICIRQ_CHGINS,
284 MAX8997_PMICIRQ_CHGRM,
285 MAX8997_PMICIRQ_DCINOVP,
286 MAX8997_PMICIRQ_TOPOFFR,
287 MAX8997_PMICIRQ_CHGRSTF,
288 MAX8997_PMICIRQ_MBCHGTMEXPD,
289
290 MAX8997_PMICIRQ_RTC60S,
291 MAX8997_PMICIRQ_RTCA1,
292 MAX8997_PMICIRQ_RTCA2,
293 MAX8997_PMICIRQ_SMPL_INT,
294 MAX8997_PMICIRQ_RTC1S,
295 MAX8997_PMICIRQ_WTSR,
296
297 MAX8997_MUICIRQ_ADCError,
298 MAX8997_MUICIRQ_ADCLow,
299 MAX8997_MUICIRQ_ADC,
300
301 MAX8997_MUICIRQ_VBVolt,
302 MAX8997_MUICIRQ_DBChg,
303 MAX8997_MUICIRQ_DCDTmr,
304 MAX8997_MUICIRQ_ChgDetRun,
305 MAX8997_MUICIRQ_ChgTyp,
306
307 MAX8997_MUICIRQ_OVP,
308
309 MAX8997_IRQ_NR,
310};
311
312#define MAX8997_REG_BUCK1DVS(x) (MAX8997_REG_BUCK1DVS1 + (x) - 1)
313#define MAX8997_REG_BUCK2DVS(x) (MAX8997_REG_BUCK2DVS1 + (x) - 1)
314#define MAX8997_REG_BUCK5DVS(x) (MAX8997_REG_BUCK5DVS1 + (x) - 1)
315
316struct max8997_dev {
317 struct device *dev;
318 struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */
319 struct i2c_client *rtc; /* slave addr 0x0c */
320 struct i2c_client *haptic; /* slave addr 0x90 */
321 struct i2c_client *muic; /* slave addr 0x4a */
322 struct mutex iolock;
323
324 int type;
325 struct platform_device *battery; /* battery control (not fuel gauge) */
326
327 bool wakeup;
328
329 /* For hibernation */
330 u8 reg_dump[MAX8997_REG_PMIC_END + MAX8997_MUIC_REG_END +
331 MAX8997_HAPTIC_REG_END];
332};
333
334enum max8997_types {
335 TYPE_MAX8997,
336 TYPE_MAX8966,
337};
338
339extern int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest);
340extern int max8997_bulk_read(struct i2c_client *i2c, u8 reg, int count,
341 u8 *buf);
342extern int max8997_write_reg(struct i2c_client *i2c, u8 reg, u8 value);
343extern int max8997_bulk_write(struct i2c_client *i2c, u8 reg, int count,
344 u8 *buf);
345extern int max8997_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask);
346
347#endif /* __LINUX_MFD_MAX8997_PRIV_H */
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
new file mode 100644
index 000000000000..d0d9136c104b
--- /dev/null
+++ b/include/linux/mfd/max8997.h
@@ -0,0 +1,88 @@
1/*
2 * max8997.h - Driver for the Maxim 8997/8966
3 *
4 * Copyright (C) 2009-2010 Samsung Electrnoics
5 * MyungJoo Ham <myungjoo.ham@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * This driver is based on max8998.h
22 *
23 * MAX8997 has PMIC, MUIC, HAPTIC, RTC, FLASH, and Fuel Gauge devices.
24 * Except Fuel Gauge, every device shares the same I2C bus and included in
25 * this mfd driver. Although the fuel gauge is included in the chip, it is
26 * excluded from the driver because a) it has a different I2C bus from
27 * others and b) it can be enabled simply by using MAX17042 driver.
28 */
29
30#ifndef __LINUX_MFD_MAX8998_H
31#define __LINUX_MFD_MAX8998_H
32
33#include <linux/regulator/consumer.h>
34
35/* MAX8997/8966 regulator IDs */
36enum max8998_regulators {
37 MAX8997_LDO1 = 0,
38 MAX8997_LDO2,
39 MAX8997_LDO3,
40 MAX8997_LDO4,
41 MAX8997_LDO5,
42 MAX8997_LDO6,
43 MAX8997_LDO7,
44 MAX8997_LDO8,
45 MAX8997_LDO9,
46 MAX8997_LDO10,
47 MAX8997_LDO11,
48 MAX8997_LDO12,
49 MAX8997_LDO13,
50 MAX8997_LDO14,
51 MAX8997_LDO15,
52 MAX8997_LDO16,
53 MAX8997_LDO17,
54 MAX8997_LDO18,
55 MAX8997_LDO21,
56 MAX8997_BUCK1,
57 MAX8997_BUCK2,
58 MAX8997_BUCK3,
59 MAX8997_BUCK4,
60 MAX8997_BUCK5,
61 MAX8997_BUCK6,
62 MAX8997_BUCK7,
63 MAX8997_EN32KHZ_AP,
64 MAX8997_EN32KHZ_CP,
65 MAX8997_ENVICHG,
66 MAX8997_ESAFEOUT1,
67 MAX8997_ESAFEOUT2,
68 MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */
69 MAX8997_CHARGER, /* charger current, MBCCTRL4 */
70 MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */
71};
72
73struct max8997_regulator_data {
74 int id;
75 struct regulator_init_data *initdata;
76};
77
78struct max8997_platform_data {
79 bool wakeup;
80 /* PMIC: Not implemented */
81 /* MUIC: Not implemented */
82 /* HAPTIC: Not implemented */
83 /* RTC: Not implemented */
84 /* Flash: Not implemented */
85 /* Charger control: Not implemented */
86};
87
88#endif /* __LINUX_MFD_MAX8998_H */