Re: [PATCH] dt-bindings: hwmon: pmbus: mps,mpq8785: add #thermal-sensor-cells
From: Guenter Roeck
Date: Wed Sep 30 2026 - 18:41:27 EST
On Wed, Sep 30, 2026 at 07:27:43PM +0200, Vincent Jardin wrote:
> Hi Guenter,
>
> On Wed, Sep 30, 2026 at 02:07:21PM +0000, sashiko-bot@xxxxxxxxxx wrote:
> > [Severity: Medium]
> > Is it correct to set the cell count constraint to 1 for this hardware?
> >
> > The Devicetree specification generally mandates that single-sensor devices
> > use a cell count of 0, as no index is needed to identify the sensor. By
> > forcing this to 1, it appears we might be baking a Linux-specific driver
> > quirk (the PMBus core's internal 1-based index) into the OS-agnostic
> > hardware description ABI.
>
> M. Bot has a point, and it is a PMBus core question, so I would like
> your view before a v2 of this binding.
>
> Since the commit
> 3aa74796cfd0 ("hwmon: (pmbus) Register with thermal for PSC_TEMPERATURE")
> pmbus_core registers each temperature input using its hwmon index as the
> sensor id, so temp1 is sensor 1.
>
> The hwmon core counts from 0 instead:
> for example temp1 is sensor 0 for jc42, tmp401, lm90 or adt7470.
>
> With the 1 based id, a single-sensor PMBus device cannot use
> #thermal-sensor-cells = <0>: thermal_of matches a phandle without
> cells as id 0, and no PMBus sensor has id 0. That is why this patch
> uses const 1.
>
> No current DTS references a PMBus device from a thermal zone, and no
> PMBus binding allows #thermal-sensor-cells yet.
>
> Aligning PMBus on the hwmon core would mean:
>
> drivers/hwmon/pmbus/pmbus_core.c
> static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
> ...
> if (class == PSC_TEMPERATURE && strcmp(type, "input") == 0)
> - pmbus_thermal_add_sensor(data, sensor, seq);
> + pmbus_thermal_add_sensor(data, sensor, seq - 1);
>
> return sensor;
> }
>
>
> If you agree, I will send it, with a v2 of this binding using
> const: 0, since each device of mps,mpq8785.yaml has a
> single temperature input. Otherwise, we should keep const 1.
>
Yes, that is a bug. Please send a patch. I'd prefer the index
to be handled in the call to devm_thermal_of_zone_register(),
though, with an added comment explaining that the temperature sensor
index in the PMBus core starts with 1 and the thermal core expects
a 0-based index.
Thanks,
Guenter