Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185657
b: refs/heads/master
c: 31aae2b
h: refs/heads/master
i:
  185655: 4daa343
v: v3
  • Loading branch information
Mark Brown authored and Liam Girdwood committed Mar 3, 2010
1 parent 09ecdfe commit 5e09e69
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 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: 84b6826306119dc3c41ef9d7ed6c408112f63301
refs/heads/master: 31aae2beeb3d601d556b6a8c39085940ad1e9f42
41 changes: 35 additions & 6 deletions trunk/drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/suspend.h>
#include <linux/delay.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
Expand Down Expand Up @@ -1084,6 +1085,13 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
return NULL;
}

static int _regulator_get_enable_time(struct regulator_dev *rdev)
{
if (!rdev->desc->ops->enable_time)
return 0;
return rdev->desc->ops->enable_time(rdev);
}

/* Internal regulator request function */
static struct regulator *_regulator_get(struct device *dev, const char *id,
int exclusive)
Expand Down Expand Up @@ -1251,7 +1259,7 @@ static int _regulator_can_change_status(struct regulator_dev *rdev)
/* locks held by regulator_enable() */
static int _regulator_enable(struct regulator_dev *rdev)
{
int ret;
int ret, delay;

/* do we need to enable the supply regulator first */
if (rdev->supply) {
Expand All @@ -1275,13 +1283,34 @@ static int _regulator_enable(struct regulator_dev *rdev)
if (!_regulator_can_change_status(rdev))
return -EPERM;

if (rdev->desc->ops->enable) {
ret = rdev->desc->ops->enable(rdev);
if (ret < 0)
return ret;
} else {
if (!rdev->desc->ops->enable)
return -EINVAL;

/* Query before enabling in case configuration
* dependant. */
ret = _regulator_get_enable_time(rdev);
if (ret >= 0) {
delay = ret;
} else {
printk(KERN_WARNING
"%s: enable_time() failed for %s: %d\n",
__func__, rdev_get_name(rdev),
ret);
delay = 0;
}

/* Allow the regulator to ramp; it would be useful
* to extend this for bulk operations so that the
* regulators can ramp together. */
ret = rdev->desc->ops->enable(rdev);
if (ret < 0)
return ret;

if (delay >= 1000)
mdelay(delay / 1000);
else if (delay)
udelay(delay);

} else if (ret < 0) {
printk(KERN_ERR "%s: is_enabled() failed for %s: %d\n",
__func__, rdev_get_name(rdev), ret);
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/linux/regulator/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ enum regulator_status {
* @get_optimum_mode: Get the most efficient operating mode for the regulator
* when running with the specified parameters.
*
* @enable_time: Time taken for the regulator voltage output voltage to
* stabalise after being enabled, in microseconds.
*
* @set_suspend_voltage: Set the voltage for the regulator when the system
* is suspended.
* @set_suspend_enable: Mark the regulator as enabled when the system is
Expand Down Expand Up @@ -93,6 +96,9 @@ struct regulator_ops {
int (*set_mode) (struct regulator_dev *, unsigned int mode);
unsigned int (*get_mode) (struct regulator_dev *);

/* Time taken to enable the regulator */
int (*enable_time) (struct regulator_dev *);

/* report regulator status ... most other accessors report
* control inputs, this reports results of combining inputs
* from Linux (and other sources) with the actual load.
Expand Down

0 comments on commit 5e09e69

Please sign in to comment.