Lines Matching refs:pmic

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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
402 ret = max77620_regulator_get_fps_src(pmic, id); 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()
433 ret = max77620_set_slew_rate(pmic, id, 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()
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()
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()
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()
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()
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()
641 return max77620_init_pmic(pmic, desc->id); in max77620_of_parse_cb()
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()
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()
813 config.regmap = pmic->rmap; in max77620_regulator_probe()
815 config.driver_data = pmic; in max77620_regulator_probe()
833 pmic->rinfo[id] = &rinfo[id]; in max77620_regulator_probe()
834 pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL; in max77620_regulator_probe()
835 pmic->reg_pdata[id].active_fps_src = -1; in max77620_regulator_probe()
836 pmic->reg_pdata[id].active_fps_pd_slot = -1; in max77620_regulator_probe()
837 pmic->reg_pdata[id].active_fps_pu_slot = -1; in max77620_regulator_probe()
838 pmic->reg_pdata[id].suspend_fps_src = -1; in max77620_regulator_probe()
839 pmic->reg_pdata[id].suspend_fps_pd_slot = -1; in max77620_regulator_probe()
840 pmic->reg_pdata[id].suspend_fps_pu_slot = -1; in max77620_regulator_probe()
841 pmic->reg_pdata[id].power_ok = -1; in max77620_regulator_probe()
842 pmic->reg_pdata[id].ramp_rate_setting = -1; in max77620_regulator_probe()
844 ret = max77620_read_slew_rate(pmic, id); in max77620_regulator_probe()
861 struct max77620_regulator *pmic = dev_get_drvdata(dev); in max77620_regulator_suspend() local
866 reg_pdata = &pmic->reg_pdata[id]; in max77620_regulator_suspend()
868 max77620_regulator_set_fps_slots(pmic, id, true); in max77620_regulator_suspend()
872 max77620_regulator_set_fps_src(pmic, reg_pdata->suspend_fps_src, in max77620_regulator_suspend()
881 struct max77620_regulator *pmic = dev_get_drvdata(dev); in max77620_regulator_resume() local
886 reg_pdata = &pmic->reg_pdata[id]; in max77620_regulator_resume()
888 max77620_config_power_ok(pmic, id); in max77620_regulator_resume()
890 max77620_regulator_set_fps_slots(pmic, id, false); in max77620_regulator_resume()
893 max77620_regulator_set_fps_src(pmic, reg_pdata->active_fps_src, in max77620_regulator_resume()