Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 302163
b: refs/heads/master
c: 65f2684
h: refs/heads/master
i:
  302161: a9ec0e3
  302159: fc1d81b
v: v3
  • Loading branch information
Mark Brown committed Apr 4, 2012
1 parent 6d6941b commit 9d30816
Show file tree
Hide file tree
Showing 42 changed files with 1,051 additions and 1,173 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f604c10cdeba4e068afa96be2bee878fb5227f8b
refs/heads/master: 65f26846b90611742f3b407cc538a1cad33abde8
99 changes: 67 additions & 32 deletions trunk/drivers/regulator/88pm8607.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct pm8607_regulator_info {

int vol_reg;
int vol_shift;
int vol_nbits;
int update_reg;
int update_bit;
int enable_reg;
Expand Down Expand Up @@ -215,24 +216,59 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
int ret = -EINVAL;

if (info->vol_table && (index < rdev->desc->n_voltages)) {
if (info->vol_table && (index < (1 << info->vol_nbits))) {
ret = info->vol_table[index];
if (info->slope_double)
ret <<= 1;
}
return ret;
}

static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
{
struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
int i, ret = -ENOENT;

if (info->slope_double) {
min_uV = min_uV >> 1;
max_uV = max_uV >> 1;
}
if (info->vol_table) {
for (i = 0; i < (1 << info->vol_nbits); i++) {
if (!info->vol_table[i])
break;
if ((min_uV <= info->vol_table[i])
&& (max_uV >= info->vol_table[i])) {
ret = i;
break;
}
}
}
if (ret < 0)
pr_err("invalid voltage range (%d %d) uV\n", min_uV, max_uV);
return ret;
}

static int pm8607_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector)
{
struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
uint8_t val, mask;
int ret;

val = (uint8_t)(selector << info->vol_shift);
mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
if (min_uV > max_uV) {
pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
return -EINVAL;
}

ret = choose_voltage(rdev, min_uV, max_uV);
if (ret < 0)
return -EINVAL;
*selector = ret;
val = (uint8_t)(ret << info->vol_shift);
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;

ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, selector);
ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val);
if (ret)
return ret;
switch (info->desc.id) {
Expand All @@ -246,7 +282,7 @@ static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
return ret;
}

static int pm8607_get_voltage_sel(struct regulator_dev *rdev)
static int pm8607_get_voltage(struct regulator_dev *rdev)
{
struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
uint8_t val, mask;
Expand All @@ -256,10 +292,10 @@ static int pm8607_get_voltage_sel(struct regulator_dev *rdev)
if (ret < 0)
return ret;

mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
val = ((unsigned char)ret & mask) >> info->vol_shift;

return val;
return pm8607_list_voltage(rdev, val);
}

static int pm8607_enable(struct regulator_dev *rdev)
Expand Down Expand Up @@ -292,26 +328,25 @@ static int pm8607_is_enabled(struct regulator_dev *rdev)
}

static struct regulator_ops pm8607_regulator_ops = {
.list_voltage = pm8607_list_voltage,
.set_voltage_sel = pm8607_set_voltage_sel,
.get_voltage_sel = pm8607_get_voltage_sel,
.set_voltage = pm8607_set_voltage,
.get_voltage = pm8607_get_voltage,
.enable = pm8607_enable,
.disable = pm8607_disable,
.is_enabled = pm8607_is_enabled,
};

#define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \
#define PM8607_DVC(vreg, nbits, ureg, ubit, ereg, ebit) \
{ \
.desc = { \
.name = #vreg, \
.ops = &pm8607_regulator_ops, \
.type = REGULATOR_VOLTAGE, \
.id = PM8607_ID_##vreg, \
.owner = THIS_MODULE, \
.n_voltages = ARRAY_SIZE(vreg##_table), \
}, \
.vol_reg = PM8607_##vreg, \
.vol_shift = (0), \
.vol_nbits = (nbits), \
.update_reg = PM8607_##ureg, \
.update_bit = (ubit), \
.enable_reg = PM8607_##ereg, \
Expand All @@ -321,18 +356,18 @@ static struct regulator_ops pm8607_regulator_ops = {
.vol_suspend = (unsigned int *)&vreg##_suspend_table, \
}

#define PM8607_LDO(_id, vreg, shift, ereg, ebit) \
#define PM8607_LDO(_id, vreg, shift, nbits, ereg, ebit) \
{ \
.desc = { \
.name = "LDO" #_id, \
.ops = &pm8607_regulator_ops, \
.type = REGULATOR_VOLTAGE, \
.id = PM8607_ID_LDO##_id, \
.owner = THIS_MODULE, \
.n_voltages = ARRAY_SIZE(LDO##_id##_table), \
}, \
.vol_reg = PM8607_##vreg, \
.vol_shift = (shift), \
.vol_nbits = (nbits), \
.enable_reg = PM8607_##ereg, \
.enable_bit = (ebit), \
.slope_double = (0), \
Expand All @@ -341,23 +376,23 @@ static struct regulator_ops pm8607_regulator_ops = {
}

static struct pm8607_regulator_info pm8607_regulator_info[] = {
PM8607_DVC(BUCK1, GO, 0, SUPPLIES_EN11, 0),
PM8607_DVC(BUCK2, GO, 1, SUPPLIES_EN11, 1),
PM8607_DVC(BUCK3, GO, 2, SUPPLIES_EN11, 2),

PM8607_LDO(1, LDO1, 0, SUPPLIES_EN11, 3),
PM8607_LDO(2, LDO2, 0, SUPPLIES_EN11, 4),
PM8607_LDO(3, LDO3, 0, SUPPLIES_EN11, 5),
PM8607_LDO(4, LDO4, 0, SUPPLIES_EN11, 6),
PM8607_LDO(5, LDO5, 0, SUPPLIES_EN11, 7),
PM8607_LDO(6, LDO6, 0, SUPPLIES_EN12, 0),
PM8607_LDO(7, LDO7, 0, SUPPLIES_EN12, 1),
PM8607_LDO(8, LDO8, 0, SUPPLIES_EN12, 2),
PM8607_LDO(9, LDO9, 0, SUPPLIES_EN12, 3),
PM8607_LDO(10, LDO10, 0, SUPPLIES_EN12, 4),
PM8607_LDO(12, LDO12, 0, SUPPLIES_EN12, 5),
PM8607_LDO(13, VIBRATOR_SET, 1, VIBRATOR_SET, 0),
PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6),
PM8607_DVC(BUCK1, 6, GO, 0, SUPPLIES_EN11, 0),
PM8607_DVC(BUCK2, 6, GO, 1, SUPPLIES_EN11, 1),
PM8607_DVC(BUCK3, 6, GO, 2, SUPPLIES_EN11, 2),

PM8607_LDO( 1, LDO1, 0, 2, SUPPLIES_EN11, 3),
PM8607_LDO( 2, LDO2, 0, 3, SUPPLIES_EN11, 4),
PM8607_LDO( 3, LDO3, 0, 3, SUPPLIES_EN11, 5),
PM8607_LDO( 4, LDO4, 0, 3, SUPPLIES_EN11, 6),
PM8607_LDO( 5, LDO5, 0, 2, SUPPLIES_EN11, 7),
PM8607_LDO( 6, LDO6, 0, 3, SUPPLIES_EN12, 0),
PM8607_LDO( 7, LDO7, 0, 3, SUPPLIES_EN12, 1),
PM8607_LDO( 8, LDO8, 0, 3, SUPPLIES_EN12, 2),
PM8607_LDO( 9, LDO9, 0, 3, SUPPLIES_EN12, 3),
PM8607_LDO(10, LDO10, 0, 4, SUPPLIES_EN12, 4),
PM8607_LDO(12, LDO12, 0, 4, SUPPLIES_EN12, 5),
PM8607_LDO(13, VIBRATOR_SET, 1, 3, VIBRATOR_SET, 0),
PM8607_LDO(14, LDO14, 0, 3, SUPPLIES_EN12, 6),
};

static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
Expand Down
21 changes: 2 additions & 19 deletions trunk/drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,6 @@ config REGULATOR_PCF50633
Say Y here to support the voltage regulators and convertors
on PCF50633

config REGULATOR_RC5T583
tristate "RICOH RC5T583 Power regulators"
depends on MFD_RC5T583
help
Select this option to enable the power regulator of RICOH
PMIC RC5T583.
This driver supports the control of different power rails of device
through regulator interface. The device supports multiple DCDC/LDO
outputs which can be controlled by i2c communication.

config REGULATOR_S5M8767
tristate "Samsung S5M8767A voltage regulator"
depends on MFD_S5M_CORE
Expand Down Expand Up @@ -278,11 +268,11 @@ config REGULATOR_TPS6105X
audio amplifiers.

config REGULATOR_TPS62360
tristate "TI TPS6236x Power Regulator"
tristate "TI TPS62360 Power Regulator"
depends on I2C
select REGMAP_I2C
help
This driver supports TPS6236x voltage regulator chip. This
This driver supports TPS62360 voltage regulator chip. This
regulator is meant for processor core supply. This chip is
high-frequency synchronous step down dc-dc converter optimized
for battery-powered portable applications.
Expand All @@ -304,13 +294,6 @@ config REGULATOR_TPS6507X
three step-down converters and two general-purpose LDO voltage regulators.
It supports TI's software based Class-2 SmartReflex implementation.

config REGULATOR_TPS65090
tristate "TI TPS65090 Power regulator"
depends on MFD_TPS65090
help
This driver provides support for the voltage regulators on the
TI TPS65090 PMIC.

config REGULATOR_TPS65217
tristate "TI TPS65217 Power regulators"
depends on MFD_TPS65217
Expand Down
4 changes: 1 addition & 3 deletions trunk/drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o

obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
Expand All @@ -19,7 +20,6 @@ obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
Expand All @@ -35,13 +35,11 @@ obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o
obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o
obj-$(CONFIG_REGULATOR_TPS65090) += tps65090-regulator.o
obj-$(CONFIG_REGULATOR_TPS65217) += tps65217-regulator.o
obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/regulator/aat2870-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,3 @@ module_exit(aat2870_regulator_exit);
MODULE_DESCRIPTION("AnalogicTech AAT2870 Regulator");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jin Park <jinyoungp@nvidia.com>");
MODULE_ALIAS("platform:aat2870-regulator");
18 changes: 13 additions & 5 deletions trunk/drivers/regulator/ab3100.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,20 @@ static int ab3100_get_best_voltage_index(struct regulator_dev *reg,
return bestindex;
}

static int ab3100_set_voltage_regulator_sel(struct regulator_dev *reg,
unsigned selector)
static int ab3100_set_voltage_regulator(struct regulator_dev *reg,
int min_uV, int max_uV,
unsigned *selector)
{
struct ab3100_regulator *abreg = reg->reg_data;
u8 regval;
int err;
int bestindex;

bestindex = ab3100_get_best_voltage_index(reg, min_uV, max_uV);
if (bestindex < 0)
return bestindex;

*selector = bestindex;

err = abx500_get_register_interruptible(abreg->dev, 0,
abreg->regreg, &regval);
Expand All @@ -356,7 +364,7 @@ static int ab3100_set_voltage_regulator_sel(struct regulator_dev *reg,

/* The highest three bits control the variable regulators */
regval &= ~0xE0;
regval |= (selector << 5);
regval |= (bestindex << 5);

err = abx500_set_register_interruptible(abreg->dev, 0,
abreg->regreg, regval);
Expand Down Expand Up @@ -456,7 +464,7 @@ static struct regulator_ops regulator_ops_variable = {
.disable = ab3100_disable_regulator,
.is_enabled = ab3100_is_enabled_regulator,
.get_voltage = ab3100_get_voltage_regulator,
.set_voltage_sel = ab3100_set_voltage_regulator_sel,
.set_voltage = ab3100_set_voltage_regulator,
.list_voltage = ab3100_list_voltage_regulator,
.enable_time = ab3100_enable_time_regulator,
};
Expand All @@ -466,7 +474,7 @@ static struct regulator_ops regulator_ops_variable_sleepable = {
.disable = ab3100_disable_regulator,
.is_enabled = ab3100_is_enabled_regulator,
.get_voltage = ab3100_get_voltage_regulator,
.set_voltage_sel = ab3100_set_voltage_regulator_sel,
.set_voltage = ab3100_set_voltage_regulator,
.set_suspend_voltage = ab3100_set_suspend_voltage_regulator,
.list_voltage = ab3100_list_voltage_regulator,
.enable_time = ab3100_enable_time_regulator,
Expand Down
35 changes: 31 additions & 4 deletions trunk/drivers/regulator/ab8500.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,25 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
return val;
}

static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
unsigned selector)
static int ab8500_get_best_voltage_index(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
int i;

/* check the supported voltage */
for (i = 0; i < info->voltages_len; i++) {
if ((info->voltages[i] >= min_uV) &&
(info->voltages[i] <= max_uV))
return i;
}

return -EINVAL;
}

static int ab8500_regulator_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV,
unsigned *selector)
{
int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
Expand All @@ -246,8 +263,18 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
return -EINVAL;
}

/* get the appropriate voltages within the range */
ret = ab8500_get_best_voltage_index(rdev, min_uV, max_uV);
if (ret < 0) {
dev_err(rdev_get_dev(rdev),
"couldn't get best voltage for regulator\n");
return ret;
}

*selector = ret;

/* set the registers for the request */
regval = (u8)selector;
regval = (u8)ret;
ret = abx500_mask_and_set_register_interruptible(info->dev,
info->voltage_bank, info->voltage_reg,
info->voltage_mask, regval);
Expand Down Expand Up @@ -292,7 +319,7 @@ static struct regulator_ops ab8500_regulator_ops = {
.disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled,
.get_voltage_sel = ab8500_regulator_get_voltage_sel,
.set_voltage_sel = ab8500_regulator_set_voltage_sel,
.set_voltage = ab8500_regulator_set_voltage,
.list_voltage = ab8500_list_voltage,
.enable_time = ab8500_regulator_enable_time,
.set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
Expand Down
Loading

0 comments on commit 9d30816

Please sign in to comment.