diff options
Diffstat (limited to 'drivers/regulator/s5m8767.c')
-rw-r--r-- | drivers/regulator/s5m8767.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 92f19a005dc3..c79af943a5c0 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -28,7 +28,6 @@ struct s5m8767_info { | |||
28 | struct device *dev; | 28 | struct device *dev; |
29 | struct sec_pmic_dev *iodev; | 29 | struct sec_pmic_dev *iodev; |
30 | int num_regulators; | 30 | int num_regulators; |
31 | struct regulator_dev **rdev; | ||
32 | struct sec_opmode_data *opmode; | 31 | struct sec_opmode_data *opmode; |
33 | 32 | ||
34 | int ramp_delay; | 33 | int ramp_delay; |
@@ -529,16 +528,6 @@ static int s5m8767_pmic_dt_parse_ds_gpio(struct sec_pmic_dev *iodev, | |||
529 | return 0; | 528 | return 0; |
530 | } | 529 | } |
531 | 530 | ||
532 | static void s5m8767_pmic_dt_parse_ext_control_gpio(struct sec_pmic_dev *iodev, | ||
533 | struct sec_regulator_data *rdata, | ||
534 | struct device_node *reg_np) | ||
535 | { | ||
536 | rdata->ext_control_gpio = of_get_named_gpio(reg_np, | ||
537 | "s5m8767,pmic-ext-control-gpios", 0); | ||
538 | if (!gpio_is_valid(rdata->ext_control_gpio)) | ||
539 | rdata->ext_control_gpio = 0; | ||
540 | } | ||
541 | |||
542 | static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | 531 | static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, |
543 | struct sec_platform_data *pdata) | 532 | struct sec_platform_data *pdata) |
544 | { | 533 | { |
@@ -587,7 +576,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
587 | continue; | 576 | continue; |
588 | } | 577 | } |
589 | 578 | ||
590 | s5m8767_pmic_dt_parse_ext_control_gpio(iodev, rdata, reg_np); | 579 | rdata->ext_control_gpio = of_get_named_gpio(reg_np, |
580 | "s5m8767,pmic-ext-control-gpios", 0); | ||
591 | 581 | ||
592 | rdata->id = i; | 582 | rdata->id = i; |
593 | rdata->initdata = of_get_regulator_init_data( | 583 | rdata->initdata = of_get_regulator_init_data( |
@@ -695,7 +685,6 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
695 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 685 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
696 | struct sec_platform_data *pdata = iodev->pdata; | 686 | struct sec_platform_data *pdata = iodev->pdata; |
697 | struct regulator_config config = { }; | 687 | struct regulator_config config = { }; |
698 | struct regulator_dev **rdev; | ||
699 | struct s5m8767_info *s5m8767; | 688 | struct s5m8767_info *s5m8767; |
700 | int i, ret, size, buck_init; | 689 | int i, ret, size, buck_init; |
701 | 690 | ||
@@ -737,11 +726,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
737 | return -ENOMEM; | 726 | return -ENOMEM; |
738 | 727 | ||
739 | size = sizeof(struct regulator_dev *) * (S5M8767_REG_MAX - 2); | 728 | size = sizeof(struct regulator_dev *) * (S5M8767_REG_MAX - 2); |
740 | s5m8767->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); | ||
741 | if (!s5m8767->rdev) | ||
742 | return -ENOMEM; | ||
743 | 729 | ||
744 | rdev = s5m8767->rdev; | ||
745 | s5m8767->dev = &pdev->dev; | 730 | s5m8767->dev = &pdev->dev; |
746 | s5m8767->iodev = iodev; | 731 | s5m8767->iodev = iodev; |
747 | s5m8767->num_regulators = pdata->num_regulators; | 732 | s5m8767->num_regulators = pdata->num_regulators; |
@@ -938,6 +923,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
938 | const struct sec_voltage_desc *desc; | 923 | const struct sec_voltage_desc *desc; |
939 | int id = pdata->regulators[i].id; | 924 | int id = pdata->regulators[i].id; |
940 | int enable_reg, enable_val; | 925 | int enable_reg, enable_val; |
926 | struct regulator_dev *rdev; | ||
941 | 927 | ||
942 | desc = reg_voltage_map[id]; | 928 | desc = reg_voltage_map[id]; |
943 | if (desc) { | 929 | if (desc) { |
@@ -964,26 +950,27 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
964 | config.driver_data = s5m8767; | 950 | config.driver_data = s5m8767; |
965 | config.regmap = iodev->regmap_pmic; | 951 | config.regmap = iodev->regmap_pmic; |
966 | config.of_node = pdata->regulators[i].reg_node; | 952 | config.of_node = pdata->regulators[i].reg_node; |
967 | config.ena_gpio = config.ena_gpio_flags = 0; | 953 | config.ena_gpio = -EINVAL; |
968 | if (pdata->regulators[i].ext_control_gpio) | 954 | config.ena_gpio_flags = 0; |
955 | if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) | ||
969 | s5m8767_regulator_config_ext_control(s5m8767, | 956 | s5m8767_regulator_config_ext_control(s5m8767, |
970 | &pdata->regulators[i], &config); | 957 | &pdata->regulators[i], &config); |
971 | 958 | ||
972 | rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], | 959 | rdev = devm_regulator_register(&pdev->dev, ®ulators[id], |
973 | &config); | 960 | &config); |
974 | if (IS_ERR(rdev[i])) { | 961 | if (IS_ERR(rdev)) { |
975 | ret = PTR_ERR(rdev[i]); | 962 | ret = PTR_ERR(rdev); |
976 | dev_err(s5m8767->dev, "regulator init failed for %d\n", | 963 | dev_err(s5m8767->dev, "regulator init failed for %d\n", |
977 | id); | 964 | id); |
978 | return ret; | 965 | return ret; |
979 | } | 966 | } |
980 | 967 | ||
981 | if (pdata->regulators[i].ext_control_gpio) { | 968 | if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { |
982 | ret = s5m8767_enable_ext_control(s5m8767, rdev[i]); | 969 | ret = s5m8767_enable_ext_control(s5m8767, rdev); |
983 | if (ret < 0) { | 970 | if (ret < 0) { |
984 | dev_err(s5m8767->dev, | 971 | dev_err(s5m8767->dev, |
985 | "failed to enable gpio control over %s: %d\n", | 972 | "failed to enable gpio control over %s: %d\n", |
986 | rdev[i]->desc->name, ret); | 973 | rdev->desc->name, ret); |
987 | return ret; | 974 | return ret; |
988 | } | 975 | } |
989 | } | 976 | } |