diff options
author | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> | 2014-04-16 05:01:39 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-04-18 13:35:06 -0400 |
commit | 2cce4be9e6b885c595816c45a80bcce95dae6d30 (patch) | |
tree | 242189876aeb776e3820eb94f8a725c09eaa9187 | |
parent | 4a8c475f5fd5c1271dba36a453d666d5ed473aa6 (diff) |
regulator: arizona-ldo1: Add processing of init_data from device tree
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/arizona-ldo1.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 2248733ea394..d3787e11f535 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c | |||
@@ -19,6 +19,7 @@ | |||
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/regulator/machine.h> |
22 | #include <linux/regulator/of_regulator.h> | ||
22 | #include <linux/gpio.h> | 23 | #include <linux/gpio.h> |
23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
24 | 25 | ||
@@ -178,12 +179,39 @@ static const struct regulator_init_data arizona_ldo1_default = { | |||
178 | .num_consumer_supplies = 1, | 179 | .num_consumer_supplies = 1, |
179 | }; | 180 | }; |
180 | 181 | ||
181 | static int arizona_ldo1_of_get_pdata(struct arizona *arizona) | 182 | static int arizona_ldo1_of_get_pdata(struct arizona *arizona, |
183 | struct regulator_config *config) | ||
182 | { | 184 | { |
183 | struct arizona_pdata *pdata = &arizona->pdata; | 185 | struct arizona_pdata *pdata = &arizona->pdata; |
186 | struct arizona_ldo1 *ldo1 = config->driver_data; | ||
187 | struct device_node *init_node, *dcvdd_node; | ||
188 | struct regulator_init_data *init_data; | ||
184 | 189 | ||
185 | pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true); | 190 | pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true); |
186 | 191 | ||
192 | init_node = of_get_child_by_name(arizona->dev->of_node, "ldo1"); | ||
193 | dcvdd_node = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0); | ||
194 | |||
195 | if (init_node) { | ||
196 | config->of_node = init_node; | ||
197 | |||
198 | init_data = of_get_regulator_init_data(arizona->dev, init_node); | ||
199 | |||
200 | if (init_data) { | ||
201 | init_data->consumer_supplies = &ldo1->supply; | ||
202 | init_data->num_consumer_supplies = 1; | ||
203 | |||
204 | if (dcvdd_node && dcvdd_node != init_node) | ||
205 | arizona->external_dcvdd = true; | ||
206 | |||
207 | pdata->ldo1 = init_data; | ||
208 | } | ||
209 | } else if (dcvdd_node) { | ||
210 | arizona->external_dcvdd = true; | ||
211 | } | ||
212 | |||
213 | of_node_put(dcvdd_node); | ||
214 | |||
187 | return 0; | 215 | return 0; |
188 | } | 216 | } |
189 | 217 | ||
@@ -230,7 +258,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
230 | 258 | ||
231 | if (IS_ENABLED(CONFIG_OF)) { | 259 | if (IS_ENABLED(CONFIG_OF)) { |
232 | if (!dev_get_platdata(arizona->dev)) { | 260 | if (!dev_get_platdata(arizona->dev)) { |
233 | ret = arizona_ldo1_of_get_pdata(arizona); | 261 | ret = arizona_ldo1_of_get_pdata(arizona, &config); |
234 | if (ret < 0) | 262 | if (ret < 0) |
235 | return ret; | 263 | return ret; |
236 | } | 264 | } |
@@ -258,6 +286,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
258 | return ret; | 286 | return ret; |
259 | } | 287 | } |
260 | 288 | ||
289 | of_node_put(config.of_node); | ||
290 | |||
261 | platform_set_drvdata(pdev, ldo1); | 291 | platform_set_drvdata(pdev, ldo1); |
262 | 292 | ||
263 | return 0; | 293 | return 0; |