diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-17 02:34:46 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-23 08:19:50 -0400 |
commit | a40a9c436b62251be285be9f3ba57864be10d000 (patch) | |
tree | c8aa29629b806d9e1cf8d437d11391658a7b4f60 | |
parent | 5bb6936c060aa054fa814fd29196d9f88f035637 (diff) |
regulator: tps65910: Use generic regmap enable/disable operations
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | drivers/regulator/tps65910-regulator.c | 69 |
1 files changed, 15 insertions, 54 deletions
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index fe66a2c43fd9..43bc6c6bc8f8 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -467,48 +467,6 @@ static int tps65911_get_ctrl_register(int id) | |||
467 | } | 467 | } |
468 | } | 468 | } |
469 | 469 | ||
470 | static int tps65910_is_enabled(struct regulator_dev *dev) | ||
471 | { | ||
472 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
473 | int reg, value, id = rdev_get_id(dev); | ||
474 | |||
475 | reg = pmic->get_ctrl_reg(id); | ||
476 | if (reg < 0) | ||
477 | return reg; | ||
478 | |||
479 | value = tps65910_reg_read(pmic, reg); | ||
480 | if (value < 0) | ||
481 | return value; | ||
482 | |||
483 | return value & TPS65910_SUPPLY_STATE_ENABLED; | ||
484 | } | ||
485 | |||
486 | static int tps65910_enable(struct regulator_dev *dev) | ||
487 | { | ||
488 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
489 | struct tps65910 *mfd = pmic->mfd; | ||
490 | int reg, id = rdev_get_id(dev); | ||
491 | |||
492 | reg = pmic->get_ctrl_reg(id); | ||
493 | if (reg < 0) | ||
494 | return reg; | ||
495 | |||
496 | return tps65910_set_bits(mfd, reg, TPS65910_SUPPLY_STATE_ENABLED); | ||
497 | } | ||
498 | |||
499 | static int tps65910_disable(struct regulator_dev *dev) | ||
500 | { | ||
501 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
502 | struct tps65910 *mfd = pmic->mfd; | ||
503 | int reg, id = rdev_get_id(dev); | ||
504 | |||
505 | reg = pmic->get_ctrl_reg(id); | ||
506 | if (reg < 0) | ||
507 | return reg; | ||
508 | |||
509 | return tps65910_clear_bits(mfd, reg, TPS65910_SUPPLY_STATE_ENABLED); | ||
510 | } | ||
511 | |||
512 | static int tps65910_enable_time(struct regulator_dev *dev) | 470 | static int tps65910_enable_time(struct regulator_dev *dev) |
513 | { | 471 | { |
514 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 472 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
@@ -914,9 +872,9 @@ static int tps65910_set_voltage_dcdc_time_sel(struct regulator_dev *dev, | |||
914 | 872 | ||
915 | /* Regulator ops (except VRTC) */ | 873 | /* Regulator ops (except VRTC) */ |
916 | static struct regulator_ops tps65910_ops_dcdc = { | 874 | static struct regulator_ops tps65910_ops_dcdc = { |
917 | .is_enabled = tps65910_is_enabled, | 875 | .is_enabled = regulator_is_enabled_regmap, |
918 | .enable = tps65910_enable, | 876 | .enable = regulator_enable_regmap, |
919 | .disable = tps65910_disable, | 877 | .disable = regulator_disable_regmap, |
920 | .enable_time = tps65910_enable_time, | 878 | .enable_time = tps65910_enable_time, |
921 | .set_mode = tps65910_set_mode, | 879 | .set_mode = tps65910_set_mode, |
922 | .get_mode = tps65910_get_mode, | 880 | .get_mode = tps65910_get_mode, |
@@ -927,9 +885,9 @@ static struct regulator_ops tps65910_ops_dcdc = { | |||
927 | }; | 885 | }; |
928 | 886 | ||
929 | static struct regulator_ops tps65910_ops_vdd3 = { | 887 | static struct regulator_ops tps65910_ops_vdd3 = { |
930 | .is_enabled = tps65910_is_enabled, | 888 | .is_enabled = regulator_is_enabled_regmap, |
931 | .enable = tps65910_enable, | 889 | .enable = regulator_enable_regmap, |
932 | .disable = tps65910_disable, | 890 | .disable = regulator_disable_regmap, |
933 | .enable_time = tps65910_enable_time, | 891 | .enable_time = tps65910_enable_time, |
934 | .set_mode = tps65910_set_mode, | 892 | .set_mode = tps65910_set_mode, |
935 | .get_mode = tps65910_get_mode, | 893 | .get_mode = tps65910_get_mode, |
@@ -938,9 +896,9 @@ static struct regulator_ops tps65910_ops_vdd3 = { | |||
938 | }; | 896 | }; |
939 | 897 | ||
940 | static struct regulator_ops tps65910_ops = { | 898 | static struct regulator_ops tps65910_ops = { |
941 | .is_enabled = tps65910_is_enabled, | 899 | .is_enabled = regulator_is_enabled_regmap, |
942 | .enable = tps65910_enable, | 900 | .enable = regulator_enable_regmap, |
943 | .disable = tps65910_disable, | 901 | .disable = regulator_disable_regmap, |
944 | .enable_time = tps65910_enable_time, | 902 | .enable_time = tps65910_enable_time, |
945 | .set_mode = tps65910_set_mode, | 903 | .set_mode = tps65910_set_mode, |
946 | .get_mode = tps65910_get_mode, | 904 | .get_mode = tps65910_get_mode, |
@@ -950,9 +908,9 @@ static struct regulator_ops tps65910_ops = { | |||
950 | }; | 908 | }; |
951 | 909 | ||
952 | static struct regulator_ops tps65911_ops = { | 910 | static struct regulator_ops tps65911_ops = { |
953 | .is_enabled = tps65910_is_enabled, | 911 | .is_enabled = regulator_is_enabled_regmap, |
954 | .enable = tps65910_enable, | 912 | .enable = regulator_enable_regmap, |
955 | .disable = tps65910_disable, | 913 | .disable = regulator_disable_regmap, |
956 | .enable_time = tps65910_enable_time, | 914 | .enable_time = tps65910_enable_time, |
957 | .set_mode = tps65910_set_mode, | 915 | .set_mode = tps65910_set_mode, |
958 | .get_mode = tps65910_get_mode, | 916 | .get_mode = tps65910_get_mode, |
@@ -1205,10 +1163,13 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
1205 | 1163 | ||
1206 | pmic->desc[i].type = REGULATOR_VOLTAGE; | 1164 | pmic->desc[i].type = REGULATOR_VOLTAGE; |
1207 | pmic->desc[i].owner = THIS_MODULE; | 1165 | pmic->desc[i].owner = THIS_MODULE; |
1166 | pmic->desc[i].enable_reg = pmic->get_ctrl_reg(i); | ||
1167 | pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED; | ||
1208 | 1168 | ||
1209 | config.dev = tps65910->dev; | 1169 | config.dev = tps65910->dev; |
1210 | config.init_data = reg_data; | 1170 | config.init_data = reg_data; |
1211 | config.driver_data = pmic; | 1171 | config.driver_data = pmic; |
1172 | config.regmap = tps65910->regmap; | ||
1212 | 1173 | ||
1213 | rdev = regulator_register(&pmic->desc[i], &config); | 1174 | rdev = regulator_register(&pmic->desc[i], &config); |
1214 | if (IS_ERR(rdev)) { | 1175 | if (IS_ERR(rdev)) { |