Lines Matching +full:ovp +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-or-later
140 "mp2629-batt-volt",
141 "mp2629-system-volt",
142 "mp2629-input-volt",
143 "mp2629-batt-current",
144 "mp2629-input-current",
154 ret = iio_read_channel_processed(charger->iiochan[ch], &chval); in mp2629_read_adc()
158 val->intval = chval * 1000; in mp2629_read_adc()
170 ret = regmap_field_read(charger->regmap_fields[fld], &rval); in mp2629_get_prop()
174 val->intval = rval * props[fld].step + props[fld].min; in mp2629_get_prop()
185 if (val->intval < props[fld].min || val->intval > props[fld].max) in mp2629_set_prop()
186 return -EINVAL; in mp2629_set_prop()
188 rval = (val->intval - props[fld].min) / props[fld].step; in mp2629_set_prop()
189 return regmap_field_write(charger->regmap_fields[fld], rval); in mp2629_set_prop()
206 val->intval = (vnow.intval * 100) / vlim.intval; in mp2629_get_battery_capacity()
207 val->intval = min(val->intval, MP2629_MAX_BATT_CAPACITY); in mp2629_get_battery_capacity()
216 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_battery_get_prop()
230 val->intval = 4520000; in mp2629_charger_battery_get_prop()
234 val->intval = 4670000; in mp2629_charger_battery_get_prop()
258 if (!charger->fault) in mp2629_charger_battery_get_prop()
259 val->intval = POWER_SUPPLY_HEALTH_GOOD; in mp2629_charger_battery_get_prop()
260 if (MP2629_FAULT_BATTERY & charger->fault) in mp2629_charger_battery_get_prop()
261 val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; in mp2629_charger_battery_get_prop()
262 else if (MP2629_FAULT_THERMAL & charger->fault) in mp2629_charger_battery_get_prop()
263 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; in mp2629_charger_battery_get_prop()
264 else if (MP2629_FAULT_INPUT & charger->fault) in mp2629_charger_battery_get_prop()
265 val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; in mp2629_charger_battery_get_prop()
269 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_battery_get_prop()
276 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in mp2629_charger_battery_get_prop()
280 val->intval = POWER_SUPPLY_STATUS_CHARGING; in mp2629_charger_battery_get_prop()
283 val->intval = POWER_SUPPLY_STATUS_FULL; in mp2629_charger_battery_get_prop()
288 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_battery_get_prop()
295 val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; in mp2629_charger_battery_get_prop()
298 val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; in mp2629_charger_battery_get_prop()
301 val->intval = POWER_SUPPLY_CHARGE_TYPE_STANDARD; in mp2629_charger_battery_get_prop()
304 val->intval = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; in mp2629_charger_battery_get_prop()
309 return -EINVAL; in mp2629_charger_battery_get_prop()
319 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_battery_set_prop()
335 return -EINVAL; in mp2629_charger_battery_set_prop()
343 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_usb_get_prop()
349 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_usb_get_prop()
353 val->intval = !!(rval & MP2629_MASK_INPUT_TYPE); in mp2629_charger_usb_get_prop()
357 ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); in mp2629_charger_usb_get_prop()
364 val->intval = POWER_SUPPLY_USB_TYPE_SDP; in mp2629_charger_usb_get_prop()
367 val->intval = POWER_SUPPLY_USB_TYPE_CDP; in mp2629_charger_usb_get_prop()
370 val->intval = POWER_SUPPLY_USB_TYPE_DCP; in mp2629_charger_usb_get_prop()
373 val->intval = POWER_SUPPLY_USB_TYPE_PD_DRP; in mp2629_charger_usb_get_prop()
376 val->intval = POWER_SUPPLY_USB_TYPE_UNKNOWN; in mp2629_charger_usb_get_prop()
398 return -EINVAL; in mp2629_charger_usb_get_prop()
408 struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); in mp2629_charger_usb_set_prop()
418 return -EINVAL; in mp2629_charger_usb_set_prop()
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()
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()
534 return -ERANGE; in batt_impedance_compensation_store()
538 ret = regmap_update_bits(charger->regmap, MP2629_REG_IMPEDANCE_COMP, in batt_impedance_compensation_store()
558 regmap_update_bits(charger->regmap, MP2629_REG_CHARGE_CTRL, in mp2629_charger_disable()
564 struct device *dev = &pdev->dev; in mp2629_charger_probe()
565 struct mp2629_data *ddata = dev_get_drvdata(dev->parent); in mp2629_charger_probe()
572 return -ENOMEM; in mp2629_charger_probe()
574 charger->regmap = ddata->regmap; in mp2629_charger_probe()
575 charger->dev = dev; in mp2629_charger_probe()
578 irq = platform_get_irq(to_platform_device(dev->parent), 0); 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()
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()
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()
622 dev_err(dev, "enable charge fail: %d\n", ret); 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()