aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-05 08:11:31 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-07 15:24:07 -0400
commite3d27775fcf5e78cca346d298e8e7f4afeefc5c1 (patch)
tree27f8a81bd4f96e610b058207dea2c9b91d89231e /drivers/regulator
parent0565021655dd0e4dd0f26ab4c0273e88a6ddc666 (diff)
regulator: wm8994: Provide default init data
Almost all systems use the regulators on the WM8994 series devices to provide DCVDD and AVDD1 so if no init data is supplied then set up the supplies for the user. This simplifies integration of the device into systems, especially when device tree is supported. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/wm8994-regulator.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 5115881fac42..f03fbf1ff38a 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -18,6 +18,7 @@
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h> 20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h>
21#include <linux/gpio.h> 22#include <linux/gpio.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23 24
@@ -28,6 +29,8 @@
28struct wm8994_ldo { 29struct wm8994_ldo {
29 struct regulator_dev *regulator; 30 struct regulator_dev *regulator;
30 struct wm8994 *wm8994; 31 struct wm8994 *wm8994;
32 struct regulator_consumer_supply supply;
33 struct regulator_init_data init_data;
31}; 34};
32 35
33#define WM8994_LDO1_MAX_SELECTOR 0x7 36#define WM8994_LDO1_MAX_SELECTOR 0x7
@@ -99,6 +102,26 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
99 }, 102 },
100}; 103};
101 104
105static const struct regulator_consumer_supply wm8994_ldo_consumer[] = {
106 { .supply = "AVDD1" },
107 { .supply = "DCVDD" },
108};
109
110static const struct regulator_init_data wm8994_ldo_default[] = {
111 {
112 .constraints = {
113 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
114 },
115 .num_consumer_supplies = 1,
116 },
117 {
118 .constraints = {
119 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
120 },
121 .num_consumer_supplies = 1,
122 },
123};
124
102static int wm8994_ldo_probe(struct platform_device *pdev) 125static int wm8994_ldo_probe(struct platform_device *pdev)
103{ 126{
104 struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent); 127 struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent);
@@ -117,13 +140,27 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
117 } 140 }
118 141
119 ldo->wm8994 = wm8994; 142 ldo->wm8994 = wm8994;
143 ldo->supply = wm8994_ldo_consumer[id];
144 ldo->supply.dev_name = dev_name(wm8994->dev);
120 145
121 config.dev = wm8994->dev; 146 config.dev = wm8994->dev;
122 config.driver_data = ldo; 147 config.driver_data = ldo;
123 config.regmap = wm8994->regmap; 148 config.regmap = wm8994->regmap;
124 if (pdata) { 149 config.init_data = &ldo->init_data;
125 config.init_data = pdata->ldo[id].init_data; 150 if (pdata)
126 config.ena_gpio = pdata->ldo[id].enable; 151 config.ena_gpio = pdata->ldo[id].enable;
152
153 /* Use default constraints if none set up */
154 if (!pdata || !pdata->ldo[id].init_data) {
155 dev_dbg(wm8994->dev, "Using default init data, supply %s %s\n",
156 ldo->supply.dev_name, ldo->supply.supply);
157
158 ldo->init_data = wm8994_ldo_default[id];
159 ldo->init_data.consumer_supplies = &ldo->supply;
160 if (!config.ena_gpio)
161 ldo->init_data.constraints.valid_ops_mask = 0;
162 } else {
163 ldo->init_data = *pdata->ldo[id].init_data;
127 } 164 }
128 165
129 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); 166 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);