Lines Matching full:s5m8767
14 #include <linux/mfd/samsung/s5m8767.h>
162 static int s5m8767_get_register(struct s5m8767_info *s5m8767, int reg_id, in s5m8767_get_register() argument
191 for (i = 0; i < s5m8767->num_regulators; i++) { in s5m8767_get_register()
192 if (s5m8767->opmode[i].id == reg_id) { in s5m8767_get_register()
193 mode = s5m8767->opmode[i].mode; in s5m8767_get_register()
198 if (i >= s5m8767->num_regulators) in s5m8767_get_register()
206 static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) in s5m8767_get_vsel_reg() argument
222 if (s5m8767->buck2_gpiodvs) in s5m8767_get_vsel_reg()
223 reg += s5m8767->buck_gpioindex; in s5m8767_get_vsel_reg()
227 if (s5m8767->buck3_gpiodvs) in s5m8767_get_vsel_reg()
228 reg += s5m8767->buck_gpioindex; in s5m8767_get_vsel_reg()
232 if (s5m8767->buck4_gpiodvs) in s5m8767_get_vsel_reg()
233 reg += s5m8767->buck_gpioindex; in s5m8767_get_vsel_reg()
270 static inline int s5m8767_set_high(struct s5m8767_info *s5m8767) in s5m8767_set_high() argument
272 int temp_index = s5m8767->buck_gpioindex; in s5m8767_set_high()
274 gpio_set_value(s5m8767->buck_gpios[0], (temp_index >> 2) & 0x1); in s5m8767_set_high()
275 gpio_set_value(s5m8767->buck_gpios[1], (temp_index >> 1) & 0x1); in s5m8767_set_high()
276 gpio_set_value(s5m8767->buck_gpios[2], temp_index & 0x1); in s5m8767_set_high()
281 static inline int s5m8767_set_low(struct s5m8767_info *s5m8767) in s5m8767_set_low() argument
283 int temp_index = s5m8767->buck_gpioindex; in s5m8767_set_low()
285 gpio_set_value(s5m8767->buck_gpios[2], temp_index & 0x1); in s5m8767_set_low()
286 gpio_set_value(s5m8767->buck_gpios[1], (temp_index >> 1) & 0x1); in s5m8767_set_low()
287 gpio_set_value(s5m8767->buck_gpios[0], (temp_index >> 2) & 0x1); in s5m8767_set_low()
295 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); in s5m8767_set_voltage_sel() local
304 if (reg_id == S5M8767_BUCK2 && s5m8767->buck2_gpiodvs) in s5m8767_set_voltage_sel()
305 buck234_vol = &s5m8767->buck2_vol[0]; in s5m8767_set_voltage_sel()
306 else if (reg_id == S5M8767_BUCK3 && s5m8767->buck3_gpiodvs) in s5m8767_set_voltage_sel()
307 buck234_vol = &s5m8767->buck3_vol[0]; in s5m8767_set_voltage_sel()
308 else if (reg_id == S5M8767_BUCK4 && s5m8767->buck4_gpiodvs) in s5m8767_set_voltage_sel()
309 buck234_vol = &s5m8767->buck4_vol[0]; in s5m8767_set_voltage_sel()
325 old_index = s5m8767->buck_gpioindex; in s5m8767_set_voltage_sel()
326 s5m8767->buck_gpioindex = index; in s5m8767_set_voltage_sel()
329 return s5m8767_set_high(s5m8767); in s5m8767_set_voltage_sel()
331 return s5m8767_set_low(s5m8767); in s5m8767_set_voltage_sel()
341 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); in s5m8767_set_voltage_time_sel() local
343 if ((old_sel < new_sel) && s5m8767->ramp_delay) in s5m8767_set_voltage_time_sel()
345 s5m8767->ramp_delay * 1000); in s5m8767_set_voltage_time_sel()
427 static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767, in s5m8767_regulator_config_ext_control() argument
437 for (i = 0; i < s5m8767->num_regulators; i++) { in s5m8767_regulator_config_ext_control()
438 const struct sec_opmode_data *opmode = &s5m8767->opmode[i]; in s5m8767_regulator_config_ext_control()
445 dev_warn(s5m8767->dev, in s5m8767_regulator_config_ext_control()
452 dev_warn(s5m8767->dev, in s5m8767_regulator_config_ext_control()
464 static int s5m8767_enable_ext_control(struct s5m8767_info *s5m8767, in s5m8767_enable_ext_control() argument
473 ret = s5m8767_get_register(s5m8767, id, ®, &enable_ctrl); in s5m8767_enable_ext_control()
477 return regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_enable_ext_control()
492 "s5m8767,pmic-buck-dvs-gpios", i); in s5m8767_pmic_dt_parse_dvs_gpio()
510 "s5m8767,pmic-buck-ds-gpios", i); in s5m8767_pmic_dt_parse_ds_gpio()
577 "s5m8767,pmic-ext-control", in s5m8767_pmic_dt_parse_pdata()
579 "s5m8767"); in s5m8767_pmic_dt_parse_pdata()
608 if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) { in s5m8767_pmic_dt_parse_pdata()
612 "s5m8767,pmic-buck2-dvs-voltage", in s5m8767_pmic_dt_parse_pdata()
619 if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) { in s5m8767_pmic_dt_parse_pdata()
623 "s5m8767,pmic-buck3-dvs-voltage", in s5m8767_pmic_dt_parse_pdata()
630 if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) { in s5m8767_pmic_dt_parse_pdata()
634 "s5m8767,pmic-buck4-dvs-voltage", in s5m8767_pmic_dt_parse_pdata()
648 "s5m8767,pmic-buck-default-dvs-idx", in s5m8767_pmic_dt_parse_pdata()
664 if (of_get_property(pmic_np, "s5m8767,pmic-buck2-ramp-enable", NULL)) in s5m8767_pmic_dt_parse_pdata()
667 if (of_get_property(pmic_np, "s5m8767,pmic-buck3-ramp-enable", NULL)) in s5m8767_pmic_dt_parse_pdata()
670 if (of_get_property(pmic_np, "s5m8767,pmic-buck4-ramp-enable", NULL)) in s5m8767_pmic_dt_parse_pdata()
675 if (of_property_read_u32(pmic_np, "s5m8767,pmic-buck-ramp-delay", in s5m8767_pmic_dt_parse_pdata()
695 struct s5m8767_info *s5m8767; in s5m8767_pmic_probe() local
711 dev_err(&pdev->dev, "S5M8767 GPIO DVS NOT VALID\n"); in s5m8767_pmic_probe()
718 dev_err(&pdev->dev, "S5M8767 GPIO DVS NOT VALID\n"); in s5m8767_pmic_probe()
725 dev_err(&pdev->dev, "S5M8767 GPIO DVS NOT VALID\n"); in s5m8767_pmic_probe()
730 s5m8767 = devm_kzalloc(&pdev->dev, sizeof(struct s5m8767_info), in s5m8767_pmic_probe()
732 if (!s5m8767) in s5m8767_pmic_probe()
735 s5m8767->dev = &pdev->dev; in s5m8767_pmic_probe()
736 s5m8767->iodev = iodev; in s5m8767_pmic_probe()
737 s5m8767->num_regulators = pdata->num_regulators; in s5m8767_pmic_probe()
738 platform_set_drvdata(pdev, s5m8767); in s5m8767_pmic_probe()
740 s5m8767->buck_gpioindex = pdata->buck_default_idx; in s5m8767_pmic_probe()
741 s5m8767->buck2_gpiodvs = pdata->buck2_gpiodvs; in s5m8767_pmic_probe()
742 s5m8767->buck3_gpiodvs = pdata->buck3_gpiodvs; in s5m8767_pmic_probe()
743 s5m8767->buck4_gpiodvs = pdata->buck4_gpiodvs; in s5m8767_pmic_probe()
744 s5m8767->buck_gpios[0] = pdata->buck_gpios[0]; in s5m8767_pmic_probe()
745 s5m8767->buck_gpios[1] = pdata->buck_gpios[1]; in s5m8767_pmic_probe()
746 s5m8767->buck_gpios[2] = pdata->buck_gpios[2]; in s5m8767_pmic_probe()
747 s5m8767->buck_ds[0] = pdata->buck_ds[0]; in s5m8767_pmic_probe()
748 s5m8767->buck_ds[1] = pdata->buck_ds[1]; in s5m8767_pmic_probe()
749 s5m8767->buck_ds[2] = pdata->buck_ds[2]; in s5m8767_pmic_probe()
751 s5m8767->ramp_delay = pdata->buck_ramp_delay; in s5m8767_pmic_probe()
752 s5m8767->buck2_ramp = pdata->buck2_ramp_enable; in s5m8767_pmic_probe()
753 s5m8767->buck3_ramp = pdata->buck3_ramp_enable; in s5m8767_pmic_probe()
754 s5m8767->buck4_ramp = pdata->buck4_ramp_enable; in s5m8767_pmic_probe()
755 s5m8767->opmode = pdata->opmode; in s5m8767_pmic_probe()
760 regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK2DVS2, in s5m8767_pmic_probe()
766 regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK3DVS2, in s5m8767_pmic_probe()
772 regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK4DVS2, in s5m8767_pmic_probe()
776 if (s5m8767->buck2_gpiodvs) { in s5m8767_pmic_probe()
777 s5m8767->buck2_vol[i] = in s5m8767_pmic_probe()
783 if (s5m8767->buck3_gpiodvs) { in s5m8767_pmic_probe()
784 s5m8767->buck3_vol[i] = in s5m8767_pmic_probe()
790 if (s5m8767->buck4_gpiodvs) { in s5m8767_pmic_probe()
791 s5m8767->buck4_vol[i] = in s5m8767_pmic_probe()
809 "S5M8767 SET1"); in s5m8767_pmic_probe()
814 "S5M8767 SET2"); in s5m8767_pmic_probe()
819 "S5M8767 SET3"); in s5m8767_pmic_probe()
825 (s5m8767->buck_gpioindex >> 2) & 0x1); in s5m8767_pmic_probe()
828 (s5m8767->buck_gpioindex >> 1) & 0x1); in s5m8767_pmic_probe()
831 (s5m8767->buck_gpioindex >> 0) & 0x1); in s5m8767_pmic_probe()
834 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2"); in s5m8767_pmic_probe()
838 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[1], "S5M8767 DS3"); in s5m8767_pmic_probe()
842 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[2], "S5M8767 DS4"); in s5m8767_pmic_probe()
853 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
856 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
859 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
865 if (s5m8767->buck2_gpiodvs) { in s5m8767_pmic_probe()
866 regmap_write(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
868 s5m8767->buck2_vol[i]); in s5m8767_pmic_probe()
871 if (s5m8767->buck3_gpiodvs) { in s5m8767_pmic_probe()
872 regmap_write(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
874 s5m8767->buck3_vol[i]); in s5m8767_pmic_probe()
877 if (s5m8767->buck4_gpiodvs) { in s5m8767_pmic_probe()
878 regmap_write(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
880 s5m8767->buck4_vol[i]); in s5m8767_pmic_probe()
884 if (s5m8767->buck2_ramp) in s5m8767_pmic_probe()
885 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
888 if (s5m8767->buck3_ramp) in s5m8767_pmic_probe()
889 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
892 if (s5m8767->buck4_ramp) in s5m8767_pmic_probe()
893 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
896 if (s5m8767->buck2_ramp || s5m8767->buck3_ramp in s5m8767_pmic_probe()
897 || s5m8767->buck4_ramp) { in s5m8767_pmic_probe()
899 switch (s5m8767->ramp_delay) { in s5m8767_pmic_probe()
918 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
937 s5m8767_get_vsel_reg(id, s5m8767); in s5m8767_pmic_probe()
943 ret = s5m8767_get_register(s5m8767, id, &enable_reg, in s5m8767_pmic_probe()
946 dev_err(s5m8767->dev, "error reading registers\n"); in s5m8767_pmic_probe()
954 config.dev = s5m8767->dev; in s5m8767_pmic_probe()
956 config.driver_data = s5m8767; in s5m8767_pmic_probe()
962 s5m8767_regulator_config_ext_control(s5m8767, in s5m8767_pmic_probe()
969 devm_gpiod_unhinge(s5m8767->dev, config.ena_gpiod); in s5m8767_pmic_probe()
975 dev_err(s5m8767->dev, "regulator init failed for %d\n", in s5m8767_pmic_probe()
981 ret = s5m8767_enable_ext_control(s5m8767, rdev); in s5m8767_pmic_probe()
983 dev_err(s5m8767->dev, in s5m8767_pmic_probe()
995 { "s5m8767-pmic", 0},
1002 .name = "s5m8767-pmic",
1011 MODULE_DESCRIPTION("Samsung S5M8767 Regulator Driver");