diff options
author | Keerthy <j-keerthy@ti.com> | 2014-06-18 05:58:59 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-06-23 07:30:56 -0400 |
commit | cac9e916245390d7b0b770b8577af4918f74d0ee (patch) | |
tree | 78e15719a519fb778a0870fa644ac5255d867d65 /drivers/regulator | |
parent | fe40b173441e4519347395825d15d2c5386494c8 (diff) |
regulator: palmas: add driver data and modularize the probe
add driver data and modularize the probe.
Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 658 |
1 files changed, 392 insertions, 266 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 1cf462f90df5..aa8e5516752e 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -41,7 +41,7 @@ static const struct regulator_linear_range smps_high_ranges[] = { | |||
41 | REGULATOR_LINEAR_RANGE(3300000, 0x7A, 0x7f, 0), | 41 | REGULATOR_LINEAR_RANGE(3300000, 0x7A, 0x7f, 0), |
42 | }; | 42 | }; |
43 | 43 | ||
44 | static const struct regs_info palmas_regs_info[] = { | 44 | static struct regs_info palmas_regs_info[] = { |
45 | { | 45 | { |
46 | .name = "SMPS12", | 46 | .name = "SMPS12", |
47 | .sname = "smps1-in", | 47 | .sname = "smps1-in", |
@@ -227,6 +227,42 @@ static const struct regs_info palmas_regs_info[] = { | |||
227 | }, | 227 | }, |
228 | }; | 228 | }; |
229 | 229 | ||
230 | #define EXTERNAL_REQUESTOR(_id, _offset, _pos) \ | ||
231 | [PALMAS_EXTERNAL_REQSTR_ID_##_id] = { \ | ||
232 | .id = PALMAS_EXTERNAL_REQSTR_ID_##_id, \ | ||
233 | .reg_offset = _offset, \ | ||
234 | .bit_pos = _pos, \ | ||
235 | } | ||
236 | |||
237 | struct palmas_sleep_requestor_info palma_sleep_req_info[] = { | ||
238 | EXTERNAL_REQUESTOR(REGEN1, 0, 0), | ||
239 | EXTERNAL_REQUESTOR(REGEN2, 0, 1), | ||
240 | EXTERNAL_REQUESTOR(SYSEN1, 0, 2), | ||
241 | EXTERNAL_REQUESTOR(SYSEN2, 0, 3), | ||
242 | EXTERNAL_REQUESTOR(CLK32KG, 0, 4), | ||
243 | EXTERNAL_REQUESTOR(CLK32KGAUDIO, 0, 5), | ||
244 | EXTERNAL_REQUESTOR(REGEN3, 0, 6), | ||
245 | EXTERNAL_REQUESTOR(SMPS12, 1, 0), | ||
246 | EXTERNAL_REQUESTOR(SMPS3, 1, 1), | ||
247 | EXTERNAL_REQUESTOR(SMPS45, 1, 2), | ||
248 | EXTERNAL_REQUESTOR(SMPS6, 1, 3), | ||
249 | EXTERNAL_REQUESTOR(SMPS7, 1, 4), | ||
250 | EXTERNAL_REQUESTOR(SMPS8, 1, 5), | ||
251 | EXTERNAL_REQUESTOR(SMPS9, 1, 6), | ||
252 | EXTERNAL_REQUESTOR(SMPS10, 1, 7), | ||
253 | EXTERNAL_REQUESTOR(LDO1, 2, 0), | ||
254 | EXTERNAL_REQUESTOR(LDO2, 2, 1), | ||
255 | EXTERNAL_REQUESTOR(LDO3, 2, 2), | ||
256 | EXTERNAL_REQUESTOR(LDO4, 2, 3), | ||
257 | EXTERNAL_REQUESTOR(LDO5, 2, 4), | ||
258 | EXTERNAL_REQUESTOR(LDO6, 2, 5), | ||
259 | EXTERNAL_REQUESTOR(LDO7, 2, 6), | ||
260 | EXTERNAL_REQUESTOR(LDO8, 2, 7), | ||
261 | EXTERNAL_REQUESTOR(LDO9, 3, 0), | ||
262 | EXTERNAL_REQUESTOR(LDOLN, 3, 1), | ||
263 | EXTERNAL_REQUESTOR(LDOUSB, 3, 2), | ||
264 | }; | ||
265 | |||
230 | static unsigned int palmas_smps_ramp_delay[4] = {0, 10000, 5000, 2500}; | 266 | static unsigned int palmas_smps_ramp_delay[4] = {0, 10000, 5000, 2500}; |
231 | 267 | ||
232 | #define SMPS_CTRL_MODE_OFF 0x00 | 268 | #define SMPS_CTRL_MODE_OFF 0x00 |
@@ -288,11 +324,14 @@ static int palmas_ldo_write(struct palmas *palmas, unsigned int reg, | |||
288 | static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) | 324 | static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) |
289 | { | 325 | { |
290 | struct palmas_pmic *pmic = rdev_get_drvdata(dev); | 326 | struct palmas_pmic *pmic = rdev_get_drvdata(dev); |
327 | struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata; | ||
291 | int id = rdev_get_id(dev); | 328 | int id = rdev_get_id(dev); |
292 | unsigned int reg; | 329 | unsigned int reg; |
293 | bool rail_enable = true; | 330 | bool rail_enable = true; |
294 | 331 | ||
295 | palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); | 332 | palmas_smps_read(pmic->palmas, ddata->palmas_regs_info[id].ctrl_addr, |
333 | ®); | ||
334 | |||
296 | reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; | 335 | reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; |
297 | 336 | ||
298 | if (reg == SMPS_CTRL_MODE_OFF) | 337 | if (reg == SMPS_CTRL_MODE_OFF) |
@@ -315,7 +354,7 @@ static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) | |||
315 | pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; | 354 | pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; |
316 | if (rail_enable) | 355 | if (rail_enable) |
317 | palmas_smps_write(pmic->palmas, | 356 | palmas_smps_write(pmic->palmas, |
318 | palmas_regs_info[id].ctrl_addr, reg); | 357 | ddata->palmas_regs_info[id].ctrl_addr, reg); |
319 | return 0; | 358 | return 0; |
320 | } | 359 | } |
321 | 360 | ||
@@ -343,9 +382,10 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev, | |||
343 | int ramp_delay) | 382 | int ramp_delay) |
344 | { | 383 | { |
345 | struct palmas_pmic *pmic = rdev_get_drvdata(rdev); | 384 | struct palmas_pmic *pmic = rdev_get_drvdata(rdev); |
385 | struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata; | ||
346 | int id = rdev_get_id(rdev); | 386 | int id = rdev_get_id(rdev); |
347 | unsigned int reg = 0; | 387 | unsigned int reg = 0; |
348 | unsigned int addr = palmas_regs_info[id].tstep_addr; | 388 | unsigned int addr = ddata->palmas_regs_info[id].tstep_addr; |
349 | int ret; | 389 | int ret; |
350 | 390 | ||
351 | /* SMPS3 and SMPS7 do not have tstep_addr setting */ | 391 | /* SMPS3 and SMPS7 do not have tstep_addr setting */ |
@@ -414,10 +454,12 @@ static struct regulator_ops palmas_ops_smps10 = { | |||
414 | static int palmas_is_enabled_ldo(struct regulator_dev *dev) | 454 | static int palmas_is_enabled_ldo(struct regulator_dev *dev) |
415 | { | 455 | { |
416 | struct palmas_pmic *pmic = rdev_get_drvdata(dev); | 456 | struct palmas_pmic *pmic = rdev_get_drvdata(dev); |
457 | struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata; | ||
417 | int id = rdev_get_id(dev); | 458 | int id = rdev_get_id(dev); |
418 | unsigned int reg; | 459 | unsigned int reg; |
419 | 460 | ||
420 | palmas_ldo_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); | 461 | palmas_ldo_read(pmic->palmas, |
462 | ddata->palmas_regs_info[id].ctrl_addr, ®); | ||
421 | 463 | ||
422 | reg &= PALMAS_LDO1_CTRL_STATUS; | 464 | reg &= PALMAS_LDO1_CTRL_STATUS; |
423 | 465 | ||
@@ -478,7 +520,9 @@ static int palmas_smps_init(struct palmas *palmas, int id, | |||
478 | unsigned int addr; | 520 | unsigned int addr; |
479 | int ret; | 521 | int ret; |
480 | 522 | ||
481 | addr = palmas_regs_info[id].ctrl_addr; | 523 | struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata; |
524 | |||
525 | addr = ddata->palmas_regs_info[id].ctrl_addr; | ||
482 | 526 | ||
483 | ret = palmas_smps_read(palmas, addr, ®); | 527 | ret = palmas_smps_read(palmas, addr, ®); |
484 | if (ret) | 528 | if (ret) |
@@ -513,8 +557,8 @@ static int palmas_smps_init(struct palmas *palmas, int id, | |||
513 | if (ret) | 557 | if (ret) |
514 | return ret; | 558 | return ret; |
515 | 559 | ||
516 | if (palmas_regs_info[id].vsel_addr && reg_init->vsel) { | 560 | if (ddata->palmas_regs_info[id].vsel_addr && reg_init->vsel) { |
517 | addr = palmas_regs_info[id].vsel_addr; | 561 | addr = ddata->palmas_regs_info[id].vsel_addr; |
518 | 562 | ||
519 | reg = reg_init->vsel; | 563 | reg = reg_init->vsel; |
520 | 564 | ||
@@ -526,7 +570,7 @@ static int palmas_smps_init(struct palmas *palmas, int id, | |||
526 | if (reg_init->roof_floor && (id != PALMAS_REG_SMPS10_OUT1) && | 570 | if (reg_init->roof_floor && (id != PALMAS_REG_SMPS10_OUT1) && |
527 | (id != PALMAS_REG_SMPS10_OUT2)) { | 571 | (id != PALMAS_REG_SMPS10_OUT2)) { |
528 | /* Enable externally controlled regulator */ | 572 | /* Enable externally controlled regulator */ |
529 | addr = palmas_regs_info[id].ctrl_addr; | 573 | addr = ddata->palmas_regs_info[id].ctrl_addr; |
530 | ret = palmas_smps_read(palmas, addr, ®); | 574 | ret = palmas_smps_read(palmas, addr, ®); |
531 | if (ret < 0) | 575 | if (ret < 0) |
532 | return ret; | 576 | return ret; |
@@ -549,7 +593,9 @@ static int palmas_ldo_init(struct palmas *palmas, int id, | |||
549 | unsigned int addr; | 593 | unsigned int addr; |
550 | int ret; | 594 | int ret; |
551 | 595 | ||
552 | addr = palmas_regs_info[id].ctrl_addr; | 596 | struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata; |
597 | |||
598 | addr = ddata->palmas_regs_info[id].ctrl_addr; | ||
553 | 599 | ||
554 | ret = palmas_ldo_read(palmas, addr, ®); | 600 | ret = palmas_ldo_read(palmas, addr, ®); |
555 | if (ret) | 601 | if (ret) |
@@ -571,7 +617,7 @@ static int palmas_ldo_init(struct palmas *palmas, int id, | |||
571 | 617 | ||
572 | if (reg_init->roof_floor) { | 618 | if (reg_init->roof_floor) { |
573 | /* Enable externally controlled regulator */ | 619 | /* Enable externally controlled regulator */ |
574 | addr = palmas_regs_info[id].ctrl_addr; | 620 | addr = ddata->palmas_regs_info[id].ctrl_addr; |
575 | ret = palmas_update_bits(palmas, PALMAS_LDO_BASE, | 621 | ret = palmas_update_bits(palmas, PALMAS_LDO_BASE, |
576 | addr, PALMAS_LDO1_CTRL_MODE_ACTIVE, | 622 | addr, PALMAS_LDO1_CTRL_MODE_ACTIVE, |
577 | PALMAS_LDO1_CTRL_MODE_ACTIVE); | 623 | PALMAS_LDO1_CTRL_MODE_ACTIVE); |
@@ -593,7 +639,9 @@ static int palmas_extreg_init(struct palmas *palmas, int id, | |||
593 | int ret; | 639 | int ret; |
594 | unsigned int val = 0; | 640 | unsigned int val = 0; |
595 | 641 | ||
596 | addr = palmas_regs_info[id].ctrl_addr; | 642 | struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata; |
643 | |||
644 | addr = ddata->palmas_regs_info[id].ctrl_addr; | ||
597 | 645 | ||
598 | if (reg_init->mode_sleep) | 646 | if (reg_init->mode_sleep) |
599 | val = PALMAS_REGEN1_CTRL_MODE_SLEEP; | 647 | val = PALMAS_REGEN1_CTRL_MODE_SLEEP; |
@@ -608,7 +656,7 @@ static int palmas_extreg_init(struct palmas *palmas, int id, | |||
608 | 656 | ||
609 | if (reg_init->roof_floor) { | 657 | if (reg_init->roof_floor) { |
610 | /* Enable externally controlled regulator */ | 658 | /* Enable externally controlled regulator */ |
611 | addr = palmas_regs_info[id].ctrl_addr; | 659 | addr = ddata->palmas_regs_info[id].ctrl_addr; |
612 | ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, | 660 | ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, |
613 | addr, PALMAS_REGEN1_CTRL_MODE_ACTIVE, | 661 | addr, PALMAS_REGEN1_CTRL_MODE_ACTIVE, |
614 | PALMAS_REGEN1_CTRL_MODE_ACTIVE); | 662 | PALMAS_REGEN1_CTRL_MODE_ACTIVE); |
@@ -629,7 +677,9 @@ static void palmas_enable_ldo8_track(struct palmas *palmas) | |||
629 | unsigned int addr; | 677 | unsigned int addr; |
630 | int ret; | 678 | int ret; |
631 | 679 | ||
632 | addr = palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr; | 680 | struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata; |
681 | |||
682 | addr = ddata->palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr; | ||
633 | 683 | ||
634 | ret = palmas_ldo_read(palmas, addr, ®); | 684 | ret = palmas_ldo_read(palmas, addr, ®); |
635 | if (ret) { | 685 | if (ret) { |
@@ -648,7 +698,7 @@ static void palmas_enable_ldo8_track(struct palmas *palmas) | |||
648 | * output is defined by the LDO8_VOLTAGE.VSEL register divided by two, | 698 | * output is defined by the LDO8_VOLTAGE.VSEL register divided by two, |
649 | * and can be set from 0.45 to 1.65 V. | 699 | * and can be set from 0.45 to 1.65 V. |
650 | */ | 700 | */ |
651 | addr = palmas_regs_info[PALMAS_REG_LDO8].vsel_addr; | 701 | addr = ddata->palmas_regs_info[PALMAS_REG_LDO8].vsel_addr; |
652 | ret = palmas_ldo_read(palmas, addr, ®); | 702 | ret = palmas_ldo_read(palmas, addr, ®); |
653 | if (ret) { | 703 | if (ret) { |
654 | dev_err(palmas->dev, "Error in reading ldo8 voltage reg\n"); | 704 | dev_err(palmas->dev, "Error in reading ldo8 voltage reg\n"); |
@@ -663,169 +713,131 @@ static void palmas_enable_ldo8_track(struct palmas *palmas) | |||
663 | return; | 713 | return; |
664 | } | 714 | } |
665 | 715 | ||
666 | static struct of_regulator_match palmas_matches[] = { | 716 | static int palmas_ldo_registration(struct palmas_pmic *pmic, |
667 | { .name = "smps12", }, | 717 | struct palmas_pmic_driver_data *ddata, |
668 | { .name = "smps123", }, | 718 | struct palmas_pmic_platform_data *pdata, |
669 | { .name = "smps3", }, | 719 | const char *pdev_name, |
670 | { .name = "smps45", }, | 720 | struct regulator_config config) |
671 | { .name = "smps457", }, | ||
672 | { .name = "smps6", }, | ||
673 | { .name = "smps7", }, | ||
674 | { .name = "smps8", }, | ||
675 | { .name = "smps9", }, | ||
676 | { .name = "smps10_out2", }, | ||
677 | { .name = "smps10_out1", }, | ||
678 | { .name = "ldo1", }, | ||
679 | { .name = "ldo2", }, | ||
680 | { .name = "ldo3", }, | ||
681 | { .name = "ldo4", }, | ||
682 | { .name = "ldo5", }, | ||
683 | { .name = "ldo6", }, | ||
684 | { .name = "ldo7", }, | ||
685 | { .name = "ldo8", }, | ||
686 | { .name = "ldo9", }, | ||
687 | { .name = "ldoln", }, | ||
688 | { .name = "ldousb", }, | ||
689 | { .name = "regen1", }, | ||
690 | { .name = "regen2", }, | ||
691 | { .name = "regen3", }, | ||
692 | { .name = "sysen1", }, | ||
693 | { .name = "sysen2", }, | ||
694 | }; | ||
695 | |||
696 | static void palmas_dt_to_pdata(struct device *dev, | ||
697 | struct device_node *node, | ||
698 | struct palmas_pmic_platform_data *pdata) | ||
699 | { | 721 | { |
700 | struct device_node *regulators; | 722 | int id, ret; |
701 | u32 prop; | 723 | struct regulator_dev *rdev; |
702 | int idx, ret; | 724 | struct palmas_reg_init *reg_init; |
703 | 725 | ||
704 | node = of_node_get(node); | 726 | for (id = ddata->ldo_begin; id < ddata->max_reg; id++) { |
705 | regulators = of_get_child_by_name(node, "regulators"); | 727 | if (pdata && pdata->reg_init[id]) |
706 | if (!regulators) { | 728 | reg_init = pdata->reg_init[id]; |
707 | dev_info(dev, "regulator node not found\n"); | 729 | else |
708 | return; | 730 | reg_init = NULL; |
709 | } | ||
710 | 731 | ||
711 | ret = of_regulator_match(dev, regulators, palmas_matches, | 732 | /* Miss out regulators which are not available due |
712 | PALMAS_NUM_REGS); | 733 | * to alternate functions. |
713 | of_node_put(regulators); | 734 | */ |
714 | if (ret < 0) { | ||
715 | dev_err(dev, "Error parsing regulator init data: %d\n", ret); | ||
716 | return; | ||
717 | } | ||
718 | 735 | ||
719 | for (idx = 0; idx < PALMAS_NUM_REGS; idx++) { | 736 | /* Register the regulators */ |
720 | if (!palmas_matches[idx].init_data || | 737 | pmic->desc[id].name = ddata->palmas_regs_info[id].name; |
721 | !palmas_matches[idx].of_node) | 738 | pmic->desc[id].id = id; |
722 | continue; | 739 | pmic->desc[id].type = REGULATOR_VOLTAGE; |
740 | pmic->desc[id].owner = THIS_MODULE; | ||
723 | 741 | ||
724 | pdata->reg_data[idx] = palmas_matches[idx].init_data; | 742 | if (id < PALMAS_REG_REGEN1) { |
743 | pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; | ||
744 | if (reg_init && reg_init->roof_floor) | ||
745 | pmic->desc[id].ops = | ||
746 | &palmas_ops_ext_control_ldo; | ||
747 | else | ||
748 | pmic->desc[id].ops = &palmas_ops_ldo; | ||
749 | pmic->desc[id].min_uV = 900000; | ||
750 | pmic->desc[id].uV_step = 50000; | ||
751 | pmic->desc[id].linear_min_sel = 1; | ||
752 | pmic->desc[id].enable_time = 500; | ||
753 | pmic->desc[id].vsel_reg = | ||
754 | PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, | ||
755 | ddata->palmas_regs_info[id].vsel_addr); | ||
756 | pmic->desc[id].vsel_mask = | ||
757 | PALMAS_LDO1_VOLTAGE_VSEL_MASK; | ||
758 | pmic->desc[id].enable_reg = | ||
759 | PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, | ||
760 | ddata->palmas_regs_info[id].ctrl_addr); | ||
761 | pmic->desc[id].enable_mask = | ||
762 | PALMAS_LDO1_CTRL_MODE_ACTIVE; | ||
725 | 763 | ||
726 | pdata->reg_init[idx] = devm_kzalloc(dev, | 764 | /* Check if LDO8 is in tracking mode or not */ |
727 | sizeof(struct palmas_reg_init), GFP_KERNEL); | 765 | if (pdata && (id == PALMAS_REG_LDO8) && |
766 | pdata->enable_ldo8_tracking) { | ||
767 | palmas_enable_ldo8_track(pmic->palmas); | ||
768 | pmic->desc[id].min_uV = 450000; | ||
769 | pmic->desc[id].uV_step = 25000; | ||
770 | } | ||
728 | 771 | ||
729 | pdata->reg_init[idx]->warm_reset = | 772 | /* LOD6 in vibrator mode will have enable time 2000us */ |
730 | of_property_read_bool(palmas_matches[idx].of_node, | 773 | if (pdata && pdata->ldo6_vibrator && |
731 | "ti,warm-reset"); | 774 | (id == PALMAS_REG_LDO6)) |
775 | pmic->desc[id].enable_time = 2000; | ||
776 | } else { | ||
777 | pmic->desc[id].n_voltages = 1; | ||
778 | if (reg_init && reg_init->roof_floor) | ||
779 | pmic->desc[id].ops = | ||
780 | &palmas_ops_ext_control_extreg; | ||
781 | else | ||
782 | pmic->desc[id].ops = &palmas_ops_extreg; | ||
783 | pmic->desc[id].enable_reg = | ||
784 | PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, | ||
785 | ddata->palmas_regs_info[id].ctrl_addr); | ||
786 | pmic->desc[id].enable_mask = | ||
787 | PALMAS_REGEN1_CTRL_MODE_ACTIVE; | ||
788 | } | ||
732 | 789 | ||
733 | ret = of_property_read_u32(palmas_matches[idx].of_node, | 790 | if (pdata) |
734 | "ti,roof-floor", &prop); | 791 | config.init_data = pdata->reg_data[id]; |
735 | /* EINVAL: Property not found */ | 792 | else |
736 | if (ret != -EINVAL) { | 793 | config.init_data = NULL; |
737 | int econtrol; | ||
738 | 794 | ||
739 | /* use default value, when no value is specified */ | 795 | pmic->desc[id].supply_name = ddata->palmas_regs_info[id].sname; |
740 | econtrol = PALMAS_EXT_CONTROL_NSLEEP; | 796 | config.of_node = ddata->palmas_matches[id].of_node; |
741 | if (!ret) { | ||
742 | switch (prop) { | ||
743 | case 1: | ||
744 | econtrol = PALMAS_EXT_CONTROL_ENABLE1; | ||
745 | break; | ||
746 | case 2: | ||
747 | econtrol = PALMAS_EXT_CONTROL_ENABLE2; | ||
748 | break; | ||
749 | case 3: | ||
750 | econtrol = PALMAS_EXT_CONTROL_NSLEEP; | ||
751 | break; | ||
752 | default: | ||
753 | WARN_ON(1); | ||
754 | dev_warn(dev, | ||
755 | "%s: Invalid roof-floor option: %u\n", | ||
756 | palmas_matches[idx].name, prop); | ||
757 | break; | ||
758 | } | ||
759 | } | ||
760 | pdata->reg_init[idx]->roof_floor = econtrol; | ||
761 | } | ||
762 | 797 | ||
763 | ret = of_property_read_u32(palmas_matches[idx].of_node, | 798 | rdev = devm_regulator_register(pmic->dev, &pmic->desc[id], |
764 | "ti,mode-sleep", &prop); | 799 | &config); |
765 | if (!ret) | 800 | if (IS_ERR(rdev)) { |
766 | pdata->reg_init[idx]->mode_sleep = prop; | 801 | dev_err(pmic->dev, |
802 | "failed to register %s regulator\n", | ||
803 | pdev_name); | ||
804 | return PTR_ERR(rdev); | ||
805 | } | ||
767 | 806 | ||
768 | ret = of_property_read_bool(palmas_matches[idx].of_node, | 807 | /* Save regulator for cleanup */ |
769 | "ti,smps-range"); | 808 | pmic->rdev[id] = rdev; |
770 | if (ret) | ||
771 | pdata->reg_init[idx]->vsel = | ||
772 | PALMAS_SMPS12_VOLTAGE_RANGE; | ||
773 | 809 | ||
774 | if (idx == PALMAS_REG_LDO8) | 810 | /* Initialise sleep/init values from platform data */ |
775 | pdata->enable_ldo8_tracking = of_property_read_bool( | 811 | if (pdata) { |
776 | palmas_matches[idx].of_node, | 812 | reg_init = pdata->reg_init[id]; |
777 | "ti,enable-ldo8-tracking"); | 813 | if (reg_init) { |
814 | if (id <= ddata->ldo_end) | ||
815 | ret = palmas_ldo_init(pmic->palmas, id, | ||
816 | reg_init); | ||
817 | else | ||
818 | ret = palmas_extreg_init(pmic->palmas, | ||
819 | id, reg_init); | ||
820 | if (ret) | ||
821 | return ret; | ||
822 | } | ||
823 | } | ||
778 | } | 824 | } |
779 | 825 | ||
780 | pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator"); | 826 | return 0; |
781 | } | 827 | } |
782 | 828 | ||
783 | 829 | static int palmas_smps_registration(struct palmas_pmic *pmic, | |
784 | static int palmas_regulators_probe(struct platform_device *pdev) | 830 | struct palmas_pmic_driver_data *ddata, |
831 | struct palmas_pmic_platform_data *pdata, | ||
832 | const char *pdev_name, | ||
833 | struct regulator_config config) | ||
785 | { | 834 | { |
786 | struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); | 835 | int id, ret; |
787 | struct palmas_pmic_platform_data *pdata = dev_get_platdata(&pdev->dev); | 836 | unsigned int addr, reg; |
788 | struct device_node *node = pdev->dev.of_node; | ||
789 | struct regulator_dev *rdev; | 837 | struct regulator_dev *rdev; |
790 | struct regulator_config config = { }; | ||
791 | struct palmas_pmic *pmic; | ||
792 | struct palmas_reg_init *reg_init; | 838 | struct palmas_reg_init *reg_init; |
793 | int id = 0, ret; | ||
794 | unsigned int addr, reg; | ||
795 | |||
796 | if (node && !pdata) { | ||
797 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
798 | |||
799 | if (!pdata) | ||
800 | return -ENOMEM; | ||
801 | |||
802 | palmas_dt_to_pdata(&pdev->dev, node, pdata); | ||
803 | } | ||
804 | |||
805 | pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); | ||
806 | if (!pmic) | ||
807 | return -ENOMEM; | ||
808 | |||
809 | pmic->dev = &pdev->dev; | ||
810 | pmic->palmas = palmas; | ||
811 | palmas->pmic = pmic; | ||
812 | platform_set_drvdata(pdev, pmic); | ||
813 | |||
814 | ret = palmas_smps_read(palmas, PALMAS_SMPS_CTRL, ®); | ||
815 | if (ret) | ||
816 | return ret; | ||
817 | |||
818 | if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN) | ||
819 | pmic->smps123 = 1; | ||
820 | |||
821 | if (reg & PALMAS_SMPS_CTRL_SMPS45_SMPS457_EN) | ||
822 | pmic->smps457 = 1; | ||
823 | 839 | ||
824 | config.regmap = palmas->regmap[REGULATOR_SLAVE]; | 840 | for (id = ddata->smps_start; id <= ddata->smps_end; id++) { |
825 | config.dev = &pdev->dev; | ||
826 | config.driver_data = pmic; | ||
827 | |||
828 | for (id = 0; id < PALMAS_REG_LDO1; id++) { | ||
829 | bool ramp_delay_support = false; | 841 | bool ramp_delay_support = false; |
830 | 842 | ||
831 | /* | 843 | /* |
@@ -859,7 +871,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
859 | break; | 871 | break; |
860 | case PALMAS_REG_SMPS10_OUT1: | 872 | case PALMAS_REG_SMPS10_OUT1: |
861 | case PALMAS_REG_SMPS10_OUT2: | 873 | case PALMAS_REG_SMPS10_OUT2: |
862 | if (!PALMAS_PMIC_HAS(palmas, SMPS10_BOOST)) | 874 | if (!PALMAS_PMIC_HAS(pmic->palmas, SMPS10_BOOST)) |
863 | continue; | 875 | continue; |
864 | } | 876 | } |
865 | 877 | ||
@@ -867,10 +879,10 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
867 | ramp_delay_support = true; | 879 | ramp_delay_support = true; |
868 | 880 | ||
869 | if (ramp_delay_support) { | 881 | if (ramp_delay_support) { |
870 | addr = palmas_regs_info[id].tstep_addr; | 882 | addr = ddata->palmas_regs_info[id].tstep_addr; |
871 | ret = palmas_smps_read(pmic->palmas, addr, ®); | 883 | ret = palmas_smps_read(pmic->palmas, addr, ®); |
872 | if (ret < 0) { | 884 | if (ret < 0) { |
873 | dev_err(&pdev->dev, | 885 | dev_err(pmic->dev, |
874 | "reading TSTEP reg failed: %d\n", ret); | 886 | "reading TSTEP reg failed: %d\n", ret); |
875 | return ret; | 887 | return ret; |
876 | } | 888 | } |
@@ -882,7 +894,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
882 | /* Initialise sleep/init values from platform data */ | 894 | /* Initialise sleep/init values from platform data */ |
883 | if (pdata && pdata->reg_init[id]) { | 895 | if (pdata && pdata->reg_init[id]) { |
884 | reg_init = pdata->reg_init[id]; | 896 | reg_init = pdata->reg_init[id]; |
885 | ret = palmas_smps_init(palmas, id, reg_init); | 897 | ret = palmas_smps_init(pmic->palmas, id, reg_init); |
886 | if (ret) | 898 | if (ret) |
887 | return ret; | 899 | return ret; |
888 | } else { | 900 | } else { |
@@ -890,7 +902,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
890 | } | 902 | } |
891 | 903 | ||
892 | /* Register the regulators */ | 904 | /* Register the regulators */ |
893 | pmic->desc[id].name = palmas_regs_info[id].name; | 905 | pmic->desc[id].name = ddata->palmas_regs_info[id].name; |
894 | pmic->desc[id].id = id; | 906 | pmic->desc[id].id = id; |
895 | 907 | ||
896 | switch (id) { | 908 | switch (id) { |
@@ -965,15 +977,15 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
965 | else | 977 | else |
966 | config.init_data = NULL; | 978 | config.init_data = NULL; |
967 | 979 | ||
968 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; | 980 | pmic->desc[id].supply_name = ddata->palmas_regs_info[id].sname; |
969 | config.of_node = palmas_matches[id].of_node; | 981 | config.of_node = ddata->palmas_matches[id].of_node; |
970 | 982 | ||
971 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], | 983 | rdev = devm_regulator_register(pmic->dev, &pmic->desc[id], |
972 | &config); | 984 | &config); |
973 | if (IS_ERR(rdev)) { | 985 | if (IS_ERR(rdev)) { |
974 | dev_err(&pdev->dev, | 986 | dev_err(pmic->dev, |
975 | "failed to register %s regulator\n", | 987 | "failed to register %s regulator\n", |
976 | pdev->name); | 988 | pdev_name); |
977 | return PTR_ERR(rdev); | 989 | return PTR_ERR(rdev); |
978 | } | 990 | } |
979 | 991 | ||
@@ -981,123 +993,237 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
981 | pmic->rdev[id] = rdev; | 993 | pmic->rdev[id] = rdev; |
982 | } | 994 | } |
983 | 995 | ||
984 | /* Start this loop from the id left from previous loop */ | 996 | return 0; |
985 | for (; id < PALMAS_NUM_REGS; id++) { | 997 | } |
986 | if (pdata && pdata->reg_init[id]) | ||
987 | reg_init = pdata->reg_init[id]; | ||
988 | else | ||
989 | reg_init = NULL; | ||
990 | 998 | ||
991 | /* Miss out regulators which are not available due | 999 | static struct of_regulator_match palmas_matches[] = { |
992 | * to alternate functions. | 1000 | { .name = "smps12", }, |
993 | */ | 1001 | { .name = "smps123", }, |
1002 | { .name = "smps3", }, | ||
1003 | { .name = "smps45", }, | ||
1004 | { .name = "smps457", }, | ||
1005 | { .name = "smps6", }, | ||
1006 | { .name = "smps7", }, | ||
1007 | { .name = "smps8", }, | ||
1008 | { .name = "smps9", }, | ||
1009 | { .name = "smps10_out2", }, | ||
1010 | { .name = "smps10_out1", }, | ||
1011 | { .name = "ldo1", }, | ||
1012 | { .name = "ldo2", }, | ||
1013 | { .name = "ldo3", }, | ||
1014 | { .name = "ldo4", }, | ||
1015 | { .name = "ldo5", }, | ||
1016 | { .name = "ldo6", }, | ||
1017 | { .name = "ldo7", }, | ||
1018 | { .name = "ldo8", }, | ||
1019 | { .name = "ldo9", }, | ||
1020 | { .name = "ldoln", }, | ||
1021 | { .name = "ldousb", }, | ||
1022 | { .name = "regen1", }, | ||
1023 | { .name = "regen2", }, | ||
1024 | { .name = "regen3", }, | ||
1025 | { .name = "sysen1", }, | ||
1026 | { .name = "sysen2", }, | ||
1027 | }; | ||
994 | 1028 | ||
995 | /* Register the regulators */ | 1029 | struct palmas_pmic_driver_data palmas_ddata = { |
996 | pmic->desc[id].name = palmas_regs_info[id].name; | 1030 | .smps_start = PALMAS_REG_SMPS12, |
997 | pmic->desc[id].id = id; | 1031 | .smps_end = PALMAS_REG_SMPS10_OUT1, |
998 | pmic->desc[id].type = REGULATOR_VOLTAGE; | 1032 | .ldo_begin = PALMAS_REG_LDO1, |
999 | pmic->desc[id].owner = THIS_MODULE; | 1033 | .ldo_end = PALMAS_REG_LDOUSB, |
1034 | .max_reg = PALMAS_NUM_REGS, | ||
1035 | .palmas_regs_info = palmas_regs_info, | ||
1036 | .palmas_matches = palmas_matches, | ||
1037 | .sleep_req_info = palma_sleep_req_info, | ||
1038 | .smps_register = palmas_smps_registration, | ||
1039 | .ldo_register = palmas_ldo_registration, | ||
1040 | }; | ||
1000 | 1041 | ||
1001 | if (id < PALMAS_REG_REGEN1) { | 1042 | static void palmas_dt_to_pdata(struct device *dev, |
1002 | pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; | 1043 | struct device_node *node, |
1003 | if (reg_init && reg_init->roof_floor) | 1044 | struct palmas_pmic_platform_data *pdata, |
1004 | pmic->desc[id].ops = | 1045 | struct palmas_pmic_driver_data *ddata) |
1005 | &palmas_ops_ext_control_ldo; | 1046 | { |
1006 | else | 1047 | struct device_node *regulators; |
1007 | pmic->desc[id].ops = &palmas_ops_ldo; | 1048 | u32 prop; |
1008 | pmic->desc[id].min_uV = 900000; | 1049 | int idx, ret; |
1009 | pmic->desc[id].uV_step = 50000; | ||
1010 | pmic->desc[id].linear_min_sel = 1; | ||
1011 | pmic->desc[id].enable_time = 500; | ||
1012 | pmic->desc[id].vsel_reg = | ||
1013 | PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, | ||
1014 | palmas_regs_info[id].vsel_addr); | ||
1015 | pmic->desc[id].vsel_mask = | ||
1016 | PALMAS_LDO1_VOLTAGE_VSEL_MASK; | ||
1017 | pmic->desc[id].enable_reg = | ||
1018 | PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, | ||
1019 | palmas_regs_info[id].ctrl_addr); | ||
1020 | pmic->desc[id].enable_mask = | ||
1021 | PALMAS_LDO1_CTRL_MODE_ACTIVE; | ||
1022 | 1050 | ||
1023 | /* Check if LDO8 is in tracking mode or not */ | 1051 | node = of_node_get(node); |
1024 | if (pdata && (id == PALMAS_REG_LDO8) && | 1052 | regulators = of_get_child_by_name(node, "regulators"); |
1025 | pdata->enable_ldo8_tracking) { | 1053 | if (!regulators) { |
1026 | palmas_enable_ldo8_track(palmas); | 1054 | dev_info(dev, "regulator node not found\n"); |
1027 | pmic->desc[id].min_uV = 450000; | 1055 | return; |
1028 | pmic->desc[id].uV_step = 25000; | 1056 | } |
1029 | } | ||
1030 | 1057 | ||
1031 | /* LOD6 in vibrator mode will have enable time 2000us */ | 1058 | ret = of_regulator_match(dev, regulators, ddata->palmas_matches, |
1032 | if (pdata && pdata->ldo6_vibrator && | 1059 | ddata->max_reg); |
1033 | (id == PALMAS_REG_LDO6)) | 1060 | of_node_put(regulators); |
1034 | pmic->desc[id].enable_time = 2000; | 1061 | if (ret < 0) { |
1035 | } else { | 1062 | dev_err(dev, "Error parsing regulator init data: %d\n", ret); |
1036 | pmic->desc[id].n_voltages = 1; | 1063 | return; |
1037 | if (reg_init && reg_init->roof_floor) | 1064 | } |
1038 | pmic->desc[id].ops = | ||
1039 | &palmas_ops_ext_control_extreg; | ||
1040 | else | ||
1041 | pmic->desc[id].ops = &palmas_ops_extreg; | ||
1042 | pmic->desc[id].enable_reg = | ||
1043 | PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, | ||
1044 | palmas_regs_info[id].ctrl_addr); | ||
1045 | pmic->desc[id].enable_mask = | ||
1046 | PALMAS_REGEN1_CTRL_MODE_ACTIVE; | ||
1047 | } | ||
1048 | 1065 | ||
1049 | if (pdata) | 1066 | for (idx = 0; idx < ddata->max_reg; idx++) { |
1050 | config.init_data = pdata->reg_data[id]; | 1067 | if (!ddata->palmas_matches[idx].init_data || |
1051 | else | 1068 | !ddata->palmas_matches[idx].of_node) |
1052 | config.init_data = NULL; | 1069 | continue; |
1053 | 1070 | ||
1054 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; | 1071 | pdata->reg_data[idx] = ddata->palmas_matches[idx].init_data; |
1055 | config.of_node = palmas_matches[id].of_node; | ||
1056 | 1072 | ||
1057 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], | 1073 | pdata->reg_init[idx] = devm_kzalloc(dev, |
1058 | &config); | 1074 | sizeof(struct palmas_reg_init), GFP_KERNEL); |
1059 | if (IS_ERR(rdev)) { | ||
1060 | dev_err(&pdev->dev, | ||
1061 | "failed to register %s regulator\n", | ||
1062 | pdev->name); | ||
1063 | return PTR_ERR(rdev); | ||
1064 | } | ||
1065 | 1075 | ||
1066 | /* Save regulator for cleanup */ | 1076 | pdata->reg_init[idx]->warm_reset = |
1067 | pmic->rdev[id] = rdev; | 1077 | of_property_read_bool(ddata->palmas_matches[idx].of_node, |
1078 | "ti,warm-reset"); | ||
1068 | 1079 | ||
1069 | /* Initialise sleep/init values from platform data */ | 1080 | ret = of_property_read_u32(ddata->palmas_matches[idx].of_node, |
1070 | if (pdata) { | 1081 | "ti,roof-floor", &prop); |
1071 | reg_init = pdata->reg_init[id]; | 1082 | /* EINVAL: Property not found */ |
1072 | if (reg_init) { | 1083 | if (ret != -EINVAL) { |
1073 | if (id < PALMAS_REG_REGEN1) | 1084 | int econtrol; |
1074 | ret = palmas_ldo_init(palmas, | 1085 | |
1075 | id, reg_init); | 1086 | /* use default value, when no value is specified */ |
1076 | else | 1087 | econtrol = PALMAS_EXT_CONTROL_NSLEEP; |
1077 | ret = palmas_extreg_init(palmas, | 1088 | if (!ret) { |
1078 | id, reg_init); | 1089 | switch (prop) { |
1079 | if (ret) | 1090 | case 1: |
1080 | return ret; | 1091 | econtrol = PALMAS_EXT_CONTROL_ENABLE1; |
1092 | break; | ||
1093 | case 2: | ||
1094 | econtrol = PALMAS_EXT_CONTROL_ENABLE2; | ||
1095 | break; | ||
1096 | case 3: | ||
1097 | econtrol = PALMAS_EXT_CONTROL_NSLEEP; | ||
1098 | break; | ||
1099 | default: | ||
1100 | WARN_ON(1); | ||
1101 | dev_warn(dev, | ||
1102 | "%s: Invalid roof-floor option: %u\n", | ||
1103 | palmas_matches[idx].name, prop); | ||
1104 | break; | ||
1105 | } | ||
1081 | } | 1106 | } |
1107 | pdata->reg_init[idx]->roof_floor = econtrol; | ||
1082 | } | 1108 | } |
1083 | } | ||
1084 | 1109 | ||
1110 | ret = of_property_read_u32(ddata->palmas_matches[idx].of_node, | ||
1111 | "ti,mode-sleep", &prop); | ||
1112 | if (!ret) | ||
1113 | pdata->reg_init[idx]->mode_sleep = prop; | ||
1085 | 1114 | ||
1086 | return 0; | 1115 | ret = of_property_read_bool(ddata->palmas_matches[idx].of_node, |
1116 | "ti,smps-range"); | ||
1117 | if (ret) | ||
1118 | pdata->reg_init[idx]->vsel = | ||
1119 | PALMAS_SMPS12_VOLTAGE_RANGE; | ||
1120 | |||
1121 | if (idx == PALMAS_REG_LDO8) | ||
1122 | pdata->enable_ldo8_tracking = of_property_read_bool( | ||
1123 | ddata->palmas_matches[idx].of_node, | ||
1124 | "ti,enable-ldo8-tracking"); | ||
1125 | } | ||
1126 | |||
1127 | pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator"); | ||
1087 | } | 1128 | } |
1088 | 1129 | ||
1089 | static const struct of_device_id of_palmas_match_tbl[] = { | 1130 | static struct of_device_id of_palmas_match_tbl[] = { |
1090 | { .compatible = "ti,palmas-pmic", }, | 1131 | { |
1091 | { .compatible = "ti,twl6035-pmic", }, | 1132 | .compatible = "ti,palmas-pmic", |
1092 | { .compatible = "ti,twl6036-pmic", }, | 1133 | .data = &palmas_ddata, |
1093 | { .compatible = "ti,twl6037-pmic", }, | 1134 | }, |
1094 | { .compatible = "ti,tps65913-pmic", }, | 1135 | { |
1095 | { .compatible = "ti,tps65914-pmic", }, | 1136 | .compatible = "ti,twl6035-pmic", |
1096 | { .compatible = "ti,tps80036-pmic", }, | 1137 | .data = &palmas_ddata, |
1097 | { .compatible = "ti,tps659038-pmic", }, | 1138 | }, |
1139 | { | ||
1140 | .compatible = "ti,twl6036-pmic", | ||
1141 | .data = &palmas_ddata, | ||
1142 | }, | ||
1143 | { | ||
1144 | .compatible = "ti,twl6037-pmic", | ||
1145 | .data = &palmas_ddata, | ||
1146 | }, | ||
1147 | { | ||
1148 | .compatible = "ti,tps65913-pmic", | ||
1149 | .data = &palmas_ddata, | ||
1150 | }, | ||
1151 | { | ||
1152 | .compatible = "ti,tps65914-pmic", | ||
1153 | .data = &palmas_ddata, | ||
1154 | }, | ||
1155 | { | ||
1156 | .compatible = "ti,tps80036-pmic", | ||
1157 | .data = &palmas_ddata, | ||
1158 | }, | ||
1159 | { | ||
1160 | .compatible = "ti,tps659038-pmic", | ||
1161 | .data = &palmas_ddata, | ||
1162 | }, | ||
1098 | { /* end */ } | 1163 | { /* end */ } |
1099 | }; | 1164 | }; |
1100 | 1165 | ||
1166 | static int palmas_regulators_probe(struct platform_device *pdev) | ||
1167 | { | ||
1168 | struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); | ||
1169 | struct palmas_pmic_platform_data *pdata = dev_get_platdata(&pdev->dev); | ||
1170 | struct device_node *node = pdev->dev.of_node; | ||
1171 | struct palmas_pmic_driver_data *driver_data; | ||
1172 | struct regulator_config config = { }; | ||
1173 | struct palmas_pmic *pmic; | ||
1174 | const char *pdev_name; | ||
1175 | const struct of_device_id *match; | ||
1176 | int ret = 0; | ||
1177 | unsigned int reg; | ||
1178 | |||
1179 | match = of_match_device(of_match_ptr(of_palmas_match_tbl), &pdev->dev); | ||
1180 | |||
1181 | if (!match) | ||
1182 | return -ENODATA; | ||
1183 | |||
1184 | driver_data = (struct palmas_pmic_driver_data *)match->data; | ||
1185 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
1186 | if (!pdata) | ||
1187 | return -ENOMEM; | ||
1188 | |||
1189 | pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); | ||
1190 | if (!pmic) | ||
1191 | return -ENOMEM; | ||
1192 | |||
1193 | pmic->dev = &pdev->dev; | ||
1194 | pmic->palmas = palmas; | ||
1195 | palmas->pmic = pmic; | ||
1196 | platform_set_drvdata(pdev, pmic); | ||
1197 | pmic->palmas->pmic_ddata = driver_data; | ||
1198 | |||
1199 | palmas_dt_to_pdata(&pdev->dev, node, pdata, driver_data); | ||
1200 | |||
1201 | ret = palmas_smps_read(palmas, PALMAS_SMPS_CTRL, ®); | ||
1202 | if (ret) | ||
1203 | return ret; | ||
1204 | |||
1205 | if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN) | ||
1206 | pmic->smps123 = 1; | ||
1207 | |||
1208 | if (reg & PALMAS_SMPS_CTRL_SMPS45_SMPS457_EN) | ||
1209 | pmic->smps457 = 1; | ||
1210 | |||
1211 | config.regmap = palmas->regmap[REGULATOR_SLAVE]; | ||
1212 | config.dev = &pdev->dev; | ||
1213 | config.driver_data = pmic; | ||
1214 | pdev_name = pdev->name; | ||
1215 | |||
1216 | ret = driver_data->smps_register(pmic, driver_data, pdata, pdev_name, | ||
1217 | config); | ||
1218 | if (ret) | ||
1219 | return ret; | ||
1220 | |||
1221 | ret = driver_data->ldo_register(pmic, driver_data, pdata, pdev_name, | ||
1222 | config); | ||
1223 | |||
1224 | return ret; | ||
1225 | } | ||
1226 | |||
1101 | static struct platform_driver palmas_driver = { | 1227 | static struct platform_driver palmas_driver = { |
1102 | .driver = { | 1228 | .driver = { |
1103 | .name = "palmas-pmic", | 1229 | .name = "palmas-pmic", |