diff options
author | Haojian Zhuang <haojian.zhuang@marvell.com> | 2010-01-08 06:01:24 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-03-07 16:17:01 -0500 |
commit | 53dbab7af9ca13fa95605e9a5c31bb803dcba363 (patch) | |
tree | 652214fb5b3cee8195e253e56314b913ed78cf88 /include/linux | |
parent | bbd51b1ff1bf57b9ed7f062486a415509968d4d9 (diff) |
mfd: Support 88pm8606 in 860x driver
88PM8606 and 88PM8607 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according to
requirement.
There's some logic tightly linked between these two chips. For example, USB
charger driver needs to access both chips by I2C interface.
Now share one driver to these two devices. Only one I2C client is identified
in platform init data. If another chip is also used, user should mark it in
companion_addr field of platform init data. Then driver could create another
I2C client for the companion chip.
All I2C operations are accessed by 860x-i2c driver. In order to support both
I2C client address, the read/write API is changed in below.
reg_read(client, offset)
reg_write(client, offset, data)
The benefit is that client drivers only need one kind of read/write API. I2C
and MFD driver can be shared in both 8606 and 8607.
Since API is changed, update API in 8607 regulator driver.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/mfd/88pm860x.h (renamed from include/linux/mfd/88pm8607.h) | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/include/linux/mfd/88pm8607.h b/include/linux/mfd/88pm860x.h index 6e4dcdca02a8..5845ae47df30 100644 --- a/include/linux/mfd/88pm8607.h +++ b/include/linux/mfd/88pm860x.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Marvell 88PM8607 Interface | 2 | * Marvell 88PM860x Interface |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Marvell International Ltd. | 4 | * Copyright (C) 2009 Marvell International Ltd. |
5 | * Haojian Zhuang <haojian.zhuang@marvell.com> | 5 | * Haojian Zhuang <haojian.zhuang@marvell.com> |
@@ -9,8 +9,15 @@ | |||
9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #ifndef __LINUX_MFD_88PM8607_H | 12 | #ifndef __LINUX_MFD_88PM860X_H |
13 | #define __LINUX_MFD_88PM8607_H | 13 | #define __LINUX_MFD_88PM860X_H |
14 | |||
15 | enum { | ||
16 | CHIP_INVALID = 0, | ||
17 | CHIP_PM8606, | ||
18 | CHIP_PM8607, | ||
19 | CHIP_MAX, | ||
20 | }; | ||
14 | 21 | ||
15 | enum { | 22 | enum { |
16 | PM8607_ID_BUCK1 = 0, | 23 | PM8607_ID_BUCK1 = 0, |
@@ -33,8 +40,8 @@ enum { | |||
33 | PM8607_ID_RG_MAX, | 40 | PM8607_ID_RG_MAX, |
34 | }; | 41 | }; |
35 | 42 | ||
36 | #define PM8607_ID (0x40) /* 8607 chip ID */ | 43 | #define PM8607_VERSION (0x40) /* 8607 chip ID */ |
37 | #define PM8607_ID_MASK (0xF8) /* 8607 chip ID mask */ | 44 | #define PM8607_VERSION_MASK (0xF0) /* 8607 chip ID mask */ |
38 | 45 | ||
39 | /* Interrupt Registers */ | 46 | /* Interrupt Registers */ |
40 | #define PM8607_STATUS_1 (0x01) | 47 | #define PM8607_STATUS_1 (0x01) |
@@ -180,18 +187,16 @@ enum { | |||
180 | PM8607_CHIP_B0 = 0x48, | 187 | PM8607_CHIP_B0 = 0x48, |
181 | }; | 188 | }; |
182 | 189 | ||
183 | 190 | struct pm860x_chip { | |
184 | struct pm8607_chip { | ||
185 | struct device *dev; | 191 | struct device *dev; |
186 | struct mutex io_lock; | 192 | struct mutex io_lock; |
187 | struct i2c_client *client; | 193 | struct i2c_client *client; |
188 | struct i2c_device_id id; | 194 | struct i2c_client *companion; /* companion chip client */ |
189 | |||
190 | int (*read)(struct pm8607_chip *chip, int reg, int bytes, void *dest); | ||
191 | int (*write)(struct pm8607_chip *chip, int reg, int bytes, void *src); | ||
192 | 195 | ||
193 | int buck3_double; /* DVC ramp slope double */ | 196 | int buck3_double; /* DVC ramp slope double */ |
194 | unsigned char chip_id; | 197 | unsigned short companion_addr; |
198 | int id; | ||
199 | unsigned char chip_version; | ||
195 | 200 | ||
196 | }; | 201 | }; |
197 | 202 | ||
@@ -202,22 +207,21 @@ enum { | |||
202 | PI2C_PORT, | 207 | PI2C_PORT, |
203 | }; | 208 | }; |
204 | 209 | ||
205 | struct pm8607_platform_data { | 210 | struct pm860x_platform_data { |
206 | int i2c_port; /* Controlled by GI2C or PI2C */ | 211 | unsigned short companion_addr; /* I2C address of companion chip */ |
212 | int i2c_port; /* Controlled by GI2C or PI2C */ | ||
207 | struct regulator_init_data *regulator[PM8607_MAX_REGULATOR]; | 213 | struct regulator_init_data *regulator[PM8607_MAX_REGULATOR]; |
208 | }; | 214 | }; |
209 | 215 | ||
210 | extern int pm8607_reg_read(struct pm8607_chip *, int); | 216 | extern int pm860x_reg_read(struct i2c_client *, int); |
211 | extern int pm8607_reg_write(struct pm8607_chip *, int, unsigned char); | 217 | extern int pm860x_reg_write(struct i2c_client *, int, unsigned char); |
212 | extern int pm8607_bulk_read(struct pm8607_chip *, int, int, | 218 | extern int pm860x_bulk_read(struct i2c_client *, int, int, unsigned char *); |
213 | unsigned char *); | 219 | extern int pm860x_bulk_write(struct i2c_client *, int, int, unsigned char *); |
214 | extern int pm8607_bulk_write(struct pm8607_chip *, int, int, | 220 | extern int pm860x_set_bits(struct i2c_client *, int, unsigned char, |
215 | unsigned char *); | ||
216 | extern int pm8607_set_bits(struct pm8607_chip *, int, unsigned char, | ||
217 | unsigned char); | 221 | unsigned char); |
218 | 222 | ||
219 | extern int pm860x_device_init(struct pm8607_chip *chip, | 223 | extern int pm860x_device_init(struct pm860x_chip *chip, |
220 | struct pm8607_platform_data *pdata); | 224 | struct pm860x_platform_data *pdata); |
221 | extern void pm860x_device_exit(struct pm8607_chip *chip); | 225 | extern void pm860x_device_exit(struct pm860x_chip *chip); |
222 | 226 | ||
223 | #endif /* __LINUX_MFD_88PM860X_H */ | 227 | #endif /* __LINUX_MFD_88PM860X_H */ |