Lines Matching refs:pmic
102 static int max77620_regulator_get_fps_src(struct max77620_regulator *pmic, in max77620_regulator_get_fps_src() argument
105 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_get_fps_src()
109 ret = regmap_read(pmic->rmap, rinfo->fps_addr, &val); in max77620_regulator_get_fps_src()
111 dev_err(pmic->dev, "Reg 0x%02x read failed %d\n", in max77620_regulator_get_fps_src()
119 static int max77620_regulator_set_fps_src(struct max77620_regulator *pmic, in max77620_regulator_set_fps_src() argument
122 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_set_fps_src()
137 ret = regmap_read(pmic->rmap, rinfo->fps_addr, &val); in max77620_regulator_set_fps_src()
139 dev_err(pmic->dev, "Reg 0x%02x read failed %d\n", in max77620_regulator_set_fps_src()
144 pmic->active_fps_src[id] = ret; in max77620_regulator_set_fps_src()
148 dev_err(pmic->dev, "Invalid FPS %d for regulator %d\n", in max77620_regulator_set_fps_src()
153 ret = regmap_update_bits(pmic->rmap, rinfo->fps_addr, in max77620_regulator_set_fps_src()
157 dev_err(pmic->dev, "Reg 0x%02x update failed %d\n", in max77620_regulator_set_fps_src()
161 pmic->active_fps_src[id] = fps_src; in max77620_regulator_set_fps_src()
166 static int max77620_regulator_set_fps_slots(struct max77620_regulator *pmic, in max77620_regulator_set_fps_slots() argument
169 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_regulator_set_fps_slots()
170 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_set_fps_slots()
198 ret = regmap_update_bits(pmic->rmap, rinfo->fps_addr, in max77620_regulator_set_fps_slots()
201 dev_err(pmic->dev, "Reg 0x%02x update failed: %d\n", in max77620_regulator_set_fps_slots()
210 static int max77620_regulator_set_power_mode(struct max77620_regulator *pmic, in max77620_regulator_set_power_mode() argument
213 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_set_power_mode()
228 ret = regmap_update_bits(pmic->rmap, addr, mask, power_mode << shift); in max77620_regulator_set_power_mode()
230 dev_err(pmic->dev, "Regulator %d mode set failed: %d\n", in max77620_regulator_set_power_mode()
234 pmic->current_power_mode[id] = power_mode; in max77620_regulator_set_power_mode()
239 static int max77620_regulator_get_power_mode(struct max77620_regulator *pmic, in max77620_regulator_get_power_mode() argument
242 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_get_power_mode()
257 ret = regmap_read(pmic->rmap, addr, &val); in max77620_regulator_get_power_mode()
259 dev_err(pmic->dev, "Regulator %d: Reg 0x%02x read failed: %d\n", in max77620_regulator_get_power_mode()
267 static int max77620_read_slew_rate(struct max77620_regulator *pmic, int id) in max77620_read_slew_rate() argument
269 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_read_slew_rate()
274 ret = regmap_read(pmic->rmap, rinfo->cfg_addr, &rval); in max77620_read_slew_rate()
276 dev_err(pmic->dev, "Register 0x%02x read failed: %d\n", in max77620_read_slew_rate()
317 static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id, in max77620_set_slew_rate() argument
320 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_set_slew_rate()
344 ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr, mask, val); in max77620_set_slew_rate()
346 dev_err(pmic->dev, "Regulator %d slew rate set failed: %d\n", in max77620_set_slew_rate()
354 static int max77620_config_power_ok(struct max77620_regulator *pmic, int id) in max77620_config_power_ok() argument
356 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_config_power_ok()
357 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_config_power_ok()
358 struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent); in max77620_config_power_ok()
372 ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr, in max77620_config_power_ok()
375 dev_err(pmic->dev, "Reg 0x%02x update failed %d\n", in max77620_config_power_ok()
389 static int max77620_init_pmic(struct max77620_regulator *pmic, int id) in max77620_init_pmic() argument
391 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_init_pmic()
394 max77620_config_power_ok(pmic, id); in max77620_init_pmic()
397 ret = max77620_regulator_get_power_mode(pmic, id); in max77620_init_pmic()
401 pmic->current_power_mode[id] = ret; in max77620_init_pmic()
402 pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL; in max77620_init_pmic()
405 ret = max77620_regulator_get_fps_src(pmic, id); in max77620_init_pmic()
413 ret = max77620_regulator_set_power_mode(pmic, in max77620_init_pmic()
414 pmic->enable_power_mode[id], id); in max77620_init_pmic()
418 if (pmic->current_power_mode[id] != in max77620_init_pmic()
419 pmic->enable_power_mode[id]) { in max77620_init_pmic()
420 ret = max77620_regulator_set_power_mode(pmic, in max77620_init_pmic()
421 pmic->enable_power_mode[id], id); in max77620_init_pmic()
427 ret = max77620_regulator_set_fps_src(pmic, rpdata->active_fps_src, id); in max77620_init_pmic()
431 ret = max77620_regulator_set_fps_slots(pmic, id, false); in max77620_init_pmic()
436 ret = max77620_set_slew_rate(pmic, id, in max77620_init_pmic()
447 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_enable() local
450 if (pmic->active_fps_src[id] != MAX77620_FPS_SRC_NONE) in max77620_regulator_enable()
453 return max77620_regulator_set_power_mode(pmic, in max77620_regulator_enable()
454 pmic->enable_power_mode[id], id); in max77620_regulator_enable()
459 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_disable() local
462 if (pmic->active_fps_src[id] != MAX77620_FPS_SRC_NONE) in max77620_regulator_disable()
465 return max77620_regulator_set_power_mode(pmic, in max77620_regulator_disable()
471 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_is_enabled() local
475 if (pmic->active_fps_src[id] != MAX77620_FPS_SRC_NONE) in max77620_regulator_is_enabled()
478 ret = max77620_regulator_get_power_mode(pmic, id); in max77620_regulator_is_enabled()
491 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_set_mode() local
493 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_set_mode()
494 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_regulator_set_mode()
515 dev_err(pmic->dev, "Regulator %d mode %d is invalid\n", in max77620_regulator_set_mode()
524 ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr, in max77620_regulator_set_mode()
527 dev_err(pmic->dev, "Reg 0x%02x update failed: %d\n", in max77620_regulator_set_mode()
534 ret = max77620_regulator_set_power_mode(pmic, power_mode, id); in max77620_regulator_set_mode()
538 pmic->enable_power_mode[id] = power_mode; in max77620_regulator_set_mode()
545 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_get_mode() local
547 struct max77620_regulator_info *rinfo = pmic->rinfo[id]; in max77620_regulator_get_mode()
553 ret = max77620_regulator_get_power_mode(pmic, id); in max77620_regulator_get_mode()
560 ret = regmap_read(pmic->rmap, rinfo->cfg_addr, &val); in max77620_regulator_get_mode()
562 dev_err(pmic->dev, "Reg 0x%02x read failed: %d\n", in max77620_regulator_get_mode()
591 struct max77620_regulator *pmic = rdev_get_drvdata(rdev); in max77620_regulator_set_ramp_delay() local
593 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id]; in max77620_regulator_set_ramp_delay()
602 return max77620_set_slew_rate(pmic, id, ramp_delay); in max77620_regulator_set_ramp_delay()
609 struct max77620_regulator *pmic = config->driver_data; in max77620_of_parse_cb() local
610 struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[desc->id]; in max77620_of_parse_cb()
644 return max77620_init_pmic(pmic, desc->id); in max77620_of_parse_cb()
768 struct max77620_regulator *pmic; in max77620_regulator_probe() local
772 pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); in max77620_regulator_probe()
773 if (!pmic) in max77620_regulator_probe()
776 platform_set_drvdata(pdev, pmic); in max77620_regulator_probe()
777 pmic->dev = dev; in max77620_regulator_probe()
778 pmic->rmap = max77620_chip->rmap; in max77620_regulator_probe()
791 config.regmap = pmic->rmap; in max77620_regulator_probe()
793 config.driver_data = pmic; in max77620_regulator_probe()
804 pmic->rinfo[id] = &max77620_regs_info[id]; in max77620_regulator_probe()
805 pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL; in max77620_regulator_probe()
807 ret = max77620_read_slew_rate(pmic, id); in max77620_regulator_probe()
826 struct max77620_regulator *pmic = dev_get_drvdata(dev); in max77620_regulator_suspend() local
831 reg_pdata = &pmic->reg_pdata[id]; in max77620_regulator_suspend()
833 max77620_regulator_set_fps_slots(pmic, id, true); in max77620_regulator_suspend()
837 max77620_regulator_set_fps_src(pmic, reg_pdata->suspend_fps_src, in max77620_regulator_suspend()
846 struct max77620_regulator *pmic = dev_get_drvdata(dev); in max77620_regulator_resume() local
851 reg_pdata = &pmic->reg_pdata[id]; in max77620_regulator_resume()
853 max77620_config_power_ok(pmic, id); in max77620_regulator_resume()
855 max77620_regulator_set_fps_slots(pmic, id, false); in max77620_regulator_resume()
858 max77620_regulator_set_fps_src(pmic, reg_pdata->active_fps_src, in max77620_regulator_resume()