Skip to content

Add support for MAX1720x Maxim ModelGauge m5 Fuel Gauge #2774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: "http://devicetree.org/schemas/power/supply/maxim,max1720x.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: Maxim ModelGauge m5 Fuel Gauge family (MAX17201/5, MAX1733x series)

maintainers:
- "Joan Na <joan.na@analog.com>"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't mix bindings with driver code. Bindings should be in it's own patch...


description: |
Bindings for Maxim Integrated ModelGauge m5 stand-alone fuel gauge ICs.
This includes MAX17201, MAX17205, MAX17300/1/2/3, MAX17320, MAX17330/32/35.

properties:
compatible:
enum:
- "maxim,max17201"
- "maxim,max17205"
- "maxim,max17300"
- "maxim,max17301"
- "maxim,max17302"
- "maxim,max17303"
- "maxim,max17320"
- "maxim,max17330"
- "maxim,max17332"
- "maxim,max17335"

reg:
description: I2C address of the device
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop the description

maxItems: 1

maxim,rsense:
description: Rsense register value in milliohms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

$ref: /schemas/types.yaml#/definitions/uint32

maxim,talrt-min:
description: Lower temperature limit (in degree Celsius) to trigger ALRT1
$ref: /schemas/types.yaml#/definitions/int32

maxim,talrt-max:
description: Upper temperature limit (in degree Celsius) to trigger ALRT1
$ref: /schemas/types.yaml#/definitions/int32

maxim,valrt-min:
description: Lower voltage limit (in mV) to trigger ALRT1
$ref: /schemas/types.yaml#/definitions/uint32

maxim,valrt-max:
description: Upper voltage limit (in mV) to trigger ALRT1
$ref: /schemas/types.yaml#/definitions/uint32

maxim,salrt-min:
description: Lower SOC (State of Charge) limit (in %) to trigger ALRT1
$ref: /schemas/types.yaml#/definitions/uint32

maxim,salrt-max:
description: Upper SOC (State of Charge) limit (in %) to trigger ALRT1
$ref: /schemas/types.yaml#/definitions/uint32

maxim,ialrt-min:
description: Lower current limit (in mA) to trigger ALRT1
$ref: /schemas/types.yaml#/definitions/int32

maxim,ialrt-max:
description: Upper current limit (in mA) to trigger ALRT1
$ref: /schemas/types.yaml#/definitions/int32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost all of the above feel like hwmon stuff. It seems the power supply subsystem already has some ind of bridge with hwmon. Did you looked at this:

https://elixir.bootlin.com/linux/v6.14.5/source/drivers/power/supply/power_supply_core.c#L1600

Make sure you have no way of controlling the above at runtime before considering dt properties


status:
enum: [ "okay", "disabled" ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the above property? You're not including any other bindings... If it's the DT node status, drop it.


required:
- compatible
- reg

additionalProperties: false

examples:
- |
fuel-gauge@36 {
compatible = "maxim,max17335";
status = "okay";
reg = <0x36>;
interrupt-parent = <&gpio>;
interrupts = <16 0>;
maxim,rsense = <5>;
maxim,talrt-min = <0>;
maxim,talrt-max = <50>;
maxim,valrt-min = <3000>;
maxim,valrt-max = <4500>;
maxim,salrt-min = <1>;
maxim,salrt-max = <99>;
maxim,ialrt-min = <(-5000)>;
maxim,ialrt-max = <5000>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have 4 spaces the exmaple

};
11 changes: 11 additions & 0 deletions drivers/power/supply/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,18 @@ config BATTERY_MAX1721X

Say Y here to enable support for the MAX17211/MAX17215 standalone
battery gas-gauge.

config BATTERY_MAX1721X
Copy link
Contributor

@gastmaier gastmaier May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be BATTERY_MAX1720X and before the previous entry, always in alphabetical order

I did a run with the experimental ci at https://github.com/gastmaier/adi-linux/actions/runs/14999793574
But since the driver never gets compiled (and a error is raised for it), it is only linting checking

tristate "MAX17201/MAX17215 standalone gas-gauge"
depends on I2C
select REGMAP_I2C
help
MAX1720x is fuel-gauge systems for lithium-ion (Li+) batteries
in handheld and portable equipment.

Say Y here to enable support for the MAX17201/MAX17335 standalone
battery gas-gauge.

config BATTERY_TWL4030_MADC
tristate "TWL4030 MADC battery driver"
depends on TWL4030_MADC
Expand Down
1 change: 1 addition & 0 deletions drivers/power/supply/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ obj-$(CONFIG_BATTERY_DA9150) += da9150-fg.o
obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o
obj-$(CONFIG_BATTERY_MAX1721X) += max1721x_battery.o
obj-$(CONFIG_BATTERY_MAX1720X) += max1720x_battery.o
obj-$(CONFIG_BATTERY_RT5033) += rt5033_battery.o
obj-$(CONFIG_CHARGER_RT5033) += rt5033_charger.o
obj-$(CONFIG_CHARGER_RT9455) += rt9455_charger.o
Expand Down
Loading
Loading