aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2014-04-16 05:01:38 -0400
committerMark Brown <broonie@linaro.org>2014-04-18 13:35:03 -0400
commit4a8c475f5fd5c1271dba36a453d666d5ed473aa6 (patch)
treefcbc82d2b185af50f6070323e8142e4127aca125
parent36bcdf1bb6a16d58f8d60549502fd1da6b27a81a (diff)
regulator: arizona-ldo1: Move setup processing from arizona-core
It is more idiomatic to process things relating to the regulator in its driver. This patch moves both processing of device tree relating to the regulator and checking if the regulator is external from arizona-core into the regulator driver. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/mfd/arizona-core.c12
-rw-r--r--drivers/regulator/arizona-ldo1.c27
2 files changed, 30 insertions, 9 deletions
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 37b5e1447d02..07e6e27be23c 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -533,7 +533,6 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
533 int ret, i; 533 int ret, i;
534 534
535 pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true); 535 pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true);
536 pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);
537 536
538 ret = of_property_read_u32_array(arizona->dev->of_node, 537 ret = of_property_read_u32_array(arizona->dev->of_node,
539 "wlf,gpio-defaults", 538 "wlf,gpio-defaults",
@@ -665,6 +664,9 @@ int arizona_dev_init(struct arizona *arizona)
665 return -EINVAL; 664 return -EINVAL;
666 } 665 }
667 666
667 /* Mark DCVDD as external, LDO1 driver will clear if internal */
668 arizona->external_dcvdd = true;
669
668 ret = mfd_add_devices(arizona->dev, -1, early_devs, 670 ret = mfd_add_devices(arizona->dev, -1, early_devs,
669 ARRAY_SIZE(early_devs), NULL, 0, NULL); 671 ARRAY_SIZE(early_devs), NULL, 0, NULL);
670 if (ret != 0) { 672 if (ret != 0) {
@@ -864,14 +866,6 @@ int arizona_dev_init(struct arizona *arizona)
864 arizona->pdata.gpio_defaults[i]); 866 arizona->pdata.gpio_defaults[i]);
865 } 867 }
866 868
867 /*
868 * LDO1 can only be used to supply DCVDD so if it has no
869 * consumers then DCVDD is supplied externally.
870 */
871 if (arizona->pdata.ldo1 &&
872 arizona->pdata.ldo1->num_consumer_supplies == 0)
873 arizona->external_dcvdd = true;
874
875 pm_runtime_set_autosuspend_delay(arizona->dev, 100); 869 pm_runtime_set_autosuspend_delay(arizona->dev, 100);
876 pm_runtime_use_autosuspend(arizona->dev); 870 pm_runtime_use_autosuspend(arizona->dev);
877 pm_runtime_enable(arizona->dev); 871 pm_runtime_enable(arizona->dev);
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index b1033d30b504..2248733ea394 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -178,6 +178,15 @@ static const struct regulator_init_data arizona_ldo1_default = {
178 .num_consumer_supplies = 1, 178 .num_consumer_supplies = 1,
179}; 179};
180 180
181static int arizona_ldo1_of_get_pdata(struct arizona *arizona)
182{
183 struct arizona_pdata *pdata = &arizona->pdata;
184
185 pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);
186
187 return 0;
188}
189
181static int arizona_ldo1_probe(struct platform_device *pdev) 190static int arizona_ldo1_probe(struct platform_device *pdev)
182{ 191{
183 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 192 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
@@ -186,6 +195,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
186 struct arizona_ldo1 *ldo1; 195 struct arizona_ldo1 *ldo1;
187 int ret; 196 int ret;
188 197
198 arizona->external_dcvdd = false;
199
189 ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL); 200 ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
190 if (!ldo1) 201 if (!ldo1)
191 return -ENOMEM; 202 return -ENOMEM;
@@ -216,6 +227,15 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
216 config.dev = arizona->dev; 227 config.dev = arizona->dev;
217 config.driver_data = ldo1; 228 config.driver_data = ldo1;
218 config.regmap = arizona->regmap; 229 config.regmap = arizona->regmap;
230
231 if (IS_ENABLED(CONFIG_OF)) {
232 if (!dev_get_platdata(arizona->dev)) {
233 ret = arizona_ldo1_of_get_pdata(arizona);
234 if (ret < 0)
235 return ret;
236 }
237 }
238
219 config.ena_gpio = arizona->pdata.ldoena; 239 config.ena_gpio = arizona->pdata.ldoena;
220 240
221 if (arizona->pdata.ldo1) 241 if (arizona->pdata.ldo1)
@@ -223,6 +243,13 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
223 else 243 else
224 config.init_data = &ldo1->init_data; 244 config.init_data = &ldo1->init_data;
225 245
246 /*
247 * LDO1 can only be used to supply DCVDD so if it has no
248 * consumers then DCVDD is supplied externally.
249 */
250 if (config.init_data->num_consumer_supplies == 0)
251 arizona->external_dcvdd = true;
252
226 ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); 253 ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
227 if (IS_ERR(ldo1->regulator)) { 254 if (IS_ERR(ldo1->regulator)) {
228 ret = PTR_ERR(ldo1->regulator); 255 ret = PTR_ERR(ldo1->regulator);