Lines Matching full:charger

3  * MP2629 battery charger driver
155 static int mp2629_read_adc(struct mp2629_charger *charger, in mp2629_read_adc() argument
162 ret = iio_read_channel_processed(charger->iiochan[ch], &chval); in mp2629_read_adc()
171 static int mp2629_get_prop(struct mp2629_charger *charger, in mp2629_get_prop() argument
178 ret = regmap_field_read(charger->regmap_fields[fld], &rval); in mp2629_get_prop()
187 static int mp2629_set_prop(struct mp2629_charger *charger, in mp2629_set_prop() argument
197 return regmap_field_write(charger->regmap_fields[fld], rval); in mp2629_set_prop()
200 static int mp2629_get_battery_capacity(struct mp2629_charger *charger, in mp2629_get_battery_capacity() argument
206 ret = mp2629_read_adc(charger, MP2629_BATT_VOLT, &vnow); in mp2629_get_battery_capacity()
210 ret = mp2629_get_prop(charger, CHARGE_VLIM, &vlim); in mp2629_get_battery_capacity()
224 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_battery_get_prop() local
230 ret = mp2629_read_adc(charger, MP2629_BATT_VOLT, val); in mp2629_charger_battery_get_prop()
234 ret = mp2629_read_adc(charger, MP2629_BATT_CURRENT, val); in mp2629_charger_battery_get_prop()
246 ret = mp2629_get_battery_capacity(charger, val); in mp2629_charger_battery_get_prop()
250 ret = mp2629_get_prop(charger, TERM_CURRENT, val); in mp2629_charger_battery_get_prop()
254 ret = mp2629_get_prop(charger, PRECHARGE, val); in mp2629_charger_battery_get_prop()
258 ret = mp2629_get_prop(charger, CHARGE_VLIM, val); in mp2629_charger_battery_get_prop()
262 ret = mp2629_get_prop(charger, CHARGE_ILIM, val); in mp2629_charger_battery_get_prop()
266 if (!charger->fault) in mp2629_charger_battery_get_prop()
268 if (MP2629_FAULT_BATTERY & charger->fault) in mp2629_charger_battery_get_prop()
270 else if (MP2629_FAULT_THERMAL & charger->fault) in mp2629_charger_battery_get_prop()
272 else if (MP2629_FAULT_INPUT & charger->fault) in mp2629_charger_battery_get_prop()
277 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_battery_get_prop()
296 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_battery_get_prop()
327 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_battery_set_prop() local
331 return mp2629_set_prop(charger, TERM_CURRENT, val); in mp2629_charger_battery_set_prop()
334 return mp2629_set_prop(charger, PRECHARGE, val); in mp2629_charger_battery_set_prop()
337 return mp2629_set_prop(charger, CHARGE_VLIM, val); in mp2629_charger_battery_set_prop()
340 return mp2629_set_prop(charger, CHARGE_ILIM, val); in mp2629_charger_battery_set_prop()
351 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_usb_get_prop() local
357 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_usb_get_prop()
365 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_usb_get_prop()
390 ret = mp2629_read_adc(charger, MP2629_INPUT_VOLT, val); in mp2629_charger_usb_get_prop()
394 ret = mp2629_read_adc(charger, MP2629_INPUT_CURRENT, val); in mp2629_charger_usb_get_prop()
398 ret = mp2629_get_prop(charger, INPUT_VLIM, val); in mp2629_charger_usb_get_prop()
402 ret = mp2629_get_prop(charger, INPUT_ILIM, val); in mp2629_charger_usb_get_prop()
416 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_usb_set_prop() local
420 return mp2629_set_prop(charger, INPUT_VLIM, val); in mp2629_charger_usb_set_prop()
423 return mp2629_set_prop(charger, INPUT_ILIM, val); in mp2629_charger_usb_set_prop()
448 struct mp2629_charger *charger = dev_id; in mp2629_irq_handler() local
452 mutex_lock(&charger->lock); in mp2629_irq_handler()
454 ret = regmap_read(charger->regmap, MP2629_REG_FAULT, &rval); in mp2629_irq_handler()
459 charger->fault = rval; in mp2629_irq_handler()
461 dev_err(charger->dev, "Battery fault OVP\n"); in mp2629_irq_handler()
463 dev_err(charger->dev, "Thermal shutdown fault\n"); in mp2629_irq_handler()
465 dev_err(charger->dev, "no input or input OVP\n"); in mp2629_irq_handler()
467 dev_err(charger->dev, "VIN overloaded\n"); in mp2629_irq_handler()
472 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_irq_handler()
477 power_supply_changed(charger->usb); in mp2629_irq_handler()
479 power_supply_changed(charger->battery); in mp2629_irq_handler()
482 mutex_unlock(&charger->lock); in mp2629_irq_handler()
513 struct mp2629_charger *charger = dev_get_drvdata(dev->parent); in batt_impedance_compensation_show() local
517 ret = regmap_read(charger->regmap, MP2629_REG_IMPEDANCE_COMP, &rval); in batt_impedance_compensation_show()
530 struct mp2629_charger *charger = dev_get_drvdata(dev->parent); in batt_impedance_compensation_store() local
543 ret = regmap_update_bits(charger->regmap, MP2629_REG_IMPEDANCE_COMP, in batt_impedance_compensation_store()
561 struct mp2629_charger *charger = data; in mp2629_charger_disable() local
563 regmap_update_bits(charger->regmap, MP2629_REG_CHARGE_CTRL, in mp2629_charger_disable()
571 struct mp2629_charger *charger; in mp2629_charger_probe() local
575 charger = devm_kzalloc(dev, sizeof(*charger), GFP_KERNEL); in mp2629_charger_probe()
576 if (!charger) in mp2629_charger_probe()
579 charger->regmap = ddata->regmap; in mp2629_charger_probe()
580 charger->dev = dev; in mp2629_charger_probe()
581 platform_set_drvdata(pdev, charger); in mp2629_charger_probe()
590 charger->regmap_fields[i] = devm_regmap_field_alloc(dev, in mp2629_charger_probe()
591 charger->regmap, mp2629_reg_fields[i]); in mp2629_charger_probe()
592 if (IS_ERR(charger->regmap_fields[i])) { in mp2629_charger_probe()
594 return PTR_ERR(charger->regmap_fields[i]); in mp2629_charger_probe()
599 charger->iiochan[i] = devm_iio_channel_get(dev, in mp2629_charger_probe()
601 if (IS_ERR(charger->iiochan[i])) { in mp2629_charger_probe()
603 return PTR_ERR(charger->iiochan[i]); in mp2629_charger_probe()
607 ret = devm_add_action_or_reset(dev, mp2629_charger_disable, charger); in mp2629_charger_probe()
611 charger->usb = devm_power_supply_register(dev, &mp2629_usb_desc, NULL); in mp2629_charger_probe()
612 if (IS_ERR(charger->usb)) { in mp2629_charger_probe()
614 return PTR_ERR(charger->usb); in mp2629_charger_probe()
617 psy_cfg.drv_data = charger; in mp2629_charger_probe()
619 charger->battery = devm_power_supply_register(dev, in mp2629_charger_probe()
621 if (IS_ERR(charger->battery)) { in mp2629_charger_probe()
623 return PTR_ERR(charger->battery); in mp2629_charger_probe()
626 ret = regmap_update_bits(charger->regmap, MP2629_REG_CHARGE_CTRL, in mp2629_charger_probe()
633 regmap_update_bits(charger->regmap, MP2629_REG_TIMER_CTRL, in mp2629_charger_probe()
636 mutex_init(&charger->lock); in mp2629_charger_probe()
640 "mp2629-charger", charger); in mp2629_charger_probe()
646 regmap_update_bits(charger->regmap, MP2629_REG_INTERRUPT, in mp2629_charger_probe()
668 MODULE_DESCRIPTION("MP2629 Charger driver");