summaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.cirrus.com>2018-06-19 11:10:00 -0400
committerMark Brown <broonie@kernel.org>2018-06-19 11:12:01 -0400
commita9191579ba1086d91842199263e6fe6bb5eec1ba (patch)
treece16f61a9e60460a84b13ff630030ca09fc8bb00 /drivers/regulator
parent13ed4964057e5ad183da9f7f8160841d261e9517 (diff)
regulator: arizona-ldo1: Use correct device to get enable GPIO
Currently the enable GPIO is being looked up on the regulator device itself but that does not have its own DT node, this causes the lookup to fail and the regulator not to get its GPIO. The DT node is shared across the whole MFD and as such the lookup needs to happen on that parent device. Moving the lookup to the parent device also means devres can no longer be used as the life time would attach to the wrong device. Additionally, the enable GPIO is active high so we should be passing GPIOD_OUT_LOW to ensure the regulator starts in its off state allowing the driver to enable it when it is ready. Fixes: e1739e86f0cb ("regulator: arizona-ldo1: Look up a descriptor and pass to the core") Reported-by: Matthias Reichl <hias@horus.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/arizona-ldo1.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index f6d6a4ad9e8a..e976d073f28d 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -36,6 +36,8 @@ struct arizona_ldo1 {
36 36
37 struct regulator_consumer_supply supply; 37 struct regulator_consumer_supply supply;
38 struct regulator_init_data init_data; 38 struct regulator_init_data init_data;
39
40 struct gpio_desc *ena_gpiod;
39}; 41};
40 42
41static int arizona_ldo1_hc_list_voltage(struct regulator_dev *rdev, 43static int arizona_ldo1_hc_list_voltage(struct regulator_dev *rdev,
@@ -253,12 +255,17 @@ static int arizona_ldo1_common_init(struct platform_device *pdev,
253 } 255 }
254 } 256 }
255 257
256 /* We assume that high output = regulator off */ 258 /* We assume that high output = regulator off
257 config.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "wlf,ldoena", 259 * Don't use devm, since we need to get against the parent device
258 GPIOD_OUT_HIGH); 260 * so clean up would happen at the wrong time
261 */
262 config.ena_gpiod = gpiod_get_optional(parent_dev, "wlf,ldoena",
263 GPIOD_OUT_LOW);
259 if (IS_ERR(config.ena_gpiod)) 264 if (IS_ERR(config.ena_gpiod))
260 return PTR_ERR(config.ena_gpiod); 265 return PTR_ERR(config.ena_gpiod);
261 266
267 ldo1->ena_gpiod = config.ena_gpiod;
268
262 if (pdata->init_data) 269 if (pdata->init_data)
263 config.init_data = pdata->init_data; 270 config.init_data = pdata->init_data;
264 else 271 else
@@ -276,6 +283,9 @@ static int arizona_ldo1_common_init(struct platform_device *pdev,
276 of_node_put(config.of_node); 283 of_node_put(config.of_node);
277 284
278 if (IS_ERR(ldo1->regulator)) { 285 if (IS_ERR(ldo1->regulator)) {
286 if (config.ena_gpiod)
287 gpiod_put(config.ena_gpiod);
288
279 ret = PTR_ERR(ldo1->regulator); 289 ret = PTR_ERR(ldo1->regulator);
280 dev_err(&pdev->dev, "Failed to register LDO1 supply: %d\n", 290 dev_err(&pdev->dev, "Failed to register LDO1 supply: %d\n",
281 ret); 291 ret);
@@ -334,8 +344,19 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
334 return ret; 344 return ret;
335} 345}
336 346
347static int arizona_ldo1_remove(struct platform_device *pdev)
348{
349 struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev);
350
351 if (ldo1->ena_gpiod)
352 gpiod_put(ldo1->ena_gpiod);
353
354 return 0;
355}
356
337static struct platform_driver arizona_ldo1_driver = { 357static struct platform_driver arizona_ldo1_driver = {
338 .probe = arizona_ldo1_probe, 358 .probe = arizona_ldo1_probe,
359 .remove = arizona_ldo1_remove,
339 .driver = { 360 .driver = {
340 .name = "arizona-ldo1", 361 .name = "arizona-ldo1",
341 }, 362 },