diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mfd/arizona-core.c | 41 | ||||
-rw-r--r-- | drivers/regulator/arizona-ldo1.c | 57 | ||||
-rw-r--r-- | drivers/regulator/arizona-micsupp.c | 37 |
3 files changed, 118 insertions, 17 deletions
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 1c3ae57082ed..07e6e27be23c 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c | |||
@@ -508,19 +508,31 @@ int arizona_of_get_type(struct device *dev) | |||
508 | } | 508 | } |
509 | EXPORT_SYMBOL_GPL(arizona_of_get_type); | 509 | EXPORT_SYMBOL_GPL(arizona_of_get_type); |
510 | 510 | ||
511 | int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop, | ||
512 | bool mandatory) | ||
513 | { | ||
514 | int gpio; | ||
515 | |||
516 | gpio = of_get_named_gpio(arizona->dev->of_node, prop, 0); | ||
517 | if (gpio < 0) { | ||
518 | if (mandatory) | ||
519 | dev_err(arizona->dev, | ||
520 | "Mandatory DT gpio %s missing/malformed: %d\n", | ||
521 | prop, gpio); | ||
522 | |||
523 | gpio = 0; | ||
524 | } | ||
525 | |||
526 | return gpio; | ||
527 | } | ||
528 | EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio); | ||
529 | |||
511 | static int arizona_of_get_core_pdata(struct arizona *arizona) | 530 | static int arizona_of_get_core_pdata(struct arizona *arizona) |
512 | { | 531 | { |
532 | struct arizona_pdata *pdata = &arizona->pdata; | ||
513 | int ret, i; | 533 | int ret, i; |
514 | 534 | ||
515 | arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node, | 535 | pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true); |
516 | "wlf,reset", 0); | ||
517 | if (arizona->pdata.reset < 0) | ||
518 | arizona->pdata.reset = 0; | ||
519 | |||
520 | arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node, | ||
521 | "wlf,ldoena", 0); | ||
522 | if (arizona->pdata.ldoena < 0) | ||
523 | arizona->pdata.ldoena = 0; | ||
524 | 536 | ||
525 | ret = of_property_read_u32_array(arizona->dev->of_node, | 537 | ret = of_property_read_u32_array(arizona->dev->of_node, |
526 | "wlf,gpio-defaults", | 538 | "wlf,gpio-defaults", |
@@ -652,6 +664,9 @@ int arizona_dev_init(struct arizona *arizona) | |||
652 | return -EINVAL; | 664 | return -EINVAL; |
653 | } | 665 | } |
654 | 666 | ||
667 | /* Mark DCVDD as external, LDO1 driver will clear if internal */ | ||
668 | arizona->external_dcvdd = true; | ||
669 | |||
655 | ret = mfd_add_devices(arizona->dev, -1, early_devs, | 670 | ret = mfd_add_devices(arizona->dev, -1, early_devs, |
656 | ARRAY_SIZE(early_devs), NULL, 0, NULL); | 671 | ARRAY_SIZE(early_devs), NULL, 0, NULL); |
657 | if (ret != 0) { | 672 | if (ret != 0) { |
@@ -851,14 +866,6 @@ int arizona_dev_init(struct arizona *arizona) | |||
851 | arizona->pdata.gpio_defaults[i]); | 866 | arizona->pdata.gpio_defaults[i]); |
852 | } | 867 | } |
853 | 868 | ||
854 | /* | ||
855 | * LDO1 can only be used to supply DCVDD so if it has no | ||
856 | * consumers then DCVDD is supplied externally. | ||
857 | */ | ||
858 | if (arizona->pdata.ldo1 && | ||
859 | arizona->pdata.ldo1->num_consumer_supplies == 0) | ||
860 | arizona->external_dcvdd = true; | ||
861 | |||
862 | pm_runtime_set_autosuspend_delay(arizona->dev, 100); | 869 | pm_runtime_set_autosuspend_delay(arizona->dev, 100); |
863 | pm_runtime_use_autosuspend(arizona->dev); | 870 | pm_runtime_use_autosuspend(arizona->dev); |
864 | 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..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,6 +179,42 @@ static const struct regulator_init_data arizona_ldo1_default = { | |||
178 | .num_consumer_supplies = 1, | 179 | .num_consumer_supplies = 1, |
179 | }; | 180 | }; |
180 | 181 | ||
182 | static int arizona_ldo1_of_get_pdata(struct arizona *arizona, | ||
183 | struct regulator_config *config) | ||
184 | { | ||
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; | ||
189 | |||
190 | pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true); | ||
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 | |||
215 | return 0; | ||
216 | } | ||
217 | |||
181 | static int arizona_ldo1_probe(struct platform_device *pdev) | 218 | static int arizona_ldo1_probe(struct platform_device *pdev) |
182 | { | 219 | { |
183 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); | 220 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); |
@@ -186,6 +223,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
186 | struct arizona_ldo1 *ldo1; | 223 | struct arizona_ldo1 *ldo1; |
187 | int ret; | 224 | int ret; |
188 | 225 | ||
226 | arizona->external_dcvdd = false; | ||
227 | |||
189 | ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL); | 228 | ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL); |
190 | if (!ldo1) | 229 | if (!ldo1) |
191 | return -ENOMEM; | 230 | return -ENOMEM; |
@@ -216,6 +255,15 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
216 | config.dev = arizona->dev; | 255 | config.dev = arizona->dev; |
217 | config.driver_data = ldo1; | 256 | config.driver_data = ldo1; |
218 | config.regmap = arizona->regmap; | 257 | config.regmap = arizona->regmap; |
258 | |||
259 | if (IS_ENABLED(CONFIG_OF)) { | ||
260 | if (!dev_get_platdata(arizona->dev)) { | ||
261 | ret = arizona_ldo1_of_get_pdata(arizona, &config); | ||
262 | if (ret < 0) | ||
263 | return ret; | ||
264 | } | ||
265 | } | ||
266 | |||
219 | config.ena_gpio = arizona->pdata.ldoena; | 267 | config.ena_gpio = arizona->pdata.ldoena; |
220 | 268 | ||
221 | if (arizona->pdata.ldo1) | 269 | if (arizona->pdata.ldo1) |
@@ -223,6 +271,13 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
223 | else | 271 | else |
224 | config.init_data = &ldo1->init_data; | 272 | config.init_data = &ldo1->init_data; |
225 | 273 | ||
274 | /* | ||
275 | * LDO1 can only be used to supply DCVDD so if it has no | ||
276 | * consumers then DCVDD is supplied externally. | ||
277 | */ | ||
278 | if (config.init_data->num_consumer_supplies == 0) | ||
279 | arizona->external_dcvdd = true; | ||
280 | |||
226 | ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); | 281 | ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); |
227 | if (IS_ERR(ldo1->regulator)) { | 282 | if (IS_ERR(ldo1->regulator)) { |
228 | ret = PTR_ERR(ldo1->regulator); | 283 | ret = PTR_ERR(ldo1->regulator); |
@@ -231,6 +286,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
231 | return ret; | 286 | return ret; |
232 | } | 287 | } |
233 | 288 | ||
289 | of_node_put(config.of_node); | ||
290 | |||
234 | platform_set_drvdata(pdev, ldo1); | 291 | platform_set_drvdata(pdev, ldo1); |
235 | 292 | ||
236 | return 0; | 293 | return 0; |
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index 6fdd9bf6927f..b80ebbe88bac 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.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 | #include <linux/workqueue.h> | 25 | #include <linux/workqueue.h> |
@@ -195,6 +196,32 @@ static const struct regulator_init_data arizona_micsupp_ext_default = { | |||
195 | .num_consumer_supplies = 1, | 196 | .num_consumer_supplies = 1, |
196 | }; | 197 | }; |
197 | 198 | ||
199 | static int arizona_micsupp_of_get_pdata(struct arizona *arizona, | ||
200 | struct regulator_config *config) | ||
201 | { | ||
202 | struct arizona_pdata *pdata = &arizona->pdata; | ||
203 | struct arizona_micsupp *micsupp = config->driver_data; | ||
204 | struct device_node *np; | ||
205 | struct regulator_init_data *init_data; | ||
206 | |||
207 | np = of_get_child_by_name(arizona->dev->of_node, "micvdd"); | ||
208 | |||
209 | if (np) { | ||
210 | config->of_node = np; | ||
211 | |||
212 | init_data = of_get_regulator_init_data(arizona->dev, np); | ||
213 | |||
214 | if (init_data) { | ||
215 | init_data->consumer_supplies = &micsupp->supply; | ||
216 | init_data->num_consumer_supplies = 1; | ||
217 | |||
218 | pdata->micvdd = init_data; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | return 0; | ||
223 | } | ||
224 | |||
198 | static int arizona_micsupp_probe(struct platform_device *pdev) | 225 | static int arizona_micsupp_probe(struct platform_device *pdev) |
199 | { | 226 | { |
200 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); | 227 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); |
@@ -234,6 +261,14 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
234 | config.driver_data = micsupp; | 261 | config.driver_data = micsupp; |
235 | config.regmap = arizona->regmap; | 262 | config.regmap = arizona->regmap; |
236 | 263 | ||
264 | if (IS_ENABLED(CONFIG_OF)) { | ||
265 | if (!dev_get_platdata(arizona->dev)) { | ||
266 | ret = arizona_micsupp_of_get_pdata(arizona, &config); | ||
267 | if (ret < 0) | ||
268 | return ret; | ||
269 | } | ||
270 | } | ||
271 | |||
237 | if (arizona->pdata.micvdd) | 272 | if (arizona->pdata.micvdd) |
238 | config.init_data = arizona->pdata.micvdd; | 273 | config.init_data = arizona->pdata.micvdd; |
239 | else | 274 | else |
@@ -253,6 +288,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
253 | return ret; | 288 | return ret; |
254 | } | 289 | } |
255 | 290 | ||
291 | of_node_put(config.of_node); | ||
292 | |||
256 | platform_set_drvdata(pdev, micsupp); | 293 | platform_set_drvdata(pdev, micsupp); |
257 | 294 | ||
258 | return 0; | 295 | return 0; |