Linux Power Management development
 help / color / mirror / Atom feed
From: Thomas Antoine <t.antoine@uclouvain.be>
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>,
	"André Draszik" <andre.draszik@linaro.org>
Cc: Conor Dooley <conor@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Peter Griffin <peter.griffin@linaro.org>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v6 2/2] dt-bindings: power: supply: add support for MAX77759 fuel gauge
Date: Tue, 27 Jan 2026 13:22:42 +0100	[thread overview]
Message-ID: <837005c7-63e2-4d38-a8c6-d4acb8310ea7@uclouvain.be> (raw)
In-Reply-To: <65xrumpt7ug5mqd7mkcknwyqmljrn4sofrqymg46bwvcmjoarr@wmt5fhsj3viz>

Hi,

On 9/19/25 12:32 AM, Sebastian Reichel wrote:
> Hi,
> 
> On Thu, Sep 18, 2025 at 02:02:55PM +0100, André Draszik wrote:
>>> On 9/15/25 7:31 PM, Conor Dooley wrote:
>>>> On Mon, Sep 15, 2025 at 12:14:11PM +0200, Thomas Antoine via B4 Relay wrote:
>>>>> From: Thomas Antoine <t.antoine@uclouvain.be>
>>>>>
>>>>> The Maxim MAX77759 is a companion PMIC for USB Type-C. It contains
>>>>> Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port
>>>>> Controller (TCPC), NVMEM, and additional GPIO interfaces
>>>>>
>>>>> Use max77759-fg compatible to avoid conflict with drivers for other
>>>>> functions.
>>>>>
>>>>> The battery node is used to pass the REPCAP and ICHGTERM values
>>>>> needed for the initialization of the fuel gauge.
>>>>>
>>>>> The nvmem cells are used to get initialization values and to backup
>>>>> the learning and the number of cycles. It should work out of the box
>>>>> with gs101-oriole and gs101-raven which were previously running
>>>>> Android.
>>>>>
>>>>> Signed-off-by: Thomas Antoine <t.antoine@uclouvain.be>
>>>>> ---
>>>>>  .../bindings/power/supply/maxim,max77759.yaml      | 78 ++++++++++++++++++++++
>>>>>  1 file changed, 78 insertions(+)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77759.yaml
>>>>> b/Documentation/devicetree/bindings/power/supply/maxim,max77759.yaml
>>>>> new file mode 100644
>>>>> index 0000000000000000000000000000000000000000..4d45739fcaf26273ec57b60049d6d0421df38efb
>>>>> --- /dev/null
>>>>> +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77759.yaml
>>>>> @@ -0,0 +1,78 @@
>>>>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
>>>>> +%YAML 1.2
>>>>> +---
>>>>> +$id: http://devicetree.org/schemas/power/supply/maxim,max77759.yaml#
>>>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>>>> +
>>>>> +title: Maxim Integrated MAX77759 fuel gauge
>>>>> +
>>>>> +maintainers:
>>>>> +  - Thomas Antoine <t.antoine@uclouvain.be>
>>>>> +
>>>>> +allOf:
>>>>> +  - $ref: power-supply.yaml#
>>>>> +
>>>>> +properties:
>>>>> +  compatible:
>>>>> +    const: maxim,max77759-fg
>>>>
>>>> Compatible doesn't match the filename, why?
>>>> I assume the "fg" is fuel-gauge, but can this device be anything else?
>>>
>>> The max77759 is a multifunction chip.
>>> The following compatibles are already used for some of those functions:
>>> - maxim,max77759 (for the pmic)
>>> - maxim,max77759-gpio
>>> - maxim,max77759-nvmem
>>> - maxim,max77759-tcpci
>>>
>>> The fuel gauge functionality that is added with this patch is very similar
>>> to the functionality of the max1720x which is why the filename was chosen
>>> to fit other maxim fuel gauge chips pattern.
>>>
>>> Maybe it would be better to use the maxim,max77759-battery compatible to
>>> match the filename? It would also fit with the already existing
>>> maxim,max77705-battery and maxim,max77849-battery compatibles.
>>
>> It also has a (battery) charger, a -battery compatible could be misleading.
>> The datasheet refers to these subblocks as FG (for fuelgauge) and CHARGER.
>> I'd suggest keeping those terms.
>>
>> Additionally, the FG block can also measure temperature and battery ID. For
>> those, a combination of (top-level) PMIC and FG registers are needed
>> unfortunately. Which means that the FG should probably be an MFD child
>> device, even though the FG itself doesn't depend on the top-level. Otherwise
>> it'd be hard to access the top-level PMIC register.
> 
> My understanding is, that the FG has a dedicated I2C device address
> and thus cannot be a simple MFD child of the PMIC. Did I misunderstood
> that part?
> 
> Assuming I understood things correctly, I think I suggest to model
> things like this for the battery temperature/ID:
> 
> i2c {
>     pmic: pmic@42 {
>         compatible = "maxim,max77759";
>         ...
> 
>         pmic_adc: adc {
>             compatible = "maxim,max77759-adc";
>             ...
>         };
>     };
> 
>     fuel-gauge@43 {
>         compatible = "maxim,max77759-fg";
>         ...
>         io-channels = <&pmic_adc MAX77759_ADC_BAT_TEMP>, <&pmic_adc MAX77759_ADC_BAT_ID>;
>         io-channel-names = "temperature", "ID";
>     };
> };

I have been looking into this and I don't think I understand how this
is needed.

When looking at the downstream driver for the battery level, battery
temperature is just returned based on the current level returned by
the chip. There is an optional filtering function:
LINK: https://android.googlesource.com/kernel/google-modules/bms/+/refs/heads/android-gs-raviole-mainline/google_battery.c#732
And from what I see in the downstream devicetree, it is not enabled.
So the current temperature should behave like the one on downstream if
the chip is correctly initiated.

For the battery id, it is stored in the EEPROM at address 50 of hsi2c_8
which I plan to use throught the nvmem framework like in v5 of this patch.

Am I missing something which would actually require this io-channels setup?

Greetings,
Thomas

  parent reply	other threads:[~2026-01-27 12:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15 10:14 [PATCH v6 0/2] MAX77759 Fuel Gauge driver support Thomas Antoine via B4 Relay
2025-09-15 10:14 ` [PATCH v6 1/2] power: supply: add support for MAX77759 fuel gauge Thomas Antoine via B4 Relay
2025-09-16 16:51   ` Sebastian Reichel
2025-09-15 10:14 ` [PATCH v6 2/2] dt-bindings: " Thomas Antoine via B4 Relay
2025-09-15 17:31   ` Conor Dooley
2025-09-18 12:36     ` Thomas Antoine
2025-09-18 13:02       ` André Draszik
2025-09-18 14:51         ` Conor Dooley
2025-09-18 22:32         ` Sebastian Reichel
2025-09-19 13:17           ` André Draszik
2026-01-27 12:22           ` Thomas Antoine [this message]
2026-01-06  7:12 ` [PATCH v6 0/2] MAX77759 Fuel Gauge driver support André Draszik
2026-01-06 16:54   ` Thomas Antoine
2026-01-06 17:08     ` André Draszik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=837005c7-63e2-4d38-a8c6-d4acb8310ea7@uclouvain.be \
    --to=t.antoine@uclouvain.be \
    --cc=andre.draszik@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=conor@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=robh@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox