aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-04-17 05:43:12 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-17 10:05:10 -0400
commitaa07f02793ec149d560142f25af0243fff84208b (patch)
tree62d2cb0aaf22089cc76eed1bb7bcb269aba8fd09 /drivers/regulator
parent30590d04808c03fb29341e1c6f721644b2f07650 (diff)
regulator: palmas: support for external regulator through control outputs
Palmas device have control outputs like REGEN1, REGEN2, REGEN3, SYSEN1 and SYSEN2. These control outputs can be used for controlling external voltage switches to enabled/disable voltage outputs. Add support of these control outputs through regulator framework. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/palmas-regulator.c95
1 files changed, 83 insertions, 12 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index af2109a73a80..c61c0fa83e22 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -165,6 +165,26 @@ static const struct regs_info palmas_regs_info[] = {
165 .vsel_addr = PALMAS_LDOUSB_VOLTAGE, 165 .vsel_addr = PALMAS_LDOUSB_VOLTAGE,
166 .ctrl_addr = PALMAS_LDOUSB_CTRL, 166 .ctrl_addr = PALMAS_LDOUSB_CTRL,
167 }, 167 },
168 {
169 .name = "REGEN1",
170 .ctrl_addr = PALMAS_REGEN1_CTRL,
171 },
172 {
173 .name = "REGEN2",
174 .ctrl_addr = PALMAS_REGEN2_CTRL,
175 },
176 {
177 .name = "REGEN3",
178 .ctrl_addr = PALMAS_REGEN3_CTRL,
179 },
180 {
181 .name = "SYSEN1",
182 .ctrl_addr = PALMAS_SYSEN1_CTRL,
183 },
184 {
185 .name = "SYSEN2",
186 .ctrl_addr = PALMAS_SYSEN2_CTRL,
187 },
168}; 188};
169 189
170#define SMPS_CTRL_MODE_OFF 0x00 190#define SMPS_CTRL_MODE_OFF 0x00
@@ -422,6 +442,12 @@ static struct regulator_ops palmas_ops_ldo = {
422 .map_voltage = regulator_map_voltage_linear, 442 .map_voltage = regulator_map_voltage_linear,
423}; 443};
424 444
445static struct regulator_ops palmas_ops_extreg = {
446 .is_enabled = regulator_is_enabled_regmap,
447 .enable = regulator_enable_regmap,
448 .disable = regulator_disable_regmap,
449};
450
425/* 451/*
426 * setup the hardware based sleep configuration of the SMPS/LDO regulators 452 * setup the hardware based sleep configuration of the SMPS/LDO regulators
427 * from the platform data. This is different to the software based control 453 * from the platform data. This is different to the software based control
@@ -523,6 +549,28 @@ static int palmas_ldo_init(struct palmas *palmas, int id,
523 return 0; 549 return 0;
524} 550}
525 551
552static int palmas_extreg_init(struct palmas *palmas, int id,
553 struct palmas_reg_init *reg_init)
554{
555 unsigned int addr;
556 int ret;
557 unsigned int val = 0;
558
559 addr = palmas_regs_info[id].ctrl_addr;
560
561 if (reg_init->mode_sleep)
562 val = PALMAS_REGEN1_CTRL_MODE_SLEEP;
563
564 ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE,
565 addr, PALMAS_REGEN1_CTRL_MODE_SLEEP, val);
566 if (ret < 0) {
567 dev_err(palmas->dev, "Resource reg 0x%02x update failed %d\n",
568 addr, ret);
569 return ret;
570 }
571 return 0;
572}
573
526static struct of_regulator_match palmas_matches[] = { 574static struct of_regulator_match palmas_matches[] = {
527 { .name = "smps12", }, 575 { .name = "smps12", },
528 { .name = "smps123", }, 576 { .name = "smps123", },
@@ -545,6 +593,11 @@ static struct of_regulator_match palmas_matches[] = {
545 { .name = "ldo9", }, 593 { .name = "ldo9", },
546 { .name = "ldoln", }, 594 { .name = "ldoln", },
547 { .name = "ldousb", }, 595 { .name = "ldousb", },
596 { .name = "regen1", },
597 { .name = "regen2", },
598 { .name = "regen3", },
599 { .name = "sysen1", },
600 { .name = "sysen2", },
548}; 601};
549 602
550static void palmas_dt_to_pdata(struct device *dev, 603static void palmas_dt_to_pdata(struct device *dev,
@@ -763,21 +816,34 @@ static int palmas_regulators_probe(struct platform_device *pdev)
763 /* Register the regulators */ 816 /* Register the regulators */
764 pmic->desc[id].name = palmas_regs_info[id].name; 817 pmic->desc[id].name = palmas_regs_info[id].name;
765 pmic->desc[id].id = id; 818 pmic->desc[id].id = id;
766 pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES;
767
768 pmic->desc[id].ops = &palmas_ops_ldo;
769
770 pmic->desc[id].type = REGULATOR_VOLTAGE; 819 pmic->desc[id].type = REGULATOR_VOLTAGE;
771 pmic->desc[id].owner = THIS_MODULE; 820 pmic->desc[id].owner = THIS_MODULE;
772 pmic->desc[id].min_uV = 900000; 821
773 pmic->desc[id].uV_step = 50000; 822 if (id < PALMAS_REG_REGEN1) {
774 pmic->desc[id].linear_min_sel = 1; 823 pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES;
775 pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, 824 pmic->desc[id].ops = &palmas_ops_ldo;
825 pmic->desc[id].min_uV = 900000;
826 pmic->desc[id].uV_step = 50000;
827 pmic->desc[id].linear_min_sel = 1;
828 pmic->desc[id].vsel_reg =
829 PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
776 palmas_regs_info[id].vsel_addr); 830 palmas_regs_info[id].vsel_addr);
777 pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK; 831 pmic->desc[id].vsel_mask =
778 pmic->desc[id].enable_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, 832 PALMAS_LDO1_VOLTAGE_VSEL_MASK;
833 pmic->desc[id].enable_reg =
834 PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
835 palmas_regs_info[id].ctrl_addr);
836 pmic->desc[id].enable_mask =
837 PALMAS_LDO1_CTRL_MODE_ACTIVE;
838 } else {
839 pmic->desc[id].n_voltages = 1;
840 pmic->desc[id].ops = &palmas_ops_extreg;
841 pmic->desc[id].enable_reg =
842 PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
779 palmas_regs_info[id].ctrl_addr); 843 palmas_regs_info[id].ctrl_addr);
780 pmic->desc[id].enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE; 844 pmic->desc[id].enable_mask =
845 PALMAS_REGEN1_CTRL_MODE_ACTIVE;
846 }
781 847
782 if (pdata) 848 if (pdata)
783 config.init_data = pdata->reg_data[id]; 849 config.init_data = pdata->reg_data[id];
@@ -803,7 +869,12 @@ static int palmas_regulators_probe(struct platform_device *pdev)
803 if (pdata) { 869 if (pdata) {
804 reg_init = pdata->reg_init[id]; 870 reg_init = pdata->reg_init[id];
805 if (reg_init) { 871 if (reg_init) {
806 ret = palmas_ldo_init(palmas, id, reg_init); 872 if (id < PALMAS_REG_REGEN1)
873 ret = palmas_ldo_init(palmas,
874 id, reg_init);
875 else
876 ret = palmas_extreg_init(palmas,
877 id, reg_init);
807 if (ret) { 878 if (ret) {
808 regulator_unregister(pmic->rdev[id]); 879 regulator_unregister(pmic->rdev[id]);
809 goto err_unregister_regulator; 880 goto err_unregister_regulator;