Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 365029
b: refs/heads/master
c: bd28a15
h: refs/heads/master
i:
  365027: 31a6b43
v: v3
  • Loading branch information
Emeric Vigier authored and Mark Brown committed Mar 22, 2013
1 parent 87a15ff commit f013cb0
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 19 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: d79df329d0bd425c00856915b7b12f54dd100154
refs/heads/master: bd28a15733df2f3e66e6abc073cdf300df0f01e6
112 changes: 94 additions & 18 deletions trunk/drivers/regulator/ab8500.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
* @dev: device pointer
* @desc: regulator description
* @regulator_dev: regulator device
* @is_enabled: status of regulator (on/off)
* @update_bank: bank to control on/off
* @update_reg: register to control on/off
* @update_mask: mask to enable/disable regulator
* @update_val_enable: bits to enable the regulator in normal (high power) mode
* @update_mask: mask to enable/disable and set mode of regulator
* @update_val: bits holding the regulator current mode
* @update_val_idle: bits to enable the regulator in idle (low power) mode
* @update_val_normal: bits to enable the regulator in normal (high power) mode
* @voltage_bank: bank to control regulator voltage
* @voltage_reg: register to control regulator voltage
* @voltage_mask: mask to control regulator voltage
Expand All @@ -44,10 +47,13 @@ struct ab8500_regulator_info {
struct device *dev;
struct regulator_desc desc;
struct regulator_dev *regulator;
bool is_enabled;
u8 update_bank;
u8 update_reg;
u8 update_mask;
u8 update_val_enable;
u8 update_val;
u8 update_val_idle;
u8 update_val_normal;
u8 voltage_bank;
u8 voltage_reg;
u8 voltage_mask;
Expand Down Expand Up @@ -108,15 +114,17 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev)

ret = abx500_mask_and_set_register_interruptible(info->dev,
info->update_bank, info->update_reg,
info->update_mask, info->update_val_enable);
info->update_mask, info->update_val);
if (ret < 0)
dev_err(rdev_get_dev(rdev),
"couldn't set enable bits for regulator\n");

info->is_enabled = true;

dev_vdbg(rdev_get_dev(rdev),
"%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
info->desc.name, info->update_bank, info->update_reg,
info->update_mask, info->update_val_enable);
info->update_mask, info->update_val);

return ret;
}
Expand All @@ -138,6 +146,8 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)
dev_err(rdev_get_dev(rdev),
"couldn't set disable bits for regulator\n");

info->is_enabled = false;

dev_vdbg(rdev_get_dev(rdev),
"%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
info->desc.name, info->update_bank, info->update_reg,
Expand All @@ -146,6 +156,61 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)
return ret;
}

static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
unsigned int mode)
{
int ret = 0;

struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);

if (info == NULL) {
dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
}

switch (mode) {
case REGULATOR_MODE_NORMAL:
info->update_val = info->update_val_normal;
break;
case REGULATOR_MODE_IDLE:
info->update_val = info->update_val_idle;
break;
default:
return -EINVAL;
}

if (info->is_enabled) {
ret = abx500_mask_and_set_register_interruptible(info->dev,
info->update_bank, info->update_reg,
info->update_mask, info->update_val);
if (ret < 0)
dev_err(rdev_get_dev(rdev),
"couldn't set regulator mode\n");
}

return ret;
}

static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
{
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
int ret;

if (info == NULL) {
dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
}

if (info->update_val == info->update_val_normal)
ret = REGULATOR_MODE_NORMAL;
else if (info->update_val == info->update_val_idle)
ret = REGULATOR_MODE_IDLE;
else
ret = -EINVAL;

return ret;
}

static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
{
int ret;
Expand All @@ -172,9 +237,11 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
info->update_mask, regval);

if (regval & info->update_mask)
return true;
info->is_enabled = true;
else
return false;
info->is_enabled = false;

return info->is_enabled;
}

static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
Expand Down Expand Up @@ -249,6 +316,8 @@ static int ab8500_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
static struct regulator_ops ab8500_regulator_ops = {
.enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable,
.set_mode = ab8500_regulator_set_mode,
.get_mode = ab8500_regulator_get_mode,
.is_enabled = ab8500_regulator_is_enabled,
.get_voltage_sel = ab8500_regulator_get_voltage_sel,
.set_voltage_sel = ab8500_regulator_set_voltage_sel,
Expand Down Expand Up @@ -284,7 +353,9 @@ static struct ab8500_regulator_info
.update_bank = 0x04,
.update_reg = 0x09,
.update_mask = 0x03,
.update_val_enable = 0x01,
.update_val = 0x01,
.update_val_idle = 0x03,
.update_val_normal = 0x01,
.voltage_bank = 0x04,
.voltage_reg = 0x1f,
.voltage_mask = 0x0f,
Expand All @@ -302,7 +373,9 @@ static struct ab8500_regulator_info
.update_bank = 0x04,
.update_reg = 0x09,
.update_mask = 0x0c,
.update_val_enable = 0x04,
.update_val = 0x04,
.update_val_idle = 0x0c,
.update_val_normal = 0x04,
.voltage_bank = 0x04,
.voltage_reg = 0x20,
.voltage_mask = 0x0f,
Expand All @@ -320,7 +393,9 @@ static struct ab8500_regulator_info
.update_bank = 0x04,
.update_reg = 0x0a,
.update_mask = 0x03,
.update_val_enable = 0x01,
.update_val = 0x01,
.update_val_idle = 0x03,
.update_val_normal = 0x01,
.voltage_bank = 0x04,
.voltage_reg = 0x21,
.voltage_mask = 0x07,
Expand All @@ -338,7 +413,9 @@ static struct ab8500_regulator_info
.update_bank = 0x03,
.update_reg = 0x80,
.update_mask = 0x44,
.update_val_enable = 0x04,
.update_val = 0x04,
.update_val_idle = 0x44,
.update_val_normal = 0x04,
.voltage_bank = 0x03,
.voltage_reg = 0x80,
.voltage_mask = 0x38,
Expand All @@ -365,7 +442,7 @@ static struct ab8500_regulator_info
.update_bank = 0x03,
.update_reg = 0x80,
.update_mask = 0x82,
.update_val_enable = 0x02,
.update_val = 0x02,
},
[AB8500_LDO_USB] = {
.desc = {
Expand All @@ -380,7 +457,6 @@ static struct ab8500_regulator_info
.update_bank = 0x03,
.update_reg = 0x82,
.update_mask = 0x03,
.update_val_enable = 0x01,
},
[AB8500_LDO_AUDIO] = {
.desc = {
Expand All @@ -395,7 +471,7 @@ static struct ab8500_regulator_info
.update_bank = 0x03,
.update_reg = 0x83,
.update_mask = 0x02,
.update_val_enable = 0x02,
.update_val = 0x02,
},
[AB8500_LDO_ANAMIC1] = {
.desc = {
Expand All @@ -410,7 +486,7 @@ static struct ab8500_regulator_info
.update_bank = 0x03,
.update_reg = 0x83,
.update_mask = 0x08,
.update_val_enable = 0x08,
.update_val = 0x08,
},
[AB8500_LDO_ANAMIC2] = {
.desc = {
Expand All @@ -425,7 +501,7 @@ static struct ab8500_regulator_info
.update_bank = 0x03,
.update_reg = 0x83,
.update_mask = 0x10,
.update_val_enable = 0x10,
.update_val = 0x10,
},
[AB8500_LDO_DMIC] = {
.desc = {
Expand All @@ -440,7 +516,7 @@ static struct ab8500_regulator_info
.update_bank = 0x03,
.update_reg = 0x83,
.update_mask = 0x04,
.update_val_enable = 0x04,
.update_val = 0x04,
},
[AB8500_LDO_ANA] = {
.desc = {
Expand All @@ -455,7 +531,7 @@ static struct ab8500_regulator_info
.update_bank = 0x04,
.update_reg = 0x06,
.update_mask = 0x0c,
.update_val_enable = 0x04,
.update_val = 0x04,
},


Expand Down

0 comments on commit f013cb0

Please sign in to comment.