Lines Matching refs:chg
224 struct max77693_charger *chg = power_supply_get_drvdata(psy); in max77693_charger_get_property() local
225 struct regmap *regmap = chg->max77693->regmap; in max77693_charger_get_property()
269 struct max77693_charger *chg = dev_get_drvdata(dev); in device_attr_store() local
277 ret = fn(chg, val); in device_attr_store()
287 struct max77693_charger *chg = dev_get_drvdata(dev); in fast_charge_timer_show() local
291 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_01, in fast_charge_timer_show()
312 static int max77693_set_fast_charge_timer(struct max77693_charger *chg, in max77693_set_fast_charge_timer() argument
338 return regmap_update_bits(chg->max77693->regmap, in max77693_set_fast_charge_timer()
353 struct max77693_charger *chg = dev_get_drvdata(dev); in top_off_threshold_current_show() local
357 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_03, in top_off_threshold_current_show()
373 static int max77693_set_top_off_threshold_current(struct max77693_charger *chg, in max77693_set_top_off_threshold_current() argument
389 return regmap_update_bits(chg->max77693->regmap, in max77693_set_top_off_threshold_current()
404 struct max77693_charger *chg = dev_get_drvdata(dev); in top_off_timer_show() local
408 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_03, in top_off_timer_show()
421 static int max77693_set_top_off_timer(struct max77693_charger *chg, in max77693_set_top_off_timer() argument
432 return regmap_update_bits(chg->max77693->regmap, in max77693_set_top_off_timer()
448 static int max77693_set_constant_volt(struct max77693_charger *chg, in max77693_set_constant_volt() argument
470 dev_err(chg->dev, "Wrong value for charging constant voltage\n"); in max77693_set_constant_volt()
476 dev_dbg(chg->dev, "Charging constant voltage: %u (0x%x)\n", uvolt, in max77693_set_constant_volt()
479 return regmap_update_bits(chg->max77693->regmap, in max77693_set_constant_volt()
484 static int max77693_set_min_system_volt(struct max77693_charger *chg, in max77693_set_min_system_volt() argument
490 dev_err(chg->dev, "Wrong value for minimum system regulation voltage\n"); in max77693_set_min_system_volt()
498 dev_dbg(chg->dev, "Minimum system regulation voltage: %u (0x%x)\n", in max77693_set_min_system_volt()
501 return regmap_update_bits(chg->max77693->regmap, in max77693_set_min_system_volt()
506 static int max77693_set_thermal_regulation_temp(struct max77693_charger *chg, in max77693_set_thermal_regulation_temp() argument
519 dev_err(chg->dev, "Wrong value for thermal regulation loop temperature\n"); in max77693_set_thermal_regulation_temp()
525 dev_dbg(chg->dev, "Thermal regulation loop temperature: %u (0x%x)\n", in max77693_set_thermal_regulation_temp()
528 return regmap_update_bits(chg->max77693->regmap, in max77693_set_thermal_regulation_temp()
533 static int max77693_set_batttery_overcurrent(struct max77693_charger *chg, in max77693_set_batttery_overcurrent() argument
539 dev_err(chg->dev, "Wrong value for battery overcurrent\n"); in max77693_set_batttery_overcurrent()
550 dev_dbg(chg->dev, "Battery overcurrent: %u (0x%x)\n", uamp, data); in max77693_set_batttery_overcurrent()
552 return regmap_update_bits(chg->max77693->regmap, in max77693_set_batttery_overcurrent()
557 static int max77693_set_charge_input_threshold_volt(struct max77693_charger *chg, in max77693_set_charge_input_threshold_volt() argument
571 dev_err(chg->dev, "Wrong value for charge input voltage regulation threshold\n"); in max77693_set_charge_input_threshold_volt()
577 dev_dbg(chg->dev, "Charge input voltage regulation threshold: %u (0x%x)\n", in max77693_set_charge_input_threshold_volt()
580 return regmap_update_bits(chg->max77693->regmap, in max77693_set_charge_input_threshold_volt()
588 static int max77693_reg_init(struct max77693_charger *chg) in max77693_reg_init() argument
595 ret = regmap_update_bits(chg->max77693->regmap, in max77693_reg_init()
599 dev_err(chg->dev, "Error unlocking registers: %d\n", ret); in max77693_reg_init()
603 ret = max77693_set_fast_charge_timer(chg, DEFAULT_FAST_CHARGE_TIMER); in max77693_reg_init()
607 ret = max77693_set_top_off_threshold_current(chg, in max77693_reg_init()
612 ret = max77693_set_top_off_timer(chg, DEFAULT_TOP_OFF_TIMER); in max77693_reg_init()
616 ret = max77693_set_constant_volt(chg, chg->constant_volt); in max77693_reg_init()
620 ret = max77693_set_min_system_volt(chg, chg->min_system_volt); in max77693_reg_init()
624 ret = max77693_set_thermal_regulation_temp(chg, in max77693_reg_init()
625 chg->thermal_regulation_temp); in max77693_reg_init()
629 ret = max77693_set_batttery_overcurrent(chg, chg->batttery_overcurrent); in max77693_reg_init()
633 return max77693_set_charge_input_threshold_volt(chg, in max77693_reg_init()
634 chg->charge_input_threshold_volt); in max77693_reg_init()
638 static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) in max77693_dt_init() argument
648 &chg->constant_volt)) in max77693_dt_init()
649 chg->constant_volt = DEFAULT_CONSTANT_VOLT; in max77693_dt_init()
652 &chg->min_system_volt)) in max77693_dt_init()
653 chg->min_system_volt = DEFAULT_MIN_SYSTEM_VOLT; in max77693_dt_init()
656 &chg->thermal_regulation_temp)) in max77693_dt_init()
657 chg->thermal_regulation_temp = DEFAULT_THERMAL_REGULATION_TEMP; in max77693_dt_init()
660 &chg->batttery_overcurrent)) in max77693_dt_init()
661 chg->batttery_overcurrent = DEFAULT_BATTERY_OVERCURRENT; in max77693_dt_init()
664 &chg->charge_input_threshold_volt)) in max77693_dt_init()
665 chg->charge_input_threshold_volt = in max77693_dt_init()
671 static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) in max77693_dt_init() argument
679 struct max77693_charger *chg; in max77693_charger_probe() local
684 chg = devm_kzalloc(&pdev->dev, sizeof(*chg), GFP_KERNEL); in max77693_charger_probe()
685 if (!chg) in max77693_charger_probe()
688 platform_set_drvdata(pdev, chg); in max77693_charger_probe()
689 chg->dev = &pdev->dev; in max77693_charger_probe()
690 chg->max77693 = max77693; in max77693_charger_probe()
692 ret = max77693_dt_init(&pdev->dev, chg); in max77693_charger_probe()
696 ret = max77693_reg_init(chg); in max77693_charger_probe()
700 psy_cfg.drv_data = chg; in max77693_charger_probe()
721 chg->charger = power_supply_register(&pdev->dev, in max77693_charger_probe()
724 if (IS_ERR(chg->charger)) { in max77693_charger_probe()
726 ret = PTR_ERR(chg->charger); in max77693_charger_probe()
742 struct max77693_charger *chg = platform_get_drvdata(pdev); in max77693_charger_remove() local
748 power_supply_unregister(chg->charger); in max77693_charger_remove()