aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/Kconfig11
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/core.c27
-rw-r--r--drivers/regulator/dummy.c66
-rw-r--r--drivers/regulator/dummy.h31
5 files changed, 135 insertions, 1 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 3c07169498cf..834b48441829 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -27,6 +27,17 @@ config REGULATOR_DEBUG
27 help 27 help
28 Say yes here to enable debugging support. 28 Say yes here to enable debugging support.
29 29
30config REGULATOR_DUMMY
31 bool "Provide a dummy regulator if regulator lookups fail"
32 help
33 If this option is enabled then when a regulator lookup fails
34 and the board has not specified that it has provided full
35 constraints then the regulator core will provide an always
36 enabled dummy regulator will be provided, allowing consumer
37 drivers to continue.
38
39 A warning will be generated when this substitution is done.
40
30config REGULATOR_FIXED_VOLTAGE 41config REGULATOR_FIXED_VOLTAGE
31 tristate "Fixed voltage regulator support" 42 tristate "Fixed voltage regulator support"
32 help 43 help
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 7c59bcb10613..e845b66ad59c 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
9obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o 9obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
10 10
11obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o 11obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
12obj-$(CONFIG_REGULATOR_DUMMY) += dummy.o
12obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o 13obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
13obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o 14obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
14obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o 15obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
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 */
diff --git a/drivers/regulator/dummy.c b/drivers/regulator/dummy.c
new file mode 100644
index 000000000000..c7410bde7b5d
--- /dev/null
+++ b/drivers/regulator/dummy.c
@@ -0,0 +1,66 @@
1/*
2 * dummy.c
3 *
4 * Copyright 2010 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This is useful for systems with mixed controllable and
14 * non-controllable regulators, as well as for allowing testing on
15 * systems with no controllable regulators.
16 */
17
18#include <linux/err.h>
19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h>
22
23#include "dummy.h"
24
25struct regulator_dev *dummy_regulator_rdev;
26
27static struct regulator_init_data dummy_initdata;
28
29static struct regulator_ops dummy_ops;
30
31static struct regulator_desc dummy_desc = {
32 .name = "dummy",
33 .id = -1,
34 .type = REGULATOR_VOLTAGE,
35 .owner = THIS_MODULE,
36 .ops = &dummy_ops,
37};
38
39static struct platform_device *dummy_pdev;
40
41void __init regulator_dummy_init(void)
42{
43 int ret;
44
45 dummy_pdev = platform_device_alloc("reg-dummy", -1);
46 if (!dummy_pdev) {
47 pr_err("Failed to allocate dummy regulator device\n");
48 return;
49 }
50
51 ret = platform_device_add(dummy_pdev);
52 if (ret != 0) {
53 pr_err("Failed to register dummy regulator device: %d\n", ret);
54 platform_device_put(dummy_pdev);
55 return;
56 }
57
58 dummy_regulator_rdev = regulator_register(&dummy_desc, NULL,
59 &dummy_initdata, NULL);
60 if (IS_ERR(dummy_regulator_rdev)) {
61 ret = PTR_ERR(dummy_regulator_rdev);
62 pr_err("Failed to register regulator: %d\n", ret);
63 platform_device_unregister(dummy_pdev);
64 return;
65 }
66}
diff --git a/drivers/regulator/dummy.h b/drivers/regulator/dummy.h
new file mode 100644
index 000000000000..3921c0e24249
--- /dev/null
+++ b/drivers/regulator/dummy.h
@@ -0,0 +1,31 @@
1/*
2 * dummy.h
3 *
4 * Copyright 2010 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This is useful for systems with mixed controllable and
14 * non-controllable regulators, as well as for allowing testing on
15 * systems with no controllable regulators.
16 */
17
18#ifndef _DUMMY_H
19#define _DUMMY_H
20
21struct regulator_dev;
22
23extern struct regulator_dev *dummy_regulator_rdev;
24
25#ifdef CONFIG_REGULATOR_DUMMY
26void __init regulator_dummy_init(void);
27#else
28static inline void regulator_dummy_init(void) { }
29#endif
30
31#endif