Lines Matching +full:pmic +full:- +full:specific

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
21 #define max77620_rails(_name) "max77620-"#_name
99 static int max77620_regulator_get_fps_src(struct max77620_regulator *pmic, in max77620_regulator_get_fps_src() argument
102 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_get_fps_src()
106 ret = regmap_read(pmic->rmap, rinfo->fps_addr, &val); in max77620_regulator_get_fps_src()
108 dev_err(pmic->dev, "Reg 0x%02x read failed %d\n", in max77620_regulator_get_fps_src()
109 rinfo->fps_addr, ret); in max77620_regulator_get_fps_src()
116 static int max77620_regulator_set_fps_src(struct max77620_regulator *pmic, in max77620_regulator_set_fps_src() argument
119 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_set_fps_src()
134 ret = regmap_read(pmic->rmap, rinfo->fps_addr, &val); in max77620_regulator_set_fps_src()
136 dev_err(pmic->dev, "Reg 0x%02x read failed %d\n", in max77620_regulator_set_fps_src()
137 rinfo->fps_addr, ret); in max77620_regulator_set_fps_src()
141 pmic->active_fps_src[id] = ret; in max77620_regulator_set_fps_src()
145 dev_err(pmic->dev, "Invalid FPS %d for regulator %d\n", in max77620_regulator_set_fps_src()
147 return -EINVAL; in max77620_regulator_set_fps_src()
150 ret = regmap_update_bits(pmic->rmap, rinfo->fps_addr, in max77620_regulator_set_fps_src()
154 dev_err(pmic->dev, "Reg 0x%02x update failed %d\n", in max77620_regulator_set_fps_src()
155 rinfo->fps_addr, ret); in max77620_regulator_set_fps_src()
158 pmic->active_fps_src[id] = fps_src; in max77620_regulator_set_fps_src()
163 static int max77620_regulator_set_fps_slots(struct max77620_regulator *pmic, in max77620_regulator_set_fps_slots() argument
166 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_regulator_set_fps_slots()
167 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_set_fps_slots()
170 int pu = rpdata->active_fps_pu_slot; in max77620_regulator_set_fps_slots()
171 int pd = rpdata->active_fps_pd_slot; in max77620_regulator_set_fps_slots()
178 pu = rpdata->suspend_fps_pu_slot; in max77620_regulator_set_fps_slots()
179 pd = rpdata->suspend_fps_pd_slot; in max77620_regulator_set_fps_slots()
195 ret = regmap_update_bits(pmic->rmap, rinfo->fps_addr, in max77620_regulator_set_fps_slots()
198 dev_err(pmic->dev, "Reg 0x%02x update failed: %d\n", in max77620_regulator_set_fps_slots()
199 rinfo->fps_addr, ret); in max77620_regulator_set_fps_slots()
207 static int max77620_regulator_set_power_mode(struct max77620_regulator *pmic, in max77620_regulator_set_power_mode() argument
210 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_set_power_mode()
211 u8 mask = rinfo->power_mode_mask; in max77620_regulator_set_power_mode()
212 u8 shift = rinfo->power_mode_shift; in max77620_regulator_set_power_mode()
216 switch (rinfo->type) { in max77620_regulator_set_power_mode()
218 addr = rinfo->cfg_addr; in max77620_regulator_set_power_mode()
221 addr = rinfo->volt_addr; in max77620_regulator_set_power_mode()
225 ret = regmap_update_bits(pmic->rmap, addr, mask, power_mode << shift); in max77620_regulator_set_power_mode()
227 dev_err(pmic->dev, "Regulator %d mode set failed: %d\n", in max77620_regulator_set_power_mode()
231 pmic->current_power_mode[id] = power_mode; in max77620_regulator_set_power_mode()
236 static int max77620_regulator_get_power_mode(struct max77620_regulator *pmic, in max77620_regulator_get_power_mode() argument
239 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_get_power_mode()
241 u8 mask = rinfo->power_mode_mask; in max77620_regulator_get_power_mode()
242 u8 shift = rinfo->power_mode_shift; in max77620_regulator_get_power_mode()
245 switch (rinfo->type) { in max77620_regulator_get_power_mode()
247 addr = rinfo->cfg_addr; in max77620_regulator_get_power_mode()
250 addr = rinfo->volt_addr; in max77620_regulator_get_power_mode()
254 ret = regmap_read(pmic->rmap, addr, &val); in max77620_regulator_get_power_mode()
256 dev_err(pmic->dev, "Regulator %d: Reg 0x%02x read failed: %d\n", in max77620_regulator_get_power_mode()
264 static int max77620_read_slew_rate(struct max77620_regulator *pmic, int id) in max77620_read_slew_rate() argument
266 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_read_slew_rate()
271 ret = regmap_read(pmic->rmap, rinfo->cfg_addr, &rval); in max77620_read_slew_rate()
273 dev_err(pmic->dev, "Register 0x%02x read failed: %d\n", in max77620_read_slew_rate()
274 rinfo->cfg_addr, ret); in max77620_read_slew_rate()
278 switch (rinfo->type) { in max77620_read_slew_rate()
295 rinfo->desc.ramp_delay = slew_rate; in max77620_read_slew_rate()
307 rinfo->desc.ramp_delay = slew_rate; in max77620_read_slew_rate()
314 static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id, in max77620_set_slew_rate() argument
317 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_set_slew_rate()
322 if (rinfo->type == MAX77620_REGULATOR_TYPE_SD) { in max77620_set_slew_rate()
341 ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr, mask, val); in max77620_set_slew_rate()
343 dev_err(pmic->dev, "Regulator %d slew rate set failed: %d\n", in max77620_set_slew_rate()
351 static int max77620_config_power_ok(struct max77620_regulator *pmic, int id) in max77620_config_power_ok() argument
353 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_config_power_ok()
354 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_config_power_ok()
355 struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent); in max77620_config_power_ok()
359 switch (chip->chip_id) { in max77620_config_power_ok()
361 if (rpdata->power_ok >= 0) { in max77620_config_power_ok()
362 if (rinfo->type == MAX77620_REGULATOR_TYPE_SD) in max77620_config_power_ok()
367 val = rpdata->power_ok ? mask : 0; in max77620_config_power_ok()
369 ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr, in max77620_config_power_ok()
372 dev_err(pmic->dev, "Reg 0x%02x update failed %d\n", in max77620_config_power_ok()
373 rinfo->cfg_addr, ret); in max77620_config_power_ok()
386 static int max77620_init_pmic(struct max77620_regulator *pmic, int id) in max77620_init_pmic() argument
388 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_init_pmic()
391 max77620_config_power_ok(pmic, id); in max77620_init_pmic()
394 ret = max77620_regulator_get_power_mode(pmic, id); in max77620_init_pmic()
398 pmic->current_power_mode[id] = ret; in max77620_init_pmic()
399 pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL; in max77620_init_pmic()
401 if (rpdata->active_fps_src == MAX77620_FPS_SRC_DEF) { in max77620_init_pmic()
402 ret = max77620_regulator_get_fps_src(pmic, id); in max77620_init_pmic()
405 rpdata->active_fps_src = ret; in max77620_init_pmic()
409 if (rpdata->active_fps_src == MAX77620_FPS_SRC_NONE) { in max77620_init_pmic()
410 ret = max77620_regulator_set_power_mode(pmic, in max77620_init_pmic()
411 pmic->enable_power_mode[id], id); in max77620_init_pmic()
415 if (pmic->current_power_mode[id] != in max77620_init_pmic()
416 pmic->enable_power_mode[id]) { in max77620_init_pmic()
417 ret = max77620_regulator_set_power_mode(pmic, in max77620_init_pmic()
418 pmic->enable_power_mode[id], id); in max77620_init_pmic()
424 ret = max77620_regulator_set_fps_src(pmic, rpdata->active_fps_src, id); in max77620_init_pmic()
428 ret = max77620_regulator_set_fps_slots(pmic, id, false); in max77620_init_pmic()
432 if (rpdata->ramp_rate_setting) { in max77620_init_pmic()
433 ret = max77620_set_slew_rate(pmic, id, in max77620_init_pmic()
434 rpdata->ramp_rate_setting); in max77620_init_pmic()
444 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_enable() local
447 if (pmic->active_fps_src[id] != MAX77620_FPS_SRC_NONE) in max77620_regulator_enable()
450 return max77620_regulator_set_power_mode(pmic, in max77620_regulator_enable()
451 pmic->enable_power_mode[id], id); in max77620_regulator_enable()
456 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_disable() local
459 if (pmic->active_fps_src[id] != MAX77620_FPS_SRC_NONE) in max77620_regulator_disable()
462 return max77620_regulator_set_power_mode(pmic, in max77620_regulator_disable()
468 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_is_enabled() local
472 if (pmic->active_fps_src[id] != MAX77620_FPS_SRC_NONE) in max77620_regulator_is_enabled()
475 ret = max77620_regulator_get_power_mode(pmic, id); in max77620_regulator_is_enabled()
488 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_set_mode() local
490 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_set_mode()
491 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_regulator_set_mode()
512 dev_err(pmic->dev, "Regulator %d mode %d is invalid\n", in max77620_regulator_set_mode()
514 return -EINVAL; in max77620_regulator_set_mode()
517 if (rinfo->type != MAX77620_REGULATOR_TYPE_SD) in max77620_regulator_set_mode()
521 ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr, in max77620_regulator_set_mode()
524 dev_err(pmic->dev, "Reg 0x%02x update failed: %d\n", in max77620_regulator_set_mode()
525 rinfo->cfg_addr, ret); in max77620_regulator_set_mode()
528 rpdata->current_mode = mode; in max77620_regulator_set_mode()
531 ret = max77620_regulator_set_power_mode(pmic, power_mode, id); in max77620_regulator_set_mode()
535 pmic->enable_power_mode[id] = power_mode; in max77620_regulator_set_mode()
542 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_get_mode() local
544 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_get_mode()
550 ret = max77620_regulator_get_power_mode(pmic, id); in max77620_regulator_get_mode()
556 if (rinfo->type == MAX77620_REGULATOR_TYPE_SD) { in max77620_regulator_get_mode()
557 ret = regmap_read(pmic->rmap, rinfo->cfg_addr, &val); in max77620_regulator_get_mode()
559 dev_err(pmic->dev, "Reg 0x%02x read failed: %d\n", in max77620_regulator_get_mode()
560 rinfo->cfg_addr, ret); in max77620_regulator_get_mode()
588 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_set_ramp_delay() local
590 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_regulator_set_ramp_delay()
592 /* Device specific ramp rate setting tells that platform has in max77620_regulator_set_ramp_delay()
596 if (rpdata->ramp_rate_setting) in max77620_regulator_set_ramp_delay()
599 return max77620_set_slew_rate(pmic, id, ramp_delay); in max77620_regulator_set_ramp_delay()
606 struct max77620_regulator *pmic = config->driver_data; in max77620_of_parse_cb() local
607 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[desc->id]; in max77620_of_parse_cb()
611 ret = of_property_read_u32(np, "maxim,active-fps-source", &pval); in max77620_of_parse_cb()
612 rpdata->active_fps_src = (!ret) ? pval : MAX77620_FPS_SRC_DEF; in max77620_of_parse_cb()
614 ret = of_property_read_u32(np, "maxim,active-fps-power-up-slot", &pval); in max77620_of_parse_cb()
615 rpdata->active_fps_pu_slot = (!ret) ? pval : -1; in max77620_of_parse_cb()
618 np, "maxim,active-fps-power-down-slot", &pval); in max77620_of_parse_cb()
619 rpdata->active_fps_pd_slot = (!ret) ? pval : -1; in max77620_of_parse_cb()
621 ret = of_property_read_u32(np, "maxim,suspend-fps-source", &pval); in max77620_of_parse_cb()
622 rpdata->suspend_fps_src = (!ret) ? pval : -1; in max77620_of_parse_cb()
625 np, "maxim,suspend-fps-power-up-slot", &pval); in max77620_of_parse_cb()
626 rpdata->suspend_fps_pu_slot = (!ret) ? pval : -1; in max77620_of_parse_cb()
629 np, "maxim,suspend-fps-power-down-slot", &pval); in max77620_of_parse_cb()
630 rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1; in max77620_of_parse_cb()
632 ret = of_property_read_u32(np, "maxim,power-ok-control", &pval); in max77620_of_parse_cb()
634 rpdata->power_ok = pval; in max77620_of_parse_cb()
636 rpdata->power_ok = -1; in max77620_of_parse_cb()
638 ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval); in max77620_of_parse_cb()
639 rpdata->ramp_rate_setting = (!ret) ? pval : 0; in max77620_of_parse_cb()
641 return max77620_init_pmic(pmic, desc->id); in max77620_of_parse_cb()
679 .n_voltages = ((_max_uV - _min_uV) / _step_uV) + 1, \
711 .n_voltages = ((_max_uV - _min_uV) / _step_uV) + 1, \
727 RAIL_SD(SD0, sd0, "in-sd0", SD0, 600000, 1400000, 12500, 0x22, SD0),
728 RAIL_SD(SD1, sd1, "in-sd1", SD1, 600000, 1550000, 12500, 0x22, SD1),
729 RAIL_SD(SD2, sd2, "in-sd2", SDX, 600000, 3787500, 12500, 0xFF, NONE),
730 RAIL_SD(SD3, sd3, "in-sd3", SDX, 600000, 3787500, 12500, 0xFF, NONE),
732 RAIL_LDO(LDO0, ldo0, "in-ldo0-1", N, 800000, 2375000, 25000),
733 RAIL_LDO(LDO1, ldo1, "in-ldo0-1", N, 800000, 2375000, 25000),
734 RAIL_LDO(LDO2, ldo2, "in-ldo2", P, 800000, 3950000, 50000),
735 RAIL_LDO(LDO3, ldo3, "in-ldo3-5", P, 800000, 3950000, 50000),
736 RAIL_LDO(LDO4, ldo4, "in-ldo4-6", P, 800000, 1587500, 12500),
737 RAIL_LDO(LDO5, ldo5, "in-ldo3-5", P, 800000, 3950000, 50000),
738 RAIL_LDO(LDO6, ldo6, "in-ldo4-6", P, 800000, 3950000, 50000),
739 RAIL_LDO(LDO7, ldo7, "in-ldo7-8", N, 800000, 3950000, 50000),
740 RAIL_LDO(LDO8, ldo8, "in-ldo7-8", N, 800000, 3950000, 50000),
744 RAIL_SD(SD0, sd0, "in-sd0", SD0, 800000, 1587500, 12500, 0x22, SD0),
745 RAIL_SD(SD1, sd1, "in-sd1", SD1, 600000, 3387500, 12500, 0x22, SD1),
746 RAIL_SD(SD2, sd2, "in-sd2", SDX, 600000, 3787500, 12500, 0xFF, NONE),
747 RAIL_SD(SD3, sd3, "in-sd3", SDX, 600000, 3787500, 12500, 0xFF, NONE),
748 RAIL_SD(SD4, sd4, "in-sd4", SDX, 600000, 3787500, 12500, 0xFF, NONE),
750 RAIL_LDO(LDO0, ldo0, "in-ldo0-1", N, 800000, 2375000, 25000),
751 RAIL_LDO(LDO1, ldo1, "in-ldo0-1", N, 800000, 2375000, 25000),
752 RAIL_LDO(LDO2, ldo2, "in-ldo2", P, 800000, 3950000, 50000),
753 RAIL_LDO(LDO3, ldo3, "in-ldo3-5", P, 800000, 3950000, 50000),
754 RAIL_LDO(LDO4, ldo4, "in-ldo4-6", P, 800000, 1587500, 12500),
755 RAIL_LDO(LDO5, ldo5, "in-ldo3-5", P, 800000, 3950000, 50000),
756 RAIL_LDO(LDO6, ldo6, "in-ldo4-6", P, 800000, 3950000, 50000),
757 RAIL_LDO(LDO7, ldo7, "in-ldo7-8", N, 800000, 3950000, 50000),
758 RAIL_LDO(LDO8, ldo8, "in-ldo7-8", N, 800000, 3950000, 50000),
762 RAIL_SD(SD0, sd0, "in-sd0", SD0, 600000, 3387500, 12500, 0xFF, NONE),
763 RAIL_SD(SD1, sd1, "in-sd1", SD1, 800000, 1587500, 12500, 0xFF, NONE),
764 RAIL_SD(SD2, sd2, "in-sd2", SDX, 600000, 3787500, 12500, 0xFF, NONE),
765 RAIL_SD(SD3, sd3, "in-sd3", SDX, 600000, 3787500, 12500, 0xFF, NONE),
766 RAIL_SD(SD4, sd4, "in-sd4", SDX, 600000, 3787500, 12500, 0xFF, NONE),
768 RAIL_LDO(LDO0, ldo0, "in-ldo0-1", N, 800000, 2375000, 25000),
769 RAIL_LDO(LDO1, ldo1, "in-ldo0-1", N, 800000, 2375000, 25000),
770 RAIL_LDO(LDO2, ldo2, "in-ldo2", P, 800000, 3950000, 50000),
771 RAIL_LDO(LDO3, ldo3, "in-ldo3-5", P, 800000, 3950000, 50000),
772 RAIL_LDO(LDO4, ldo4, "in-ldo4-6", P, 800000, 1587500, 12500),
773 RAIL_LDO(LDO5, ldo5, "in-ldo3-5", P, 800000, 3950000, 50000),
774 RAIL_LDO(LDO6, ldo6, "in-ldo4-6", P, 800000, 3950000, 50000),
775 RAIL_LDO(LDO7, ldo7, "in-ldo7-8", N, 800000, 3950000, 50000),
776 RAIL_LDO(LDO8, ldo8, "in-ldo7-8", N, 800000, 3950000, 50000),
781 struct max77620_chip *max77620_chip = dev_get_drvdata(pdev->dev.parent); in max77620_regulator_probe()
783 struct device *dev = &pdev->dev; in max77620_regulator_probe()
785 struct max77620_regulator *pmic; in max77620_regulator_probe() local
789 pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); in max77620_regulator_probe()
790 if (!pmic) in max77620_regulator_probe()
791 return -ENOMEM; in max77620_regulator_probe()
793 platform_set_drvdata(pdev, pmic); in max77620_regulator_probe()
794 pmic->dev = dev; in max77620_regulator_probe()
795 pmic->rmap = max77620_chip->rmap; in max77620_regulator_probe()
796 if (!dev->of_node) in max77620_regulator_probe()
797 dev->of_node = pdev->dev.parent->of_node; in max77620_regulator_probe()
799 switch (max77620_chip->chip_id) { in max77620_regulator_probe()
810 return -EINVAL; in max77620_regulator_probe()
813 config.regmap = pmic->rmap; in max77620_regulator_probe()
815 config.driver_data = pmic; in max77620_regulator_probe()
821 if ((max77620_chip->chip_id == MAX77620) && in max77620_regulator_probe()
826 pmic->rinfo[id] = &rinfo[id]; in max77620_regulator_probe()
827 pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL; in max77620_regulator_probe()
828 pmic->reg_pdata[id].active_fps_src = -1; in max77620_regulator_probe()
829 pmic->reg_pdata[id].active_fps_pd_slot = -1; in max77620_regulator_probe()
830 pmic->reg_pdata[id].active_fps_pu_slot = -1; in max77620_regulator_probe()
831 pmic->reg_pdata[id].suspend_fps_src = -1; in max77620_regulator_probe()
832 pmic->reg_pdata[id].suspend_fps_pd_slot = -1; in max77620_regulator_probe()
833 pmic->reg_pdata[id].suspend_fps_pu_slot = -1; in max77620_regulator_probe()
834 pmic->reg_pdata[id].power_ok = -1; in max77620_regulator_probe()
835 pmic->reg_pdata[id].ramp_rate_setting = -1; in max77620_regulator_probe()
837 ret = max77620_read_slew_rate(pmic, id); in max77620_regulator_probe()
845 rdesc->name, ret); in max77620_regulator_probe()
856 struct max77620_regulator *pmic = dev_get_drvdata(dev); in max77620_regulator_suspend() local
861 reg_pdata = &pmic->reg_pdata[id]; in max77620_regulator_suspend()
863 max77620_regulator_set_fps_slots(pmic, id, true); in max77620_regulator_suspend()
864 if (reg_pdata->suspend_fps_src < 0) in max77620_regulator_suspend()
867 max77620_regulator_set_fps_src(pmic, reg_pdata->suspend_fps_src, in max77620_regulator_suspend()
876 struct max77620_regulator *pmic = dev_get_drvdata(dev); in max77620_regulator_resume() local
881 reg_pdata = &pmic->reg_pdata[id]; in max77620_regulator_resume()
883 max77620_config_power_ok(pmic, id); in max77620_regulator_resume()
885 max77620_regulator_set_fps_slots(pmic, id, false); in max77620_regulator_resume()
886 if (reg_pdata->active_fps_src < 0) in max77620_regulator_resume()
888 max77620_regulator_set_fps_src(pmic, reg_pdata->active_fps_src, in max77620_regulator_resume()
902 { .name = "max77620-pmic", },
903 { .name = "max20024-pmic", },
904 { .name = "max77663-pmic", },
913 .name = "max77620-pmic",