diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2014-11-05 04:47:50 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-11-26 15:39:06 -0500 |
commit | 0480395264fa361fc3feed05b26800debe026f57 (patch) | |
tree | ebdb784f85bd1639ba4927ed618f2fae7eb5667e | |
parent | 75ff9420448e7bb30ab8265463595e794ce0c3aa (diff) |
regulator: max77686: Remove support for board files
The driver is used only on Exynos based boards with DTS support.
Simplify the driver and remove dead (unused) entries in platform_data
structure.
Convert the driver to DTS-only version. Parse all regulators at once,
not one-by-one. Remove dependency on data provided by max77686 MFD
driver. Use new DT style parsing method for regulators init data.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/max77686.c | 91 |
1 files changed, 19 insertions, 72 deletions
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 2063532e0763..871b96bcd2d0 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c | |||
@@ -281,6 +281,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
281 | 281 | ||
282 | #define regulator_desc_ldo(num) { \ | 282 | #define regulator_desc_ldo(num) { \ |
283 | .name = "LDO"#num, \ | 283 | .name = "LDO"#num, \ |
284 | .of_match = of_match_ptr("LDO"#num), \ | ||
285 | .regulators_node = of_match_ptr("voltage-regulators"), \ | ||
284 | .id = MAX77686_LDO##num, \ | 286 | .id = MAX77686_LDO##num, \ |
285 | .ops = &max77686_ops, \ | 287 | .ops = &max77686_ops, \ |
286 | .type = REGULATOR_VOLTAGE, \ | 288 | .type = REGULATOR_VOLTAGE, \ |
@@ -297,6 +299,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
297 | } | 299 | } |
298 | #define regulator_desc_lpm_ldo(num) { \ | 300 | #define regulator_desc_lpm_ldo(num) { \ |
299 | .name = "LDO"#num, \ | 301 | .name = "LDO"#num, \ |
302 | .of_match = of_match_ptr("LDO"#num), \ | ||
303 | .regulators_node = of_match_ptr("voltage-regulators"), \ | ||
300 | .id = MAX77686_LDO##num, \ | 304 | .id = MAX77686_LDO##num, \ |
301 | .ops = &max77686_ldo_ops, \ | 305 | .ops = &max77686_ldo_ops, \ |
302 | .type = REGULATOR_VOLTAGE, \ | 306 | .type = REGULATOR_VOLTAGE, \ |
@@ -313,6 +317,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
313 | } | 317 | } |
314 | #define regulator_desc_ldo_low(num) { \ | 318 | #define regulator_desc_ldo_low(num) { \ |
315 | .name = "LDO"#num, \ | 319 | .name = "LDO"#num, \ |
320 | .of_match = of_match_ptr("LDO"#num), \ | ||
321 | .regulators_node = of_match_ptr("voltage-regulators"), \ | ||
316 | .id = MAX77686_LDO##num, \ | 322 | .id = MAX77686_LDO##num, \ |
317 | .ops = &max77686_ldo_ops, \ | 323 | .ops = &max77686_ldo_ops, \ |
318 | .type = REGULATOR_VOLTAGE, \ | 324 | .type = REGULATOR_VOLTAGE, \ |
@@ -329,6 +335,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
329 | } | 335 | } |
330 | #define regulator_desc_ldo1_low(num) { \ | 336 | #define regulator_desc_ldo1_low(num) { \ |
331 | .name = "LDO"#num, \ | 337 | .name = "LDO"#num, \ |
338 | .of_match = of_match_ptr("LDO"#num), \ | ||
339 | .regulators_node = of_match_ptr("voltage-regulators"), \ | ||
332 | .id = MAX77686_LDO##num, \ | 340 | .id = MAX77686_LDO##num, \ |
333 | .ops = &max77686_ops, \ | 341 | .ops = &max77686_ops, \ |
334 | .type = REGULATOR_VOLTAGE, \ | 342 | .type = REGULATOR_VOLTAGE, \ |
@@ -345,6 +353,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
345 | } | 353 | } |
346 | #define regulator_desc_buck(num) { \ | 354 | #define regulator_desc_buck(num) { \ |
347 | .name = "BUCK"#num, \ | 355 | .name = "BUCK"#num, \ |
356 | .of_match = of_match_ptr("BUCK"#num), \ | ||
357 | .regulators_node = of_match_ptr("voltage-regulators"), \ | ||
348 | .id = MAX77686_BUCK##num, \ | 358 | .id = MAX77686_BUCK##num, \ |
349 | .ops = &max77686_ops, \ | 359 | .ops = &max77686_ops, \ |
350 | .type = REGULATOR_VOLTAGE, \ | 360 | .type = REGULATOR_VOLTAGE, \ |
@@ -360,6 +370,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
360 | } | 370 | } |
361 | #define regulator_desc_buck1(num) { \ | 371 | #define regulator_desc_buck1(num) { \ |
362 | .name = "BUCK"#num, \ | 372 | .name = "BUCK"#num, \ |
373 | .of_match = of_match_ptr("BUCK"#num), \ | ||
374 | .regulators_node = of_match_ptr("voltage-regulators"), \ | ||
363 | .id = MAX77686_BUCK##num, \ | 375 | .id = MAX77686_BUCK##num, \ |
364 | .ops = &max77686_buck1_ops, \ | 376 | .ops = &max77686_buck1_ops, \ |
365 | .type = REGULATOR_VOLTAGE, \ | 377 | .type = REGULATOR_VOLTAGE, \ |
@@ -375,6 +387,8 @@ static struct regulator_ops max77686_buck_dvs_ops = { | |||
375 | } | 387 | } |
376 | #define regulator_desc_buck_dvs(num) { \ | 388 | #define regulator_desc_buck_dvs(num) { \ |
377 | .name = "BUCK"#num, \ | 389 | .name = "BUCK"#num, \ |
390 | .of_match = of_match_ptr("BUCK"#num), \ | ||
391 | .regulators_node = of_match_ptr("voltage-regulators"), \ | ||
378 | .id = MAX77686_BUCK##num, \ | 392 | .id = MAX77686_BUCK##num, \ |
379 | .ops = &max77686_buck_dvs_ops, \ | 393 | .ops = &max77686_buck_dvs_ops, \ |
380 | .type = REGULATOR_VOLTAGE, \ | 394 | .type = REGULATOR_VOLTAGE, \ |
@@ -428,86 +442,21 @@ static const struct regulator_desc regulators[] = { | |||
428 | regulator_desc_buck(9), | 442 | regulator_desc_buck(9), |
429 | }; | 443 | }; |
430 | 444 | ||
431 | #ifdef CONFIG_OF | ||
432 | static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev, | ||
433 | struct max77686_platform_data *pdata) | ||
434 | { | ||
435 | struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); | ||
436 | struct device_node *pmic_np, *regulators_np; | ||
437 | struct max77686_regulator_data *rdata; | ||
438 | struct of_regulator_match rmatch = { }; | ||
439 | unsigned int i; | ||
440 | |||
441 | pmic_np = iodev->dev->of_node; | ||
442 | regulators_np = of_get_child_by_name(pmic_np, "voltage-regulators"); | ||
443 | if (!regulators_np) { | ||
444 | dev_err(&pdev->dev, "could not find regulators sub-node\n"); | ||
445 | return -EINVAL; | ||
446 | } | ||
447 | |||
448 | pdata->num_regulators = ARRAY_SIZE(regulators); | ||
449 | rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * | ||
450 | pdata->num_regulators, GFP_KERNEL); | ||
451 | if (!rdata) { | ||
452 | of_node_put(regulators_np); | ||
453 | return -ENOMEM; | ||
454 | } | ||
455 | |||
456 | for (i = 0; i < pdata->num_regulators; i++) { | ||
457 | rmatch.name = regulators[i].name; | ||
458 | rmatch.init_data = NULL; | ||
459 | rmatch.of_node = NULL; | ||
460 | of_regulator_match(&pdev->dev, regulators_np, &rmatch, 1); | ||
461 | rdata[i].initdata = rmatch.init_data; | ||
462 | rdata[i].of_node = rmatch.of_node; | ||
463 | } | ||
464 | |||
465 | pdata->regulators = rdata; | ||
466 | of_node_put(regulators_np); | ||
467 | |||
468 | return 0; | ||
469 | } | ||
470 | #else | ||
471 | static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev, | ||
472 | struct max77686_platform_data *pdata) | ||
473 | { | ||
474 | return 0; | ||
475 | } | ||
476 | #endif /* CONFIG_OF */ | ||
477 | |||
478 | static int max77686_pmic_probe(struct platform_device *pdev) | 445 | static int max77686_pmic_probe(struct platform_device *pdev) |
479 | { | 446 | { |
480 | struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 447 | struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
481 | struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev); | ||
482 | struct max77686_data *max77686; | 448 | struct max77686_data *max77686; |
483 | int i, ret = 0; | 449 | int i; |
484 | struct regulator_config config = { }; | 450 | struct regulator_config config = { }; |
485 | 451 | ||
486 | dev_dbg(&pdev->dev, "%s\n", __func__); | 452 | dev_dbg(&pdev->dev, "%s\n", __func__); |
487 | 453 | ||
488 | if (!pdata) { | ||
489 | dev_err(&pdev->dev, "no platform data found for regulator\n"); | ||
490 | return -ENODEV; | ||
491 | } | ||
492 | |||
493 | if (iodev->dev->of_node) { | ||
494 | ret = max77686_pmic_dt_parse_pdata(pdev, pdata); | ||
495 | if (ret) | ||
496 | return ret; | ||
497 | } | ||
498 | |||
499 | if (pdata->num_regulators != MAX77686_REGULATORS) { | ||
500 | dev_err(&pdev->dev, | ||
501 | "Invalid initial data for regulator's initialiation\n"); | ||
502 | return -EINVAL; | ||
503 | } | ||
504 | |||
505 | max77686 = devm_kzalloc(&pdev->dev, sizeof(struct max77686_data), | 454 | max77686 = devm_kzalloc(&pdev->dev, sizeof(struct max77686_data), |
506 | GFP_KERNEL); | 455 | GFP_KERNEL); |
507 | if (!max77686) | 456 | if (!max77686) |
508 | return -ENOMEM; | 457 | return -ENOMEM; |
509 | 458 | ||
510 | config.dev = &pdev->dev; | 459 | config.dev = iodev->dev; |
511 | config.regmap = iodev->regmap; | 460 | config.regmap = iodev->regmap; |
512 | config.driver_data = max77686; | 461 | config.driver_data = max77686; |
513 | platform_set_drvdata(pdev, max77686); | 462 | platform_set_drvdata(pdev, max77686); |
@@ -516,16 +465,14 @@ static int max77686_pmic_probe(struct platform_device *pdev) | |||
516 | struct regulator_dev *rdev; | 465 | struct regulator_dev *rdev; |
517 | int id = regulators[i].id; | 466 | int id = regulators[i].id; |
518 | 467 | ||
519 | config.init_data = pdata->regulators[i].initdata; | ||
520 | config.of_node = pdata->regulators[i].of_node; | ||
521 | |||
522 | max77686->opmode[id] = MAX77686_NORMAL; | 468 | max77686->opmode[id] = MAX77686_NORMAL; |
523 | rdev = devm_regulator_register(&pdev->dev, | 469 | rdev = devm_regulator_register(&pdev->dev, |
524 | ®ulators[i], &config); | 470 | ®ulators[i], &config); |
525 | if (IS_ERR(rdev)) { | 471 | if (IS_ERR(rdev)) { |
472 | int ret = PTR_ERR(rdev); | ||
526 | dev_err(&pdev->dev, | 473 | dev_err(&pdev->dev, |
527 | "regulator init failed for %d\n", i); | 474 | "regulator init failed for %d: %d\n", i, ret); |
528 | return PTR_ERR(rdev); | 475 | return ret; |
529 | } | 476 | } |
530 | } | 477 | } |
531 | 478 | ||