Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312539
b: refs/heads/master
c: a967fbf
h: refs/heads/master
i:
  312537: dcf7978
  312535: 94e2ccd
v: v3
  • Loading branch information
Axel Lin authored and Mark Brown committed Jun 17, 2012
1 parent 0375e2c commit cc1e0e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 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: b4bc9ef6253578ecc71eec79a7dd423d0a282a4b
refs/heads/master: a967fbfaca0a979fc34c1097b37d824039a709b1
52 changes: 21 additions & 31 deletions trunk/drivers/regulator/wm8350-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ static int get_isink_val(int min_uA, int max_uA, u16 *setting)
return -EINVAL;
}

static inline int wm8350_ldo_val_to_mvolts(unsigned int val)
{
if (val < 16)
return (val * 50) + 900;
else
return ((val - 16) * 100) + 1800;

}

static inline unsigned int wm8350_ldo_mvolts_to_val(int mV)
{
if (mV < 1800)
Expand Down Expand Up @@ -671,10 +662,22 @@ static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev)
return 0;
}

static int wm8350_ldo_list_voltage(struct regulator_dev *rdev,
unsigned selector)
{
if (selector > WM8350_LDO1_VSEL_MASK)
return -EINVAL;

if (selector < 16)
return (selector * 50000) + 900000;
else
return ((selector - 16) * 100000) + 1800000;
}

static int wm8350_ldo_map_voltage(struct regulator_dev *rdev, int min_uV,
int max_uV)
{
int mV;
int volt, sel;
int min_mV = min_uV / 1000;
int max_mV = max_uV / 1000;

Expand All @@ -683,29 +686,16 @@ static int wm8350_ldo_map_voltage(struct regulator_dev *rdev, int min_uV,
if (max_mV < 900 || max_mV > 3300)
return -EINVAL;

if (min_mV < 1800) {
/* step size is 50mV < 1800mV */
mV = (min_mV - 851) / 50;
if (wm8350_ldo_val_to_mvolts(mV) > max_mV)
return -EINVAL;
BUG_ON(wm8350_ldo_val_to_mvolts(mV) < min_mV);
} else {
/* step size is 100mV > 1800mV */
mV = ((min_mV - 1701) / 100) + 16;
if (wm8350_ldo_val_to_mvolts(mV) > max_mV)
return -EINVAL;
BUG_ON(wm8350_ldo_val_to_mvolts(mV) < min_mV);
}

return mV;
}
if (min_mV < 1800) /* step size is 50mV < 1800mV */
sel = DIV_ROUND_UP(min_uV - 900, 50);
else /* step size is 100mV > 1800mV */
sel = DIV_ROUND_UP(min_uV - 1800, 100) + 16;

static int wm8350_ldo_list_voltage(struct regulator_dev *rdev,
unsigned selector)
{
if (selector > WM8350_LDO1_VSEL_MASK)
volt = wm8350_ldo_list_voltage(rdev, sel);
if (volt < min_uV || volt > max_uV)
return -EINVAL;
return wm8350_ldo_val_to_mvolts(selector) * 1000;

return sel;
}

int wm8350_dcdc_set_slot(struct wm8350 *wm8350, int dcdc, u16 start,
Expand Down

0 comments on commit cc1e0e9

Please sign in to comment.