diff options
-rw-r--r-- | drivers/mfd/88pm8607.c | 302 | ||||
-rw-r--r-- | drivers/mfd/Kconfig | 10 | ||||
-rw-r--r-- | drivers/mfd/Makefile | 1 | ||||
-rw-r--r-- | include/linux/mfd/88pm8607.h | 217 |
4 files changed, 530 insertions, 0 deletions
diff --git a/drivers/mfd/88pm8607.c b/drivers/mfd/88pm8607.c new file mode 100644 index 000000000000..7e3f65907993 --- /dev/null +++ b/drivers/mfd/88pm8607.c | |||
@@ -0,0 +1,302 @@ | |||
1 | /* | ||
2 | * Base driver for Marvell 88PM8607 | ||
3 | * | ||
4 | * Copyright (C) 2009 Marvell International Ltd. | ||
5 | * Haojian Zhuang <haojian.zhuang@marvell.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 version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/i2c.h> | ||
17 | #include <linux/mfd/core.h> | ||
18 | #include <linux/mfd/88pm8607.h> | ||
19 | |||
20 | |||
21 | #define PM8607_REG_RESOURCE(_start, _end) \ | ||
22 | { \ | ||
23 | .start = PM8607_##_start, \ | ||
24 | .end = PM8607_##_end, \ | ||
25 | .flags = IORESOURCE_IO, \ | ||
26 | } | ||
27 | |||
28 | static struct resource pm8607_regulator_resources[] = { | ||
29 | PM8607_REG_RESOURCE(BUCK1, BUCK1), | ||
30 | PM8607_REG_RESOURCE(BUCK2, BUCK2), | ||
31 | PM8607_REG_RESOURCE(BUCK3, BUCK3), | ||
32 | PM8607_REG_RESOURCE(LDO1, LDO1), | ||
33 | PM8607_REG_RESOURCE(LDO2, LDO2), | ||
34 | PM8607_REG_RESOURCE(LDO3, LDO3), | ||
35 | PM8607_REG_RESOURCE(LDO4, LDO4), | ||
36 | PM8607_REG_RESOURCE(LDO5, LDO5), | ||
37 | PM8607_REG_RESOURCE(LDO6, LDO6), | ||
38 | PM8607_REG_RESOURCE(LDO7, LDO7), | ||
39 | PM8607_REG_RESOURCE(LDO8, LDO8), | ||
40 | PM8607_REG_RESOURCE(LDO9, LDO9), | ||
41 | PM8607_REG_RESOURCE(LDO10, LDO10), | ||
42 | PM8607_REG_RESOURCE(LDO12, LDO12), | ||
43 | PM8607_REG_RESOURCE(LDO14, LDO14), | ||
44 | }; | ||
45 | |||
46 | #define PM8607_REG_DEVS(_name, _id) \ | ||
47 | { \ | ||
48 | .name = "88pm8607-" #_name, \ | ||
49 | .num_resources = 1, \ | ||
50 | .resources = &pm8607_regulator_resources[PM8607_ID_##_id], \ | ||
51 | } | ||
52 | |||
53 | static struct mfd_cell pm8607_devs[] = { | ||
54 | PM8607_REG_DEVS(buck1, BUCK1), | ||
55 | PM8607_REG_DEVS(buck2, BUCK2), | ||
56 | PM8607_REG_DEVS(buck3, BUCK3), | ||
57 | PM8607_REG_DEVS(ldo1, LDO1), | ||
58 | PM8607_REG_DEVS(ldo2, LDO2), | ||
59 | PM8607_REG_DEVS(ldo3, LDO3), | ||
60 | PM8607_REG_DEVS(ldo4, LDO4), | ||
61 | PM8607_REG_DEVS(ldo5, LDO5), | ||
62 | PM8607_REG_DEVS(ldo6, LDO6), | ||
63 | PM8607_REG_DEVS(ldo7, LDO7), | ||
64 | PM8607_REG_DEVS(ldo8, LDO8), | ||
65 | PM8607_REG_DEVS(ldo9, LDO9), | ||
66 | PM8607_REG_DEVS(ldo10, LDO10), | ||
67 | PM8607_REG_DEVS(ldo12, LDO12), | ||
68 | PM8607_REG_DEVS(ldo14, LDO14), | ||
69 | }; | ||
70 | |||
71 | static inline int pm8607_read_device(struct pm8607_chip *chip, | ||
72 | int reg, int bytes, void *dest) | ||
73 | { | ||
74 | struct i2c_client *i2c = chip->client; | ||
75 | unsigned char data; | ||
76 | int ret; | ||
77 | |||
78 | data = (unsigned char)reg; | ||
79 | ret = i2c_master_send(i2c, &data, 1); | ||
80 | if (ret < 0) | ||
81 | return ret; | ||
82 | |||
83 | ret = i2c_master_recv(i2c, dest, bytes); | ||
84 | if (ret < 0) | ||
85 | return ret; | ||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static inline int pm8607_write_device(struct pm8607_chip *chip, | ||
90 | int reg, int bytes, void *src) | ||
91 | { | ||
92 | struct i2c_client *i2c = chip->client; | ||
93 | unsigned char buf[bytes + 1]; | ||
94 | int ret; | ||
95 | |||
96 | buf[0] = (unsigned char)reg; | ||
97 | memcpy(&buf[1], src, bytes); | ||
98 | |||
99 | ret = i2c_master_send(i2c, buf, bytes + 1); | ||
100 | if (ret < 0) | ||
101 | return ret; | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | int pm8607_reg_read(struct pm8607_chip *chip, int reg) | ||
106 | { | ||
107 | unsigned char data; | ||
108 | int ret; | ||
109 | |||
110 | mutex_lock(&chip->io_lock); | ||
111 | ret = chip->read(chip, reg, 1, &data); | ||
112 | mutex_unlock(&chip->io_lock); | ||
113 | |||
114 | if (ret < 0) | ||
115 | return ret; | ||
116 | else | ||
117 | return (int)data; | ||
118 | } | ||
119 | EXPORT_SYMBOL(pm8607_reg_read); | ||
120 | |||
121 | int pm8607_reg_write(struct pm8607_chip *chip, int reg, | ||
122 | unsigned char data) | ||
123 | { | ||
124 | int ret; | ||
125 | |||
126 | mutex_lock(&chip->io_lock); | ||
127 | ret = chip->write(chip, reg, 1, &data); | ||
128 | mutex_unlock(&chip->io_lock); | ||
129 | |||
130 | return ret; | ||
131 | } | ||
132 | EXPORT_SYMBOL(pm8607_reg_write); | ||
133 | |||
134 | int pm8607_bulk_read(struct pm8607_chip *chip, int reg, | ||
135 | int count, unsigned char *buf) | ||
136 | { | ||
137 | int ret; | ||
138 | |||
139 | mutex_lock(&chip->io_lock); | ||
140 | ret = chip->read(chip, reg, count, buf); | ||
141 | mutex_unlock(&chip->io_lock); | ||
142 | |||
143 | return ret; | ||
144 | } | ||
145 | EXPORT_SYMBOL(pm8607_bulk_read); | ||
146 | |||
147 | int pm8607_bulk_write(struct pm8607_chip *chip, int reg, | ||
148 | int count, unsigned char *buf) | ||
149 | { | ||
150 | int ret; | ||
151 | |||
152 | mutex_lock(&chip->io_lock); | ||
153 | ret = chip->write(chip, reg, count, buf); | ||
154 | mutex_unlock(&chip->io_lock); | ||
155 | |||
156 | return ret; | ||
157 | } | ||
158 | EXPORT_SYMBOL(pm8607_bulk_write); | ||
159 | |||
160 | int pm8607_set_bits(struct pm8607_chip *chip, int reg, | ||
161 | unsigned char mask, unsigned char data) | ||
162 | { | ||
163 | unsigned char value; | ||
164 | int ret; | ||
165 | |||
166 | mutex_lock(&chip->io_lock); | ||
167 | ret = chip->read(chip, reg, 1, &value); | ||
168 | if (ret < 0) | ||
169 | goto out; | ||
170 | value &= ~mask; | ||
171 | value |= data; | ||
172 | ret = chip->write(chip, reg, 1, &value); | ||
173 | out: | ||
174 | mutex_unlock(&chip->io_lock); | ||
175 | return ret; | ||
176 | } | ||
177 | EXPORT_SYMBOL(pm8607_set_bits); | ||
178 | |||
179 | |||
180 | static const struct i2c_device_id pm8607_id_table[] = { | ||
181 | { "88PM8607", 0 }, | ||
182 | {} | ||
183 | }; | ||
184 | MODULE_DEVICE_TABLE(i2c, pm8607_id_table); | ||
185 | |||
186 | |||
187 | static int __devinit pm8607_probe(struct i2c_client *client, | ||
188 | const struct i2c_device_id *id) | ||
189 | { | ||
190 | struct pm8607_platform_data *pdata = client->dev.platform_data; | ||
191 | struct pm8607_chip *chip; | ||
192 | int i, count; | ||
193 | int ret; | ||
194 | |||
195 | chip = kzalloc(sizeof(struct pm8607_chip), GFP_KERNEL); | ||
196 | if (chip == NULL) | ||
197 | return -ENOMEM; | ||
198 | |||
199 | chip->client = client; | ||
200 | chip->dev = &client->dev; | ||
201 | chip->read = pm8607_read_device; | ||
202 | chip->write = pm8607_write_device; | ||
203 | i2c_set_clientdata(client, chip); | ||
204 | |||
205 | mutex_init(&chip->io_lock); | ||
206 | dev_set_drvdata(chip->dev, chip); | ||
207 | |||
208 | ret = pm8607_reg_read(chip, PM8607_CHIP_ID); | ||
209 | if (ret < 0) { | ||
210 | dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret); | ||
211 | goto out; | ||
212 | } | ||
213 | if ((ret & CHIP_ID_MASK) == CHIP_ID) | ||
214 | dev_info(chip->dev, "Marvell 88PM8607 (ID: %02x) detected\n", | ||
215 | ret); | ||
216 | else { | ||
217 | dev_err(chip->dev, "Failed to detect Marvell 88PM8607. " | ||
218 | "Chip ID: %02x\n", ret); | ||
219 | goto out; | ||
220 | } | ||
221 | chip->chip_id = ret; | ||
222 | |||
223 | ret = pm8607_reg_read(chip, PM8607_BUCK3); | ||
224 | if (ret < 0) { | ||
225 | dev_err(chip->dev, "Failed to read BUCK3 register: %d\n", ret); | ||
226 | goto out; | ||
227 | } | ||
228 | if (ret & PM8607_BUCK3_DOUBLE) | ||
229 | chip->buck3_double = 1; | ||
230 | |||
231 | ret = pm8607_reg_read(chip, PM8607_MISC1); | ||
232 | if (ret < 0) { | ||
233 | dev_err(chip->dev, "Failed to read MISC1 register: %d\n", ret); | ||
234 | goto out; | ||
235 | } | ||
236 | if (pdata->i2c_port == PI2C_PORT) | ||
237 | ret |= PM8607_MISC1_PI2C; | ||
238 | else | ||
239 | ret &= ~PM8607_MISC1_PI2C; | ||
240 | ret = pm8607_reg_write(chip, PM8607_MISC1, ret); | ||
241 | if (ret < 0) { | ||
242 | dev_err(chip->dev, "Failed to write MISC1 register: %d\n", ret); | ||
243 | goto out; | ||
244 | } | ||
245 | |||
246 | |||
247 | count = ARRAY_SIZE(pm8607_devs); | ||
248 | for (i = 0; i < count; i++) { | ||
249 | ret = mfd_add_devices(chip->dev, i, &pm8607_devs[i], | ||
250 | 1, NULL, 0); | ||
251 | if (ret != 0) { | ||
252 | dev_err(chip->dev, "Failed to add subdevs\n"); | ||
253 | goto out; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | return 0; | ||
258 | |||
259 | out: | ||
260 | i2c_set_clientdata(client, NULL); | ||
261 | kfree(chip); | ||
262 | return ret; | ||
263 | } | ||
264 | |||
265 | static int __devexit pm8607_remove(struct i2c_client *client) | ||
266 | { | ||
267 | struct pm8607_chip *chip = i2c_get_clientdata(client); | ||
268 | |||
269 | mfd_remove_devices(chip->dev); | ||
270 | kfree(chip); | ||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | static struct i2c_driver pm8607_driver = { | ||
275 | .driver = { | ||
276 | .name = "88PM8607", | ||
277 | .owner = THIS_MODULE, | ||
278 | }, | ||
279 | .probe = pm8607_probe, | ||
280 | .remove = __devexit_p(pm8607_remove), | ||
281 | .id_table = pm8607_id_table, | ||
282 | }; | ||
283 | |||
284 | static int __init pm8607_init(void) | ||
285 | { | ||
286 | int ret; | ||
287 | ret = i2c_add_driver(&pm8607_driver); | ||
288 | if (ret != 0) | ||
289 | pr_err("Failed to register 88PM8607 I2C driver: %d\n", ret); | ||
290 | return ret; | ||
291 | } | ||
292 | subsys_initcall(pm8607_init); | ||
293 | |||
294 | static void __exit pm8607_exit(void) | ||
295 | { | ||
296 | i2c_del_driver(&pm8607_driver); | ||
297 | } | ||
298 | module_exit(pm8607_exit); | ||
299 | |||
300 | MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM8607"); | ||
301 | MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); | ||
302 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index a296e717e86e..26a36f887357 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -319,6 +319,16 @@ config EZX_PCAP | |||
319 | This enables the PCAP ASIC present on EZX Phones. This is | 319 | This enables the PCAP ASIC present on EZX Phones. This is |
320 | needed for MMC, TouchScreen, Sound, USB, etc.. | 320 | needed for MMC, TouchScreen, Sound, USB, etc.. |
321 | 321 | ||
322 | config MFD_88PM8607 | ||
323 | bool "Support Marvell 88PM8607" | ||
324 | depends on I2C | ||
325 | select MFD_CORE | ||
326 | help | ||
327 | This supports for Marvell 88PM8607 Power Management IC. This includes | ||
328 | the I2C driver and the core APIs _only_, you have to select | ||
329 | individual components like voltage regulators, RTC and | ||
330 | battery-charger under the corresponding menus. | ||
331 | |||
322 | endmenu | 332 | endmenu |
323 | 333 | ||
324 | menu "Multimedia Capabilities Port drivers" | 334 | menu "Multimedia Capabilities Port drivers" |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 11350c1d9301..2596add427a2 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -52,3 +52,4 @@ obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o | |||
52 | obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o | 52 | obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o |
53 | obj-$(CONFIG_AB3100_CORE) += ab3100-core.o | 53 | obj-$(CONFIG_AB3100_CORE) += ab3100-core.o |
54 | obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o | 54 | obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o |
55 | obj-$(CONFIG_MFD_88PM8607) += 88pm8607.o | ||
diff --git a/include/linux/mfd/88pm8607.h b/include/linux/mfd/88pm8607.h new file mode 100644 index 000000000000..f41b428d2cec --- /dev/null +++ b/include/linux/mfd/88pm8607.h | |||
@@ -0,0 +1,217 @@ | |||
1 | /* | ||
2 | * Marvell 88PM8607 Interface | ||
3 | * | ||
4 | * Copyright (C) 2009 Marvell International Ltd. | ||
5 | * Haojian Zhuang <haojian.zhuang@marvell.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 version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef __LINUX_MFD_88PM8607_H | ||
13 | #define __LINUX_MFD_88PM8607_H | ||
14 | |||
15 | enum { | ||
16 | PM8607_ID_BUCK1 = 0, | ||
17 | PM8607_ID_BUCK2, | ||
18 | PM8607_ID_BUCK3, | ||
19 | |||
20 | PM8607_ID_LDO1, | ||
21 | PM8607_ID_LDO2, | ||
22 | PM8607_ID_LDO3, | ||
23 | PM8607_ID_LDO4, | ||
24 | PM8607_ID_LDO5, | ||
25 | PM8607_ID_LDO6, | ||
26 | PM8607_ID_LDO7, | ||
27 | PM8607_ID_LDO8, | ||
28 | PM8607_ID_LDO9, | ||
29 | PM8607_ID_LDO10, | ||
30 | PM8607_ID_LDO12, | ||
31 | PM8607_ID_LDO14, | ||
32 | |||
33 | PM8607_ID_RG_MAX, | ||
34 | }; | ||
35 | |||
36 | #define CHIP_ID (0x40) | ||
37 | #define CHIP_ID_MASK (0xF8) | ||
38 | |||
39 | /* Interrupt Registers */ | ||
40 | #define PM8607_STATUS_1 (0x01) | ||
41 | #define PM8607_STATUS_2 (0x02) | ||
42 | #define PM8607_INT_STATUS1 (0x03) | ||
43 | #define PM8607_INT_STATUS2 (0x04) | ||
44 | #define PM8607_INT_STATUS3 (0x05) | ||
45 | #define PM8607_INT_MASK_1 (0x06) | ||
46 | #define PM8607_INT_MASK_2 (0x07) | ||
47 | #define PM8607_INT_MASK_3 (0x08) | ||
48 | |||
49 | /* Regulator Control Registers */ | ||
50 | #define PM8607_LDO1 (0x10) | ||
51 | #define PM8607_LDO2 (0x11) | ||
52 | #define PM8607_LDO3 (0x12) | ||
53 | #define PM8607_LDO4 (0x13) | ||
54 | #define PM8607_LDO5 (0x14) | ||
55 | #define PM8607_LDO6 (0x15) | ||
56 | #define PM8607_LDO7 (0x16) | ||
57 | #define PM8607_LDO8 (0x17) | ||
58 | #define PM8607_LDO9 (0x18) | ||
59 | #define PM8607_LDO10 (0x19) | ||
60 | #define PM8607_LDO12 (0x1A) | ||
61 | #define PM8607_LDO14 (0x1B) | ||
62 | #define PM8607_SLEEP_MODE1 (0x1C) | ||
63 | #define PM8607_SLEEP_MODE2 (0x1D) | ||
64 | #define PM8607_SLEEP_MODE3 (0x1E) | ||
65 | #define PM8607_SLEEP_MODE4 (0x1F) | ||
66 | #define PM8607_GO (0x20) | ||
67 | #define PM8607_SLEEP_BUCK1 (0x21) | ||
68 | #define PM8607_SLEEP_BUCK2 (0x22) | ||
69 | #define PM8607_SLEEP_BUCK3 (0x23) | ||
70 | #define PM8607_BUCK1 (0x24) | ||
71 | #define PM8607_BUCK2 (0x25) | ||
72 | #define PM8607_BUCK3 (0x26) | ||
73 | #define PM8607_BUCK_CONTROLS (0x27) | ||
74 | #define PM8607_SUPPLIES_EN11 (0x2B) | ||
75 | #define PM8607_SUPPLIES_EN12 (0x2C) | ||
76 | #define PM8607_GROUP1 (0x2D) | ||
77 | #define PM8607_GROUP2 (0x2E) | ||
78 | #define PM8607_GROUP3 (0x2F) | ||
79 | #define PM8607_GROUP4 (0x30) | ||
80 | #define PM8607_GROUP5 (0x31) | ||
81 | #define PM8607_GROUP6 (0x32) | ||
82 | #define PM8607_SUPPLIES_EN21 (0x33) | ||
83 | #define PM8607_SUPPLIES_EN22 (0x34) | ||
84 | |||
85 | /* RTC Control Registers */ | ||
86 | #define PM8607_RTC1 (0xA0) | ||
87 | #define PM8607_RTC_COUNTER1 (0xA1) | ||
88 | #define PM8607_RTC_COUNTER2 (0xA2) | ||
89 | #define PM8607_RTC_COUNTER3 (0xA3) | ||
90 | #define PM8607_RTC_COUNTER4 (0xA4) | ||
91 | #define PM8607_RTC_EXPIRE1 (0xA5) | ||
92 | #define PM8607_RTC_EXPIRE2 (0xA6) | ||
93 | #define PM8607_RTC_EXPIRE3 (0xA7) | ||
94 | #define PM8607_RTC_EXPIRE4 (0xA8) | ||
95 | #define PM8607_RTC_TRIM1 (0xA9) | ||
96 | #define PM8607_RTC_TRIM2 (0xAA) | ||
97 | #define PM8607_RTC_TRIM3 (0xAB) | ||
98 | #define PM8607_RTC_TRIM4 (0xAC) | ||
99 | #define PM8607_RTC_MISC1 (0xAD) | ||
100 | #define PM8607_RTC_MISC2 (0xAE) | ||
101 | #define PM8607_RTC_MISC3 (0xAF) | ||
102 | |||
103 | /* Misc Registers */ | ||
104 | #define PM8607_CHIP_ID (0x00) | ||
105 | #define PM8607_LDO1 (0x10) | ||
106 | #define PM8607_DVC3 (0x26) | ||
107 | #define PM8607_MISC1 (0x40) | ||
108 | |||
109 | /* bit definitions for PM8607 events */ | ||
110 | #define PM8607_EVENT_ONKEY (1 << 0) | ||
111 | #define PM8607_EVENT_EXTON (1 << 1) | ||
112 | #define PM8607_EVENT_CHG (1 << 2) | ||
113 | #define PM8607_EVENT_BAT (1 << 3) | ||
114 | #define PM8607_EVENT_RTC (1 << 4) | ||
115 | #define PM8607_EVENT_CC (1 << 5) | ||
116 | #define PM8607_EVENT_VBAT (1 << 8) | ||
117 | #define PM8607_EVENT_VCHG (1 << 9) | ||
118 | #define PM8607_EVENT_VSYS (1 << 10) | ||
119 | #define PM8607_EVENT_TINT (1 << 11) | ||
120 | #define PM8607_EVENT_GPADC0 (1 << 12) | ||
121 | #define PM8607_EVENT_GPADC1 (1 << 13) | ||
122 | #define PM8607_EVENT_GPADC2 (1 << 14) | ||
123 | #define PM8607_EVENT_GPADC3 (1 << 15) | ||
124 | #define PM8607_EVENT_AUDIO_SHORT (1 << 16) | ||
125 | #define PM8607_EVENT_PEN (1 << 17) | ||
126 | #define PM8607_EVENT_HEADSET (1 << 18) | ||
127 | #define PM8607_EVENT_HOOK (1 << 19) | ||
128 | #define PM8607_EVENT_MICIN (1 << 20) | ||
129 | #define PM8607_EVENT_CHG_TIMEOUT (1 << 21) | ||
130 | #define PM8607_EVENT_CHG_DONE (1 << 22) | ||
131 | #define PM8607_EVENT_CHG_FAULT (1 << 23) | ||
132 | |||
133 | /* bit definitions of Status Query Interface */ | ||
134 | #define PM8607_STATUS_CC (1 << 3) | ||
135 | #define PM8607_STATUS_PEN (1 << 4) | ||
136 | #define PM8607_STATUS_HEADSET (1 << 5) | ||
137 | #define PM8607_STATUS_HOOK (1 << 6) | ||
138 | #define PM8607_STATUS_MICIN (1 << 7) | ||
139 | #define PM8607_STATUS_ONKEY (1 << 8) | ||
140 | #define PM8607_STATUS_EXTON (1 << 9) | ||
141 | #define PM8607_STATUS_CHG (1 << 10) | ||
142 | #define PM8607_STATUS_BAT (1 << 11) | ||
143 | #define PM8607_STATUS_VBUS (1 << 12) | ||
144 | #define PM8607_STATUS_OV (1 << 13) | ||
145 | |||
146 | /* bit definitions of BUCK3 */ | ||
147 | #define PM8607_BUCK3_DOUBLE (1 << 6) | ||
148 | |||
149 | /* bit definitions of Misc1 */ | ||
150 | #define PM8607_MISC1_PI2C (1 << 0) | ||
151 | |||
152 | /* Interrupt Number in 88PM8607 */ | ||
153 | enum { | ||
154 | PM8607_IRQ_ONKEY = 0, | ||
155 | PM8607_IRQ_EXTON, | ||
156 | PM8607_IRQ_CHG, | ||
157 | PM8607_IRQ_BAT, | ||
158 | PM8607_IRQ_RTC, | ||
159 | PM8607_IRQ_VBAT = 8, | ||
160 | PM8607_IRQ_VCHG, | ||
161 | PM8607_IRQ_VSYS, | ||
162 | PM8607_IRQ_TINT, | ||
163 | PM8607_IRQ_GPADC0, | ||
164 | PM8607_IRQ_GPADC1, | ||
165 | PM8607_IRQ_GPADC2, | ||
166 | PM8607_IRQ_GPADC3, | ||
167 | PM8607_IRQ_AUDIO_SHORT = 16, | ||
168 | PM8607_IRQ_PEN, | ||
169 | PM8607_IRQ_HEADSET, | ||
170 | PM8607_IRQ_HOOK, | ||
171 | PM8607_IRQ_MICIN, | ||
172 | PM8607_IRQ_CHG_FAIL, | ||
173 | PM8607_IRQ_CHG_DONE, | ||
174 | PM8607_IRQ_CHG_FAULT, | ||
175 | }; | ||
176 | |||
177 | enum { | ||
178 | PM8607_CHIP_A0 = 0x40, | ||
179 | PM8607_CHIP_A1 = 0x41, | ||
180 | PM8607_CHIP_B0 = 0x48, | ||
181 | }; | ||
182 | |||
183 | |||
184 | struct pm8607_chip { | ||
185 | struct device *dev; | ||
186 | struct mutex io_lock; | ||
187 | struct i2c_client *client; | ||
188 | |||
189 | int (*read)(struct pm8607_chip *chip, int reg, int bytes, void *dest); | ||
190 | int (*write)(struct pm8607_chip *chip, int reg, int bytes, void *src); | ||
191 | |||
192 | int buck3_double; /* DVC ramp slope double */ | ||
193 | unsigned char chip_id; | ||
194 | |||
195 | }; | ||
196 | |||
197 | #define PM8607_MAX_REGULATOR 15 /* 3 Bucks, 12 LDOs */ | ||
198 | |||
199 | enum { | ||
200 | GI2C_PORT = 0, | ||
201 | PI2C_PORT, | ||
202 | }; | ||
203 | |||
204 | struct pm8607_platform_data { | ||
205 | int i2c_port; /* Controlled by GI2C or PI2C */ | ||
206 | struct regulator_init_data *regulator[PM8607_MAX_REGULATOR]; | ||
207 | }; | ||
208 | |||
209 | extern int pm8607_reg_read(struct pm8607_chip *, int); | ||
210 | extern int pm8607_reg_write(struct pm8607_chip *, int, unsigned char); | ||
211 | extern int pm8607_bulk_read(struct pm8607_chip *, int, int, | ||
212 | unsigned char *); | ||
213 | extern int pm8607_bulk_write(struct pm8607_chip *, int, int, | ||
214 | unsigned char *); | ||
215 | extern int pm8607_set_bits(struct pm8607_chip *, int, unsigned char, | ||
216 | unsigned char); | ||
217 | #endif /* __LINUX_MFD_88PM8607_H */ | ||