Lines Matching refs:chg
214 struct max77693_charger *chg = power_supply_get_drvdata(psy); in max77693_charger_get_property() local
215 struct regmap *regmap = chg->max77693->regmap; in max77693_charger_get_property()
259 struct max77693_charger *chg = dev_get_drvdata(dev); in device_attr_store() local
267 ret = fn(chg, val); in device_attr_store()
277 struct max77693_charger *chg = dev_get_drvdata(dev); in fast_charge_timer_show() local
281 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_01, in fast_charge_timer_show()
302 static int max77693_set_fast_charge_timer(struct max77693_charger *chg, in max77693_set_fast_charge_timer() argument
328 return regmap_update_bits(chg->max77693->regmap, in max77693_set_fast_charge_timer()
343 struct max77693_charger *chg = dev_get_drvdata(dev); in top_off_threshold_current_show() local
347 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_03, in top_off_threshold_current_show()
363 static int max77693_set_top_off_threshold_current(struct max77693_charger *chg, in max77693_set_top_off_threshold_current() argument
379 return regmap_update_bits(chg->max77693->regmap, in max77693_set_top_off_threshold_current()
394 struct max77693_charger *chg = dev_get_drvdata(dev); in top_off_timer_show() local
398 ret = regmap_read(chg->max77693->regmap, MAX77693_CHG_REG_CHG_CNFG_03, in top_off_timer_show()
411 static int max77693_set_top_off_timer(struct max77693_charger *chg, in max77693_set_top_off_timer() argument
422 return regmap_update_bits(chg->max77693->regmap, in max77693_set_top_off_timer()
438 static int max77693_set_constant_volt(struct max77693_charger *chg, in max77693_set_constant_volt() argument
460 dev_err(chg->dev, "Wrong value for charging constant voltage\n"); in max77693_set_constant_volt()
466 dev_dbg(chg->dev, "Charging constant voltage: %u (0x%x)\n", uvolt, in max77693_set_constant_volt()
469 return regmap_update_bits(chg->max77693->regmap, in max77693_set_constant_volt()
474 static int max77693_set_min_system_volt(struct max77693_charger *chg, in max77693_set_min_system_volt() argument
480 dev_err(chg->dev, "Wrong value for minimum system regulation voltage\n"); in max77693_set_min_system_volt()
488 dev_dbg(chg->dev, "Minimum system regulation voltage: %u (0x%x)\n", in max77693_set_min_system_volt()
491 return regmap_update_bits(chg->max77693->regmap, in max77693_set_min_system_volt()
496 static int max77693_set_thermal_regulation_temp(struct max77693_charger *chg, in max77693_set_thermal_regulation_temp() argument
509 dev_err(chg->dev, "Wrong value for thermal regulation loop temperature\n"); in max77693_set_thermal_regulation_temp()
515 dev_dbg(chg->dev, "Thermal regulation loop temperature: %u (0x%x)\n", in max77693_set_thermal_regulation_temp()
518 return regmap_update_bits(chg->max77693->regmap, in max77693_set_thermal_regulation_temp()
523 static int max77693_set_batttery_overcurrent(struct max77693_charger *chg, in max77693_set_batttery_overcurrent() argument
529 dev_err(chg->dev, "Wrong value for battery overcurrent\n"); in max77693_set_batttery_overcurrent()
540 dev_dbg(chg->dev, "Battery overcurrent: %u (0x%x)\n", uamp, data); in max77693_set_batttery_overcurrent()
542 return regmap_update_bits(chg->max77693->regmap, in max77693_set_batttery_overcurrent()
547 static int max77693_set_charge_input_threshold_volt(struct max77693_charger *chg, in max77693_set_charge_input_threshold_volt() argument
562 dev_err(chg->dev, "Wrong value for charge input voltage regulation threshold\n"); in max77693_set_charge_input_threshold_volt()
568 dev_dbg(chg->dev, "Charge input voltage regulation threshold: %u (0x%x)\n", in max77693_set_charge_input_threshold_volt()
571 return regmap_update_bits(chg->max77693->regmap, in max77693_set_charge_input_threshold_volt()
579 static int max77693_reg_init(struct max77693_charger *chg) in max77693_reg_init() argument
586 ret = regmap_update_bits(chg->max77693->regmap, in max77693_reg_init()
590 dev_err(chg->dev, "Error unlocking registers: %d\n", ret); in max77693_reg_init()
594 ret = max77693_set_fast_charge_timer(chg, DEFAULT_FAST_CHARGE_TIMER); in max77693_reg_init()
598 ret = max77693_set_top_off_threshold_current(chg, in max77693_reg_init()
603 ret = max77693_set_top_off_timer(chg, DEFAULT_TOP_OFF_TIMER); in max77693_reg_init()
607 ret = max77693_set_constant_volt(chg, chg->constant_volt); in max77693_reg_init()
611 ret = max77693_set_min_system_volt(chg, chg->min_system_volt); in max77693_reg_init()
615 ret = max77693_set_thermal_regulation_temp(chg, in max77693_reg_init()
616 chg->thermal_regulation_temp); in max77693_reg_init()
620 ret = max77693_set_batttery_overcurrent(chg, chg->batttery_overcurrent); in max77693_reg_init()
624 return max77693_set_charge_input_threshold_volt(chg, in max77693_reg_init()
625 chg->charge_input_threshold_volt); in max77693_reg_init()
629 static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) in max77693_dt_init() argument
639 &chg->constant_volt)) in max77693_dt_init()
640 chg->constant_volt = DEFAULT_CONSTANT_VOLT; in max77693_dt_init()
643 &chg->min_system_volt)) in max77693_dt_init()
644 chg->min_system_volt = DEFAULT_MIN_SYSTEM_VOLT; in max77693_dt_init()
647 &chg->thermal_regulation_temp)) in max77693_dt_init()
648 chg->thermal_regulation_temp = DEFAULT_THERMAL_REGULATION_TEMP; in max77693_dt_init()
651 &chg->batttery_overcurrent)) in max77693_dt_init()
652 chg->batttery_overcurrent = DEFAULT_BATTERY_OVERCURRENT; in max77693_dt_init()
655 &chg->charge_input_threshold_volt)) in max77693_dt_init()
656 chg->charge_input_threshold_volt = in max77693_dt_init()
662 static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) in max77693_dt_init() argument
670 struct max77693_charger *chg; in max77693_charger_probe() local
675 chg = devm_kzalloc(&pdev->dev, sizeof(*chg), GFP_KERNEL); in max77693_charger_probe()
676 if (!chg) in max77693_charger_probe()
679 platform_set_drvdata(pdev, chg); in max77693_charger_probe()
680 chg->dev = &pdev->dev; in max77693_charger_probe()
681 chg->max77693 = max77693; in max77693_charger_probe()
683 ret = max77693_dt_init(&pdev->dev, chg); in max77693_charger_probe()
687 ret = max77693_reg_init(chg); in max77693_charger_probe()
691 psy_cfg.drv_data = chg; in max77693_charger_probe()
712 chg->charger = power_supply_register(&pdev->dev, in max77693_charger_probe()
715 if (IS_ERR(chg->charger)) { in max77693_charger_probe()
717 ret = PTR_ERR(chg->charger); in max77693_charger_probe()
733 struct max77693_charger *chg = platform_get_drvdata(pdev); in max77693_charger_remove() local
739 power_supply_unregister(chg->charger); in max77693_charger_remove()