mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge
@ 2026-02-27  7:15 André Draszik
  2026-02-27  7:15 ` [PATCH v2 01/11] dt-bindings: power: supply: max17042: add support for max77759 André Draszik
                   ` (10 more replies)
  0 siblings, 11 replies; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik, Conor Dooley

Hi,

This series adds support for the fuel gauge integrated into the Maxim
MAX77759, which is a companion PMIC intended for use in mobile phones
and tablets and is used on Google Pixel 6 and 6 Pro (oriole and raven).

Amongst others, the PMIC contains a fuel gauge employing the Maxim
ModelGauge m5 algorithm, that is similar to the ones supported by the
max17042 driver and binding.

The Maxim ModelGauge m5 algorithm, as well as previous generations like
m3 on max17047/max17050, requires the host to save/restore some
register values across power cycles to maintain full accuracy.
Extending the driver for such support is out of scope in this initial
series.

The series starts with binding updates, followed by driver updates and
improvements in preparation for finally adding max77759 support.

A DT update for Pixel 6 will be posted separately.

Note: While there was a previous attempt to add support for this fuel
gauge via a new driver [1], development seems to have come to a halt,
and extending this driver here seems more appropriate. The patches here
are unrelated to that other attempt, other than supporting the same
device.

Test results:
    $ ./test_power_supply_properties.sh max170xx_battery
    TAP version 13
    1..33
    # Testing device max170xx_battery
    ok 1 max170xx_battery.exists
    ok 2 max170xx_battery.uevent.NAME
    ok 3 max170xx_battery.sysfs.type
    ok 4 max170xx_battery.uevent.TYPE
    ok 5 max170xx_battery.sysfs.usb_type # SKIP
    ok 6 max170xx_battery.sysfs.online # SKIP
    # Reported: '1' ()
    ok 7 max170xx_battery.sysfs.present
    # Reported: 'Unknown'
    ok 8 max170xx_battery.sysfs.status
    # Reported: '92' % ()
    ok 9 max170xx_battery.sysfs.capacity
    ok 10 max170xx_battery.sysfs.capacity_level # SKIP
    ok 11 max170xx_battery.sysfs.model_name # SKIP
    ok 12 max170xx_battery.sysfs.manufacturer # SKIP
    ok 13 max170xx_battery.sysfs.serial_number # SKIP
    # Reported: 'Li-ion'
    ok 14 max170xx_battery.sysfs.technology
    # Reported: '36032' ()
    ok 15 max170xx_battery.sysfs.cycle_count
    # Reported: 'System'
    ok 16 max170xx_battery.sysfs.scope
    ok 17 max170xx_battery.sysfs.input_current_limit # SKIP
    ok 18 max170xx_battery.sysfs.input_voltage_limit # SKIP
    # Reported: '4323906' uV (4.32391 V)
    ok 19 max170xx_battery.sysfs.voltage_now
    # Reported: '3660000' uV (3.66 V)
    ok 20 max170xx_battery.sysfs.voltage_min
    # Reported: '4320000' uV (4.32 V)
    ok 21 max170xx_battery.sysfs.voltage_max
    # Reported: '3300000' uV (3.3 V)
    ok 22 max170xx_battery.sysfs.voltage_min_design
    ok 23 max170xx_battery.sysfs.voltage_max_design # SKIP
    # Reported: '289687' uA (289.687 mA)
    ok 24 max170xx_battery.sysfs.current_now
    ok 25 max170xx_battery.sysfs.current_max # SKIP
    # Reported: '3942000' uAh (3.942 Ah)
    ok 26 max170xx_battery.sysfs.charge_now
    # Reported: '4330000' uAh (4.33 Ah)
    ok 27 max170xx_battery.sysfs.charge_full
    # Reported: '4524000' uAh (4.524 Ah)
    ok 28 max170xx_battery.sysfs.charge_full_design
    ok 29 max170xx_battery.sysfs.power_now # SKIP
    ok 30 max170xx_battery.sysfs.energy_now # SKIP
    ok 31 max170xx_battery.sysfs.energy_full # SKIP
    ok 32 max170xx_battery.sysfs.energy_full_design # SKIP
    ok 33 max170xx_battery.sysfs.energy_full_design # SKIP
    # 15 skipped test(s) detected.  Consider enabling relevant config options to improve coverage.
    # Totals: pass:18 fail:0 xfail:0 xpass:0 skip:15 error:0

Cheers,
Andre'

Link: https://lore.kernel.org/all/20250915-b4-gs101_max77759_fg-v6-0-31d08581500f@uclouvain.be/ [1]
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
Changes in v2:
- collect tags
- update commit message subject prefix of patch 10 to avoid duplication
- patch 11 (time to full reporting):
  - 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.
- Link to v1: https://lore.kernel.org/r/20260226-max77759-fg-v1-0-ff0a08a70a9f@linaro.org

---
André Draszik (11):
      dt-bindings: power: supply: max17042: add support for max77759
      dt-bindings: power: supply: max17042: support shunt-resistor-micro-ohms
      dt-bindings: power: supply: max17042: drop formatting specifier |
      power: supply: max17042: fix a comment typo (then -> than)
      power: supply: max17042: use dev_err_probe() where appropriate
      power: supply: max17042: avoid overflow when determining health
      power: supply: max17042: time to empty is meaningless when charging
      power: supply: max17042: support standard shunt-resistor-micro-ohms DT property
      power: supply: max17042: initial support for Maxim MAX77759
      power: supply: max17042: consider task period (max77759)
      power: supply: max17042: report time to full (max17055 & max77759)

 .../bindings/power/supply/maxim,max17042.yaml      |  21 ++--
 drivers/power/supply/max17042_battery.c            | 134 ++++++++++++++++++---
 include/linux/power/max17042_battery.h             |  25 +++-
 3 files changed, 152 insertions(+), 28 deletions(-)
---
base-commit: 877552aa875839314afad7154b5a561889e87ea9
change-id: 20260226-max77759-fg-0f4bf0816ced

Best regards,
-- 
André Draszik <andre.draszik@linaro.org>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 01/11] dt-bindings: power: supply: max17042: add support for max77759
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
@ 2026-02-27  7:15 ` André Draszik
  2026-02-27  7:15 ` [PATCH v2 02/11] dt-bindings: power: supply: max17042: support shunt-resistor-micro-ohms André Draszik
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik, Conor Dooley

The Maxim MAX77759 is a companion PMIC intended for use in mobile
phones and tablets. It is used on Google Pixel 6 and 6 Pro (oriole and
raven). Amongst others, it contains a fuel gauge that is similar to the
ones supported by this binding.

The fuel gauge can measure battery charge and discharge current,
battery voltage, battery temperature, and the Type C connector's
temperature.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
index 14242de7fc08..055d1f2ee0ba 100644
--- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
+++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
@@ -20,6 +20,7 @@ properties:
       - maxim,max17050
       - maxim,max17055
       - maxim,max77705-battery
+      - maxim,max77759-fg
       - maxim,max77849-battery
 
   reg:
@@ -28,7 +29,7 @@ properties:
   interrupts:
     maxItems: 1
     description: |
-      The ALRT pin, an open-drain interrupt.
+      The ALRT pin (or FG_INTB pin on MAX77759), an open-drain interrupt.
 
   maxim,rsns-microohm:
     $ref: /schemas/types.yaml#/definitions/uint32

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 02/11] dt-bindings: power: supply: max17042: support shunt-resistor-micro-ohms
  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 ` André Draszik
  2026-02-27  7:15 ` [PATCH v2 03/11] dt-bindings: power: supply: max17042: drop formatting specifier | André Draszik
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik, Conor Dooley

This binding supports the vendor-specific property maxim,rsns-microohm
to describe the value of a shunt resistor required when measuring
currents. shunt-resistor-micro-ohms is a standard property with the
same meaning. Standard properties should be used instead of vendor-
specific ones of similar intention when possible.

Allow this standard property here, while also deprecating the existing
vendor-specific property maxim,rsns-microohm.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
index 055d1f2ee0ba..25ea8e19b980 100644
--- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
+++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
@@ -31,7 +31,13 @@ properties:
     description: |
       The ALRT pin (or FG_INTB pin on MAX77759), an open-drain interrupt.
 
+  shunt-resistor-micro-ohms:
+    description:
+      Resistance of rsns resistor in micro Ohms (datasheet-recommended value is 10000).
+      Defining this property enables current-sense functionality.
+
   maxim,rsns-microohm:
+    deprecated: true
     $ref: /schemas/types.yaml#/definitions/uint32
     description: |
       Resistance of rsns resistor in micro Ohms (datasheet-recommended value is 10000).

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 03/11] dt-bindings: power: supply: max17042: drop formatting specifier |
  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 ` André Draszik
  2026-02-27  7:15 ` [PATCH v2 04/11] power: supply: max17042: fix a comment typo (then -> than) André Draszik
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik, Conor Dooley

| denotes a literal (preformatted) block and is not necessary here.

Drop them from this file.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 .../devicetree/bindings/power/supply/maxim,max17042.yaml     | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
index 25ea8e19b980..242b33f2bcba 100644
--- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
+++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
@@ -28,7 +28,7 @@ properties:
 
   interrupts:
     maxItems: 1
-    description: |
+    description:
       The ALRT pin (or FG_INTB pin on MAX77759), an open-drain interrupt.
 
   shunt-resistor-micro-ohms:
@@ -39,31 +39,31 @@ properties:
   maxim,rsns-microohm:
     deprecated: true
     $ref: /schemas/types.yaml#/definitions/uint32
-    description: |
+    description:
       Resistance of rsns resistor in micro Ohms (datasheet-recommended value is 10000).
       Defining this property enables current-sense functionality.
 
   maxim,cold-temp:
     $ref: /schemas/types.yaml#/definitions/uint32
-    description: |
+    description:
       Temperature threshold to report battery as cold (in tenths of degree Celsius).
       Default is not to report cold events.
 
   maxim,over-heat-temp:
     $ref: /schemas/types.yaml#/definitions/uint32
-    description: |
+    description:
       Temperature threshold to report battery as over heated (in tenths of degree Celsius).
       Default is not to report over heating events.
 
   maxim,dead-volt:
     $ref: /schemas/types.yaml#/definitions/uint32
-    description: |
+    description:
       Voltage threshold to report battery as dead (in mV).
       Default is not to report dead battery events.
 
   maxim,over-volt:
     $ref: /schemas/types.yaml#/definitions/uint32
-    description: |
+    description:
       Voltage threshold to report battery as over voltage (in mV).
       Default is not to report over-voltage events.
 

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 04/11] power: supply: max17042: fix a comment typo (then -> than)
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
                   ` (2 preceding siblings ...)
  2026-02-27  7:15 ` [PATCH v2 03/11] dt-bindings: power: supply: max17042: drop formatting specifier | André Draszik
@ 2026-02-27  7:15 ` André Draszik
  2026-02-27  7:15 ` [PATCH v2 05/11] power: supply: max17042: use dev_err_probe() where appropriate André Draszik
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik

Fix this trivial typo where than should be used instead of then.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/power/supply/max17042_battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index acea176101fa..07759d4fdc37 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -131,7 +131,7 @@ static int max17042_get_status(struct max17042_chip *chip, int *status)
 	 * FullCAP to match RepCap when it detects end of charging.
 	 *
 	 * When this cycle the battery gets charged to a higher (calculated)
-	 * capacity then the previous cycle then FullCAP will get updated
+	 * capacity than the previous cycle then FullCAP will get updated
 	 * continuously once end-of-charge detection kicks in, so allow the
 	 * 2 to differ a bit.
 	 */

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 05/11] power: supply: max17042: use dev_err_probe() where appropriate
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
                   ` (3 preceding siblings ...)
  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 ` André Draszik
  2026-02-27  7:15 ` [PATCH v2 06/11] power: supply: max17042: avoid overflow when determining health André Draszik
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik

dev_err_probe() exists to simplify code, harmonise error messages, and
set the deferred probe reason if relevant - there's no reason not to
use it here.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/power/supply/max17042_battery.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 07759d4fdc37..b9277f81a25d 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -1053,16 +1053,14 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq
 	chip->dev = dev;
 	chip->chip_type = chip_type;
 	chip->regmap = devm_regmap_init_i2c(client, &max17042_regmap_config);
-	if (IS_ERR(chip->regmap)) {
-		dev_err(dev, "Failed to initialize regmap\n");
-		return -EINVAL;
-	}
+	if (IS_ERR(chip->regmap))
+		return dev_err_probe(dev, PTR_ERR(chip->regmap),
+				     "Failed to initialize regmap\n");
 
 	chip->pdata = max17042_get_pdata(chip);
-	if (!chip->pdata) {
-		dev_err(dev, "no platform data provided\n");
-		return -EINVAL;
-	}
+	if (!chip->pdata)
+		return dev_err_probe(dev, -EINVAL,
+				     "no platform data provided\n");
 
 	dev_set_drvdata(dev, chip);
 	psy_cfg.drv_data = chip;
@@ -1090,10 +1088,9 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq
 
 	chip->battery = devm_power_supply_register(dev, max17042_desc,
 						   &psy_cfg);
-	if (IS_ERR(chip->battery)) {
-		dev_err(dev, "failed: power supply register\n");
-		return PTR_ERR(chip->battery);
-	}
+	if (IS_ERR(chip->battery))
+		return dev_err_probe(dev, PTR_ERR(chip->battery),
+				     "failed: power supply register\n");
 
 	if (irq) {
 		unsigned int flags = IRQF_ONESHOT | IRQF_SHARED | IRQF_PROBE_SHARED;

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 06/11] power: supply: max17042: avoid overflow when determining health
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
                   ` (4 preceding siblings ...)
  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 ` André Draszik
  2026-02-27  7:15 ` [PATCH v2 07/11] power: supply: max17042: time to empty is meaningless when charging André Draszik
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik

If vmax has the default value of INT_MAX (e.g. because not specified in
DT), battery health is reported as over-voltage. This is because adding
any value to vmax (the vmax tolerance in this case) causes it to wrap
around, making it negative and smaller than the measured battery
voltage.

Avoid that by using size_add().

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/power/supply/max17042_battery.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index b9277f81a25d..8808c0d2ad10 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -201,7 +201,11 @@ static int max17042_get_battery_health(struct max17042_chip *chip, int *health)
 		goto out;
 	}
 
-	if (vbatt > chip->pdata->vmax + MAX17042_VMAX_TOLERANCE) {
+	/* avoid
+	 * /sys/class/power_supply/max170xx_battery/health:Over voltage
+	 * due to overflow
+	 */
+	if (vbatt > size_add(chip->pdata->vmax, MAX17042_VMAX_TOLERANCE)) {
 		*health = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
 		goto out;
 	}

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 07/11] power: supply: max17042: time to empty is meaningless when charging
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
                   ` (5 preceding siblings ...)
  2026-02-27  7:15 ` [PATCH v2 06/11] power: supply: max17042: avoid overflow when determining health André Draszik
@ 2026-02-27  7:15 ` 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
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik

When charging, the fuel gauge reports U16_MAX as time to empty.
Ignoring this special case (as this driver currently does), causes the
remaining time to be reported as ~102hours, which is incorrect.

Update the code to not return anything in this case.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/power/supply/max17042_battery.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 8808c0d2ad10..bae0670e2496 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -434,6 +434,10 @@ static int max17042_get_property(struct power_supply *psy,
 		if (ret < 0)
 			return ret;
 
+		/* when charging, the value is not meaningful */
+		if (data == U16_MAX)
+			return -ENODATA;
+
 		val->intval = data * 5625 / 1000;
 		break;
 	default:

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 08/11] power: supply: max17042: support standard shunt-resistor-micro-ohms DT property
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
                   ` (6 preceding siblings ...)
  2026-02-27  7:15 ` [PATCH v2 07/11] power: supply: max17042: time to empty is meaningless when charging André Draszik
@ 2026-02-27  7:15 ` 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
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik

shunt-resistor-micro-ohms is a standard property used to describe the
value of a shunt resistor required when measuring currents. Standard
properties should be used instead of vendor-specific ones of similar
intention when possible.

Try to read it from DT, and fall back to the vendor-specific property
maxim,rsns-microohm if unsuccessful for compatibility with existing
DTs.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/power/supply/max17042_battery.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index bae0670e2496..823533ea5a17 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -929,8 +929,12 @@ max17042_get_of_pdata(struct max17042_chip *chip)
 	/*
 	 * Require current sense resistor value to be specified for
 	 * current-sense functionality to be enabled at all.
+	 * maxim,rsns-microohm is the property name used by older DTs and kept
+	 * for compatibility.
 	 */
-	if (of_property_read_u32(np, "maxim,rsns-microohm", &prop) == 0) {
+	if ((of_property_read_u32(np, "shunt-resistor-micro-ohms",
+				  &prop) == 0) ||
+	    (of_property_read_u32(np, "maxim,rsns-microohm", &prop) == 0)) {
 		pdata->r_sns = prop;
 		pdata->enable_current_sense = true;
 	}

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 09/11] power: supply: max17042: initial support for Maxim MAX77759
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
                   ` (7 preceding siblings ...)
  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  7:15 ` 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  7:15 ` [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759) André Draszik
  10 siblings, 1 reply; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik

The Maxim MAX77759 is a companion PMIC intended for use in mobile
phones and tablets. It is used on Google Pixel 6 and 6 Pro (oriole and
raven). Amongst others, it contains a fuel gauge that is similar to the
ones supported by this driver.

The fuel gauge can measure battery charge and discharge current,
battery voltage, battery temperature, and the Type C connector's
temperature.

The MAX77759 incorporates the Maxim ModelGauge m5 algorithm. It, as
well as previous generations like m3 on max17047/max17050, requires
the host to save/restore some register values across power cycles to
maintain full accuracy. Extending the driver for such support is out of
scope in this initial commit.

Signed-off-by: André Draszik <andre.draszik@linaro.org>

---
v2: fix typo MAX77759_T_convert -> MAX77759_Tconvert
---
 drivers/power/supply/max17042_battery.c | 59 ++++++++++++++++++++++++++++++---
 include/linux/power/max17042_battery.h  | 24 ++++++++++++--
 2 files changed, 77 insertions(+), 6 deletions(-)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 823533ea5a17..44626abdab34 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -654,7 +654,8 @@ static void max17042_write_config_regs(struct max17042_chip *chip)
 	regmap_write(map, MAX17042_RelaxCFG, config->relax_cfg);
 	if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047 ||
 			chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050 ||
-			chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055)
+			chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055 ||
+			chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759)
 		regmap_write(map, MAX17047_FullSOCThr,
 						config->full_soc_thresh);
 }
@@ -791,7 +792,8 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
 
 	if ((chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042) ||
 	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047) ||
-	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050)) {
+	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050) ||
+	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759)) {
 		max17042_override_por(map, MAX17042_IAvg_empty, config->iavg_empty);
 		max17042_override_por(map, MAX17042_TempNom, config->temp_nom);
 		max17042_override_por(map, MAX17042_TempLim, config->temp_lim);
@@ -800,7 +802,8 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
 
 	if ((chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047) ||
 	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050) ||
-	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055)) {
+	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055) ||
+	    (chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759)) {
 		max17042_override_por(map, MAX17047_V_empty, config->vempty);
 	}
 }
@@ -1023,6 +1026,45 @@ static const struct regmap_config max17042_regmap_config = {
 	.val_format_endian = REGMAP_ENDIAN_NATIVE,
 };
 
+static const struct regmap_range max77759_fg_registers[] = {
+	regmap_reg_range(MAX17042_STATUS, MAX77759_MixAtFull),
+	regmap_reg_range(MAX17042_VFSOC0Enable, MAX17042_VFSOC0Enable),
+	regmap_reg_range(MAX17042_MLOCKReg1, MAX17042_MLOCKReg2),
+	regmap_reg_range(MAX17042_MODELChrTbl, MAX17055_TimerH),
+	regmap_reg_range(MAX77759_IIn, MAX77759_IIn),
+	regmap_reg_range(MAX17055_AtQResidual, MAX17055_AtAvCap),
+	regmap_reg_range(MAX17042_OCVInternal, MAX17042_OCVInternal),
+	regmap_reg_range(MAX17042_VFSOC, MAX17042_VFSOC),
+};
+
+static const struct regmap_range max77759_fg_ro_registers[] = {
+	regmap_reg_range(MAX17042_FSTAT, MAX17042_FSTAT),
+	regmap_reg_range(MAX17042_OCVInternal, MAX17042_OCVInternal),
+	regmap_reg_range(MAX17042_VFSOC, MAX17042_VFSOC),
+};
+
+static const struct regmap_access_table max77759_fg_write_table = {
+	.yes_ranges = max77759_fg_registers,
+	.n_yes_ranges = ARRAY_SIZE(max77759_fg_registers),
+	.no_ranges = max77759_fg_ro_registers,
+	.n_no_ranges = ARRAY_SIZE(max77759_fg_ro_registers),
+};
+
+static const struct regmap_access_table max77759_fg_rd_table = {
+	.yes_ranges = max77759_fg_registers,
+	.n_yes_ranges = ARRAY_SIZE(max77759_fg_registers),
+};
+
+static const struct regmap_config max77759_fg_regmap_cfg = {
+	.reg_bits = 8,
+	.val_bits = 16,
+	.max_register = 0xff,
+	.wr_table = &max77759_fg_write_table,
+	.rd_table = &max77759_fg_rd_table,
+	.val_format_endian = REGMAP_ENDIAN_NATIVE,
+	.cache_type = REGCACHE_NONE,
+};
+
 static const struct power_supply_desc max17042_psy_desc = {
 	.name		= "max170xx_battery",
 	.type		= POWER_SUPPLY_TYPE_BATTERY,
@@ -1049,6 +1091,7 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq
 {
 	struct i2c_adapter *adapter = client->adapter;
 	const struct power_supply_desc *max17042_desc = &max17042_psy_desc;
+	const struct regmap_config *regmap_config;
 	struct power_supply_config psy_cfg = {};
 	struct max17042_chip *chip;
 	int ret;
@@ -1064,7 +1107,12 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq
 
 	chip->dev = dev;
 	chip->chip_type = chip_type;
-	chip->regmap = devm_regmap_init_i2c(client, &max17042_regmap_config);
+
+	if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759)
+		regmap_config = &max77759_fg_regmap_cfg;
+	else
+		regmap_config = &max17042_regmap_config;
+	chip->regmap = devm_regmap_init_i2c(client, regmap_config);
 	if (IS_ERR(chip->regmap))
 		return dev_err_probe(dev, PTR_ERR(chip->regmap),
 				     "Failed to initialize regmap\n");
@@ -1245,6 +1293,8 @@ static const struct of_device_id max17042_dt_match[] __used = {
 		.data = (void *) MAXIM_DEVICE_TYPE_MAX17055 },
 	{ .compatible = "maxim,max77705-battery",
 		.data = (void *) MAXIM_DEVICE_TYPE_MAX17047 },
+	{ .compatible = "maxim,max77759-fg",
+		.data = (void *) MAXIM_DEVICE_TYPE_MAX77759 },
 	{ .compatible = "maxim,max77849-battery",
 		.data = (void *) MAXIM_DEVICE_TYPE_MAX17047 },
 	{ },
@@ -1257,6 +1307,7 @@ static const struct i2c_device_id max17042_id[] = {
 	{ "max17047", MAXIM_DEVICE_TYPE_MAX17047 },
 	{ "max17050", MAXIM_DEVICE_TYPE_MAX17050 },
 	{ "max17055", MAXIM_DEVICE_TYPE_MAX17055 },
+	{ "max77759-fg", MAXIM_DEVICE_TYPE_MAX77759 },
 	{ "max77849-battery", MAXIM_DEVICE_TYPE_MAX17047 },
 	{ }
 };
diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
index c417abd2ab70..05097f08ea36 100644
--- a/include/linux/power/max17042_battery.h
+++ b/include/linux/power/max17042_battery.h
@@ -105,7 +105,7 @@ enum max17042_register {
 
 	MAX17042_OCV		= 0xEE,
 
-	MAX17042_OCVInternal	= 0xFB,  /* MAX17055 VFOCV */
+	MAX17042_OCVInternal	= 0xFB, /* MAX17055/77759 VFOCV */
 
 	MAX17042_VFSOC		= 0xFF,
 };
@@ -156,7 +156,7 @@ enum max17055_register {
 	MAX17055_AtAvCap	= 0xDF,
 };
 
-/* Registers specific to max17047/50/55 */
+/* Registers specific to max17047/50/55/77759 */
 enum max17047_register {
 	MAX17047_QRTbl00	= 0x12,
 	MAX17047_FullSOCThr	= 0x13,
@@ -167,12 +167,32 @@ enum max17047_register {
 	MAX17047_QRTbl30	= 0x42,
 };
 
+enum max77759_register {
+	MAX77759_AvgTA0		= 0x26,
+	MAX77759_AtTTF		= 0x33,
+	MAX77759_Tconvert	= 0x34,
+	MAX77759_AvgCurrent0	= 0x3B,
+	MAX77759_THMHOT		= 0x40,
+	MAX77759_CTESample	= 0x41,
+	MAX77759_ISys		= 0x43,
+	MAX77759_AvgVCell0	= 0x44,
+	MAX77759_RlxSOC		= 0x47,
+	MAX77759_AvgISys	= 0x4B,
+	MAX77759_QH0		= 0x4C,
+	MAX77759_MixAtFull	= 0x4F,
+	MAX77759_VSys		= 0xB1,
+	MAX77759_TAlrtTh2	= 0xB2,
+	MAX77759_VByp		= 0xB3,
+	MAX77759_IIn		= 0xD0,
+};
+
 enum max170xx_chip_type {
 	MAXIM_DEVICE_TYPE_UNKNOWN	= 0,
 	MAXIM_DEVICE_TYPE_MAX17042,
 	MAXIM_DEVICE_TYPE_MAX17047,
 	MAXIM_DEVICE_TYPE_MAX17050,
 	MAXIM_DEVICE_TYPE_MAX17055,
+	MAXIM_DEVICE_TYPE_MAX77759,
 
 	MAXIM_DEVICE_TYPE_NUM
 };

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 10/11] power: supply: max17042: consider task period (max77759)
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
                   ` (8 preceding siblings ...)
  2026-02-27  7:15 ` [PATCH v2 09/11] power: supply: max17042: initial support for Maxim MAX77759 André Draszik
@ 2026-02-27  7:15 ` André Draszik
  2026-02-27 17:01   ` Peter Griffin
  2026-02-27  7:15 ` [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759) André Draszik
  10 siblings, 1 reply; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik

Several (register) values reported by the fuel gauge depend on its
internal task period and it needs to be taken into account when
calculating results. All relevant example formulas in the data sheet
assume the default task period (of 5760) and final results need to be
adjusted based on the task period in effect.

Update the code as and where necessary.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
While I do believe this should apply to all devices supported by this
driver, given the register description in max17042_battery.h, I've made
this change specific to max77759, as I have no way to confirm this
works as expected on those. I've found a data sheet for
max17047/max17050 online, which does describe the relevant register
0x3c as 'reserved', hence I'm a bit hesitant to enable this for all.

v2:
* update commit message subject prefix
---
 drivers/power/supply/max17042_battery.c | 20 ++++++++++++++++++++
 include/linux/power/max17042_battery.h  |  1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 44626abdab34..89909b140cf9 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -61,6 +61,7 @@ struct max17042_chip {
 	struct work_struct work;
 	int    init_complete;
 	int    irq;
+	int    task_period;
 };
 
 static enum power_supply_property max17042_battery_props[] = {
@@ -335,6 +336,8 @@ static int max17042_get_property(struct power_supply *psy,
 			return ret;
 
 		data64 = data * 5000000ll;
+		data64 *= chip->task_period;
+		do_div(data64, MAX17042_DEFAULT_TASK_PERIOD);
 		do_div(data64, chip->pdata->r_sns);
 		val->intval = data64;
 		break;
@@ -344,6 +347,8 @@ static int max17042_get_property(struct power_supply *psy,
 			return ret;
 
 		data64 = data * 5000000ll;
+		data64 *= chip->task_period;
+		do_div(data64, MAX17042_DEFAULT_TASK_PERIOD);
 		do_div(data64, chip->pdata->r_sns);
 		val->intval = data64;
 		break;
@@ -353,6 +358,8 @@ static int max17042_get_property(struct power_supply *psy,
 			return ret;
 
 		data64 = data * 5000000ll;
+		data64 *= chip->task_period;
+		do_div(data64, MAX17042_DEFAULT_TASK_PERIOD);
 		do_div(data64, chip->pdata->r_sns);
 		val->intval = data64;
 		break;
@@ -362,6 +369,8 @@ static int max17042_get_property(struct power_supply *psy,
 			return ret;
 
 		data64 = sign_extend64(data, 15) * 5000000ll;
+		data64 *= chip->task_period;
+		data64 = div_s64(data64, MAX17042_DEFAULT_TASK_PERIOD);
 		val->intval = div_s64(data64, chip->pdata->r_sns);
 		break;
 	case POWER_SUPPLY_PROP_TEMP:
@@ -1146,6 +1155,17 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq
 		regmap_write(chip->regmap, MAX17042_LearnCFG, 0x0007);
 	}
 
+	chip->task_period = MAX17042_DEFAULT_TASK_PERIOD;
+	if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759) {
+		ret = regmap_read(chip->regmap, MAX17042_TaskPeriod, &val);
+		if (ret)
+			return dev_err_probe(dev, ret,
+					     "failed to read task period\n");
+		chip->task_period = val;
+	}
+	dev_dbg(dev, "task period: %#.4x (%d)\n", chip->task_period,
+		chip->task_period);
+
 	chip->battery = devm_power_supply_register(dev, max17042_desc,
 						   &psy_cfg);
 	if (IS_ERR(chip->battery))
diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
index 05097f08ea36..d5b08313cf11 100644
--- a/include/linux/power/max17042_battery.h
+++ b/include/linux/power/max17042_battery.h
@@ -17,6 +17,7 @@
 #define MAX17042_DEFAULT_VMAX		(4500) /* LiHV cell max */
 #define MAX17042_DEFAULT_TEMP_MIN	(0)    /* For sys without temp sensor */
 #define MAX17042_DEFAULT_TEMP_MAX	(700)  /* 70 degrees Celcius */
+#define MAX17042_DEFAULT_TASK_PERIOD	(5760)
 
 /* Consider RepCap which is less then 10 units below FullCAP full */
 #define MAX17042_FULL_THRESHOLD		10

-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759)
  2026-02-27  7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
                   ` (9 preceding siblings ...)
  2026-02-27  7:15 ` [PATCH v2 10/11] power: supply: max17042: consider task period (max77759) André Draszik
@ 2026-02-27  7:15 ` André Draszik
  2026-02-27 16:53   ` Peter Griffin
  10 siblings, 1 reply; 17+ messages in thread
From: André Draszik @ 2026-02-27  7:15 UTC (permalink / raw)
  To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley
  Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
	kernel-team, linux-pm, devicetree, linux-kernel,
	André Draszik

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 08/11] power: supply: max17042: support standard shunt-resistor-micro-ohms DT property
  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
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Griffin @ 2026-02-27 16:07 UTC (permalink / raw)
  To: André Draszik
  Cc: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley, Tudor Ambarus, Juan Yescas,
	Amit Sunil Dhamne, kernel-team, linux-pm, devicetree,
	linux-kernel

On Fri, 27 Feb 2026 at 07:15, André Draszik <andre.draszik@linaro.org> wrote:
>
> shunt-resistor-micro-ohms is a standard property used to describe the
> value of a shunt resistor required when measuring currents. Standard
> properties should be used instead of vendor-specific ones of similar
> intention when possible.
>
> Try to read it from DT, and fall back to the vendor-specific property
> maxim,rsns-microohm if unsuccessful for compatibility with existing
> DTs.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 07/11] power: supply: max17042: time to empty is meaningless when charging
  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
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Griffin @ 2026-02-27 16:47 UTC (permalink / raw)
  To: André Draszik
  Cc: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley, Tudor Ambarus, Juan Yescas,
	Amit Sunil Dhamne, kernel-team, linux-pm, devicetree,
	linux-kernel

On Fri, 27 Feb 2026 at 07:15, André Draszik <andre.draszik@linaro.org> wrote:
>
> When charging, the fuel gauge reports U16_MAX as time to empty.
> Ignoring this special case (as this driver currently does), causes the
> remaining time to be reported as ~102hours, which is incorrect.
>
> Update the code to not return anything in this case.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759)
  2026-02-27  7:15 ` [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759) André Draszik
@ 2026-02-27 16:53   ` Peter Griffin
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Griffin @ 2026-02-27 16:53 UTC (permalink / raw)
  To: André Draszik
  Cc: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley, Tudor Ambarus, Juan Yescas,
	Amit Sunil Dhamne, kernel-team, linux-pm, devicetree,
	linux-kernel

On Fri, 27 Feb 2026 at 07:15, André Draszik <andre.draszik@linaro.org> wrote:
>
> 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>
>
> ---

Reviewed-by: Peter Griffin <peter.griffin@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
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 09/11] power: supply: max17042: initial support for Maxim MAX77759
  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
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Griffin @ 2026-02-27 17:00 UTC (permalink / raw)
  To: André Draszik
  Cc: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley, Tudor Ambarus, Juan Yescas,
	Amit Sunil Dhamne, kernel-team, linux-pm, devicetree,
	linux-kernel

On Fri, 27 Feb 2026 at 07:15, André Draszik <andre.draszik@linaro.org> wrote:
>
> The Maxim MAX77759 is a companion PMIC intended for use in mobile
> phones and tablets. It is used on Google Pixel 6 and 6 Pro (oriole and
> raven). Amongst others, it contains a fuel gauge that is similar to the
> ones supported by this driver.
>
> The fuel gauge can measure battery charge and discharge current,
> battery voltage, battery temperature, and the Type C connector's
> temperature.
>
> The MAX77759 incorporates the Maxim ModelGauge m5 algorithm. It, as
> well as previous generations like m3 on max17047/max17050, requires
> the host to save/restore some register values across power cycles to
> maintain full accuracy. Extending the driver for such support is out of
> scope in this initial commit.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
>
> ---

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>

> v2: fix typo MAX77759_T_convert -> MAX77759_Tconvert
> ---
>  drivers/power/supply/max17042_battery.c | 59 ++++++++++++++++++++++++++++++---
>  include/linux/power/max17042_battery.h  | 24 ++++++++++++--
>  2 files changed, 77 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 823533ea5a17..44626abdab34 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -654,7 +654,8 @@ static void max17042_write_config_regs(struct max17042_chip *chip)
>         regmap_write(map, MAX17042_RelaxCFG, config->relax_cfg);
>         if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047 ||
>                         chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050 ||
> -                       chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055)
> +                       chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055 ||
> +                       chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759)
>                 regmap_write(map, MAX17047_FullSOCThr,
>                                                 config->full_soc_thresh);
>  }
> @@ -791,7 +792,8 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
>
>         if ((chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042) ||
>             (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047) ||
> -           (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050)) {
> +           (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050) ||
> +           (chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759)) {
>                 max17042_override_por(map, MAX17042_IAvg_empty, config->iavg_empty);
>                 max17042_override_por(map, MAX17042_TempNom, config->temp_nom);
>                 max17042_override_por(map, MAX17042_TempLim, config->temp_lim);
> @@ -800,7 +802,8 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
>
>         if ((chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047) ||
>             (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050) ||
> -           (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055)) {
> +           (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055) ||
> +           (chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759)) {
>                 max17042_override_por(map, MAX17047_V_empty, config->vempty);
>         }
>  }
> @@ -1023,6 +1026,45 @@ static const struct regmap_config max17042_regmap_config = {
>         .val_format_endian = REGMAP_ENDIAN_NATIVE,
>  };
>
> +static const struct regmap_range max77759_fg_registers[] = {
> +       regmap_reg_range(MAX17042_STATUS, MAX77759_MixAtFull),
> +       regmap_reg_range(MAX17042_VFSOC0Enable, MAX17042_VFSOC0Enable),
> +       regmap_reg_range(MAX17042_MLOCKReg1, MAX17042_MLOCKReg2),
> +       regmap_reg_range(MAX17042_MODELChrTbl, MAX17055_TimerH),
> +       regmap_reg_range(MAX77759_IIn, MAX77759_IIn),
> +       regmap_reg_range(MAX17055_AtQResidual, MAX17055_AtAvCap),
> +       regmap_reg_range(MAX17042_OCVInternal, MAX17042_OCVInternal),
> +       regmap_reg_range(MAX17042_VFSOC, MAX17042_VFSOC),
> +};
> +
> +static const struct regmap_range max77759_fg_ro_registers[] = {
> +       regmap_reg_range(MAX17042_FSTAT, MAX17042_FSTAT),
> +       regmap_reg_range(MAX17042_OCVInternal, MAX17042_OCVInternal),
> +       regmap_reg_range(MAX17042_VFSOC, MAX17042_VFSOC),
> +};
> +
> +static const struct regmap_access_table max77759_fg_write_table = {
> +       .yes_ranges = max77759_fg_registers,
> +       .n_yes_ranges = ARRAY_SIZE(max77759_fg_registers),
> +       .no_ranges = max77759_fg_ro_registers,
> +       .n_no_ranges = ARRAY_SIZE(max77759_fg_ro_registers),
> +};
> +
> +static const struct regmap_access_table max77759_fg_rd_table = {
> +       .yes_ranges = max77759_fg_registers,
> +       .n_yes_ranges = ARRAY_SIZE(max77759_fg_registers),
> +};
> +
> +static const struct regmap_config max77759_fg_regmap_cfg = {
> +       .reg_bits = 8,
> +       .val_bits = 16,
> +       .max_register = 0xff,
> +       .wr_table = &max77759_fg_write_table,
> +       .rd_table = &max77759_fg_rd_table,
> +       .val_format_endian = REGMAP_ENDIAN_NATIVE,
> +       .cache_type = REGCACHE_NONE,
> +};
> +
>  static const struct power_supply_desc max17042_psy_desc = {
>         .name           = "max170xx_battery",
>         .type           = POWER_SUPPLY_TYPE_BATTERY,
> @@ -1049,6 +1091,7 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq
>  {
>         struct i2c_adapter *adapter = client->adapter;
>         const struct power_supply_desc *max17042_desc = &max17042_psy_desc;
> +       const struct regmap_config *regmap_config;
>         struct power_supply_config psy_cfg = {};
>         struct max17042_chip *chip;
>         int ret;
> @@ -1064,7 +1107,12 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq
>
>         chip->dev = dev;
>         chip->chip_type = chip_type;
> -       chip->regmap = devm_regmap_init_i2c(client, &max17042_regmap_config);
> +
> +       if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759)
> +               regmap_config = &max77759_fg_regmap_cfg;
> +       else
> +               regmap_config = &max17042_regmap_config;
> +       chip->regmap = devm_regmap_init_i2c(client, regmap_config);
>         if (IS_ERR(chip->regmap))
>                 return dev_err_probe(dev, PTR_ERR(chip->regmap),
>                                      "Failed to initialize regmap\n");
> @@ -1245,6 +1293,8 @@ static const struct of_device_id max17042_dt_match[] __used = {
>                 .data = (void *) MAXIM_DEVICE_TYPE_MAX17055 },
>         { .compatible = "maxim,max77705-battery",
>                 .data = (void *) MAXIM_DEVICE_TYPE_MAX17047 },
> +       { .compatible = "maxim,max77759-fg",
> +               .data = (void *) MAXIM_DEVICE_TYPE_MAX77759 },
>         { .compatible = "maxim,max77849-battery",
>                 .data = (void *) MAXIM_DEVICE_TYPE_MAX17047 },
>         { },
> @@ -1257,6 +1307,7 @@ static const struct i2c_device_id max17042_id[] = {
>         { "max17047", MAXIM_DEVICE_TYPE_MAX17047 },
>         { "max17050", MAXIM_DEVICE_TYPE_MAX17050 },
>         { "max17055", MAXIM_DEVICE_TYPE_MAX17055 },
> +       { "max77759-fg", MAXIM_DEVICE_TYPE_MAX77759 },
>         { "max77849-battery", MAXIM_DEVICE_TYPE_MAX17047 },
>         { }
>  };
> diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
> index c417abd2ab70..05097f08ea36 100644
> --- a/include/linux/power/max17042_battery.h
> +++ b/include/linux/power/max17042_battery.h
> @@ -105,7 +105,7 @@ enum max17042_register {
>
>         MAX17042_OCV            = 0xEE,
>
> -       MAX17042_OCVInternal    = 0xFB,  /* MAX17055 VFOCV */
> +       MAX17042_OCVInternal    = 0xFB, /* MAX17055/77759 VFOCV */
>
>         MAX17042_VFSOC          = 0xFF,
>  };
> @@ -156,7 +156,7 @@ enum max17055_register {
>         MAX17055_AtAvCap        = 0xDF,
>  };
>
> -/* Registers specific to max17047/50/55 */
> +/* Registers specific to max17047/50/55/77759 */
>  enum max17047_register {
>         MAX17047_QRTbl00        = 0x12,
>         MAX17047_FullSOCThr     = 0x13,
> @@ -167,12 +167,32 @@ enum max17047_register {
>         MAX17047_QRTbl30        = 0x42,
>  };
>
> +enum max77759_register {
> +       MAX77759_AvgTA0         = 0x26,
> +       MAX77759_AtTTF          = 0x33,
> +       MAX77759_Tconvert       = 0x34,
> +       MAX77759_AvgCurrent0    = 0x3B,
> +       MAX77759_THMHOT         = 0x40,
> +       MAX77759_CTESample      = 0x41,
> +       MAX77759_ISys           = 0x43,
> +       MAX77759_AvgVCell0      = 0x44,
> +       MAX77759_RlxSOC         = 0x47,
> +       MAX77759_AvgISys        = 0x4B,
> +       MAX77759_QH0            = 0x4C,
> +       MAX77759_MixAtFull      = 0x4F,
> +       MAX77759_VSys           = 0xB1,
> +       MAX77759_TAlrtTh2       = 0xB2,
> +       MAX77759_VByp           = 0xB3,
> +       MAX77759_IIn            = 0xD0,
> +};
> +
>  enum max170xx_chip_type {
>         MAXIM_DEVICE_TYPE_UNKNOWN       = 0,
>         MAXIM_DEVICE_TYPE_MAX17042,
>         MAXIM_DEVICE_TYPE_MAX17047,
>         MAXIM_DEVICE_TYPE_MAX17050,
>         MAXIM_DEVICE_TYPE_MAX17055,
> +       MAXIM_DEVICE_TYPE_MAX77759,
>
>         MAXIM_DEVICE_TYPE_NUM
>  };
>
> --
> 2.53.0.473.g4a7958ca14-goog
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 10/11] power: supply: max17042: consider task period (max77759)
  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
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Griffin @ 2026-02-27 17:01 UTC (permalink / raw)
  To: André Draszik
  Cc: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel,
	Rob Herring, Conor Dooley, Tudor Ambarus, Juan Yescas,
	Amit Sunil Dhamne, kernel-team, linux-pm, devicetree,
	linux-kernel

On Fri, 27 Feb 2026 at 07:15, André Draszik <andre.draszik@linaro.org> wrote:
>
> Several (register) values reported by the fuel gauge depend on its
> internal task period and it needs to be taken into account when
> calculating results. All relevant example formulas in the data sheet
> assume the default task period (of 5760) and final results need to be
> adjusted based on the task period in effect.
>
> Update the code as and where necessary.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>

> While I do believe this should apply to all devices supported by this
> driver, given the register description in max17042_battery.h, I've made
> this change specific to max77759, as I have no way to confirm this
> works as expected on those. I've found a data sheet for
> max17047/max17050 online, which does describe the relevant register
> 0x3c as 'reserved', hence I'm a bit hesitant to enable this for all.
>
> v2:
> * update commit message subject prefix
> ---
>  drivers/power/supply/max17042_battery.c | 20 ++++++++++++++++++++
>  include/linux/power/max17042_battery.h  |  1 +
>  2 files changed, 21 insertions(+)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 44626abdab34..89909b140cf9 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -61,6 +61,7 @@ struct max17042_chip {
>         struct work_struct work;
>         int    init_complete;
>         int    irq;
> +       int    task_period;
>  };
>
>  static enum power_supply_property max17042_battery_props[] = {
> @@ -335,6 +336,8 @@ static int max17042_get_property(struct power_supply *psy,
>                         return ret;
>
>                 data64 = data * 5000000ll;
> +               data64 *= chip->task_period;
> +               do_div(data64, MAX17042_DEFAULT_TASK_PERIOD);
>                 do_div(data64, chip->pdata->r_sns);
>                 val->intval = data64;
>                 break;
> @@ -344,6 +347,8 @@ static int max17042_get_property(struct power_supply *psy,
>                         return ret;
>
>                 data64 = data * 5000000ll;
> +               data64 *= chip->task_period;
> +               do_div(data64, MAX17042_DEFAULT_TASK_PERIOD);
>                 do_div(data64, chip->pdata->r_sns);
>                 val->intval = data64;
>                 break;
> @@ -353,6 +358,8 @@ static int max17042_get_property(struct power_supply *psy,
>                         return ret;
>
>                 data64 = data * 5000000ll;
> +               data64 *= chip->task_period;
> +               do_div(data64, MAX17042_DEFAULT_TASK_PERIOD);
>                 do_div(data64, chip->pdata->r_sns);
>                 val->intval = data64;
>                 break;
> @@ -362,6 +369,8 @@ static int max17042_get_property(struct power_supply *psy,
>                         return ret;
>
>                 data64 = sign_extend64(data, 15) * 5000000ll;
> +               data64 *= chip->task_period;
> +               data64 = div_s64(data64, MAX17042_DEFAULT_TASK_PERIOD);
>                 val->intval = div_s64(data64, chip->pdata->r_sns);
>                 break;
>         case POWER_SUPPLY_PROP_TEMP:
> @@ -1146,6 +1155,17 @@ static int max17042_probe(struct i2c_client *client, struct device *dev, int irq
>                 regmap_write(chip->regmap, MAX17042_LearnCFG, 0x0007);
>         }
>
> +       chip->task_period = MAX17042_DEFAULT_TASK_PERIOD;
> +       if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX77759) {
> +               ret = regmap_read(chip->regmap, MAX17042_TaskPeriod, &val);
> +               if (ret)
> +                       return dev_err_probe(dev, ret,
> +                                            "failed to read task period\n");
> +               chip->task_period = val;
> +       }
> +       dev_dbg(dev, "task period: %#.4x (%d)\n", chip->task_period,
> +               chip->task_period);
> +
>         chip->battery = devm_power_supply_register(dev, max17042_desc,
>                                                    &psy_cfg);
>         if (IS_ERR(chip->battery))
> diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
> index 05097f08ea36..d5b08313cf11 100644
> --- a/include/linux/power/max17042_battery.h
> +++ b/include/linux/power/max17042_battery.h
> @@ -17,6 +17,7 @@
>  #define MAX17042_DEFAULT_VMAX          (4500) /* LiHV cell max */
>  #define MAX17042_DEFAULT_TEMP_MIN      (0)    /* For sys without temp sensor */
>  #define MAX17042_DEFAULT_TEMP_MAX      (700)  /* 70 degrees Celcius */
> +#define MAX17042_DEFAULT_TASK_PERIOD   (5760)
>
>  /* Consider RepCap which is less then 10 units below FullCAP full */
>  #define MAX17042_FULL_THRESHOLD                10
>
> --
> 2.53.0.473.g4a7958ca14-goog
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-02-27 17:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759) André Draszik
2026-02-27 16:53   ` Peter Griffin

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®