Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 302295
b: refs/heads/master
c: 70b4e78
h: refs/heads/master
i:
  302293: 2d50dac
  302291: 0e71c64
  302287: c70fdd8
v: v3
  • Loading branch information
Axel Lin authored and Mark Brown committed May 15, 2012
1 parent c42312c commit 9c35fe8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 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: 9a00630c3db8ca064a8904dbcd9632fb81244bc0
refs/heads/master: 70b4e7862d604aa6ae30a772830670bf7288ec42
54 changes: 21 additions & 33 deletions trunk/drivers/regulator/da903x.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@
struct da903x_regulator_info {
struct regulator_desc desc;

int min_uV;
int max_uV;
int step_uV;
int vol_reg;
int vol_shift;
int vol_nbits;
Expand All @@ -96,7 +94,7 @@ static inline struct device *to_da903x_dev(struct regulator_dev *rdev)
static inline int check_range(struct da903x_regulator_info *info,
int min_uV, int max_uV)
{
if (min_uV < info->min_uV || min_uV > info->max_uV)
if (min_uV < info->desc.min_uV || min_uV > info->max_uV)
return -EINVAL;

return 0;
Expand All @@ -115,7 +113,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
return -EINVAL;
}

val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
val = DIV_ROUND_UP(min_uV - info->desc.min_uV, info->desc.uV_step);
*selector = val;
val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
Expand Down Expand Up @@ -172,17 +170,6 @@ static int da903x_is_enabled(struct regulator_dev *rdev)
return !!(reg_val & (1 << info->enable_bit));
}

static int da903x_list_voltage(struct regulator_dev *rdev, unsigned selector)
{
struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
int ret;

ret = info->min_uV + info->step_uV * selector;
if (ret > info->max_uV)
return -EINVAL;
return ret;
}

/* DA9030 specific operations */
static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV,
Expand All @@ -198,7 +185,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
return -EINVAL;
}

val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
val = DIV_ROUND_UP(min_uV - info->desc.min_uV, info->desc.uV_step);
*selector = val;
val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
Expand Down Expand Up @@ -227,12 +214,12 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
return -EINVAL;
}

thresh = (info->max_uV + info->min_uV) / 2;
thresh = (info->max_uV + info->desc.min_uV) / 2;
if (min_uV < thresh) {
val = DIV_ROUND_UP(thresh - min_uV, info->step_uV);
val = DIV_ROUND_UP(thresh - min_uV, info->desc.uV_step);
val |= 0x4;
} else {
val = DIV_ROUND_UP(min_uV - thresh, info->step_uV);
val = DIV_ROUND_UP(min_uV - thresh, info->desc.uV_step);
}

*selector = val;
Expand Down Expand Up @@ -266,10 +253,11 @@ static int da9030_list_ldo14_voltage(struct regulator_dev *rdev,
int volt;

if (selector & 0x4)
volt = info->min_uV + info->step_uV * (3 - (selector & ~0x4));
volt = rdev->desc->min_uV +
rdev->desc->uV_step * (3 - (selector & ~0x4));
else
volt = (info->max_uV + info->min_uV) / 2 +
info->step_uV * (selector & ~0x4);
volt = (info->max_uV + rdev->desc->min_uV) / 2 +
rdev->desc->uV_step * (selector & ~0x4);

if (volt > info->max_uV)
return -EINVAL;
Expand All @@ -291,7 +279,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
return -EINVAL;
}

val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
val = DIV_ROUND_UP(min_uV - info->desc.min_uV, info->desc.uV_step);
*selector = val;
val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
Expand All @@ -317,7 +305,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
return -EINVAL;
}

val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
val = DIV_ROUND_UP(min_uV - info->desc.min_uV, info->desc.uV_step);
val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val);
*selector = val;
val <<= info->vol_shift;
Expand Down Expand Up @@ -350,9 +338,9 @@ static int da9034_list_ldo12_voltage(struct regulator_dev *rdev,
int volt;

if (selector >= 8)
volt = 2700000 + info->step_uV * (selector - 8);
volt = 2700000 + rdev->desc->uV_step * (selector - 8);
else
volt = info->min_uV + info->step_uV * selector;
volt = rdev->desc->min_uV + rdev->desc->uV_step * selector;

if (volt > info->max_uV)
return -EINVAL;
Expand All @@ -363,7 +351,7 @@ static int da9034_list_ldo12_voltage(struct regulator_dev *rdev,
static struct regulator_ops da903x_regulator_ldo_ops = {
.set_voltage = da903x_set_ldo_voltage,
.get_voltage_sel = da903x_get_voltage_sel,
.list_voltage = da903x_list_voltage,
.list_voltage = regulator_list_voltage_linear,
.enable = da903x_enable,
.disable = da903x_disable,
.is_enabled = da903x_is_enabled,
Expand All @@ -383,7 +371,7 @@ static struct regulator_ops da9030_regulator_ldo14_ops = {
static struct regulator_ops da9030_regulator_ldo1_15_ops = {
.set_voltage = da9030_set_ldo1_15_voltage,
.get_voltage_sel = da903x_get_voltage_sel,
.list_voltage = da903x_list_voltage,
.list_voltage = regulator_list_voltage_linear,
.enable = da903x_enable,
.disable = da903x_disable,
.is_enabled = da903x_is_enabled,
Expand All @@ -392,7 +380,7 @@ static struct regulator_ops da9030_regulator_ldo1_15_ops = {
static struct regulator_ops da9034_regulator_dvc_ops = {
.set_voltage = da9034_set_dvc_voltage,
.get_voltage_sel = da903x_get_voltage_sel,
.list_voltage = da903x_list_voltage,
.list_voltage = regulator_list_voltage_linear,
.enable = da903x_enable,
.disable = da903x_disable,
.is_enabled = da903x_is_enabled,
Expand All @@ -417,10 +405,10 @@ static struct regulator_ops da9034_regulator_ldo12_ops = {
.id = _pmic##_ID_LDO##_id, \
.n_voltages = (step) ? ((max - min) / step + 1) : 1, \
.owner = THIS_MODULE, \
.min_uV = (min) * 1000, \
.uV_step = (step) * 1000, \
}, \
.min_uV = (min) * 1000, \
.max_uV = (max) * 1000, \
.step_uV = (step) * 1000, \
.vol_reg = _pmic##_##vreg, \
.vol_shift = (shift), \
.vol_nbits = (nbits), \
Expand All @@ -437,10 +425,10 @@ static struct regulator_ops da9034_regulator_ldo12_ops = {
.id = _pmic##_ID_##_id, \
.n_voltages = (step) ? ((max - min) / step + 1) : 1, \
.owner = THIS_MODULE, \
.min_uV = (min) * 1000, \
.uV_step = (step) * 1000, \
}, \
.min_uV = (min) * 1000, \
.max_uV = (max) * 1000, \
.step_uV = (step) * 1000, \
.vol_reg = _pmic##_##vreg, \
.vol_shift = (0), \
.vol_nbits = (nbits), \
Expand Down

0 comments on commit 9c35fe8

Please sign in to comment.