Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/lrg/voltage-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6:
  regulator: max8952 - fix max8952_set_voltage
  regulator: max8952 - fix max8952_pmic_probe error path
  regulator: fix build when CONFIG_REGULATOR_DUMMY=n
  regulator: avoid deadlock when disabling regulator with supply
  regulator: Add option for machine drivers to enable the dummy regulator
  Regulator: lp3972 cleanup
  Regulator: LP3972 PMIC regulator driver
  MAX8952 PMIC Driver Initial Release
  • Loading branch information
torvalds committed Oct 28, 2010
2 parents a0e3390 + ec10b0e commit 9aca0e7
Show file tree
Hide file tree
Showing 9 changed files with 1,280 additions and 15 deletions.
15 changes: 15 additions & 0 deletions drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ config REGULATOR_MAX8925
help
Say y here to support the voltage regulaltor of Maxim MAX8925 PMIC.

config REGULATOR_MAX8952
tristate "Maxim MAX8952 Power Management IC"
depends on I2C
help
This driver controls a Maxim 8952 voltage output regulator
via I2C bus. Maxim 8952 has one voltage output and supports 4 DVS
modes ranging from 0.77V to 1.40V by 0.01V steps.

config REGULATOR_MAX8998
tristate "Maxim 8998 voltage regulator"
depends on MFD_MAX8998
Expand Down Expand Up @@ -164,6 +172,13 @@ config REGULATOR_LP3971
Say Y here to support the voltage regulators and convertors
on National Semiconductors LP3971 PMIC

config REGULATOR_LP3972
tristate "National Semiconductors LP3972 PMIC regulator driver"
depends on I2C
help
Say Y here to support the voltage regulators and convertors
on National Semiconductors LP3972 PMIC

config REGULATOR_PCAP
tristate "PCAP2 regulator driver"
depends on EZX_PCAP
Expand Down
5 changes: 3 additions & 2 deletions drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
#


obj-$(CONFIG_REGULATOR) += core.o
obj-$(CONFIG_REGULATOR) += core.o dummy.o
obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o

obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
obj-$(CONFIG_REGULATOR_DUMMY) += dummy.o
obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o
obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o
obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o
obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o
obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
Expand Down
57 changes: 48 additions & 9 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static DEFINE_MUTEX(regulator_list_mutex);
static LIST_HEAD(regulator_list);
static LIST_HEAD(regulator_map_list);
static int has_full_constraints;
static bool board_wants_dummy_regulator;

/*
* struct regulator_map
Expand Down Expand Up @@ -63,7 +64,8 @@ struct regulator {
};

static int _regulator_is_enabled(struct regulator_dev *rdev);
static int _regulator_disable(struct regulator_dev *rdev);
static int _regulator_disable(struct regulator_dev *rdev,
struct regulator_dev **supply_rdev_ptr);
static int _regulator_get_voltage(struct regulator_dev *rdev);
static int _regulator_get_current_limit(struct regulator_dev *rdev);
static unsigned int _regulator_get_mode(struct regulator_dev *rdev);
Expand Down Expand Up @@ -1108,6 +1110,11 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
}
}

if (board_wants_dummy_regulator) {
rdev = dummy_regulator_rdev;
goto found;
}

#ifdef CONFIG_REGULATOR_DUMMY
if (!devname)
devname = "deviceless";
Expand Down Expand Up @@ -1348,7 +1355,8 @@ int regulator_enable(struct regulator *regulator)
EXPORT_SYMBOL_GPL(regulator_enable);

/* locks held by regulator_disable() */
static int _regulator_disable(struct regulator_dev *rdev)
static int _regulator_disable(struct regulator_dev *rdev,
struct regulator_dev **supply_rdev_ptr)
{
int ret = 0;

Expand Down Expand Up @@ -1376,8 +1384,7 @@ static int _regulator_disable(struct regulator_dev *rdev)
}

/* decrease our supplies ref count and disable if required */
if (rdev->supply)
_regulator_disable(rdev->supply);
*supply_rdev_ptr = rdev->supply;

rdev->use_count = 0;
} else if (rdev->use_count > 1) {
Expand Down Expand Up @@ -1407,17 +1414,29 @@ static int _regulator_disable(struct regulator_dev *rdev)
int regulator_disable(struct regulator *regulator)
{
struct regulator_dev *rdev = regulator->rdev;
struct regulator_dev *supply_rdev = NULL;
int ret = 0;

mutex_lock(&rdev->mutex);
ret = _regulator_disable(rdev);
ret = _regulator_disable(rdev, &supply_rdev);
mutex_unlock(&rdev->mutex);

/* decrease our supplies ref count and disable if required */
while (supply_rdev != NULL) {
rdev = supply_rdev;

mutex_lock(&rdev->mutex);
_regulator_disable(rdev, &supply_rdev);
mutex_unlock(&rdev->mutex);
}

return ret;
}
EXPORT_SYMBOL_GPL(regulator_disable);

/* locks held by regulator_force_disable() */
static int _regulator_force_disable(struct regulator_dev *rdev)
static int _regulator_force_disable(struct regulator_dev *rdev,
struct regulator_dev **supply_rdev_ptr)
{
int ret = 0;

Expand All @@ -1436,8 +1455,7 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
}

/* decrease our supplies ref count and disable if required */
if (rdev->supply)
_regulator_disable(rdev->supply);
*supply_rdev_ptr = rdev->supply;

rdev->use_count = 0;
return ret;
Expand All @@ -1454,12 +1472,17 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
*/
int regulator_force_disable(struct regulator *regulator)
{
struct regulator_dev *supply_rdev = NULL;
int ret;

mutex_lock(&regulator->rdev->mutex);
regulator->uA_load = 0;
ret = _regulator_force_disable(regulator->rdev);
ret = _regulator_force_disable(regulator->rdev, &supply_rdev);
mutex_unlock(&regulator->rdev->mutex);

if (supply_rdev)
regulator_disable(get_device_regulator(rdev_get_dev(supply_rdev)));

return ret;
}
EXPORT_SYMBOL_GPL(regulator_force_disable);
Expand Down Expand Up @@ -2462,6 +2485,22 @@ void regulator_has_full_constraints(void)
}
EXPORT_SYMBOL_GPL(regulator_has_full_constraints);

/**
* regulator_use_dummy_regulator - Provide a dummy regulator when none is found
*
* Calling this function will cause the regulator API to provide a
* dummy regulator to consumers if no physical regulator is found,
* allowing most consumers to proceed as though a regulator were
* configured. This allows systems such as those with software
* controllable regulators for the CPU core only to be brought up more
* readily.
*/
void regulator_use_dummy_regulator(void)
{
board_wants_dummy_regulator = true;
}
EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator);

/**
* rdev_get_drvdata - get rdev regulator driver data
* @rdev: regulator
Expand Down
4 changes: 0 additions & 4 deletions drivers/regulator/dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ struct regulator_dev;

extern struct regulator_dev *dummy_regulator_rdev;

#ifdef CONFIG_REGULATOR_DUMMY
void __init regulator_dummy_init(void);
#else
static inline void regulator_dummy_init(void) { }
#endif

#endif
Loading

0 comments on commit 9aca0e7

Please sign in to comment.