Skip to content

Commit

Permalink
Merge branch 'topic/min' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/broonie/regulator into regulator-change
  • Loading branch information
Mark Brown committed Dec 11, 2012
2 parents d1e7de3 + e1b0144 commit b17fc86
Show file tree
Hide file tree
Showing 11 changed files with 1,115 additions and 202 deletions.
21 changes: 21 additions & 0 deletions drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ config REGULATOR_DA9052
This driver supports the voltage regulators of DA9052-BC and
DA9053-AA/Bx PMIC.

config REGULATOR_DA9055
tristate "Dialog Semiconductor DA9055 regulators"
depends on MFD_DA9055
help
Say y here to support the BUCKs and LDOs regulators found on
Dialog Semiconductor DA9055 PMIC.

This driver can also be built as a module. If so, the module
will be called da9055-regulator.

config REGULATOR_FAN53555
tristate "Fairchild FAN53555 Regulator"
depends on I2C
Expand Down Expand Up @@ -335,6 +345,17 @@ config REGULATOR_PALMAS
on the muxing. This is handled automatically in the driver by
reading the mux info from OTP.

config REGULATOR_TPS51632
tristate "TI TPS51632 Power Regulator"
depends on I2C
select REGMAP_I2C
help
This driver supports TPS51632 voltage regulator chip.
The TPS51632 is 3-2-1 Phase D-Cap+ Step Down Driverless Controller
with Serial VID control and DVFS.
The voltage output can be configure through I2C interface or PWM
interface.

config REGULATOR_TPS6105X
tristate "TI TPS6105X Power regulators"
depends on TPS6105X
Expand Down
2 changes: 2 additions & 0 deletions drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
Expand All @@ -41,6 +42,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
Expand Down
28 changes: 9 additions & 19 deletions drivers/regulator/anatop-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,21 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg,
unsigned selector)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
u32 val, mask;

if (!anatop_reg->control_reg)
return -ENOTSUPP;

val = anatop_reg->min_bit_val + selector;
dev_dbg(&reg->dev, "%s: calculated val %d\n", __func__, val);
mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
anatop_reg->vol_bit_shift;
val <<= anatop_reg->vol_bit_shift;
regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg,
mask, val);

return 0;
return regulator_set_voltage_sel_regmap(reg, selector);
}

static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
u32 val, mask;

if (!anatop_reg->control_reg)
return -ENOTSUPP;

regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val);
mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
anatop_reg->vol_bit_shift;
val = (val & mask) >> anatop_reg->vol_bit_shift;

return val - anatop_reg->min_bit_val;
return regulator_get_voltage_sel_regmap(reg);
}

static struct regulator_ops anatop_rops = {
Expand Down Expand Up @@ -158,15 +143,20 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev)
goto anatop_probe_end;
}

rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage)
/ 25000 + 1;
rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1
+ sreg->min_bit_val;
rdesc->min_uV = sreg->min_voltage;
rdesc->uV_step = 25000;
rdesc->linear_min_sel = sreg->min_bit_val;
rdesc->vsel_reg = sreg->control_reg;
rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) <<
sreg->vol_bit_shift;

config.dev = &pdev->dev;
config.init_data = initdata;
config.driver_data = sreg;
config.of_node = pdev->dev.of_node;
config.regmap = sreg->anatop;

/* register regulator */
rdev = regulator_register(rdesc, &config);
Expand Down
6 changes: 6 additions & 0 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,10 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev,
{
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
if (selector < rdev->desc->linear_min_sel)
return 0;

selector -= rdev->desc->linear_min_sel;

return rdev->desc->min_uV + (rdev->desc->uV_step * selector);
}
Expand Down Expand Up @@ -2142,6 +2146,8 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
if (ret < 0)
return ret;

ret += rdev->desc->linear_min_sel;

/* Map back into a voltage to verify we're still in bounds */
voltage = rdev->desc->ops->list_voltage(rdev, ret);
if (voltage < min_uV || voltage > max_uV)
Expand Down
Loading

0 comments on commit b17fc86

Please sign in to comment.