Skip to contentSkip to conversation

power: supply: Add support for Maxim MAX8971 charger

PATCH Superseded Svyatoslav Ryhel 2 participants 6 messages Mar 3, 2025 – Mar 4, 2025

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 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 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

 .../bindings/power/supply/maxim,max8971.yaml  |  68 ++
 drivers/power/supply/Kconfig                  |  14 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/max8971_charger.c        | 758 ++++++++++++++++++
 4 files changed, 841 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.43.0
#1 lore raw

PATCH v3 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.43.0
maintainer
#2 lore raw

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

Quoted 38 lines · Svyatoslav Ryhel

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 +24 -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

Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml new file +10 -0
+
+  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

extcon as a binding is pretty much deprecated in favor of connector bindings.

The OF graph is an overkill here too. You should just need a phandle to the connector node.

Rob

#3 lore raw

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

вт, 4 бер. 2025 р. о 15:58 Rob Herring <[email protected]> пише:

Quoted 54 lines · Svyatoslav Ryhel
Quoted 38 lines

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 +24 -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

Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml new file +10 -0
+
+  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

extcon as a binding is pretty much deprecated in favor of connector bindings.

Quoted 3 lines

The OF graph is an overkill here too. You should just need a phandle to the connector node.

What if extcon controls the connector? Why OF graph is not suitable, it fits trends in supply bindings and it is optional anyway.

Quoted 1 line

Rob

#4 lore raw

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

In reply to Rob Herring

вт, 4 бер. 2025 р. о 15:58 Rob Herring <[email protected]> пише:

Quoted 54 lines · Svyatoslav Ryhel
Quoted 38 lines

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 +24 -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

Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/power/supply/maxim,max8971.yaml new file +10 -0
+
+  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

extcon as a binding is pretty much deprecated in favor of connector bindings.

Quoted 3 lines

The OF graph is an overkill here too. You should just need a phandle to the connector node.

Actually, I am fine with using connector phandle if this will lead to acceptance of schema.
I will add this in v4 once time comes. Thanks.

Quoted 1 line

Rob

#5 lore raw

PATCH v3 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.

---
 drivers/power/supply/Kconfig           |  14 +
 drivers/power/supply/Makefile          |   1 +
 drivers/power/supply/max8971_charger.c | 758 +++++++++++++++++++++++++
 3 files changed, 773 insertions(+)
 create mode 100644 drivers/power/supply/max8971_charger.c
drivers/power/supply/Kconfig +14 -0
index 9f2eef6787f7..7c86116c2947 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 59c4a9f40d28..8fa051ff87ff 100644
@@ -81,6 +81,7 @@ obj-$(CONFIG_CHARGER_DETECTOR_MAX14656)	+= max14656_charger_detector.o
 obj-$(CONFIG_CHARGER_MAX77650)	+= max77650-charger.o
 obj-$(CONFIG_CHARGER_MAX77693)	+= max77693_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 +758 -0

758 lines not on this page · raw message

Signature · 1 line
2.43.0