Skip to content

Commit bee5465

Browse files
committed
Merge remote-tracking branch 'regulator/topic/wm8994' into v3.9-rc8
2 parents bcd5d1d + 3ea9389 commit bee5465

1 file changed

Lines changed: 42 additions & 19 deletions

File tree

‎drivers/regulator/wm8994-regulator.c‎

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/err.h>
1919
#include <linux/platform_device.h>
2020
#include <linux/regulator/driver.h>
21+
#include <linux/regulator/machine.h>
2122
#include <linux/gpio.h>
2223
#include <linux/slab.h>
2324

@@ -28,6 +29,8 @@
2829
struct wm8994_ldo {
2930
struct regulator_dev *regulator;
3031
struct wm8994 *wm8994;
32+
struct regulator_consumer_supply supply;
33+
struct regulator_init_data init_data;
3134
};
3235

3336
#define WM8994_LDO1_MAX_SELECTOR 0x7
@@ -99,6 +102,26 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
99102
},
100103
};
101104

105+
static const struct regulator_consumer_supply wm8994_ldo_consumer[] = {
106+
{ .supply = "AVDD1" },
107+
{ .supply = "DCVDD" },
108+
};
109+
110+
static 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+
102125
static int wm8994_ldo_probe(struct platform_device *pdev)
103126
{
104127
struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent);
@@ -117,13 +140,29 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
117140
}
118141

119142
ldo->wm8994 = wm8994;
143+
ldo->supply = wm8994_ldo_consumer[id];
144+
ldo->supply.dev_name = dev_name(wm8994->dev);
120145

121146
config.dev = wm8994->dev;
122147
config.driver_data = ldo;
123148
config.regmap = wm8994->regmap;
124-
if (pdata) {
125-
config.init_data = pdata->ldo[id].init_data;
149+
config.init_data = &ldo->init_data;
150+
if (pdata)
126151
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;
127166
}
128167

129168
ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);
@@ -162,23 +201,7 @@ static struct platform_driver wm8994_ldo_driver = {
162201
},
163202
};
164203

165-
static int __init wm8994_ldo_init(void)
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-
}
175-
subsys_initcall(wm8994_ldo_init);
176-
177-
static void __exit wm8994_ldo_exit(void)
178-
{
179-
platform_driver_unregister(&wm8994_ldo_driver);
180-
}
181-
module_exit(wm8994_ldo_exit);
204+
module_platform_driver(wm8994_ldo_driver);
182205

183206
/* Module information */
184207
MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");

0 commit comments

Comments
 (0)