Lines Matching full:charger

3  * Battery charger driver for RT5033
31 static int rt5033_get_charger_state(struct rt5033_charger *charger) in rt5033_get_charger_state() argument
33 struct regmap *regmap = charger->regmap; in rt5033_get_charger_state()
62 static int rt5033_get_charger_type(struct rt5033_charger *charger) in rt5033_get_charger_type() argument
64 struct regmap *regmap = charger->regmap; in rt5033_get_charger_type()
84 static int rt5033_get_charger_current_limit(struct rt5033_charger *charger) in rt5033_get_charger_current_limit() argument
86 struct regmap *regmap = charger->regmap; in rt5033_get_charger_current_limit()
100 static int rt5033_get_charger_const_voltage(struct rt5033_charger *charger) in rt5033_get_charger_const_voltage() argument
102 struct regmap *regmap = charger->regmap; in rt5033_get_charger_const_voltage()
116 static inline int rt5033_init_const_charge(struct rt5033_charger *charger) in rt5033_init_const_charge() argument
118 struct rt5033_charger_data *chg = charger->chg; in rt5033_init_const_charge()
126 dev_err(charger->dev, in rt5033_init_const_charge()
142 ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL2, in rt5033_init_const_charge()
146 dev_err(charger->dev, "Failed regmap update\n"); in rt5033_init_const_charge()
153 dev_err(charger->dev, in rt5033_init_const_charge()
177 ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL4, in rt5033_init_const_charge()
180 dev_err(charger->dev, "Failed regmap update\n"); in rt5033_init_const_charge()
187 static inline int rt5033_init_fast_charge(struct rt5033_charger *charger) in rt5033_init_fast_charge() argument
189 struct rt5033_charger_data *chg = charger->chg; in rt5033_init_fast_charge()
195 ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL1, in rt5033_init_fast_charge()
198 dev_err(charger->dev, "Failed regmap update\n"); in rt5033_init_fast_charge()
205 dev_err(charger->dev, in rt5033_init_fast_charge()
221 ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL5, in rt5033_init_fast_charge()
225 dev_err(charger->dev, "Failed regmap update\n"); in rt5033_init_fast_charge()
232 static inline int rt5033_init_pre_charge(struct rt5033_charger *charger) in rt5033_init_pre_charge() argument
234 struct rt5033_charger_data *chg = charger->chg; in rt5033_init_pre_charge()
242 dev_err(charger->dev, in rt5033_init_pre_charge()
258 ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL5, in rt5033_init_pre_charge()
261 dev_err(charger->dev, "Failed regmap update\n"); in rt5033_init_pre_charge()
268 dev_err(charger->dev, in rt5033_init_pre_charge()
284 ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL4, in rt5033_init_pre_charge()
288 dev_err(charger->dev, "Failed regmap update\n"); in rt5033_init_pre_charge()
295 static int rt5033_charger_reg_init(struct rt5033_charger *charger) in rt5033_charger_reg_init() argument
300 ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL1, in rt5033_charger_reg_init()
303 dev_err(charger->dev, "Failed to enable charging termination.\n"); in rt5033_charger_reg_init()
311 ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL4, in rt5033_charger_reg_init()
314 dev_err(charger->dev, "Failed to disable MIVR.\n"); in rt5033_charger_reg_init()
318 ret = rt5033_init_pre_charge(charger); in rt5033_charger_reg_init()
322 ret = rt5033_init_fast_charge(charger); in rt5033_charger_reg_init()
326 ret = rt5033_init_const_charge(charger); in rt5033_charger_reg_init()
347 struct rt5033_charger *charger = power_supply_get_drvdata(psy); in rt5033_charger_get_property() local
351 val->intval = rt5033_get_charger_state(charger); in rt5033_charger_get_property()
354 val->intval = rt5033_get_charger_type(charger); in rt5033_charger_get_property()
357 val->intval = rt5033_get_charger_current_limit(charger); in rt5033_charger_get_property()
360 val->intval = rt5033_get_charger_const_voltage(charger); in rt5033_charger_get_property()
369 val->intval = (rt5033_get_charger_state(charger) == in rt5033_charger_get_property()
380 struct rt5033_charger *charger) in rt5033_charger_dt_init() argument
386 chg = devm_kzalloc(charger->dev, sizeof(*chg), GFP_KERNEL); in rt5033_charger_dt_init()
390 ret = power_supply_get_battery_info(charger->psy, &info); in rt5033_charger_dt_init()
392 return ERR_PTR(dev_err_probe(charger->dev, -EINVAL, in rt5033_charger_dt_init()
406 .name = "rt5033-charger",
415 struct rt5033_charger *charger; in rt5033_charger_probe() local
419 charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL); in rt5033_charger_probe()
420 if (!charger) in rt5033_charger_probe()
423 platform_set_drvdata(pdev, charger); in rt5033_charger_probe()
424 charger->dev = &pdev->dev; in rt5033_charger_probe()
425 charger->regmap = dev_get_regmap(pdev->dev.parent, NULL); in rt5033_charger_probe()
428 psy_cfg.drv_data = charger; in rt5033_charger_probe()
430 charger->psy = devm_power_supply_register(&pdev->dev, in rt5033_charger_probe()
433 if (IS_ERR(charger->psy)) in rt5033_charger_probe()
434 return dev_err_probe(&pdev->dev, PTR_ERR(charger->psy), in rt5033_charger_probe()
437 charger->chg = rt5033_charger_dt_init(charger); in rt5033_charger_probe()
438 if (IS_ERR_OR_NULL(charger->chg)) in rt5033_charger_probe()
439 return PTR_ERR(charger->chg); in rt5033_charger_probe()
441 ret = rt5033_charger_reg_init(charger); in rt5033_charger_probe()
449 { "rt5033-charger", },
455 { .compatible = "richtek,rt5033-charger", },
462 .name = "rt5033-charger",
470 MODULE_DESCRIPTION("Richtek RT5033 charger driver");