aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@sirena.org.uk>2013-04-27 21:13:50 -0400
committerMark Brown <broonie@sirena.org.uk>2013-04-27 21:13:50 -0400
commitbee546581424b5514ec6a034fb83fd4e95b804da (patch)
treea7ea259aaedb63025eb7e7db8789c21ef53d9f36 /drivers/regulator
parentbcd5d1d978c70841d68c7a3725269df9d5a4abf8 (diff)
parent3ea9389656ddf8beb1b5b52b8db6333fa4a7c00e (diff)
Merge remote-tracking branch 'regulator/topic/wm8994' into v3.9-rc8
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/wm8994-regulator.c61
1 files changed, 42 insertions, 19 deletions
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 6ff872342648..a612c356a697 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,29 @@ 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 else if (wm8994->dev->of_node)
153 config.ena_gpio = wm8994->pdata.ldo[id].enable;
154
155 /* Use default constraints if none set up */
156 if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) {
157 dev_dbg(wm8994->dev, "Using default init data, supply %s %s\n",
158 ldo->supply.dev_name, ldo->supply.supply);
159
160 ldo->init_data = wm8994_ldo_default[id];
161 ldo->init_data.consumer_supplies = &ldo->supply;
162 if (!config.ena_gpio)
163 ldo->init_data.constraints.valid_ops_mask = 0;
164 } else {
165 ldo->init_data = *pdata->ldo[id].init_data;
127 } 166 }
128 167
129 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); 168 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);
@@ -162,23 +201,7 @@ static struct platform_driver wm8994_ldo_driver = {
162 }, 201 },
163}; 202};
164 203
165static int __init wm8994_ldo_init(void) 204module_platform_driver(wm8994_ldo_driver);
166{
167 int ret;
168
169 ret = platform_driver_register(&wm8994_ldo_driver);
170 if (ret != 0)
171 pr_err("Failed to register Wm8994 GP LDO driver: %d\n", ret);
172
173 return ret;
174}
175subsys_initcall(wm8994_ldo_init);
176
177static void __exit wm8994_ldo_exit(void)
178{
179 platform_driver_unregister(&wm8994_ldo_driver);
180}
181module_exit(wm8994_ldo_exit);
182 205
183/* Module information */ 206/* Module information */
184MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 207MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");