Skip to content

Commit 688fe99

Browse files
broonieLiam Girdwood
authored andcommitted
regulator: Add option for machine drivers to enable the dummy regulator
Allow machine drivers to explicitly enable the use of the dummy regulator, enabling simpler support for systems with only a few specific supplies visible to software. It is strongly recommended that this is not used on systems with substantial software control over their PMICs, for maximum functionality constrints should be as fully specified as possible. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
1 parent 993af7c commit 688fe99

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

‎drivers/regulator/Makefile‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
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
1514
obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
1615
obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o

‎drivers/regulator/core.c‎

Lines changed: 22 additions & 0 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
@@ -1108,6 +1109,11 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
11081109
}
11091110
}
11101111

1112+
if (board_wants_dummy_regulator) {
1113+
rdev = dummy_regulator_rdev;
1114+
goto found;
1115+
}
1116+
11111117
#ifdef CONFIG_REGULATOR_DUMMY
11121118
if (!devname)
11131119
devname = "deviceless";
@@ -2462,6 +2468,22 @@ void regulator_has_full_constraints(void)
24622468
}
24632469
EXPORT_SYMBOL_GPL(regulator_has_full_constraints);
24642470

2471+
/**
2472+
* regulator_use_dummy_regulator - Provide a dummy regulator when none is found
2473+
*
2474+
* Calling this function will cause the regulator API to provide a
2475+
* dummy regulator to consumers if no physical regulator is found,
2476+
* allowing most consumers to proceed as though a regulator were
2477+
* configured. This allows systems such as those with software
2478+
* controllable regulators for the CPU core only to be brought up more
2479+
* readily.
2480+
*/
2481+
void regulator_use_dummy_regulator(void)
2482+
{
2483+
board_wants_dummy_regulator = true;
2484+
}
2485+
EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator);
2486+
24652487
/**
24662488
* rdev_get_drvdata - get rdev regulator driver data
24672489
* @rdev: regulator

‎include/linux/regulator/machine.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,15 @@ int regulator_suspend_prepare(suspend_state_t state);
189189

190190
#ifdef CONFIG_REGULATOR
191191
void regulator_has_full_constraints(void);
192+
void regulator_use_dummy_regulator(void);
192193
#else
193194
static inline void regulator_has_full_constraints(void)
194195
{
195196
}
197+
198+
static inline void regulator_use_dummy_regulator(void)
199+
{
200+
}
196201
#endif
197202

198203
#endif

0 commit comments

Comments
 (0)