summaryrefslogtreecommitdiff
path: root/drivers/mfd/88pm860x-core.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@marvell.com>2010-01-08 06:01:24 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2010-03-07 22:17:01 +0100
commit53dbab7af9ca13fa95605e9a5c31bb803dcba363 (patch)
tree652214fb5b3cee8195e253e56314b913ed78cf88 /drivers/mfd/88pm860x-core.c
parentbbd51b1ff1bf57b9ed7f062486a415509968d4d9 (diff)
downloadlwn-53dbab7af9ca13fa95605e9a5c31bb803dcba363.tar.gz
lwn-53dbab7af9ca13fa95605e9a5c31bb803dcba363.zip
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 'drivers/mfd/88pm860x-core.c')
-rw-r--r--drivers/mfd/88pm860x-core.c61
1 files changed, 41 insertions, 20 deletions
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index d1464e54e656..72b00304dc3a 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -14,7 +14,7 @@
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/mfd/core.h>
-#include <linux/mfd/88pm8607.h>
+#include <linux/mfd/88pm860x.h>
#define PM8607_REG_RESOURCE(_start, _end) \
@@ -67,18 +67,23 @@ static struct mfd_cell pm8607_devs[] = {
PM8607_REG_DEVS(ldo14, LDO14),
};
-int pm860x_device_init(struct pm8607_chip *chip,
- struct pm8607_platform_data *pdata)
+static void device_8606_init(struct pm860x_chip *chip, struct i2c_client *i2c,
+ struct pm860x_platform_data *pdata)
+{
+}
+
+static void device_8607_init(struct pm860x_chip *chip, struct i2c_client *i2c,
+ struct pm860x_platform_data *pdata)
{
int i, count;
int ret;
- ret = pm8607_reg_read(chip, PM8607_CHIP_ID);
+ ret = pm860x_reg_read(i2c, PM8607_CHIP_ID);
if (ret < 0) {
dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
goto out;
}
- if ((ret & PM8607_ID_MASK) == PM8607_ID)
+ if ((ret & PM8607_VERSION_MASK) == PM8607_VERSION)
dev_info(chip->dev, "Marvell 88PM8607 (ID: %02x) detected\n",
ret);
else {
@@ -86,9 +91,9 @@ int pm860x_device_init(struct pm8607_chip *chip,
"Chip ID: %02x\n", ret);
goto out;
}
- chip->chip_id = ret;
+ chip->chip_version = ret;
- ret = pm8607_reg_read(chip, PM8607_BUCK3);
+ ret = pm860x_reg_read(i2c, PM8607_BUCK3);
if (ret < 0) {
dev_err(chip->dev, "Failed to read BUCK3 register: %d\n", ret);
goto out;
@@ -96,20 +101,11 @@ int pm860x_device_init(struct pm8607_chip *chip,
if (ret & PM8607_BUCK3_DOUBLE)
chip->buck3_double = 1;
- ret = pm8607_reg_read(chip, PM8607_MISC1);
+ ret = pm860x_reg_read(i2c, PM8607_MISC1);
if (ret < 0) {
dev_err(chip->dev, "Failed to read MISC1 register: %d\n", ret);
goto out;
}
- if (pdata->i2c_port == PI2C_PORT)
- ret |= PM8607_MISC1_PI2C;
- else
- ret &= ~PM8607_MISC1_PI2C;
- ret = pm8607_reg_write(chip, PM8607_MISC1, ret);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to write MISC1 register: %d\n", ret);
- goto out;
- }
count = ARRAY_SIZE(pm8607_devs);
for (i = 0; i < count; i++) {
@@ -121,14 +117,39 @@ int pm860x_device_init(struct pm8607_chip *chip,
}
}
out:
- return ret;
+ return;
+}
+
+int pm860x_device_init(struct pm860x_chip *chip,
+ struct pm860x_platform_data *pdata)
+{
+ switch (chip->id) {
+ case CHIP_PM8606:
+ device_8606_init(chip, chip->client, pdata);
+ break;
+ case CHIP_PM8607:
+ device_8607_init(chip, chip->client, pdata);
+ break;
+ }
+
+ if (chip->companion) {
+ switch (chip->id) {
+ case CHIP_PM8607:
+ device_8606_init(chip, chip->companion, pdata);
+ break;
+ case CHIP_PM8606:
+ device_8607_init(chip, chip->companion, pdata);
+ break;
+ }
+ }
+ return 0;
}
-void pm8607_device_exit(struct pm8607_chip *chip)
+void pm860x_device_exit(struct pm860x_chip *chip)
{
mfd_remove_devices(chip->dev);
}
-MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM8607");
+MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM860x");
MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
MODULE_LICENSE("GPL");