aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-02-12 05:18:08 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-03-03 09:49:26 -0500
commit34abbd68efe09765465b81dfedeee9994f13302f (patch)
tree24fe9ed360f8673f74fc513ac98347bc8896b3db /drivers/regulator/core.c
parent9a7f6a4c6edc84748c6477c9df56691a0e61b8fd (diff)
regulator: Provide optional dummy regulator for consumers
In order to ease transitions with drivers are boards start using regulators provide an option to cause all regulator_get() calls to succeed, with a dummy always on regulator being supplied where one has not been configured. A warning is printed whenever the dummy regulator is used to aid system development. This regulator does not implement any regulator operations but will allow simple consumers which only do enable() and disable() calls to run. It is kept separate from the fixed voltage regulator to avoid Kconfig confusion on the part of users when it is extended to allow boards to explicitly use the dummy regulator to simplify cases where the majority of supplies are from fixed regulators without software control. This option is currently only effective for systems which do not specify full constriants. If required an override could also be provided to allow these systems to use the dummy regulator, though it is likely that unconfigured supplies on such systems will lead to error due to regulators being powered down more aggressively when not in use. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 75a26f780918..c7bbe30010f7 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -24,6 +24,8 @@
24#include <linux/regulator/driver.h> 24#include <linux/regulator/driver.h>
25#include <linux/regulator/machine.h> 25#include <linux/regulator/machine.h>
26 26
27#include "dummy.h"
28
27#define REGULATOR_VERSION "0.5" 29#define REGULATOR_VERSION "0.5"
28 30
29static DEFINE_MUTEX(regulator_list_mutex); 31static DEFINE_MUTEX(regulator_list_mutex);
@@ -1123,6 +1125,22 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
1123 goto found; 1125 goto found;
1124 } 1126 }
1125 } 1127 }
1128
1129#ifdef CONFIG_REGULATOR_DUMMY
1130 if (!devname)
1131 devname = "deviceless";
1132
1133 /* If the board didn't flag that it was fully constrained then
1134 * substitute in a dummy regulator so consumers can continue.
1135 */
1136 if (!has_full_constraints) {
1137 pr_warning("%s supply %s not found, using dummy regulator\n",
1138 devname, id);
1139 rdev = dummy_regulator_rdev;
1140 goto found;
1141 }
1142#endif
1143
1126 mutex_unlock(&regulator_list_mutex); 1144 mutex_unlock(&regulator_list_mutex);
1127 return regulator; 1145 return regulator;
1128 1146
@@ -2483,8 +2501,15 @@ EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);
2483 2501
2484static int __init regulator_init(void) 2502static int __init regulator_init(void)
2485{ 2503{
2504 int ret;
2505
2486 printk(KERN_INFO "regulator: core version %s\n", REGULATOR_VERSION); 2506 printk(KERN_INFO "regulator: core version %s\n", REGULATOR_VERSION);
2487 return class_register(&regulator_class); 2507
2508 ret = class_register(&regulator_class);
2509
2510 regulator_dummy_init();
2511
2512 return ret;
2488} 2513}
2489 2514
2490/* init early to allow our consumers to complete system booting */ 2515/* init early to allow our consumers to complete system booting */