From: Guenter Roeck <linux@roeck-us.net>
To: Pablo Mazzini <pmazzini@gmail.com>
Cc: Alistair Francis <alistair@alistair23.me>,
Andreas Kemnade <andreas@kemnade.info>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/7] hwmon: sy7636a: read the temperature only while the rails are on
Date: Mon, 2 Nov 2026 06:41:05 -0800 [thread overview]
Message-ID: <862b0b65-6c7e-4521-9fd3-c5d53e4ddb72@roeck-us.net> (raw)
In-Reply-To: <CAAxh=jvHthWQb2zi-XKM9ggM3Qi7Ra=QSfCGsVTPk54HexQqHA@mail.gmail.com>
On 11/2/26 00:09, Pablo Mazzini wrote:
> Thanks for looking at it.
>
> Reading the temperature races with the rails being switched on and
> off, as Andreas pointed out on v1.
>
This should be explained as comment, with source (I don't see that
in the datasheet).
> PG only goes high once all rails are up, after the first measurement.
> It is also in register 0x07, next to the thermistor readout, so one
> short transfer reads both.
>
That is not really an argument. With the current implementation,
static state with EN=1 and PG=0 will report no temperatures even though
temperatures may be available.
Guenter
> Pablo
>
> On Mon, Nov 2, 2026 at 3:35 AM Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> On 11/1/26 14:31, Pablo Mazzini wrote:
>>> The driver enables VCOM at probe, which keeps the panel's high voltage
>>> rails on for good, and gets a dummy regulator if it probes before the
>>> regulator exists. Read the temperature only while the rails are on, when
>>> the chip samples it, and return -ENODATA otherwise. Read power good with
>>> it in one transfer, so the value can not be from before the first sample
>>> or after the rails went off. Register it under the chip name, as the
>>> TPS65185 and FP9931 drivers do.
>>>
>>> Signed-off-by: Pablo Mazzini <pmazzini@gmail.com>
>>> ---
>>> drivers/hwmon/sy7636a-hwmon.c | 25 ++++++++++++++-----------
>>> 1 file changed, 14 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/sy7636a-hwmon.c b/drivers/hwmon/sy7636a-hwmon.c
>>> index f01f368d68e5..475aff997c2d 100644
>>> --- a/drivers/hwmon/sy7636a-hwmon.c
>>> +++ b/drivers/hwmon/sy7636a-hwmon.c
>>> @@ -14,7 +14,6 @@
>>> #include <linux/module.h>
>>> #include <linux/platform_device.h>
>>> #include <linux/regmap.h>
>>> -#include <linux/regulator/machine.h>
>>>
>>> #include <linux/mfd/sy7636a.h>
>>>
>>> @@ -22,14 +21,22 @@ static int sy7636a_read(struct device *dev, enum hwmon_sensor_types type,
>>> u32 attr, int channel, long *temp)
>>> {
>>> struct regmap *regmap = dev_get_drvdata(dev);
>>> - int ret, reg_val;
>>> -
>>> - ret = regmap_read(regmap,
>>> - SY7636A_REG_TERMISTOR_READOUT, ®_val);
>>> + u8 buf[2];
>>> + int ret;
>>> +
>>> + /*
>>> + * Read power good and the thermistor in one transfer: the thermistor is
>>> + * only sampled while the rails are on, and power good comes after the
>>> + * first sample
>>> + */
>>> + ret = regmap_bulk_read(regmap, SY7636A_REG_FAULT_FLAG, buf, sizeof(buf));
>>> if (ret)
>>> return ret;
>>>
>>> - *temp = (s8)reg_val * 1000;
>>> + if (!(buf[0] & SY7636A_FAULT_FLAG_PG))
>>> + return -ENODATA;
>>> +
>>
>> I had a look at the datasheet. It does not say anything about the
>> temperature not being measured when PG is not set.
>>
>> The datasheet does suggest that temperatures are only measured
>> if bit 7 of the operation mode register is set, but that is
>> different from the "power good" bit in the fault register.
>>
>> So why the association with the PG bit and not with the On/Off bit
>> of the operation mode register ? That warrants some more explanation.
>>
>> Thanks,
>> Guenter
>> > + *temp = (s8)buf[1] * 1000;
>>>
>>> return 0;
>>> }
>>> @@ -72,12 +79,8 @@ static int sy7636a_sensor_probe(struct platform_device *pdev)
>>> if (!regmap)
>>> return -EPROBE_DEFER;
>>>
>>> - err = devm_regulator_get_enable(&pdev->dev, "vcom");
>>> - if (err)
>>> - return err;
>>> -
>>> hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
>>> - "sy7636a_temperature", regmap,
>>> + "sy7636a", regmap,
>>> &sy7636a_chip_info, NULL);
>>>
>>> if (IS_ERR(hwmon_dev)) {
>>
next prev parent reply other threads:[~2026-11-02 14:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 22:31 [PATCH v2 0/7] sy7636a: power the panel only during updates Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 1/7] regulator: sy7636a: fix the chip name Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 2/7] regulator: sy7636a: add VCOM voltage control Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 3/7] regulator: sy7636a: wait for power good on enable Pablo Mazzini
2026-11-02 7:28 ` Andreas Kemnade
2026-11-02 13:30 ` Mark Brown
2026-11-02 17:08 ` Pablo Mazzini
2026-11-02 17:17 ` Mark Brown
2026-11-01 22:31 ` [PATCH v2 4/7] hwmon: sy7636a: fix negative temperatures Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 5/7] hwmon: sy7636a: read the temperature only while the rails are on Pablo Mazzini
2026-11-02 3:35 ` Guenter Roeck
2026-11-02 8:09 ` Pablo Mazzini
2026-11-02 14:41 ` Guenter Roeck [this message]
2026-11-02 10:25 ` Andreas Kemnade
2026-11-02 14:43 ` Guenter Roeck
2026-11-02 17:09 ` Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 6/7] regulator: sy7636a: bind to the I2C device directly Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 7/7] ARM: imx_v6_v7_defconfig: drop the SY7636A MFD option Pablo Mazzini
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=862b0b65-6c7e-4521-9fd3-c5d53e4ddb72@roeck-us.net \
--to=linux@roeck-us.net \
--cc=alistair@alistair23.me \
--cc=andreas@kemnade.info \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmazzini@gmail.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
all inboxes | Powered by JetHome®