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

Conversation

joan-na-good
Copy link
Collaborator

The MAX1720x is a stand-alone fuel gauge that communicates via I2C and provides battery voltage, current.

The driver registers as a power supply class device and supports basic property reads via the sysfs interface.

The binding document for the Device Tree has been added at: Documentation/devicetree/bindings/power/supply/maxim,max1720x.yaml

PR Description

  • Please replace this comment with a summary of your changes, and add any context
    necessary to understand them. List any dependencies required for this change.
  • To check the checkboxes below, insert a 'x' between square brackets (without
    any space), or simply check them after publishing the PR.
  • If you changes include a breaking change, please specify dependent PRs in the
    description and try to push all related PRs simultaneously.

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

The MAX1720x is a stand-alone fuel gauge that communicates
via I2C and provides battery voltage, current.

The driver registers as a power supply class device and
supports basic property reads via the sysfs interface.

The binding document for the Device Tree has been added at:
Documentation/devicetree/bindings/power/supply/maxim,max1720x.yaml

Signed-off-by: Joan Na <joan.na@analog.com>
Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Stopping the review now... The driver has 6k lines! Please make our life easier and properly separate things. Start by adding the basic power supply features of the device and then start building on top of that.

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

- "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/int32

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.


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

[ID_MAX17320] = max17320_get_battery_health,
[ID_MAX17330] = max17330_get_battery_health,
[ID_MAX17332] = max17330_get_battery_health,
[ID_MAX17335] = max17330_get_battery_health,
Copy link
Collaborator

Choose a reason for hiding this comment

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

put this in a chip info structure

[ID_MAX17335] = max17330_get_battery_health,
};

static u32 register_to_read;
Copy link
Collaborator

Choose a reason for hiding this comment

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

global variable like this is very questionable

static irqreturn_t max17330_irq_handler(int id, void *dev);

static int max1720x_regmap_write(struct max1720x_priv *priv, unsigned int reg, unsigned int val);
static int max1720x_regmap_read(struct max1720x_priv *priv, unsigned int reg, unsigned int *val);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

[ID_MAX17330] = max17330_irq_handler,
[ID_MAX17332] = max17330_irq_handler,
[ID_MAX17335] = max17330_irq_handler,
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

[ID_MAX17330] = max17330_regs,
[ID_MAX17332] = max17332_regs,
[ID_MAX17335] = max17335_regs,
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dunno the above is really needed

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants