Skip to content

Commit 9aca0e7

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/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
2 parents a0e3390 + ec10b0e commit 9aca0e7

File tree

9 files changed

+1280
-15
lines changed

9 files changed

+1280
-15
lines changed

drivers/regulator/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ config REGULATOR_MAX8925
100100
help
101101
Say y here to support the voltage regulaltor of Maxim MAX8925 PMIC.
102102

103+
config REGULATOR_MAX8952
104+
tristate "Maxim MAX8952 Power Management IC"
105+
depends on I2C
106+
help
107+
This driver controls a Maxim 8952 voltage output regulator
108+
via I2C bus. Maxim 8952 has one voltage output and supports 4 DVS
109+
modes ranging from 0.77V to 1.40V by 0.01V steps.
110+
103111
config REGULATOR_MAX8998
104112
tristate "Maxim 8998 voltage regulator"
105113
depends on MFD_MAX8998
@@ -164,6 +172,13 @@ config REGULATOR_LP3971
164172
Say Y here to support the voltage regulators and convertors
165173
on National Semiconductors LP3971 PMIC
166174

175+
config REGULATOR_LP3972
176+
tristate "National Semiconductors LP3972 PMIC regulator driver"
177+
depends on I2C
178+
help
179+
Say Y here to support the voltage regulators and convertors
180+
on National Semiconductors LP3972 PMIC
181+
167182
config REGULATOR_PCAP
168183
tristate "PCAP2 regulator driver"
169184
depends on EZX_PCAP

drivers/regulator/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
#
44

55

6-
obj-$(CONFIG_REGULATOR) += core.o
6+
obj-$(CONFIG_REGULATOR) += core.o dummy.o
77
obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
88
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
99
obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
1010

1111
obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
1212
obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
13-
obj-$(CONFIG_REGULATOR_DUMMY) += dummy.o
1413
obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
14+
obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
1515
obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
1616
obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
1717
obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o
1818
obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o
1919
obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o
20+
obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o
2021
obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
2122
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
2223
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o

drivers/regulator/core.c

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static DEFINE_MUTEX(regulator_list_mutex);
3333
static LIST_HEAD(regulator_list);
3434
static LIST_HEAD(regulator_map_list);
3535
static int has_full_constraints;
36+
static bool board_wants_dummy_regulator;
3637

3738
/*
3839
* struct regulator_map
@@ -63,7 +64,8 @@ struct regulator {
6364
};
6465

6566
static int _regulator_is_enabled(struct regulator_dev *rdev);
66-
static int _regulator_disable(struct regulator_dev *rdev);
67+
static int _regulator_disable(struct regulator_dev *rdev,
68+
struct regulator_dev **supply_rdev_ptr);
6769
static int _regulator_get_voltage(struct regulator_dev *rdev);
6870
static int _regulator_get_current_limit(struct regulator_dev *rdev);
6971
static unsigned int _regulator_get_mode(struct regulator_dev *rdev);
@@ -1108,6 +1110,11 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
11081110
}
11091111
}
11101112

1113+
if (board_wants_dummy_regulator) {
1114+
rdev = dummy_regulator_rdev;
1115+
goto found;
1116+
}
1117+
11111118
#ifdef CONFIG_REGULATOR_DUMMY
11121119
if (!devname)
11131120
devname = "deviceless";
@@ -1348,7 +1355,8 @@ int regulator_enable(struct regulator *regulator)
13481355
EXPORT_SYMBOL_GPL(regulator_enable);
13491356

13501357
/* locks held by regulator_disable() */
1351-
static int _regulator_disable(struct regulator_dev *rdev)
1358+
static int _regulator_disable(struct regulator_dev *rdev,
1359+
struct regulator_dev **supply_rdev_ptr)
13521360
{
13531361
int ret = 0;
13541362

@@ -1376,8 +1384,7 @@ static int _regulator_disable(struct regulator_dev *rdev)
13761384
}
13771385

13781386
/* decrease our supplies ref count and disable if required */
1379-
if (rdev->supply)
1380-
_regulator_disable(rdev->supply);
1387+
*supply_rdev_ptr = rdev->supply;
13811388

13821389
rdev->use_count = 0;
13831390
} else if (rdev->use_count > 1) {
@@ -1407,17 +1414,29 @@ static int _regulator_disable(struct regulator_dev *rdev)
14071414
int regulator_disable(struct regulator *regulator)
14081415
{
14091416
struct regulator_dev *rdev = regulator->rdev;
1417+
struct regulator_dev *supply_rdev = NULL;
14101418
int ret = 0;
14111419

14121420
mutex_lock(&rdev->mutex);
1413-
ret = _regulator_disable(rdev);
1421+
ret = _regulator_disable(rdev, &supply_rdev);
14141422
mutex_unlock(&rdev->mutex);
1423+
1424+
/* decrease our supplies ref count and disable if required */
1425+
while (supply_rdev != NULL) {
1426+
rdev = supply_rdev;
1427+
1428+
mutex_lock(&rdev->mutex);
1429+
_regulator_disable(rdev, &supply_rdev);
1430+
mutex_unlock(&rdev->mutex);
1431+
}
1432+
14151433
return ret;
14161434
}
14171435
EXPORT_SYMBOL_GPL(regulator_disable);
14181436

14191437
/* locks held by regulator_force_disable() */
1420-
static int _regulator_force_disable(struct regulator_dev *rdev)
1438+
static int _regulator_force_disable(struct regulator_dev *rdev,
1439+
struct regulator_dev **supply_rdev_ptr)
14211440
{
14221441
int ret = 0;
14231442

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

14381457
/* decrease our supplies ref count and disable if required */
1439-
if (rdev->supply)
1440-
_regulator_disable(rdev->supply);
1458+
*supply_rdev_ptr = rdev->supply;
14411459

14421460
rdev->use_count = 0;
14431461
return ret;
@@ -1454,12 +1472,17 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
14541472
*/
14551473
int regulator_force_disable(struct regulator *regulator)
14561474
{
1475+
struct regulator_dev *supply_rdev = NULL;
14571476
int ret;
14581477

14591478
mutex_lock(&regulator->rdev->mutex);
14601479
regulator->uA_load = 0;
1461-
ret = _regulator_force_disable(regulator->rdev);
1480+
ret = _regulator_force_disable(regulator->rdev, &supply_rdev);
14621481
mutex_unlock(&regulator->rdev->mutex);
1482+
1483+
if (supply_rdev)
1484+
regulator_disable(get_device_regulator(rdev_get_dev(supply_rdev)));
1485+
14631486
return ret;
14641487
}
14651488
EXPORT_SYMBOL_GPL(regulator_force_disable);
@@ -2462,6 +2485,22 @@ void regulator_has_full_constraints(void)
24622485
}
24632486
EXPORT_SYMBOL_GPL(regulator_has_full_constraints);
24642487

2488+
/**
2489+
* regulator_use_dummy_regulator - Provide a dummy regulator when none is found
2490+
*
2491+
* Calling this function will cause the regulator API to provide a
2492+
* dummy regulator to consumers if no physical regulator is found,
2493+
* allowing most consumers to proceed as though a regulator were
2494+
* configured. This allows systems such as those with software
2495+
* controllable regulators for the CPU core only to be brought up more
2496+
* readily.
2497+
*/
2498+
void regulator_use_dummy_regulator(void)
2499+
{
2500+
board_wants_dummy_regulator = true;
2501+
}
2502+
EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator);
2503+
24652504
/**
24662505
* rdev_get_drvdata - get rdev regulator driver data
24672506
* @rdev: regulator

drivers/regulator/dummy.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ struct regulator_dev;
2222

2323
extern struct regulator_dev *dummy_regulator_rdev;
2424

25-
#ifdef CONFIG_REGULATOR_DUMMY
2625
void __init regulator_dummy_init(void);
27-
#else
28-
static inline void regulator_dummy_init(void) { }
29-
#endif
3026

3127
#endif

0 commit comments

Comments
 (0)