Devicetree
 help / color / mirror / Atom feed
* [PATCH v2 0/4] power: supply: initialize MAX17055 from battery info
@ 2026-07-20  1:11 Vincent Cloutier
  2026-07-20  1:11 ` [PATCH v2 1/4] power: supply: Add registration init callback Vincent Cloutier
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Vincent Cloutier @ 2026-07-20  1:11 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
	Sebastian Krzyszkowiak, Purism Kernel Team, Rob Herring,
	Conor Dooley, linux-pm, devicetree, linux-kernel,
	Vincent Cloutier

From: Vincent Cloutier <vincent@cloutier.co>

Hi,

This is the remaining unmerged tail of the MAX17042/MAX17055 v1 series.
Six v1 patches are upstream, and the v1 cleanup patch is covered by
699f0f71ac98. This revision retains the requested registration callback
architecture and strengthens the MAX17055 POR sequence.

The power-supply callback runs after the core parses monitored-battery but
before device_add(). This lets the driver validate and prepare DesignCap,
IChgTerm, dQAcc, and VChg without another firmware parser or a
power_supply_config handoff. dPAcc is derived later from register
read-back.

The MAX17055 path waits for FSTAT.DNR, saves HibCfg, exits hibernate,
writes each stable battery register once, and verifies it after 1 ms.
SoftWakeup is written directly, and Refresh is requested once before
polling. The driver derives dPAcc from read-back DesignCap, dQAcc, and
ModelCfg values, restores HibCfg, and clears POR only after the complete
sequence succeeds.

Driver-backed properties remain unavailable while initialization is
incomplete. An interrupted transaction restores hibernate and retries
every 10 seconds without depending on POR still being set, so a transient
startup error does not become permanent.

VChg remains a masked ModelCfg update. A voltage-only override reads
effective DesignCap and dQAcc and refreshes dPAcc for the selected voltage
range. Zero is rejected. Exactly 4.275 V selects the low range; only values
above 4.275 V set VChg. An absent property preserves firmware's setting.

---

Changes since v1:

- send only the unmerged battery-info and VChg work
- split the power-supply core and MAX17055 driver changes
- use the requested registration init callback
- wait for FSTAT.DNR before programming POR values
- save, exit, and restore hibernate around MAX17055 EZ Config
- write stable registers once, wait 1 ms, and verify their read-back
- issue each command once and poll ModelCfg.Refresh
- derive dPAcc from register read-back values
- retry interrupted initialization periodically without a POR recheck
- keep properties unavailable until initialization completes
- recalculate dPAcc for a VChg-only override and reject zero voltage
- allow monitored-battery in the MAX17042 family binding
- drop the Librem 5 battery description because its user-replaceable pack
  cannot be identified reliably from the board revision

The series was also folded into a Librem 5r4 kernel and tested after a full
battery-removal gauge POR using a local battery description. Status.POR and
FSTAT.DNR cleared, HibCfg was restored, and ModelCfg.Refresh cleared. The
driver programmed dQAcc=0x002b and dPAcc=0x054b; the live dQAcc had moved to
0x002a after initialization. The other raw values and sysfs properties
matched the expected 4.2 V EZ Config result, with no MAX17055 initialization
errors.

v1: https://lore.kernel.org/all/20260406205759.493288-1-vincent.cloutier@icloud.com/

Vincent Cloutier (4):
  power: supply: Add registration init callback
  power: supply: max17042_battery: Initialize MAX17055 from battery info
  power: supply: max17042_battery: Honor MAX17055 charge voltage
  dt-bindings: power: supply: max17042: Allow monitored-battery

 .../bindings/power/supply/maxim,max17042.yaml |   2 +
 drivers/power/supply/max17042_battery.c       | 373 ++++++++++++++++--
 drivers/power/supply/power_supply_core.c      |   8 +
 include/linux/power/max17042_battery.h        |   2 +
 include/linux/power_supply.h                  |   8 +
 5 files changed, 361 insertions(+), 32 deletions(-)


base-commit: f2ec6312bf711369561bdcb22f8a63c0b118c479
-- 
2.55.0

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

end of thread, other threads:[~2026-07-20  7:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20  1:11 [PATCH v2 0/4] power: supply: initialize MAX17055 from battery info Vincent Cloutier
2026-07-20  1:11 ` [PATCH v2 1/4] power: supply: Add registration init callback Vincent Cloutier
2026-07-20  1:26   ` sashiko-bot
2026-07-20  1:11 ` [PATCH v2 2/4] power: supply: max17042_battery: Initialize MAX17055 from battery info Vincent Cloutier
2026-07-20  1:11 ` [PATCH v2 3/4] power: supply: max17042_battery: Honor MAX17055 charge voltage Vincent Cloutier
2026-07-20  1:11 ` [PATCH v2 4/4] dt-bindings: power: supply: max17042: Allow monitored-battery Vincent Cloutier
2026-07-20  1:21   ` sashiko-bot
2026-07-20  7:06   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox