Skip to contentSkip to conversation

power: supply: Add support for Maxim MAX8971 charger

PATCH Applied Svyatoslav Ryhel 2 participants 6 messages Apr 30, 2025 – May 3, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v6 cover power: supply: Add support for Maxim MAX8971 charger

The MAX8971 is a compact, high-frequency, high-efficiency switch-mode charger for a one-cell lithium-ion (Li+) battery.

---
Changes on switching from v5 to v6:
- upgraded ABI properties description
- minor formatting improvements

Changes on switching from v4 to v5:
- revert schema to v3
- removed i2c_client from driver data
- removed max8971_supplied_to
- swapped power_supply_config filling .of_node with .fwnode
- attr group liked to power_supply_config
- added ABI properties description

Changes on switching from v3 to v4:
- swap graph with connector phandle

Changes on switching from v2 to v3:
- fast_charge_timer, top_off_threshold_current and top_off_timer converted to device attributes. Other vendor properties removed.
- removed max8971_config
- removed unneded functions and definitions along vendor props removal
- added __maybe_unused for resume function

Changes on switching from v1 to v2:
- swap phandle with graph for extcon
- added power-supply ref
---

Svyatoslav Ryhel (2):
dt-bindings: power: supply: Document Maxim MAX8971 charger
power: supply: Add support for Maxim MAX8971 charger

 Documentation/ABI/testing/sysfs-class-power   |  43 +
 .../bindings/power/supply/maxim,max8971.yaml  |  68 ++
 drivers/power/supply/Kconfig                  |  14 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/max8971_charger.c        | 752 ++++++++++++++++++
 5 files changed, 878 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml
 create mode 100644 drivers/power/supply/max8971_charger.c
Signature · 1 line
2.48.1
#1 lore raw

PATCH v6 1/2 dt-bindings: power: supply: Document Maxim MAX8971 charger

Add bindings for Maxim MAX8971 charger.

---
 .../bindings/power/supply/maxim,max8971.yaml  | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml
Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml new file +68 -0
new file mode 100644
index 000000000000..2244cc3d45a6
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/maxim,max8971.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim MAX8971 IC charger
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+description:
+  The MAX8971 is a compact, high-frequency, high-efficiency switch-mode charger
+  for a one-cell lithium-ion (Li+) battery.
+
+allOf:
+  - $ref: power-supply.yaml#
+
+properties:
+  compatible:
+    const: maxim,max8971
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  monitored-battery: true
+
+  port:
+    description:
+      An optional port node to link the extcon device to detect type of plug.
+    $ref: /schemas/graph.yaml#/properties/port
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        charger@35 {
+            compatible = "maxim,max8971";
+            reg = <0x35>;
+
+            interrupt-parent = <&gpio>;
+            interrupts = <74 IRQ_TYPE_LEVEL_LOW>;
+
+            monitored-battery = <&battery>;
+
+            port {
+                charger_input: endpoint {
+                    remote-endpoint = <&extcon_output>;
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.48.1
#2 lore raw

PATCH v6 2/2 power: supply: Add support for Maxim MAX8971 charger

In reply to Svyatoslav Ryhel

The MAX8971 is a compact, high-frequency, high-efficiency switch-mode charger for a one-cell lithium-ion (Li+) battery.

---
 Documentation/ABI/testing/sysfs-class-power |  43 ++
 drivers/power/supply/Kconfig                |  14 +
 drivers/power/supply/Makefile               |   1 +
 drivers/power/supply/max8971_charger.c      | 752 ++++++++++++++++++++
 4 files changed, 810 insertions(+)
 create mode 100644 drivers/power/supply/max8971_charger.c
Documentation/ABI/testing/sysfs-class-power +43 -0
index 2a5c1a09a28f..560124cc3177 100644
@@ -822,3 +822,46 @@ Description:
 		Each entry is a link to the device which registered the extension.
 
 		Access: Read
+
+What:		/sys/class/power_supply/max8971-charger/fast_charge_timer
+Date:		May 2025
+KernelVersion:	6.15.0
+Contact:	Svyatoslav Ryhel <[email protected]>
+Description:
+		This entry shows and sets the maximum time the max8971
+		charger operates in fast-charge mode. When the timer expires
+		the device will terminate fast-charge mode (charging current
+		will drop to 0 A) and will trigger interrupt.
+
+		Valid values:
+
+		- 4 - 10 (hours), step by 1
+		- 0: disabled.
+
+What:		/sys/class/power_supply/max8971-charger/top_off_threshold_current
+Date:		May 2025
+KernelVersion:	6.15.0
+Contact:	Svyatoslav Ryhel <[email protected]>
+Description:
+		This entry shows and sets the charging current threshold for
+		entering top-off charging mode. When charging current in fast
+		charge mode drops below this value, the charger will trigger
+		interrupt and start top-off charging mode.
+
+		Valid values:
+
+		- 50000 - 200000 (microamps), step by 50000 (rounded down)
+
+What:		/sys/class/power_supply/max8971-charger/top_off_timer
+Date:		May 2025
+KernelVersion:	6.15.0
+Contact:	Svyatoslav Ryhel <[email protected]>
+Description:
+		This entry shows and sets the maximum time the max8971
+		charger operates in top-off charge mode. When the timer expires
+		the device will terminate top-off charge mode (charging current
+		will drop to 0 A) and will trigger interrupt.
+
+		Valid values:
+
+		- 0 - 70 (minutes), step by 10 (rounded down)
drivers/power/supply/Kconfig +14 -0
index 8dbd39afa43c..09fb123efe4f 100644
@@ -595,6 +595,20 @@ config CHARGER_MAX77976
 	  This driver can also be built as a module. If so, the module will be
 	  called max77976_charger.
 
+config CHARGER_MAX8971
+	tristate "Maxim MAX8971 battery charger driver"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  The MAX8971 is a compact, high-frequency, high-efficiency switch-mode
+	  charger for a one-cell lithium-ion (Li+) battery. It delivers up to
+	  1.55A of current to the battery from inputs up to 7.5V and withstands
+	  transient inputs up to 22V.
+
+	  Say Y to enable support for the Maxim MAX8971 battery charger.
+	  This driver can also be built as a module. If so, the module will be
+	  called max8971_charger.
+
 config CHARGER_MAX8997
 	tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver"
 	depends on MFD_MAX8997 && REGULATOR_MAX8997
drivers/power/supply/Makefile +1 -0
index 61677be328b0..f1c28ba34e4a 100644
@@ -81,6 +81,7 @@ obj-$(CONFIG_CHARGER_MAX77650)	+= max77650-charger.o
 obj-$(CONFIG_CHARGER_MAX77693)	+= max77693_charger.o
 obj-$(CONFIG_CHARGER_MAX77705)	+= max77705_charger.o
 obj-$(CONFIG_CHARGER_MAX77976)	+= max77976_charger.o
+obj-$(CONFIG_CHARGER_MAX8971)	+= max8971_charger.o
 obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
 obj-$(CONFIG_CHARGER_MP2629)	+= mp2629_charger.o
drivers/power/supply/max8971_charger.c new file +752 -0

752 lines not on this page · raw message

Signature · 1 line
2.48.1
#3 lore raw

ср, 30 квіт. 2025 р. о 08:51 Svyatoslav Ryhel <[email protected]> пише:

Quoted 13 lines

The MAX8971 is a compact, high-frequency, high-efficiency switch-mode charger for a one-cell lithium-ion (Li+) battery.

---
 Documentation/ABI/testing/sysfs-class-power |  43 ++
 drivers/power/supply/Kconfig                |  14 +
 drivers/power/supply/Makefile               |   1 +
 drivers/power/supply/max8971_charger.c      | 752 ++++++++++++++++++++
 4 files changed, 810 insertions(+)
 create mode 100644 drivers/power/supply/max8971_charger.c

...

drivers/power/supply/Kconfig config CHARGER_MAX77976 · line 600

Quoted 11 lines
drivers/power/supply/Kconfig +3 -0
index 8dbd39afa43c..09fb123efe4f 100644
@@ -595,6 +595,20 @@ config CHARGER_MAX77976
          This driver can also be built as a module. If so, the module will be
          called max77976_charger.
 
+config CHARGER_MAX8971
+       tristate "Maxim MAX8971 battery charger driver"
+       depends on I2C

Greetings, Sebastian!

Kernel test robot caught an issue regards dependencies of this driver. Although, it was made in way that extcon is optional, unfortunately extcon framework is not. Extcon header does not provide inline versions of functions used here hence undefined references pop up. I suppose proper fix would be by adding depends on EXTCON. Would you amend this commit or should I send a v7?

Thank you for all your efforts and sorry for inconvenience.

Best regards,
Svyatoslav R.

Quoted 14 lines
drivers/power/supply/Kconfig +11 -0
+       select REGMAP_I2C
+       help
+         The MAX8971 is a compact, high-frequency, high-efficiency switch-mode
+         charger for a one-cell lithium-ion (Li+) battery. It delivers up to
+         1.55A of current to the battery from inputs up to 7.5V and withstands
+         transient inputs up to 22V.
+
+         Say Y to enable support for the Maxim MAX8971 battery charger.
+         This driver can also be built as a module. If so, the module will be
+         called max8971_charger.
+
 config CHARGER_MAX8997
        tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver"
        depends on MFD_MAX8997 && REGULATOR_MAX8997

...

#4 lore raw

сб, 3 трав. 2025 р. о 09:07 Svyatoslav Ryhel <[email protected]> пише:

Quoted 39 lines

ср, 30 квіт. 2025 р. о 08:51 Svyatoslav Ryhel <[email protected]> пише:

Quoted 13 lines

The MAX8971 is a compact, high-frequency, high-efficiency switch-mode charger for a one-cell lithium-ion (Li+) battery.

---
 Documentation/ABI/testing/sysfs-class-power |  43 ++
 drivers/power/supply/Kconfig                |  14 +
 drivers/power/supply/Makefile               |   1 +
 drivers/power/supply/max8971_charger.c      | 752 ++++++++++++++++++++
 4 files changed, 810 insertions(+)
 create mode 100644 drivers/power/supply/max8971_charger.c

...

drivers/power/supply/Kconfig config CHARGER_MAX77976 · line 600

Quoted 11 lines
drivers/power/supply/Kconfig +3 -0
index 8dbd39afa43c..09fb123efe4f 100644
@@ -595,6 +595,20 @@ config CHARGER_MAX77976
          This driver can also be built as a module. If so, the module will be
          called max77976_charger.
 
+config CHARGER_MAX8971
+       tristate "Maxim MAX8971 battery charger driver"
+       depends on I2C

Greetings, Sebastian!

Kernel test robot caught an issue regards dependencies of this driver. Although, it was made in way that extcon is optional, unfortunately extcon framework is not. Extcon header does not provide inline versions of functions used here hence undefined references pop up. I suppose proper fix would be by adding depends on EXTCON. Would you amend this commit or should I send a v7?

Quoted 5 lines

Thank you for all your efforts and sorry for inconvenience.

Best regards,
Svyatoslav R.

UPD: addressed by Arnd Bergmann here
https://lkml.org/lkml/2025/5/3/271

Quoted 15 lines
Quoted 14 lines
drivers/power/supply/Kconfig +11 -0
+       select REGMAP_I2C
+       help
+         The MAX8971 is a compact, high-frequency, high-efficiency switch-mode
+         charger for a one-cell lithium-ion (Li+) battery. It delivers up to
+         1.55A of current to the battery from inputs up to 7.5V and withstands
+         transient inputs up to 22V.
+
+         Say Y to enable support for the Maxim MAX8971 battery charger.
+         This driver can also be built as a module. If so, the module will be
+         called max8971_charger.
+
 config CHARGER_MAX8997
        tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver"
        depends on MFD_MAX8997 && REGULATOR_MAX8997

...

#5 lore raw
In reply to Svyatoslav Ryhel
Quoted 3 lines · Svyatoslav Ryhel

The MAX8971 is a compact, high-frequency, high-efficiency switch-mode charger for a one-cell lithium-ion (Li+) battery.

Applied, thanks!

[1/2] dt-bindings: power: supply: Document Maxim MAX8971 charger

      commit: c5a0a64c1222cd2bfab3ae4227caba2f1c0499f5
[2/2] power: supply: Add support for Maxim MAX8971 charger
      commit: 60cd40eee4f4f57e88bd5dd03f299eb9e17c73e5

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>