diff options
author | Yadwinder Singh Brar <yadi.brar@samsung.com> | 2013-06-29 08:51:18 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-07-15 13:56:20 -0400 |
commit | 6c683c929977b90795939e1e862271c112e7d10f (patch) | |
tree | 33367d1d0f8ae7ecff74244d338f24d4e871cbb5 /drivers/regulator | |
parent | a50c6b3255b819c9e18c1cc350ed46698b346c1a (diff) |
regulator: s2mps11: Convert driver completely to use set_ramp_delay callback
Since now we have ramp_delay and ramp_disable as standard regulator
constraints and DT part using it so this patch removes legacy part i.e. getting
ramp_delayxx and ramp_enable from pdata since it can be passed as
standard regulator constraints.
Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/s2mps11.c | 62 |
1 files changed, 9 insertions, 53 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index b316d40c8e14..f047d36f6027 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
@@ -36,11 +36,6 @@ struct s2mps11_info { | |||
36 | int ramp_delay16; | 36 | int ramp_delay16; |
37 | int ramp_delay7810; | 37 | int ramp_delay7810; |
38 | int ramp_delay9; | 38 | int ramp_delay9; |
39 | |||
40 | bool buck6_ramp; | ||
41 | bool buck2_ramp; | ||
42 | bool buck3_ramp; | ||
43 | bool buck4_ramp; | ||
44 | }; | 39 | }; |
45 | 40 | ||
46 | static int get_ramp_delay(int ramp_delay) | 41 | static int get_ramp_delay(int ramp_delay) |
@@ -68,26 +63,18 @@ static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev, | |||
68 | 63 | ||
69 | switch (rdev->desc->id) { | 64 | switch (rdev->desc->id) { |
70 | case S2MPS11_BUCK2: | 65 | case S2MPS11_BUCK2: |
71 | if (!s2mps11->buck2_ramp) | ||
72 | return 0; | ||
73 | ramp_delay = s2mps11->ramp_delay2; | 66 | ramp_delay = s2mps11->ramp_delay2; |
74 | break; | 67 | break; |
75 | case S2MPS11_BUCK3: | 68 | case S2MPS11_BUCK3: |
76 | if (!s2mps11->buck3_ramp) | ||
77 | return 0; | ||
78 | ramp_delay = s2mps11->ramp_delay34; | 69 | ramp_delay = s2mps11->ramp_delay34; |
79 | break; | 70 | break; |
80 | case S2MPS11_BUCK4: | 71 | case S2MPS11_BUCK4: |
81 | if (!s2mps11->buck4_ramp) | ||
82 | return 0; | ||
83 | ramp_delay = s2mps11->ramp_delay34; | 72 | ramp_delay = s2mps11->ramp_delay34; |
84 | break; | 73 | break; |
85 | case S2MPS11_BUCK5: | 74 | case S2MPS11_BUCK5: |
86 | ramp_delay = s2mps11->ramp_delay5; | 75 | ramp_delay = s2mps11->ramp_delay5; |
87 | break; | 76 | break; |
88 | case S2MPS11_BUCK6: | 77 | case S2MPS11_BUCK6: |
89 | if (!s2mps11->buck6_ramp) | ||
90 | return 0; | ||
91 | case S2MPS11_BUCK1: | 78 | case S2MPS11_BUCK1: |
92 | ramp_delay = s2mps11->ramp_delay16; | 79 | ramp_delay = s2mps11->ramp_delay16; |
93 | break; | 80 | break; |
@@ -416,15 +403,21 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
416 | struct regulator_config config = { }; | 403 | struct regulator_config config = { }; |
417 | struct s2mps11_info *s2mps11; | 404 | struct s2mps11_info *s2mps11; |
418 | int i, ret; | 405 | int i, ret; |
419 | unsigned char ramp_enable, ramp_reg = 0; | ||
420 | 406 | ||
421 | s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info), | 407 | s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info), |
422 | GFP_KERNEL); | 408 | GFP_KERNEL); |
423 | if (!s2mps11) | 409 | if (!s2mps11) |
424 | return -ENOMEM; | 410 | return -ENOMEM; |
425 | 411 | ||
426 | if (!iodev->dev->of_node) | 412 | if (!iodev->dev->of_node) { |
427 | goto p_data; | 413 | if (pdata) { |
414 | goto common_reg; | ||
415 | } else { | ||
416 | dev_err(pdev->dev.parent, | ||
417 | "Platform data or DT node not supplied\n"); | ||
418 | return -ENODEV; | ||
419 | } | ||
420 | } | ||
428 | 421 | ||
429 | for (i = 0; i < S2MPS11_REGULATOR_CNT; i++) | 422 | for (i = 0; i < S2MPS11_REGULATOR_CNT; i++) |
430 | rdata[i].name = regulators[i].name; | 423 | rdata[i].name = regulators[i].name; |
@@ -437,43 +430,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
437 | 430 | ||
438 | of_regulator_match(&pdev->dev, reg_np, rdata, S2MPS11_REGULATOR_MAX); | 431 | of_regulator_match(&pdev->dev, reg_np, rdata, S2MPS11_REGULATOR_MAX); |
439 | 432 | ||
440 | goto common_reg; | ||
441 | p_data: | ||
442 | if (!pdata) { | ||
443 | dev_err(pdev->dev.parent, "Platform data not supplied\n"); | ||
444 | return -ENODEV; | ||
445 | } | ||
446 | |||
447 | s2mps11->ramp_delay2 = pdata->buck2_ramp_delay; | ||
448 | s2mps11->ramp_delay34 = pdata->buck34_ramp_delay; | ||
449 | s2mps11->ramp_delay5 = pdata->buck5_ramp_delay; | ||
450 | s2mps11->ramp_delay16 = pdata->buck16_ramp_delay; | ||
451 | s2mps11->ramp_delay7810 = pdata->buck7810_ramp_delay; | ||
452 | s2mps11->ramp_delay9 = pdata->buck9_ramp_delay; | ||
453 | |||
454 | s2mps11->buck6_ramp = pdata->buck6_ramp_enable; | ||
455 | s2mps11->buck2_ramp = pdata->buck2_ramp_enable; | ||
456 | s2mps11->buck3_ramp = pdata->buck3_ramp_enable; | ||
457 | s2mps11->buck4_ramp = pdata->buck4_ramp_enable; | ||
458 | |||
459 | ramp_enable = (s2mps11->buck2_ramp << 3) | (s2mps11->buck3_ramp << 2) | | ||
460 | (s2mps11->buck4_ramp << 1) | s2mps11->buck6_ramp ; | ||
461 | |||
462 | if (ramp_enable) { | ||
463 | if (s2mps11->buck2_ramp) | ||
464 | ramp_reg |= get_ramp_delay(s2mps11->ramp_delay2) << 6; | ||
465 | if (s2mps11->buck3_ramp || s2mps11->buck4_ramp) | ||
466 | ramp_reg |= get_ramp_delay(s2mps11->ramp_delay34) << 4; | ||
467 | sec_reg_write(iodev, S2MPS11_REG_RAMP, ramp_reg | ramp_enable); | ||
468 | } | ||
469 | |||
470 | ramp_reg &= 0x00; | ||
471 | ramp_reg |= get_ramp_delay(s2mps11->ramp_delay5) << 6; | ||
472 | ramp_reg |= get_ramp_delay(s2mps11->ramp_delay16) << 4; | ||
473 | ramp_reg |= get_ramp_delay(s2mps11->ramp_delay7810) << 2; | ||
474 | ramp_reg |= get_ramp_delay(s2mps11->ramp_delay9); | ||
475 | sec_reg_write(iodev, S2MPS11_REG_RAMP_BUCK, ramp_reg); | ||
476 | |||
477 | common_reg: | 433 | common_reg: |
478 | platform_set_drvdata(pdev, s2mps11); | 434 | platform_set_drvdata(pdev, s2mps11); |
479 | 435 | ||