Lines Matching +full:fuel +full:- +full:gauge
1 // SPDX-License-Identifier: GPL-2.0+
86 ret = regmap_bulk_read(info->rn5t618->regmap, in rn5t618_battery_read_doublereg()
131 ret = regmap_read(info->rn5t618->regmap, RN5T618_CHGSTATE, &v); in rn5t618_battery_status()
135 val->intval = POWER_SUPPLY_STATUS_UNKNOWN; in rn5t618_battery_status()
138 val->intval = rn5t618_decode_status(v); in rn5t618_battery_status()
140 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in rn5t618_battery_status()
151 ret = regmap_read(info->rn5t618->regmap, RN5T618_CHGSTATE, &v); in rn5t618_battery_present()
157 val->intval = 0; in rn5t618_battery_present()
159 val->intval = 1; in rn5t618_battery_present()
174 val->intval = res * 2 * 2500 / 4095 * 1000; in rn5t618_battery_voltage_now()
190 val->intval = sign_extend32(res, 13) * 1000; in rn5t618_battery_current_now()
201 ret = regmap_read(info->rn5t618->regmap, RN5T618_SOC, &v); in rn5t618_battery_capacity()
205 val->intval = v; in rn5t618_battery_capacity()
220 val->intval = sign_extend32(res, 11) * 10 / 16; in rn5t618_battery_temp()
236 return -ENODATA; in rn5t618_battery_tte()
238 val->intval = res * 60; in rn5t618_battery_tte()
254 return -ENODATA; in rn5t618_battery_ttf()
256 val->intval = res * 60; in rn5t618_battery_ttf()
271 val->intval = res * 1000; in rn5t618_battery_charge_full()
286 val->intval = res * 1000; in rn5t618_battery_charge_now()
324 val->intval = POWER_SUPPLY_TECHNOLOGY_LION; in rn5t618_battery_get_property()
333 return -EINVAL; in rn5t618_battery_get_property()
348 ret = regmap_read(info->rn5t618->regmap, RN5T618_CHGSTATE, &chgstate); in rn5t618_adp_get_property()
356 val->intval = online; in rn5t618_adp_get_property()
360 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in rn5t618_adp_get_property()
363 val->intval = rn5t618_decode_status(chgstate); in rn5t618_adp_get_property()
364 if (val->intval != POWER_SUPPLY_STATUS_CHARGING) in rn5t618_adp_get_property()
365 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in rn5t618_adp_get_property()
369 return -EINVAL; in rn5t618_adp_get_property()
384 ret = regmap_read(info->rn5t618->regmap, RN5T618_CHGSTATE, &chgstate); in rn5t618_usb_get_property()
392 val->intval = online; in rn5t618_usb_get_property()
396 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in rn5t618_usb_get_property()
399 val->intval = rn5t618_decode_status(chgstate); in rn5t618_usb_get_property()
400 if (val->intval != POWER_SUPPLY_STATUS_CHARGING) in rn5t618_usb_get_property()
401 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in rn5t618_usb_get_property()
405 return -EINVAL; in rn5t618_usb_get_property()
412 .name = "rn5t618-battery",
420 .name = "rn5t618-adp",
428 .name = "rn5t618-usb",
442 regmap_read(info->rn5t618->regmap, RN5T618_CHGERR_IRR, &err); in rn5t618_charger_irq()
443 regmap_read(info->rn5t618->regmap, RN5T618_CHGCTRL_IRR, &ctrl); in rn5t618_charger_irq()
444 regmap_read(info->rn5t618->regmap, RN5T618_CHGSTAT_IRR1, &stat1); in rn5t618_charger_irq()
445 regmap_read(info->rn5t618->regmap, RN5T618_CHGSTAT_IRR2, &stat2); in rn5t618_charger_irq()
447 regmap_write(info->rn5t618->regmap, RN5T618_CHGERR_IRR, 0); in rn5t618_charger_irq()
448 regmap_write(info->rn5t618->regmap, RN5T618_CHGCTRL_IRR, 0); in rn5t618_charger_irq()
449 regmap_write(info->rn5t618->regmap, RN5T618_CHGSTAT_IRR1, 0); in rn5t618_charger_irq()
450 regmap_write(info->rn5t618->regmap, RN5T618_CHGSTAT_IRR2, 0); in rn5t618_charger_irq()
455 power_supply_changed(info->usb); in rn5t618_charger_irq()
456 power_supply_changed(info->adp); in rn5t618_charger_irq()
457 power_supply_changed(info->battery); in rn5t618_charger_irq()
469 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in rn5t618_power_probe()
471 return -ENOMEM; in rn5t618_power_probe()
473 info->pdev = pdev; in rn5t618_power_probe()
474 info->rn5t618 = dev_get_drvdata(pdev->dev.parent); in rn5t618_power_probe()
475 info->irq = -1; in rn5t618_power_probe()
479 ret = regmap_read(info->rn5t618->regmap, RN5T618_CONTROL, &v); in rn5t618_power_probe()
485 * readers disable the fuel gauge on shutdown. If a kernel in rn5t618_power_probe()
486 * without fuel gauge support is booted after that, the fuel in rn5t618_power_probe()
487 * gauge will get decalibrated. in rn5t618_power_probe()
489 dev_info(&pdev->dev, "Fuel gauge not enabled, enabling now\n"); in rn5t618_power_probe()
490 dev_info(&pdev->dev, "Expect imprecise results\n"); in rn5t618_power_probe()
491 regmap_update_bits(info->rn5t618->regmap, RN5T618_CONTROL, in rn5t618_power_probe()
496 info->battery = devm_power_supply_register(&pdev->dev, in rn5t618_power_probe()
499 if (IS_ERR(info->battery)) { in rn5t618_power_probe()
500 ret = PTR_ERR(info->battery); in rn5t618_power_probe()
501 dev_err(&pdev->dev, "failed to register battery: %d\n", ret); in rn5t618_power_probe()
505 info->adp = devm_power_supply_register(&pdev->dev, in rn5t618_power_probe()
508 if (IS_ERR(info->adp)) { in rn5t618_power_probe()
509 ret = PTR_ERR(info->adp); in rn5t618_power_probe()
510 dev_err(&pdev->dev, "failed to register adp: %d\n", ret); in rn5t618_power_probe()
514 info->usb = devm_power_supply_register(&pdev->dev, in rn5t618_power_probe()
517 if (IS_ERR(info->usb)) { in rn5t618_power_probe()
518 ret = PTR_ERR(info->usb); in rn5t618_power_probe()
519 dev_err(&pdev->dev, "failed to register usb: %d\n", ret); in rn5t618_power_probe()
523 if (info->rn5t618->irq_data) in rn5t618_power_probe()
524 info->irq = regmap_irq_get_virq(info->rn5t618->irq_data, in rn5t618_power_probe()
527 if (info->irq < 0) in rn5t618_power_probe()
528 info->irq = -1; in rn5t618_power_probe()
530 ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, in rn5t618_power_probe()
534 &pdev->dev); in rn5t618_power_probe()
537 dev_err(&pdev->dev, "request IRQ:%d fail\n", in rn5t618_power_probe()
538 info->irq); in rn5t618_power_probe()
539 info->irq = -1; in rn5t618_power_probe()
548 .name = "rn5t618-power",
554 MODULE_ALIAS("platform:rn5t618-power");