aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
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 16:17:01 -0500
commit53dbab7af9ca13fa95605e9a5c31bb803dcba363 (patch)
tree652214fb5b3cee8195e253e56314b913ed78cf88 /drivers/regulator
parentbbd51b1ff1bf57b9ed7f062486a415509968d4d9 (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 'drivers/regulator')
-rw-r--r--drivers/regulator/88pm8607.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 04719551381b..97897a6bf4f3 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -11,15 +11,17 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/i2c.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
15#include <linux/regulator/driver.h> 16#include <linux/regulator/driver.h>
16#include <linux/regulator/machine.h> 17#include <linux/regulator/machine.h>
17#include <linux/mfd/88pm8607.h> 18#include <linux/mfd/88pm860x.h>
18 19
19struct pm8607_regulator_info { 20struct pm8607_regulator_info {
20 struct regulator_desc desc; 21 struct regulator_desc desc;
21 struct pm8607_chip *chip; 22 struct pm860x_chip *chip;
22 struct regulator_dev *regulator; 23 struct regulator_dev *regulator;
24 struct i2c_client *i2c;
23 25
24 int min_uV; 26 int min_uV;
25 int max_uV; 27 int max_uV;
@@ -46,7 +48,7 @@ static inline int check_range(struct pm8607_regulator_info *info,
46static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index) 48static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
47{ 49{
48 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 50 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
49 uint8_t chip_id = info->chip->chip_id; 51 uint8_t chip_id = info->chip->chip_version;
50 int ret = -EINVAL; 52 int ret = -EINVAL;
51 53
52 switch (info->desc.id) { 54 switch (info->desc.id) {
@@ -169,7 +171,7 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
169static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) 171static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
170{ 172{
171 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 173 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
172 uint8_t chip_id = info->chip->chip_id; 174 uint8_t chip_id = info->chip->chip_version;
173 int val = -ENOENT; 175 int val = -ENOENT;
174 int ret; 176 int ret;
175 177
@@ -428,7 +430,6 @@ static int pm8607_set_voltage(struct regulator_dev *rdev,
428 int min_uV, int max_uV) 430 int min_uV, int max_uV)
429{ 431{
430 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 432 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
431 struct pm8607_chip *chip = info->chip;
432 uint8_t val, mask; 433 uint8_t val, mask;
433 int ret; 434 int ret;
434 435
@@ -443,13 +444,13 @@ static int pm8607_set_voltage(struct regulator_dev *rdev,
443 val = (uint8_t)(ret << info->vol_shift); 444 val = (uint8_t)(ret << info->vol_shift);
444 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; 445 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
445 446
446 ret = pm8607_set_bits(chip, info->vol_reg, mask, val); 447 ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val);
447 if (ret) 448 if (ret)
448 return ret; 449 return ret;
449 switch (info->desc.id) { 450 switch (info->desc.id) {
450 case PM8607_ID_BUCK1: 451 case PM8607_ID_BUCK1:
451 case PM8607_ID_BUCK3: 452 case PM8607_ID_BUCK3:
452 ret = pm8607_set_bits(chip, info->update_reg, 453 ret = pm860x_set_bits(info->i2c, info->update_reg,
453 1 << info->update_bit, 454 1 << info->update_bit,
454 1 << info->update_bit); 455 1 << info->update_bit);
455 break; 456 break;
@@ -460,11 +461,10 @@ static int pm8607_set_voltage(struct regulator_dev *rdev,
460static int pm8607_get_voltage(struct regulator_dev *rdev) 461static int pm8607_get_voltage(struct regulator_dev *rdev)
461{ 462{
462 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 463 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
463 struct pm8607_chip *chip = info->chip;
464 uint8_t val, mask; 464 uint8_t val, mask;
465 int ret; 465 int ret;
466 466
467 ret = pm8607_reg_read(chip, info->vol_reg); 467 ret = pm860x_reg_read(info->i2c, info->vol_reg);
468 if (ret < 0) 468 if (ret < 0)
469 return ret; 469 return ret;
470 470
@@ -477,9 +477,8 @@ static int pm8607_get_voltage(struct regulator_dev *rdev)
477static int pm8607_enable(struct regulator_dev *rdev) 477static int pm8607_enable(struct regulator_dev *rdev)
478{ 478{
479 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 479 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
480 struct pm8607_chip *chip = info->chip;
481 480
482 return pm8607_set_bits(chip, info->enable_reg, 481 return pm860x_set_bits(info->i2c, info->enable_reg,
483 1 << info->enable_bit, 482 1 << info->enable_bit,
484 1 << info->enable_bit); 483 1 << info->enable_bit);
485} 484}
@@ -487,19 +486,17 @@ static int pm8607_enable(struct regulator_dev *rdev)
487static int pm8607_disable(struct regulator_dev *rdev) 486static int pm8607_disable(struct regulator_dev *rdev)
488{ 487{
489 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 488 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
490 struct pm8607_chip *chip = info->chip;
491 489
492 return pm8607_set_bits(chip, info->enable_reg, 490 return pm860x_set_bits(info->i2c, info->enable_reg,
493 1 << info->enable_bit, 0); 491 1 << info->enable_bit, 0);
494} 492}
495 493
496static int pm8607_is_enabled(struct regulator_dev *rdev) 494static int pm8607_is_enabled(struct regulator_dev *rdev)
497{ 495{
498 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 496 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
499 struct pm8607_chip *chip = info->chip;
500 int ret; 497 int ret;
501 498
502 ret = pm8607_reg_read(chip, info->enable_reg); 499 ret = pm860x_reg_read(info->i2c, info->enable_reg);
503 if (ret < 0) 500 if (ret < 0)
504 return ret; 501 return ret;
505 502
@@ -589,8 +586,8 @@ static inline struct pm8607_regulator_info *find_regulator_info(int id)
589 586
590static int __devinit pm8607_regulator_probe(struct platform_device *pdev) 587static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
591{ 588{
592 struct pm8607_chip *chip = dev_get_drvdata(pdev->dev.parent); 589 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
593 struct pm8607_platform_data *pdata = chip->dev->platform_data; 590 struct pm860x_platform_data *pdata = chip->dev->platform_data;
594 struct pm8607_regulator_info *info = NULL; 591 struct pm8607_regulator_info *info = NULL;
595 592
596 info = find_regulator_info(pdev->id); 593 info = find_regulator_info(pdev->id);
@@ -599,6 +596,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
599 return -EINVAL; 596 return -EINVAL;
600 } 597 }
601 598
599 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
602 info->chip = chip; 600 info->chip = chip;
603 601
604 info->regulator = regulator_register(&info->desc, &pdev->dev, 602 info->regulator = regulator_register(&info->desc, &pdev->dev,