Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312536
b: refs/heads/master
c: df2643c
h: refs/heads/master
v: v3
  • Loading branch information
Sangbeom Kim authored and Mark Brown committed Jun 13, 2012
1 parent 94e2ccd commit 68f5e65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 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: 38c20eb23fb7b5505ac80595f18f4209abc19cd3
refs/heads/master: df2643cfa4ad4f3775838ad0c0815c465f351f92
38 changes: 14 additions & 24 deletions trunk/drivers/regulator/s5m8767.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,32 +357,34 @@ static int s5m8767_convert_voltage_to_sel(
return selector;
}

static inline void s5m8767_set_high(struct s5m8767_info *s5m8767)
static inline int s5m8767_set_high(struct s5m8767_info *s5m8767)
{
int temp_index = s5m8767->buck_gpioindex;

gpio_set_value(s5m8767->buck_gpios[0], (temp_index >> 2) & 0x1);
gpio_set_value(s5m8767->buck_gpios[1], (temp_index >> 1) & 0x1);
gpio_set_value(s5m8767->buck_gpios[2], temp_index & 0x1);

return 0;
}

static inline void s5m8767_set_low(struct s5m8767_info *s5m8767)
static inline int s5m8767_set_low(struct s5m8767_info *s5m8767)
{
int temp_index = s5m8767->buck_gpioindex;

gpio_set_value(s5m8767->buck_gpios[2], temp_index & 0x1);
gpio_set_value(s5m8767->buck_gpios[1], (temp_index >> 1) & 0x1);
gpio_set_value(s5m8767->buck_gpios[0], (temp_index >> 2) & 0x1);

return 0;
}

static int s5m8767_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector)
static int s5m8767_set_voltage_sel(struct regulator_dev *rdev,
unsigned selector)
{
struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
const struct s5m_voltage_desc *desc;
int reg_id = rdev_get_id(rdev);
int sel, reg, mask, ret = 0, old_index, index = 0;
u8 val;
int reg, mask, ret = 0, old_index, index = 0;
u8 *buck234_vol = NULL;

switch (reg_id) {
Expand All @@ -407,38 +409,26 @@ static int s5m8767_set_voltage(struct regulator_dev *rdev,
return -EINVAL;
}

desc = reg_voltage_map[reg_id];

sel = s5m8767_convert_voltage_to_sel(desc, min_uV, max_uV);
if (sel < 0)
return sel;

/* buck234_vol != NULL means to control buck234 voltage via DVS GPIO */
if (buck234_vol) {
while (*buck234_vol != sel) {
while (*buck234_vol != selector) {
buck234_vol++;
index++;
}
old_index = s5m8767->buck_gpioindex;
s5m8767->buck_gpioindex = index;

if (index > old_index)
s5m8767_set_high(s5m8767);
return s5m8767_set_high(s5m8767);
else
s5m8767_set_low(s5m8767);
return s5m8767_set_low(s5m8767);
} else {
ret = s5m8767_get_voltage_register(rdev, &reg);
if (ret)
return ret;

s5m_reg_read(s5m8767->iodev, reg, &val);
val = (val & ~mask) | sel;

ret = s5m_reg_write(s5m8767->iodev, reg, val);
return s5m_reg_update(s5m8767->iodev, reg, selector, mask);
}

*selector = sel;
return ret;
}

static int s5m8767_set_voltage_time_sel(struct regulator_dev *rdev,
Expand All @@ -463,7 +453,7 @@ static struct regulator_ops s5m8767_ops = {
.enable = s5m8767_reg_enable,
.disable = s5m8767_reg_disable,
.get_voltage_sel = s5m8767_get_voltage_sel,
.set_voltage = s5m8767_set_voltage,
.set_voltage_sel = s5m8767_set_voltage_sel,
.set_voltage_time_sel = s5m8767_set_voltage_time_sel,
};

Expand Down

0 comments on commit 68f5e65

Please sign in to comment.