From: "André Draszik" <andre.draszik@linaro.org>
To: Hans de Goede <hansg@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>,
Purism Kernel Team <kernel@puri.sm>,
Sebastian Reichel <sre@kernel.org>,
Rob Herring <robh@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: "Peter Griffin" <peter.griffin@linaro.org>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>,
"Juan Yescas" <jyescas@google.com>,
"Amit Sunil Dhamne" <amitsd@google.com>,
kernel-team@android.com, linux-pm@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
"André Draszik" <andre.draszik@linaro.org>
Subject: [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759)
Date: Fri, 27 Feb 2026 07:15:16 +0000 [thread overview]
Message-ID: <20260227-max77759-fg-v2-11-e50be5f191f0@linaro.org> (raw)
In-Reply-To: <20260227-max77759-fg-v2-0-e50be5f191f0@linaro.org>
Report the remaining time to full as calculated by the firmware for
devices that implement this.
Similar to time to empty, the reported value is only meaningful when
charging, i.e. if it is != U16_MAX.
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
v2:
- limit to max17055 & max77759, the datasheet for max17047 and max17050
describes the register as 'reserved'. I was mislead by the comment
and enum ordering in max17042_battery.h
- report as POWER_SUPPLY_PROP_TIME_TO_FULL_NOW (not _AVG). The max17050
datasheet is a bit clearer than the max77759 one on that.
---
drivers/power/supply/max17042_battery.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 89909b140cf9..770d806033b9 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -89,6 +89,7 @@ static enum power_supply_property max17042_battery_props[] = {
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_SCOPE,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
+ POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
// these two have to be at the end on the list
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_CURRENT_AVG,
@@ -447,6 +448,21 @@ static int max17042_get_property(struct power_supply *psy,
if (data == U16_MAX)
return -ENODATA;
+ val->intval = data * 5625 / 1000;
+ break;
+ case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
+ if (chip->chip_type != MAXIM_DEVICE_TYPE_MAX17055 &&
+ chip->chip_type != MAXIM_DEVICE_TYPE_MAX77759)
+ return -EINVAL;
+
+ ret = regmap_read(map, MAX17055_TTF, &data);
+ if (ret < 0)
+ return ret;
+
+ /* when discharging, the value is not meaningful */
+ if (data == U16_MAX)
+ return -ENODATA;
+
val->intval = data * 5625 / 1000;
break;
default:
--
2.53.0.473.g4a7958ca14-goog
next prev parent reply other threads:[~2026-02-27 7:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
2026-02-27 7:15 ` [PATCH v2 01/11] dt-bindings: power: supply: max17042: add support for max77759 André Draszik
2026-02-27 7:15 ` [PATCH v2 02/11] dt-bindings: power: supply: max17042: support shunt-resistor-micro-ohms André Draszik
2026-02-27 7:15 ` [PATCH v2 03/11] dt-bindings: power: supply: max17042: drop formatting specifier | André Draszik
2026-02-27 7:15 ` [PATCH v2 04/11] power: supply: max17042: fix a comment typo (then -> than) André Draszik
2026-02-27 7:15 ` [PATCH v2 05/11] power: supply: max17042: use dev_err_probe() where appropriate André Draszik
2026-02-27 7:15 ` [PATCH v2 06/11] power: supply: max17042: avoid overflow when determining health André Draszik
2026-02-27 7:15 ` [PATCH v2 07/11] power: supply: max17042: time to empty is meaningless when charging André Draszik
2026-02-27 16:47 ` Peter Griffin
2026-02-27 7:15 ` [PATCH v2 08/11] power: supply: max17042: support standard shunt-resistor-micro-ohms DT property André Draszik
2026-02-27 16:07 ` Peter Griffin
2026-02-27 7:15 ` [PATCH v2 09/11] power: supply: max17042: initial support for Maxim MAX77759 André Draszik
2026-02-27 17:00 ` Peter Griffin
2026-02-27 7:15 ` [PATCH v2 10/11] power: supply: max17042: consider task period (max77759) André Draszik
2026-02-27 17:01 ` Peter Griffin
2026-02-27 7:15 ` André Draszik [this message]
2026-02-27 16:53 ` [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759) Peter Griffin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260227-max77759-fg-v2-11-e50be5f191f0@linaro.org \
--to=andre.draszik@linaro.org \
--cc=amitsd@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hansg@kernel.org \
--cc=jyescas@google.com \
--cc=kernel-team@android.com \
--cc=kernel@puri.sm \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=peter.griffin@linaro.org \
--cc=robh@kernel.org \
--cc=sebastian.krzyszkowiak@puri.sm \
--cc=sre@kernel.org \
--cc=tudor.ambarus@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®