Lines Matching full:s5m8767

15 #include <linux/mfd/samsung/s5m8767.h>
163 static int s5m8767_get_register(struct s5m8767_info *s5m8767, int reg_id, in s5m8767_get_register() argument
192 for (i = 0; i < s5m8767->num_regulators; i++) { in s5m8767_get_register()
193 if (s5m8767->opmode[i].id == reg_id) { in s5m8767_get_register()
194 mode = s5m8767->opmode[i].mode; in s5m8767_get_register()
199 if (i >= s5m8767->num_regulators) in s5m8767_get_register()
207 static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) in s5m8767_get_vsel_reg() argument
223 if (s5m8767->buck2_gpiodvs) in s5m8767_get_vsel_reg()
224 reg += s5m8767->buck_gpioindex; in s5m8767_get_vsel_reg()
228 if (s5m8767->buck3_gpiodvs) in s5m8767_get_vsel_reg()
229 reg += s5m8767->buck_gpioindex; in s5m8767_get_vsel_reg()
233 if (s5m8767->buck4_gpiodvs) in s5m8767_get_vsel_reg()
234 reg += s5m8767->buck_gpioindex; in s5m8767_get_vsel_reg()
271 static inline int s5m8767_set_high(struct s5m8767_info *s5m8767) in s5m8767_set_high() argument
273 int temp_index = s5m8767->buck_gpioindex; in s5m8767_set_high()
275 gpio_set_value(s5m8767->buck_gpios[0], (temp_index >> 2) & 0x1); in s5m8767_set_high()
276 gpio_set_value(s5m8767->buck_gpios[1], (temp_index >> 1) & 0x1); in s5m8767_set_high()
277 gpio_set_value(s5m8767->buck_gpios[2], temp_index & 0x1); in s5m8767_set_high()
282 static inline int s5m8767_set_low(struct s5m8767_info *s5m8767) in s5m8767_set_low() argument
284 int temp_index = s5m8767->buck_gpioindex; in s5m8767_set_low()
286 gpio_set_value(s5m8767->buck_gpios[2], temp_index & 0x1); in s5m8767_set_low()
287 gpio_set_value(s5m8767->buck_gpios[1], (temp_index >> 1) & 0x1); in s5m8767_set_low()
288 gpio_set_value(s5m8767->buck_gpios[0], (temp_index >> 2) & 0x1); in s5m8767_set_low()
296 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); in s5m8767_set_voltage_sel() local
305 if (reg_id == S5M8767_BUCK2 && s5m8767->buck2_gpiodvs) in s5m8767_set_voltage_sel()
306 buck234_vol = &s5m8767->buck2_vol[0]; in s5m8767_set_voltage_sel()
307 else if (reg_id == S5M8767_BUCK3 && s5m8767->buck3_gpiodvs) in s5m8767_set_voltage_sel()
308 buck234_vol = &s5m8767->buck3_vol[0]; in s5m8767_set_voltage_sel()
309 else if (reg_id == S5M8767_BUCK4 && s5m8767->buck4_gpiodvs) in s5m8767_set_voltage_sel()
310 buck234_vol = &s5m8767->buck4_vol[0]; in s5m8767_set_voltage_sel()
326 old_index = s5m8767->buck_gpioindex; in s5m8767_set_voltage_sel()
327 s5m8767->buck_gpioindex = index; in s5m8767_set_voltage_sel()
330 return s5m8767_set_high(s5m8767); in s5m8767_set_voltage_sel()
332 return s5m8767_set_low(s5m8767); in s5m8767_set_voltage_sel()
342 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); in s5m8767_set_voltage_time_sel() local
344 if ((old_sel < new_sel) && s5m8767->ramp_delay) in s5m8767_set_voltage_time_sel()
346 s5m8767->ramp_delay * 1000); in s5m8767_set_voltage_time_sel()
428 static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767, in s5m8767_regulator_config_ext_control() argument
438 for (i = 0; i < s5m8767->num_regulators; i++) { in s5m8767_regulator_config_ext_control()
439 const struct sec_opmode_data *opmode = &s5m8767->opmode[i]; in s5m8767_regulator_config_ext_control()
446 dev_warn(s5m8767->dev, in s5m8767_regulator_config_ext_control()
453 dev_warn(s5m8767->dev, in s5m8767_regulator_config_ext_control()
465 static int s5m8767_enable_ext_control(struct s5m8767_info *s5m8767, in s5m8767_enable_ext_control() argument
474 ret = s5m8767_get_register(s5m8767, id, &reg, &enable_ctrl); in s5m8767_enable_ext_control()
478 return regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_enable_ext_control()
493 "s5m8767,pmic-buck-dvs-gpios", i); in s5m8767_pmic_dt_parse_dvs_gpio()
511 "s5m8767,pmic-buck-ds-gpios", i); in s5m8767_pmic_dt_parse_ds_gpio()
575 "s5m8767,pmic-ext-control", in s5m8767_pmic_dt_parse_pdata()
577 "s5m8767"); in s5m8767_pmic_dt_parse_pdata()
603 if (of_property_read_bool(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs")) { in s5m8767_pmic_dt_parse_pdata()
607 "s5m8767,pmic-buck2-dvs-voltage", in s5m8767_pmic_dt_parse_pdata()
614 if (of_property_read_bool(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs")) { in s5m8767_pmic_dt_parse_pdata()
618 "s5m8767,pmic-buck3-dvs-voltage", in s5m8767_pmic_dt_parse_pdata()
625 if (of_property_read_bool(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs")) { in s5m8767_pmic_dt_parse_pdata()
629 "s5m8767,pmic-buck4-dvs-voltage", in s5m8767_pmic_dt_parse_pdata()
643 "s5m8767,pmic-buck-default-dvs-idx", in s5m8767_pmic_dt_parse_pdata()
659 pdata->buck2_ramp_enable = of_property_read_bool(pmic_np, "s5m8767,pmic-buck2-ramp-enable"); in s5m8767_pmic_dt_parse_pdata()
660 pdata->buck3_ramp_enable = of_property_read_bool(pmic_np, "s5m8767,pmic-buck3-ramp-enable"); in s5m8767_pmic_dt_parse_pdata()
661 pdata->buck4_ramp_enable = of_property_read_bool(pmic_np, "s5m8767,pmic-buck4-ramp-enable"); in s5m8767_pmic_dt_parse_pdata()
665 if (of_property_read_u32(pmic_np, "s5m8767,pmic-buck-ramp-delay", in s5m8767_pmic_dt_parse_pdata()
685 struct s5m8767_info *s5m8767; in s5m8767_pmic_probe() local
701 dev_err(&pdev->dev, "S5M8767 GPIO DVS NOT VALID\n"); in s5m8767_pmic_probe()
708 dev_err(&pdev->dev, "S5M8767 GPIO DVS NOT VALID\n"); in s5m8767_pmic_probe()
715 dev_err(&pdev->dev, "S5M8767 GPIO DVS NOT VALID\n"); in s5m8767_pmic_probe()
720 s5m8767 = devm_kzalloc(&pdev->dev, sizeof(struct s5m8767_info), in s5m8767_pmic_probe()
722 if (!s5m8767) in s5m8767_pmic_probe()
725 s5m8767->dev = &pdev->dev; in s5m8767_pmic_probe()
726 s5m8767->iodev = iodev; in s5m8767_pmic_probe()
727 s5m8767->num_regulators = pdata->num_regulators; in s5m8767_pmic_probe()
728 platform_set_drvdata(pdev, s5m8767); in s5m8767_pmic_probe()
730 s5m8767->buck_gpioindex = pdata->buck_default_idx; in s5m8767_pmic_probe()
731 s5m8767->buck2_gpiodvs = pdata->buck2_gpiodvs; in s5m8767_pmic_probe()
732 s5m8767->buck3_gpiodvs = pdata->buck3_gpiodvs; in s5m8767_pmic_probe()
733 s5m8767->buck4_gpiodvs = pdata->buck4_gpiodvs; in s5m8767_pmic_probe()
734 s5m8767->buck_gpios[0] = pdata->buck_gpios[0]; in s5m8767_pmic_probe()
735 s5m8767->buck_gpios[1] = pdata->buck_gpios[1]; in s5m8767_pmic_probe()
736 s5m8767->buck_gpios[2] = pdata->buck_gpios[2]; in s5m8767_pmic_probe()
737 s5m8767->buck_ds[0] = pdata->buck_ds[0]; in s5m8767_pmic_probe()
738 s5m8767->buck_ds[1] = pdata->buck_ds[1]; in s5m8767_pmic_probe()
739 s5m8767->buck_ds[2] = pdata->buck_ds[2]; in s5m8767_pmic_probe()
741 s5m8767->ramp_delay = pdata->buck_ramp_delay; in s5m8767_pmic_probe()
742 s5m8767->buck2_ramp = pdata->buck2_ramp_enable; in s5m8767_pmic_probe()
743 s5m8767->buck3_ramp = pdata->buck3_ramp_enable; in s5m8767_pmic_probe()
744 s5m8767->buck4_ramp = pdata->buck4_ramp_enable; in s5m8767_pmic_probe()
745 s5m8767->opmode = pdata->opmode; in s5m8767_pmic_probe()
750 regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK2DVS2, in s5m8767_pmic_probe()
756 regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK3DVS2, in s5m8767_pmic_probe()
762 regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK4DVS2, in s5m8767_pmic_probe()
766 if (s5m8767->buck2_gpiodvs) { in s5m8767_pmic_probe()
767 s5m8767->buck2_vol[i] = in s5m8767_pmic_probe()
773 if (s5m8767->buck3_gpiodvs) { in s5m8767_pmic_probe()
774 s5m8767->buck3_vol[i] = in s5m8767_pmic_probe()
780 if (s5m8767->buck4_gpiodvs) { in s5m8767_pmic_probe()
781 s5m8767->buck4_vol[i] = in s5m8767_pmic_probe()
799 "S5M8767 SET1"); in s5m8767_pmic_probe()
804 "S5M8767 SET2"); in s5m8767_pmic_probe()
809 "S5M8767 SET3"); in s5m8767_pmic_probe()
815 (s5m8767->buck_gpioindex >> 2) & 0x1); in s5m8767_pmic_probe()
818 (s5m8767->buck_gpioindex >> 1) & 0x1); in s5m8767_pmic_probe()
821 (s5m8767->buck_gpioindex >> 0) & 0x1); in s5m8767_pmic_probe()
824 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2"); in s5m8767_pmic_probe()
828 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[1], "S5M8767 DS3"); in s5m8767_pmic_probe()
832 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[2], "S5M8767 DS4"); in s5m8767_pmic_probe()
843 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
846 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
849 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
855 if (s5m8767->buck2_gpiodvs) { in s5m8767_pmic_probe()
856 regmap_write(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
858 s5m8767->buck2_vol[i]); in s5m8767_pmic_probe()
861 if (s5m8767->buck3_gpiodvs) { in s5m8767_pmic_probe()
862 regmap_write(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
864 s5m8767->buck3_vol[i]); in s5m8767_pmic_probe()
867 if (s5m8767->buck4_gpiodvs) { in s5m8767_pmic_probe()
868 regmap_write(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
870 s5m8767->buck4_vol[i]); in s5m8767_pmic_probe()
874 if (s5m8767->buck2_ramp) in s5m8767_pmic_probe()
875 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
878 if (s5m8767->buck3_ramp) in s5m8767_pmic_probe()
879 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
882 if (s5m8767->buck4_ramp) in s5m8767_pmic_probe()
883 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
886 if (s5m8767->buck2_ramp || s5m8767->buck3_ramp in s5m8767_pmic_probe()
887 || s5m8767->buck4_ramp) { in s5m8767_pmic_probe()
889 switch (s5m8767->ramp_delay) { in s5m8767_pmic_probe()
908 regmap_update_bits(s5m8767->iodev->regmap_pmic, in s5m8767_pmic_probe()
931 s5m8767_get_vsel_reg(id, s5m8767); in s5m8767_pmic_probe()
937 ret = s5m8767_get_register(s5m8767, id, &enable_reg, in s5m8767_pmic_probe()
940 dev_err(s5m8767->dev, "error reading registers\n"); in s5m8767_pmic_probe()
948 config.dev = s5m8767->dev; in s5m8767_pmic_probe()
950 config.driver_data = s5m8767; in s5m8767_pmic_probe()
956 s5m8767_regulator_config_ext_control(s5m8767, in s5m8767_pmic_probe()
963 devm_gpiod_unhinge(s5m8767->dev, config.ena_gpiod); in s5m8767_pmic_probe()
969 dev_err(s5m8767->dev, "regulator init failed for %d\n", in s5m8767_pmic_probe()
975 ret = s5m8767_enable_ext_control(s5m8767, rdev); in s5m8767_pmic_probe()
977 dev_err(s5m8767->dev, in s5m8767_pmic_probe()
989 { "s5m8767-pmic", 0},
996 .name = "s5m8767-pmic",
1006 MODULE_DESCRIPTION("Samsung S5M8767 Regulator Driver");