Lines Matching full:charger

3  * MP2629 battery charger driver
147 static int mp2629_read_adc(struct mp2629_charger *charger, in mp2629_read_adc() argument
154 ret = iio_read_channel_processed(charger->iiochan[ch], &chval); in mp2629_read_adc()
163 static int mp2629_get_prop(struct mp2629_charger *charger, in mp2629_get_prop() argument
170 ret = regmap_field_read(charger->regmap_fields[fld], &rval); in mp2629_get_prop()
179 static int mp2629_set_prop(struct mp2629_charger *charger, in mp2629_set_prop() argument
189 return regmap_field_write(charger->regmap_fields[fld], rval); in mp2629_set_prop()
192 static int mp2629_get_battery_capacity(struct mp2629_charger *charger, in mp2629_get_battery_capacity() argument
198 ret = mp2629_read_adc(charger, MP2629_BATT_VOLT, &vnow); in mp2629_get_battery_capacity()
202 ret = mp2629_get_prop(charger, CHARGE_VLIM, &vlim); in mp2629_get_battery_capacity()
216 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_battery_get_prop() local
222 ret = mp2629_read_adc(charger, MP2629_BATT_VOLT, val); in mp2629_charger_battery_get_prop()
226 ret = mp2629_read_adc(charger, MP2629_BATT_CURRENT, val); in mp2629_charger_battery_get_prop()
238 ret = mp2629_get_battery_capacity(charger, val); in mp2629_charger_battery_get_prop()
242 ret = mp2629_get_prop(charger, TERM_CURRENT, val); in mp2629_charger_battery_get_prop()
246 ret = mp2629_get_prop(charger, PRECHARGE, val); in mp2629_charger_battery_get_prop()
250 ret = mp2629_get_prop(charger, CHARGE_VLIM, val); in mp2629_charger_battery_get_prop()
254 ret = mp2629_get_prop(charger, CHARGE_ILIM, val); in mp2629_charger_battery_get_prop()
258 if (!charger->fault) in mp2629_charger_battery_get_prop()
260 if (MP2629_FAULT_BATTERY & charger->fault) in mp2629_charger_battery_get_prop()
262 else if (MP2629_FAULT_THERMAL & charger->fault) in mp2629_charger_battery_get_prop()
264 else if (MP2629_FAULT_INPUT & charger->fault) in mp2629_charger_battery_get_prop()
269 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_battery_get_prop()
288 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_battery_get_prop()
319 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_battery_set_prop() local
323 return mp2629_set_prop(charger, TERM_CURRENT, val); in mp2629_charger_battery_set_prop()
326 return mp2629_set_prop(charger, PRECHARGE, val); in mp2629_charger_battery_set_prop()
329 return mp2629_set_prop(charger, CHARGE_VLIM, val); in mp2629_charger_battery_set_prop()
332 return mp2629_set_prop(charger, CHARGE_ILIM, val); in mp2629_charger_battery_set_prop()
343 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_usb_get_prop() local
349 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_usb_get_prop()
357 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_usb_get_prop()
382 ret = mp2629_read_adc(charger, MP2629_INPUT_VOLT, val); in mp2629_charger_usb_get_prop()
386 ret = mp2629_read_adc(charger, MP2629_INPUT_CURRENT, val); in mp2629_charger_usb_get_prop()
390 ret = mp2629_get_prop(charger, INPUT_VLIM, val); in mp2629_charger_usb_get_prop()
394 ret = mp2629_get_prop(charger, INPUT_ILIM, val); in mp2629_charger_usb_get_prop()
408 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_usb_set_prop() local
412 return mp2629_set_prop(charger, INPUT_VLIM, val); in mp2629_charger_usb_set_prop()
415 return mp2629_set_prop(charger, INPUT_ILIM, val); in mp2629_charger_usb_set_prop()
440 struct mp2629_charger *charger = dev_id; in mp2629_irq_handler() local
444 mutex_lock(&charger->lock); in mp2629_irq_handler()
446 ret = regmap_read(charger->regmap, MP2629_REG_FAULT, &rval); in mp2629_irq_handler()
451 charger->fault = rval; in mp2629_irq_handler()
453 dev_err(charger->dev, "Battery fault OVP\n"); in mp2629_irq_handler()
455 dev_err(charger->dev, "Thermal shutdown fault\n"); in mp2629_irq_handler()
457 dev_err(charger->dev, "no input or input OVP\n"); in mp2629_irq_handler()
459 dev_err(charger->dev, "VIN overloaded\n"); in mp2629_irq_handler()
464 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_irq_handler()
469 power_supply_changed(charger->usb); in mp2629_irq_handler()
471 power_supply_changed(charger->battery); in mp2629_irq_handler()
474 mutex_unlock(&charger->lock); in mp2629_irq_handler()
508 struct mp2629_charger *charger = dev_get_drvdata(dev->parent); in batt_impedance_compensation_show() local
512 ret = regmap_read(charger->regmap, MP2629_REG_IMPEDANCE_COMP, &rval); in batt_impedance_compensation_show()
525 struct mp2629_charger *charger = dev_get_drvdata(dev->parent); in batt_impedance_compensation_store() local
538 ret = regmap_update_bits(charger->regmap, MP2629_REG_IMPEDANCE_COMP, in batt_impedance_compensation_store()
556 struct mp2629_charger *charger = data; in mp2629_charger_disable() local
558 regmap_update_bits(charger->regmap, MP2629_REG_CHARGE_CTRL, in mp2629_charger_disable()
566 struct mp2629_charger *charger; in mp2629_charger_probe() local
570 charger = devm_kzalloc(dev, sizeof(*charger), GFP_KERNEL); in mp2629_charger_probe()
571 if (!charger) in mp2629_charger_probe()
574 charger->regmap = ddata->regmap; in mp2629_charger_probe()
575 charger->dev = dev; in mp2629_charger_probe()
576 platform_set_drvdata(pdev, charger); in mp2629_charger_probe()
583 charger->regmap_fields[i] = devm_regmap_field_alloc(dev, in mp2629_charger_probe()
584 charger->regmap, mp2629_reg_fields[i]); in mp2629_charger_probe()
585 if (IS_ERR(charger->regmap_fields[i])) { in mp2629_charger_probe()
587 return PTR_ERR(charger->regmap_fields[i]); in mp2629_charger_probe()
592 charger->iiochan[i] = devm_iio_channel_get(dev, in mp2629_charger_probe()
594 if (IS_ERR(charger->iiochan[i])) { in mp2629_charger_probe()
596 return PTR_ERR(charger->iiochan[i]); in mp2629_charger_probe()
600 ret = devm_add_action_or_reset(dev, mp2629_charger_disable, charger); in mp2629_charger_probe()
604 charger->usb = devm_power_supply_register(dev, &mp2629_usb_desc, NULL); in mp2629_charger_probe()
605 if (IS_ERR(charger->usb)) { in mp2629_charger_probe()
607 return PTR_ERR(charger->usb); in mp2629_charger_probe()
610 psy_cfg.drv_data = charger; in mp2629_charger_probe()
612 charger->battery = devm_power_supply_register(dev, in mp2629_charger_probe()
614 if (IS_ERR(charger->battery)) { in mp2629_charger_probe()
616 return PTR_ERR(charger->battery); in mp2629_charger_probe()
619 ret = regmap_update_bits(charger->regmap, MP2629_REG_CHARGE_CTRL, in mp2629_charger_probe()
626 regmap_update_bits(charger->regmap, MP2629_REG_TIMER_CTRL, in mp2629_charger_probe()
629 mutex_init(&charger->lock); in mp2629_charger_probe()
633 "mp2629-charger", charger); in mp2629_charger_probe()
639 regmap_update_bits(charger->regmap, MP2629_REG_INTERRUPT, in mp2629_charger_probe()
661 MODULE_DESCRIPTION("MP2629 Charger driver");