* [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support
@ 2026-07-28 3:07 Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470 Luiz Angelo Daros de Luca
` (4 more replies)
0 siblings, 5 replies; 15+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-28 3:07 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König
Cc: linux-hwmon, devicetree, linux-kernel, Luiz Angelo Daros de Luca,
linux-pwm
The ADT7470 is a temperature monitor and PWM fan controller capable of
monitoring up to ten external temperature sensors and controlling up to
four PWM outputs.
Currently, the driver exposes these sensors and PWM controls only
through the hwmon sysfs interface. This patch series integrates the
ADT7470 driver with the kernel's thermal and PWM subsystems. This allows
temperature sensors to participate in Device Tree thermal zones while
exposing the PWM outputs as generic PWM providers for consumers such as
pwm-fan.
Patch 1 adds the YAML device tree binding documentation.
Patch 2 introduces the ADT7470_PWM_MAX macro.
Patch 3 registers the four PWM channels as a generic PWM provider.
Patch 4 registers the external temperature sensors with the thermal
framework.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
Changes in v3:
- Migrated from the `.apply` callback to the PWM Waveform API.
- Moved fixes to another patch series:
20260727-adt7470_thermalzone-v3-0-21424d550c3d@gmail.com
- Use guard(mutex) for simpler locking.
- Link to v2: https://patch.msgid.link/20260717-adt7470_thermalzone-v2-0-a55147958fad@gmail.com
Changes in v2:
- Fixed 2 previous bugs uncovered by Sashiko-bot during review.
- Dropped the thermal cooling device registration for the PWM channels.
- Implemented generic PWM provider support using the PWM subsystem.
- Updated Kconfig to safely handle the PWM subsystem dependency (depends on PWM || PWM=n).
- Updated Device Tree bindings to require #pwm-cells instead of #cooling-cells.
- Link to v1: https://patch.msgid.link/20260716-adt7470_thermalzone-v1-0-cc55ef35edde@gmail.com
To: Guenter Roeck <linux@roeck-us.net>
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>
To: Andrew Morton <akpm@linux-foundation.org>
To: "Darrick J. Wong" <djwong@us.ibm.com>
To: Uwe Kleine-König <ukleinek@kernel.org>
Cc: linux-hwmon@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pwm@vger.kernel.org
---
Luiz Angelo Daros de Luca (4):
dt-bindings: hwmon: adi,adt7470
hwmon: (adt7470) Add ADT7470_PWM_MAX macro
hwmon: (adt7470) Expose fan control via PWM framework
hwmon: (adt7470) Add thermal zone sensor support
.../devicetree/bindings/hwmon/adi,adt7470.yaml | 55 ++++++++
drivers/hwmon/Kconfig | 1 +
drivers/hwmon/adt7470.c | 146 ++++++++++++++++++++-
3 files changed, 199 insertions(+), 3 deletions(-)
---
base-commit: 858071a1ca5f9a3330b4559dab41565086ab4862
change-id: 20260716-adt7470_thermalzone-59a102278d72
prerequisite-message-id: <20260727-adt7470_fixes-v2-0-598e38a46ba6@gmail.com>
prerequisite-patch-id: c9bcf1ff38418e47f71472b71dfde900d8d930ec
prerequisite-patch-id: 13a1e87608fe9df25880aa4d1a415aa2dc0b6ffd
prerequisite-patch-id: 01857ee7a1f867a6d415a72f471db5cfef294235
prerequisite-patch-id: 4472685c2096d7d07e580b5d07c37328e0a13ad5
prerequisite-patch-id: 7a40cf8dfb0282f8b7341a1277d4169d8573cb13
prerequisite-patch-id: c8f47ab359354fcc2a7c742adb4b26e3a761bd07
prerequisite-patch-id: 1b37470872d5d5d7795370ceec16e2695894bb44
prerequisite-patch-id: 5ba552f8997854e2f24c3ef005490b5eedcf083f
Best regards,
--
Luiz Angelo Daros de Luca <luizluca@gmail.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-28 3:07 [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support Luiz Angelo Daros de Luca
@ 2026-07-28 3:07 ` Luiz Angelo Daros de Luca
2026-07-28 8:14 ` Krzysztof Kozlowski
2026-07-28 3:07 ` [hwmon-next PATCH v3 2/4] hwmon: (adt7470) Add ADT7470_PWM_MAX macro Luiz Angelo Daros de Luca
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-28 3:07 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König
Cc: linux-hwmon, devicetree, linux-kernel, Luiz Angelo Daros de Luca,
linux-pwm
The Analog Devices ADT7470 is a multichannel temperature sensor and
PWM fan controller. It supports monitoring up to 10 external
temperature sensors and controlling up to 4 fans.
Add the device tree binding documentation for it. This includes
support for the thermal framework by defining the "#thermal-sensor-cells"
property, and models the fan control lines as PWM channels by
defining the "#pwm-cells" property.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
.../devicetree/bindings/hwmon/adi,adt7470.yaml | 55 ++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
new file mode 100644
index 000000000000..bb2375a4a490
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/adi,adt7470.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices ADT7470 hwmon sensor
+
+maintainers:
+ - Luiz Angelo Daros de Luca <luizluca@gmail.com>
+
+description:
+ Multi-channel temperature monitor and PWM fan controller.
+ It supports monitoring up to 10 external temperature sensors and
+ controlling up to four fans. The fan control lines are modeled
+ as standard PWM channels.
+
+properties:
+ compatible:
+ const: adi,adt7470
+
+ reg:
+ maxItems: 1
+
+ "#pwm-cells":
+ const: 3
+ description:
+ See Documentation/devicetree/bindings/pwm/pwm.yaml for the
+ generic PWM binding description.
+
+ "#thermal-sensor-cells":
+ const: 1
+ description:
+ Number of cells required to uniquely identify the temperature sensors.
+ Valid index values are 0 to 9, corresponding to temp1 through temp10.
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ hwmon@2f {
+ compatible = "adi,adt7470";
+ reg = <0x2f>;
+ #pwm-cells = <3>;
+ #thermal-sensor-cells = <1>;
+ };
+ };
--
2.55.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [hwmon-next PATCH v3 2/4] hwmon: (adt7470) Add ADT7470_PWM_MAX macro
2026-07-28 3:07 [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470 Luiz Angelo Daros de Luca
@ 2026-07-28 3:07 ` Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 3/4] hwmon: (adt7470) Expose fan control via PWM framework Luiz Angelo Daros de Luca
` (2 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-28 3:07 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König
Cc: linux-hwmon, devicetree, linux-kernel, Luiz Angelo Daros de Luca,
linux-pwm
Instead of a magic 255, use a macro to refer to it.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/hwmon/adt7470.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index c45b984c02e6..87ddd7b8ddae 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -100,6 +100,7 @@ static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END };
#define ADT7470_REG_FAN_MAX(x) (ADT7470_REG_FAN_MAX_BASE_ADDR + ((x) * 2))
#define ADT7470_PWM_COUNT 4
+#define ADT7470_PWM_MAX 255
#define ADT7470_REG_PWM(x) (ADT7470_REG_PWM_BASE_ADDR + (x))
#define ADT7470_REG_PWM_MAX(x) (ADT7470_REG_PWM_MAX_BASE_ADDR + (x))
#define ADT7470_REG_PWM_MIN(x) (ADT7470_REG_PWM_MIN_BASE_ADDR + (x))
@@ -850,7 +851,7 @@ static int adt7470_pwm_write(struct device *dev, u32 attr, int channel, long val
switch (attr) {
case hwmon_pwm_input:
- val = clamp_val(val, 0, 255);
+ val = clamp_val(val, 0, ADT7470_PWM_MAX);
mutex_lock(&data->lock);
err = regmap_write(data->regmap, ADT7470_REG_PWM(channel),
val);
@@ -910,7 +911,7 @@ static ssize_t pwm_max_store(struct device *dev,
if (kstrtol(buf, 10, &temp))
return -EINVAL;
- temp = clamp_val(temp, 0, 255);
+ temp = clamp_val(temp, 0, ADT7470_PWM_MAX);
mutex_lock(&data->lock);
data->pwm_max[attr->index] = temp;
@@ -945,7 +946,7 @@ static ssize_t pwm_min_store(struct device *dev,
if (kstrtol(buf, 10, &temp))
return -EINVAL;
- temp = clamp_val(temp, 0, 255);
+ temp = clamp_val(temp, 0, ADT7470_PWM_MAX);
mutex_lock(&data->lock);
data->pwm_min[attr->index] = temp;
--
2.55.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [hwmon-next PATCH v3 3/4] hwmon: (adt7470) Expose fan control via PWM framework
2026-07-28 3:07 [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470 Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 2/4] hwmon: (adt7470) Add ADT7470_PWM_MAX macro Luiz Angelo Daros de Luca
@ 2026-07-28 3:07 ` Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 4/4] hwmon: (adt7470) Add thermal zone sensor support Luiz Angelo Daros de Luca
2026-07-28 3:21 ` [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal " Luiz Angelo Daros de Luca
4 siblings, 0 replies; 15+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-28 3:07 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König
Cc: linux-hwmon, devicetree, linux-kernel, Luiz Angelo Daros de Luca,
linux-pwm
The ADT7470 features four PWM outputs designed to control fans.
Previously, these were only accessible through the legacy hwmon
sysfs interface.
Expose the ADT7470 fan control lines through the generic PWM framework.
This allows generic PWM consumers described in Device Tree, such as
"pwm-fan", to use the device through the "#pwm-cells" property. This is
particularly necessary for boards where the ADT7470 external temperature
sensors are not populated and the chip is used strictly as a fan
controller (e.g., Edgecore ECS-2100-52T switches). In such setups,
delegating control to the generic PWM subsystem allows the kernel's
thermal framework to manage the fans based on unrelated temperature
zones, such as internal SoC sensors.
When a PWM consumer applies a new PWM state, the driver automatically
switches the corresponding PWM channel to manual mode so that the
requested duty cycle takes effect. The duty cycle specified by the PWM
framework is internally converted to the 0-255 scale expected by the
hardware registers.
The legacy sysfs interface remains unaffected and operates in parallel.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/hwmon/Kconfig | 1 +
drivers/hwmon/adt7470.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 138 insertions(+)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 6b71e3304b4f..0d6bd117d14d 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -224,6 +224,7 @@ config SENSORS_ADT7462
config SENSORS_ADT7470
tristate "Analog Devices ADT7470"
depends on I2C
+ depends on PWM || PWM=n
select REGMAP_I2C
help
If you say yes here you get support for the Analog Devices
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 87ddd7b8ddae..883838fdcd7d 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -22,6 +22,9 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/util_macros.h>
+#include <linux/pwm.h>
+#include <linux/cleanup.h>
+#include <linux/math64.h>
/* Addresses to scan */
static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END };
@@ -887,6 +890,125 @@ static int adt7470_pwm_write(struct device *dev, u32 attr, int channel, long val
return err;
}
+struct adt7470_pwm_wfhw {
+ u8 val;
+};
+
+static int adt7470_pwm_round_waveform_tohw(struct pwm_chip *chip,
+ struct pwm_device *pwm,
+ const struct pwm_waveform *wf,
+ void *_wfhw)
+{
+ struct adt7470_data *data = pwmchip_get_drvdata(chip);
+ struct adt7470_pwm_wfhw *wfhw = _wfhw;
+ u64 period_ns;
+
+ if (wf->duty_length_ns == 0) {
+ wfhw->val = 0;
+ return 0;
+ }
+
+ /*
+ * The PWM frequency (period) is a single chip-wide setting shared by
+ * all 4 channels, so it cannot be changed on a per-pwm_device basis
+ * through this API. The duty cycle is rounded against the currently
+ * configured hardware period rather than the period requested in
+ * @wf; round_waveform_fromhw() reports the actual resulting
+ * waveform back so the core/consumer can detect a mismatch.
+ */
+ period_ns = DIV_ROUND_CLOSEST(NSEC_PER_SEC, data->pwm_freq);
+ wfhw->val = min_t(u64,
+ mul_u64_u64_div_u64(wf->duty_length_ns, ADT7470_PWM_MAX, period_ns),
+ ADT7470_PWM_MAX);
+ return 0;
+}
+
+static int adt7470_pwm_round_waveform_fromhw(struct pwm_chip *chip,
+ struct pwm_device *pwm,
+ const void *_wfhw,
+ struct pwm_waveform *wf)
+{
+ struct adt7470_data *data = pwmchip_get_drvdata(chip);
+ const struct adt7470_pwm_wfhw *wfhw = _wfhw;
+
+ wf->period_length_ns = DIV_ROUND_CLOSEST(NSEC_PER_SEC, data->pwm_freq);
+ wf->duty_offset_ns = 0;
+ wf->duty_length_ns = mul_u64_u64_div_u64(wfhw->val,
+ wf->period_length_ns,
+ ADT7470_PWM_MAX);
+
+ return 0;
+}
+
+static int adt7470_pwm_read_waveform(struct pwm_chip *chip,
+ struct pwm_device *pwm,
+ void *_wfhw)
+{
+ struct adt7470_data *data = pwmchip_get_drvdata(chip);
+ struct device *dev = regmap_get_device(data->regmap);
+ struct adt7470_pwm_wfhw *wfhw = _wfhw;
+
+ data = adt7470_update_device(dev);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+
+ /*
+ * No lock needed: like the other hwmon_ops read callbacks in this
+ * driver (e.g. adt7470_pwm_read()), this only does a single byte
+ * read from the cache populated by adt7470_update_device().
+ */
+ wfhw->val = data->pwm[pwm->hwpwm];
+
+ return 0;
+}
+
+static int adt7470_pwm_write_waveform(struct pwm_chip *chip,
+ struct pwm_device *pwm,
+ const void *_wfhw)
+{
+ struct adt7470_data *data = pwmchip_get_drvdata(chip);
+ const struct adt7470_pwm_wfhw *wfhw = _wfhw;
+ unsigned int pwm_auto_reg_mask;
+ int err;
+
+ if (pwm->hwpwm % 2)
+ pwm_auto_reg_mask = ADT7470_PWM2_AUTO_MASK;
+ else
+ pwm_auto_reg_mask = ADT7470_PWM1_AUTO_MASK;
+
+ guard(mutex)(&data->lock);
+
+ if (data->pwm[pwm->hwpwm] == wfhw->val &&
+ data->pwm_automatic[pwm->hwpwm] == 0)
+ return 0;
+
+ /* Put the PWM channel in manual mode before updating it. */
+ err = regmap_update_bits(data->regmap,
+ ADT7470_REG_PWM_CFG(pwm->hwpwm),
+ pwm_auto_reg_mask, 0);
+ if (err < 0)
+ return err;
+
+ data->pwm_automatic[pwm->hwpwm] = 0;
+
+ err = regmap_write(data->regmap,
+ ADT7470_REG_PWM(pwm->hwpwm), wfhw->val);
+ if (err < 0)
+ return err;
+
+ data->pwm[pwm->hwpwm] = wfhw->val;
+
+ return 0;
+}
+
+static const struct pwm_ops adt7470_pwm_ops = {
+ .sizeof_wfhw = sizeof(struct adt7470_pwm_wfhw),
+ .round_waveform_tohw = adt7470_pwm_round_waveform_tohw,
+ .round_waveform_fromhw = adt7470_pwm_round_waveform_fromhw,
+ .read_waveform = adt7470_pwm_read_waveform,
+ .write_waveform = adt7470_pwm_write_waveform,
+};
+
static ssize_t pwm_max_show(struct device *dev,
struct device_attribute *devattr, char *buf)
{
@@ -1336,6 +1458,21 @@ static int adt7470_probe(struct i2c_client *client)
if (IS_ERR(hwmon_dev))
return PTR_ERR(hwmon_dev);
+ if (IS_REACHABLE(CONFIG_PWM)) {
+ struct pwm_chip *chip;
+
+ chip = devm_pwmchip_alloc(dev, ADT7470_PWM_COUNT, 0);
+ if (IS_ERR(chip))
+ return PTR_ERR(chip);
+
+ chip->ops = &adt7470_pwm_ops;
+ pwmchip_set_drvdata(chip, data);
+
+ err = devm_pwmchip_add(dev, chip);
+ if (err)
+ return dev_err_probe(dev, err, "failed to register PWM chip\n");
+ }
+
data->auto_update = kthread_run(adt7470_update_thread, client, "%s",
dev_name(hwmon_dev));
if (IS_ERR(data->auto_update))
--
2.55.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [hwmon-next PATCH v3 4/4] hwmon: (adt7470) Add thermal zone sensor support
2026-07-28 3:07 [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support Luiz Angelo Daros de Luca
` (2 preceding siblings ...)
2026-07-28 3:07 ` [hwmon-next PATCH v3 3/4] hwmon: (adt7470) Expose fan control via PWM framework Luiz Angelo Daros de Luca
@ 2026-07-28 3:07 ` Luiz Angelo Daros de Luca
2026-07-28 3:21 ` [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal " Luiz Angelo Daros de Luca
4 siblings, 0 replies; 15+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-28 3:07 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König
Cc: linux-hwmon, devicetree, linux-kernel, Luiz Angelo Daros de Luca,
linux-pwm
Register the ADT7470 temperature channels as thermal zone sensors.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/hwmon/adt7470.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 883838fdcd7d..6cc246aa1285 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -1349,6 +1349,8 @@ static const struct hwmon_ops adt7470_hwmon_ops = {
};
static const struct hwmon_channel_info * const adt7470_info[] = {
+ HWMON_CHANNEL_INFO(chip,
+ HWMON_C_REGISTER_TZ),
HWMON_CHANNEL_INFO(temp,
HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | HWMON_T_ALARM,
HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX | HWMON_T_ALARM,
--
2.55.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support
2026-07-28 3:07 [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support Luiz Angelo Daros de Luca
` (3 preceding siblings ...)
2026-07-28 3:07 ` [hwmon-next PATCH v3 4/4] hwmon: (adt7470) Add thermal zone sensor support Luiz Angelo Daros de Luca
@ 2026-07-28 3:21 ` Luiz Angelo Daros de Luca
2026-07-28 3:52 ` Guenter Roeck
4 siblings, 1 reply; 15+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-28 3:21 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König
Cc: linux-hwmon, devicetree, linux-kernel, linux-pwm
It looks like Sashiko had trouble applying the patchset on top of
hwmon-next. I likely should have used a base commit that's available
across other trees, such as linux-next. I'll double-check whether I
misconfigured the prerequisites (it was my first time using them),
though b4 validated everything fine locally.
In any case, I can resend the series without prerequisites once the
necessary hwmon patches sync to hwmon-next.
Regards,
Luiz
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support
2026-07-28 3:21 ` [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal " Luiz Angelo Daros de Luca
@ 2026-07-28 3:52 ` Guenter Roeck
0 siblings, 0 replies; 15+ messages in thread
From: Guenter Roeck @ 2026-07-28 3:52 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König
Cc: linux-hwmon, devicetree, linux-kernel, linux-pwm
On 7/27/26 20:21, Luiz Angelo Daros de Luca wrote:
> It looks like Sashiko had trouble applying the patchset on top of
> hwmon-next. I likely should have used a base commit that's available
> across other trees, such as linux-next. I'll double-check whether I
> misconfigured the prerequisites (it was my first time using them),
> though b4 validated everything fine locally.
>
I pushed the patch series only into the hwmon branch. I guess Sashiko
doesn't know about that branch. I now rebased hwmon-next on top of hwmon
and pushed it out, so Sashiko should now be able to see the previous
patches.
Guenter
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-28 3:07 ` [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470 Luiz Angelo Daros de Luca
@ 2026-07-28 8:14 ` Krzysztof Kozlowski
2026-07-28 8:19 ` Krzysztof Kozlowski
2026-07-29 4:45 ` Luiz Angelo Daros de Luca
0 siblings, 2 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-28 8:14 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König, linux-hwmon, devicetree, linux-kernel,
linux-pwm
On Tue, Jul 28, 2026 at 12:07:09AM -0300, Luiz Angelo Daros de Luca wrote:
> The Analog Devices ADT7470 is a multichannel temperature sensor and
> PWM fan controller. It supports monitoring up to 10 external
> temperature sensors and controlling up to 4 fans.
>
> Add the device tree binding documentation for it. This includes
> support for the thermal framework by defining the "#thermal-sensor-cells"
> property, and models the fan control lines as PWM channels by
> defining the "#pwm-cells" property.
>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> ---
> .../devicetree/bindings/hwmon/adi,adt7470.yaml | 55 ++++++++++++++++++++++
> 1 file changed, 55 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
> new file mode 100644
> index 000000000000..bb2375a4a490
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
> @@ -0,0 +1,55 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/hwmon/adi,adt7470.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices ADT7470 hwmon sensor
> +
> +maintainers:
> + - Luiz Angelo Daros de Luca <luizluca@gmail.com>
> +
> +description:
> + Multi-channel temperature monitor and PWM fan controller.
> + It supports monitoring up to 10 external temperature sensors and
> + controlling up to four fans. The fan control lines are modeled
> + as standard PWM channels.
> +
> +properties:
> + compatible:
> + const: adi,adt7470
> +
> + reg:
> + maxItems: 1
> +
> + "#pwm-cells":
> + const: 3
> + description:
> + See Documentation/devicetree/bindings/pwm/pwm.yaml for the
> + generic PWM binding description.
Drop description.
You OTOH, miss ref to pwm schema. Referencing here in description should
raise you questions... And then use unevaluatedProperties.
> +
> + "#thermal-sensor-cells":
> + const: 1
> + description:
> + Number of cells required to uniquely identify the temperature sensors.
Drop sentence, you never need to explain standard properties. It only
adds bloat and more places to fix/change if we do any refactoring.
> + Valid index values are 0 to 9, corresponding to temp1 through temp10.
Only this is needed.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-28 8:14 ` Krzysztof Kozlowski
@ 2026-07-28 8:19 ` Krzysztof Kozlowski
2026-07-29 4:45 ` Luiz Angelo Daros de Luca
1 sibling, 0 replies; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-28 8:19 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König, linux-hwmon, devicetree, linux-kernel,
linux-pwm
On 28/07/2026 10:14, Krzysztof Kozlowski wrote:
> On Tue, Jul 28, 2026 at 12:07:09AM -0300, Luiz Angelo Daros de Luca wrote:
>> The Analog Devices ADT7470 is a multichannel temperature sensor and
>> PWM fan controller. It supports monitoring up to 10 external
>> temperature sensors and controlling up to 4 fans.
>>
>> Add the device tree binding documentation for it. This includes
>> support for the thermal framework by defining the "#thermal-sensor-cells"
>> property, and models the fan control lines as PWM channels by
>> defining the "#pwm-cells" property.
>>
>> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
>> ---
>> .../devicetree/bindings/hwmon/adi,adt7470.yaml | 55 ++++++++++++++++++++++
>> 1 file changed, 55 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
>> new file mode 100644
>> index 000000000000..bb2375a4a490
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
>> @@ -0,0 +1,55 @@
>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/hwmon/adi,adt7470.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Analog Devices ADT7470 hwmon sensor
>> +
>> +maintainers:
>> + - Luiz Angelo Daros de Luca <luizluca@gmail.com>
>> +
>> +description:
>> + Multi-channel temperature monitor and PWM fan controller.
>> + It supports monitoring up to 10 external temperature sensors and
>> + controlling up to four fans. The fan control lines are modeled
>> + as standard PWM channels.
>> +
>> +properties:
>> + compatible:
>> + const: adi,adt7470
>> +
>> + reg:
>> + maxItems: 1
>> +
>> + "#pwm-cells":
>> + const: 3
>> + description:
>> + See Documentation/devicetree/bindings/pwm/pwm.yaml for the
>> + generic PWM binding description.
>
> Drop description.
>
> You OTOH, miss ref to pwm schema. Referencing here in description should
> raise you questions... And then use unevaluatedProperties.
>
You most likely miss ref to thermal-sensor.yaml as well, but that would
change the ABI since hwmon would fail on missing cells, right?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-28 8:14 ` Krzysztof Kozlowski
2026-07-28 8:19 ` Krzysztof Kozlowski
@ 2026-07-29 4:45 ` Luiz Angelo Daros de Luca
2026-07-30 6:17 ` Krzysztof Kozlowski
1 sibling, 1 reply; 15+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-29 4:45 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König, linux-hwmon, devicetree, linux-kernel,
linux-pwm
Hi Krzysztof,
Thanks for the review.
> On Tue, Jul 28, 2026 at 12:07:09AM -0300, Luiz Angelo Daros de Luca wrote:
> > The Analog Devices ADT7470 is a multichannel temperature sensor and
> > PWM fan controller. It supports monitoring up to 10 external
> > temperature sensors and controlling up to 4 fans.
> >
> > Add the device tree binding documentation for it. This includes
> > support for the thermal framework by defining the "#thermal-sensor-cells"
> > property, and models the fan control lines as PWM channels by
> > defining the "#pwm-cells" property.
> >
> > Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> > ---
> > .../devicetree/bindings/hwmon/adi,adt7470.yaml | 55 ++++++++++++++++++++++
> > 1 file changed, 55 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
> > new file mode 100644
> > index 000000000000..bb2375a4a490
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
> > @@ -0,0 +1,55 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/hwmon/adi,adt7470.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Analog Devices ADT7470 hwmon sensor
> > +
> > +maintainers:
> > + - Luiz Angelo Daros de Luca <luizluca@gmail.com>
> > +
> > +description:
> > + Multi-channel temperature monitor and PWM fan controller.
> > + It supports monitoring up to 10 external temperature sensors and
> > + controlling up to four fans. The fan control lines are modeled
> > + as standard PWM channels.
> > +
> > +properties:
> > + compatible:
> > + const: adi,adt7470
> > +
> > + reg:
> > + maxItems: 1
> > +
> > + "#pwm-cells":
> > + const: 3
> > + description:
> > + See Documentation/devicetree/bindings/pwm/pwm.yaml for the
> > + generic PWM binding description.
>
> Drop description.
>
> You OTOH, miss ref to pwm schema. Referencing here in description should
> raise you questions... And then use unevaluatedProperties.
I will drop the description and change to `unevaluatedProperties: false`.
Regarding the reference to the PWM schema, adding `$ref:
/schemas/pwm/pwm.yaml#` enforces the `$nodename` to match
`^pwm(@.*|-([0-9a-f]+))?$`. Since the ADT7470 is primarily a hardware
monitor, its node is typically named `sensor@...`,
`fan-controller@...` or `hwmon@...`. Importing `pwm.yaml` causes
`dtbs_check` to fail on existing node names because of this mismatch.
Since we cannot override the `$nodename` from an imported schema, what
is the preferred approach here? Should I skip the `$ref` to `pwm.yaml`
in this specific case, or is there an accepted workaround for sensors
acting as PWM providers?
> You most likely miss ref to thermal-sensor.yaml as well, but that would
> change the ABI since hwmon would fail on missing cells, right?
Yes, you are right. It would require #thermal-sensor-cells and the
device might not have a thermal sensor connected if it is used as a
pure fan controller. Likewise, it can also be used as a simple
analog-to-digital temperature adapter, with no fans connected (and
"#pwm-cells" might be missing).
To address this without breaking the ABI, we could add the ref
conditionally if "#thermal-sensor-cells" is present.
allOf:
- if:
required:
- "#thermal-sensor-cells"
then:
$ref: /schemas/thermal/thermal-sensor.yaml#
I just don't know if it is ok to ref thermal-sensor but not pwm.
> > +
> > + "#thermal-sensor-cells":
> > + const: 1
> > + description:
> > + Number of cells required to uniquely identify the temperature sensors.
>
> Drop sentence, you never need to explain standard properties. It only
> adds bloat and more places to fix/change if we do any refactoring.
>
> > + Valid index values are 0 to 9, corresponding to temp1 through temp10.
>
> Only this is needed.
I'll keep only the sentence regarding the valid index values.
I'll send a v4 with the updates mostly because Sashiko-bot failed to
merge v3 with dependencies.
Regards,
Luiz
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-29 4:45 ` Luiz Angelo Daros de Luca
@ 2026-07-30 6:17 ` Krzysztof Kozlowski
2026-07-30 15:38 ` Guenter Roeck
0 siblings, 1 reply; 15+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-30 6:17 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König, linux-hwmon, devicetree, linux-kernel,
linux-pwm
On 29/07/2026 06:45, Luiz Angelo Daros de Luca wrote:
> Hi Krzysztof,
>
> Thanks for the review.
>
>> On Tue, Jul 28, 2026 at 12:07:09AM -0300, Luiz Angelo Daros de Luca wrote:
>>> The Analog Devices ADT7470 is a multichannel temperature sensor and
>>> PWM fan controller. It supports monitoring up to 10 external
>>> temperature sensors and controlling up to 4 fans.
>>>
>>> Add the device tree binding documentation for it. This includes
>>> support for the thermal framework by defining the "#thermal-sensor-cells"
>>> property, and models the fan control lines as PWM channels by
>>> defining the "#pwm-cells" property.
>>>
>>> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
>>> ---
>>> .../devicetree/bindings/hwmon/adi,adt7470.yaml | 55 ++++++++++++++++++++++
>>> 1 file changed, 55 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
>>> new file mode 100644
>>> index 000000000000..bb2375a4a490
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
>>> @@ -0,0 +1,55 @@
>>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/hwmon/adi,adt7470.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: Analog Devices ADT7470 hwmon sensor
>>> +
>>> +maintainers:
>>> + - Luiz Angelo Daros de Luca <luizluca@gmail.com>
>>> +
>>> +description:
>>> + Multi-channel temperature monitor and PWM fan controller.
>>> + It supports monitoring up to 10 external temperature sensors and
>>> + controlling up to four fans. The fan control lines are modeled
>>> + as standard PWM channels.
>>> +
>>> +properties:
>>> + compatible:
>>> + const: adi,adt7470
>>> +
>>> + reg:
>>> + maxItems: 1
>>> +
>>> + "#pwm-cells":
>>> + const: 3
>>> + description:
>>> + See Documentation/devicetree/bindings/pwm/pwm.yaml for the
>>> + generic PWM binding description.
>>
>> Drop description.
>>
>> You OTOH, miss ref to pwm schema. Referencing here in description should
>> raise you questions... And then use unevaluatedProperties.
>
> I will drop the description and change to `unevaluatedProperties: false`.
>
> Regarding the reference to the PWM schema, adding `$ref:
> /schemas/pwm/pwm.yaml#` enforces the `$nodename` to match
> `^pwm(@.*|-([0-9a-f]+))?$`. Since the ADT7470 is primarily a hardware
> monitor, its node is typically named `sensor@...`,
> `fan-controller@...` or `hwmon@...`. Importing `pwm.yaml` causes
> `dtbs_check` to fail on existing node names because of this mismatch.
If it is a fan-controller then it should use common fan schema, because
you might be missing several properties.
Device having PWM outputs alone does not make it a fan controller, though.
>
> Since we cannot override the `$nodename` from an imported schema, what
> is the preferred approach here? Should I skip the `$ref` to `pwm.yaml`
> in this specific case, or is there an accepted workaround for sensors
> acting as PWM providers?
You can skip the pwm.yaml in such case.
>
>> You most likely miss ref to thermal-sensor.yaml as well, but that would
>> change the ABI since hwmon would fail on missing cells, right?
>
> Yes, you are right. It would require #thermal-sensor-cells and the
> device might not have a thermal sensor connected if it is used as a
> pure fan controller. Likewise, it can also be used as a simple
> analog-to-digital temperature adapter, with no fans connected (and
> "#pwm-cells" might be missing).
>
> To address this without breaking the ABI, we could add the ref
> conditionally if "#thermal-sensor-cells" is present.
>
> allOf:
> - if:
> required:
> - "#thermal-sensor-cells"
> then:
> $ref: /schemas/thermal/thermal-sensor.yaml#
>
> I just don't know if it is ok to ref thermal-sensor but not pwm.
Feels ok.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-30 6:17 ` Krzysztof Kozlowski
@ 2026-07-30 15:38 ` Guenter Roeck
2026-07-30 21:11 ` Luiz Angelo Daros de Luca
0 siblings, 1 reply; 15+ messages in thread
From: Guenter Roeck @ 2026-07-30 15:38 UTC (permalink / raw)
To: Krzysztof Kozlowski, Luiz Angelo Daros de Luca
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chris Packham,
Andrew Morton, Darrick J. Wong, Uwe Kleine-König,
linux-hwmon, devicetree, linux-kernel, linux-pwm
On 7/29/26 23:17, Krzysztof Kozlowski wrote:
> On 29/07/2026 06:45, Luiz Angelo Daros de Luca wrote:
>> Hi Krzysztof,
>>
>> Thanks for the review.
>>
>>> On Tue, Jul 28, 2026 at 12:07:09AM -0300, Luiz Angelo Daros de Luca wrote:
>>>> The Analog Devices ADT7470 is a multichannel temperature sensor and
>>>> PWM fan controller. It supports monitoring up to 10 external
>>>> temperature sensors and controlling up to 4 fans.
>>>>
>>>> Add the device tree binding documentation for it. This includes
>>>> support for the thermal framework by defining the "#thermal-sensor-cells"
>>>> property, and models the fan control lines as PWM channels by
>>>> defining the "#pwm-cells" property.
>>>>
>>>> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
>>>> ---
>>>> .../devicetree/bindings/hwmon/adi,adt7470.yaml | 55 ++++++++++++++++++++++
>>>> 1 file changed, 55 insertions(+)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
>>>> new file mode 100644
>>>> index 000000000000..bb2375a4a490
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
>>>> @@ -0,0 +1,55 @@
>>>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>>>> +%YAML 1.2
>>>> +---
>>>> +$id: http://devicetree.org/schemas/hwmon/adi,adt7470.yaml#
>>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>>> +
>>>> +title: Analog Devices ADT7470 hwmon sensor
>>>> +
>>>> +maintainers:
>>>> + - Luiz Angelo Daros de Luca <luizluca@gmail.com>
>>>> +
>>>> +description:
>>>> + Multi-channel temperature monitor and PWM fan controller.
>>>> + It supports monitoring up to 10 external temperature sensors and
>>>> + controlling up to four fans. The fan control lines are modeled
>>>> + as standard PWM channels.
>>>> +
>>>> +properties:
>>>> + compatible:
>>>> + const: adi,adt7470
>>>> +
>>>> + reg:
>>>> + maxItems: 1
>>>> +
>>>> + "#pwm-cells":
>>>> + const: 3
>>>> + description:
>>>> + See Documentation/devicetree/bindings/pwm/pwm.yaml for the
>>>> + generic PWM binding description.
>>>
>>> Drop description.
>>>
>>> You OTOH, miss ref to pwm schema. Referencing here in description should
>>> raise you questions... And then use unevaluatedProperties.
>>
>> I will drop the description and change to `unevaluatedProperties: false`.
>>
>> Regarding the reference to the PWM schema, adding `$ref:
>> /schemas/pwm/pwm.yaml#` enforces the `$nodename` to match
>> `^pwm(@.*|-([0-9a-f]+))?$`. Since the ADT7470 is primarily a hardware
>> monitor, its node is typically named `sensor@...`,
>> `fan-controller@...` or `hwmon@...`. Importing `pwm.yaml` causes
>> `dtbs_check` to fail on existing node names because of this mismatch.
>
> If it is a fan-controller then it should use common fan schema, because
> you might be missing several properties.
>
> Device having PWM outputs alone does not make it a fan controller, though.
>
It is a fan controller. The logic used here is the opposite:
It has pwm outputs to control the fans, therefore it should be modeled as
pwm controller and use pwm controller bindings (to clarify, this is not
my logic, but both DT and PWM maintainers insist on it).
Also, to clarify: I do not like the idea of registering pwm outputs with
the pwm subsystem and require the pwm-fan driver to actually control the
fan. I prefer the mechanism used by, for example, then emc2305 driver,
which registers cooling devices with the thermal subsystem directly
and uses of_parse_phandle_with_args() to extract the pwm configuration.
However, the patch author claims that the pwm outputs are used for
non-fan-control purposes (such as controlling LEDs), making the two-driver
approach necessary.
Guenter
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-30 15:38 ` Guenter Roeck
@ 2026-07-30 21:11 ` Luiz Angelo Daros de Luca
2026-07-30 21:37 ` Guenter Roeck
0 siblings, 1 reply; 15+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-30 21:11 UTC (permalink / raw)
To: Guenter Roeck
Cc: Krzysztof Kozlowski, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König, linux-hwmon, devicetree, linux-kernel,
linux-pwm
Em qui., 30 de jul. de 2026 às 12:38, Guenter Roeck
<linux@roeck-us.net> escreveu:
>
> On 7/29/26 23:17, Krzysztof Kozlowski wrote:
> > On 29/07/2026 06:45, Luiz Angelo Daros de Luca wrote:
> >> Hi Krzysztof,
> >>
> >> Thanks for the review.
> >>
> >>> On Tue, Jul 28, 2026 at 12:07:09AM -0300, Luiz Angelo Daros de Luca wrote:
> >>>> The Analog Devices ADT7470 is a multichannel temperature sensor and
> >>>> PWM fan controller. It supports monitoring up to 10 external
> >>>> temperature sensors and controlling up to 4 fans.
> >>>>
> >>>> Add the device tree binding documentation for it. This includes
> >>>> support for the thermal framework by defining the "#thermal-sensor-cells"
> >>>> property, and models the fan control lines as PWM channels by
> >>>> defining the "#pwm-cells" property.
> >>>>
> >>>> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> >>>> ---
> >>>> .../devicetree/bindings/hwmon/adi,adt7470.yaml | 55 ++++++++++++++++++++++
> >>>> 1 file changed, 55 insertions(+)
> >>>>
> >>>> diff --git a/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
> >>>> new file mode 100644
> >>>> index 000000000000..bb2375a4a490
> >>>> --- /dev/null
> >>>> +++ b/Documentation/devicetree/bindings/hwmon/adi,adt7470.yaml
> >>>> @@ -0,0 +1,55 @@
> >>>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> >>>> +%YAML 1.2
> >>>> +---
> >>>> +$id: http://devicetree.org/schemas/hwmon/adi,adt7470.yaml#
> >>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >>>> +
> >>>> +title: Analog Devices ADT7470 hwmon sensor
> >>>> +
> >>>> +maintainers:
> >>>> + - Luiz Angelo Daros de Luca <luizluca@gmail.com>
> >>>> +
> >>>> +description:
> >>>> + Multi-channel temperature monitor and PWM fan controller.
> >>>> + It supports monitoring up to 10 external temperature sensors and
> >>>> + controlling up to four fans. The fan control lines are modeled
> >>>> + as standard PWM channels.
> >>>> +
> >>>> +properties:
> >>>> + compatible:
> >>>> + const: adi,adt7470
> >>>> +
> >>>> + reg:
> >>>> + maxItems: 1
> >>>> +
> >>>> + "#pwm-cells":
> >>>> + const: 3
> >>>> + description:
> >>>> + See Documentation/devicetree/bindings/pwm/pwm.yaml for the
> >>>> + generic PWM binding description.
> >>>
> >>> Drop description.
> >>>
> >>> You OTOH, miss ref to pwm schema. Referencing here in description should
> >>> raise you questions... And then use unevaluatedProperties.
> >>
> >> I will drop the description and change to `unevaluatedProperties: false`.
> >>
> >> Regarding the reference to the PWM schema, adding `$ref:
> >> /schemas/pwm/pwm.yaml#` enforces the `$nodename` to match
> >> `^pwm(@.*|-([0-9a-f]+))?$`. Since the ADT7470 is primarily a hardware
> >> monitor, its node is typically named `sensor@...`,
> >> `fan-controller@...` or `hwmon@...`. Importing `pwm.yaml` causes
> >> `dtbs_check` to fail on existing node names because of this mismatch.
> >
> > If it is a fan-controller then it should use common fan schema, because
> > you might be missing several properties.
> >
> > Device having PWM outputs alone does not make it a fan controller, though.
>
> It is a fan controller. The logic used here is the opposite:
> It has pwm outputs to control the fans, therefore it should be modeled as
> pwm controller and use pwm controller bindings (to clarify, this is not
> my logic, but both DT and PWM maintainers insist on it).
Hi Guenter, Hi Krzysztof,
Thanks for your review. You are both right about the nature of this
device. While the manufacturer markets the ADT7470 as a "PWM fan
controller" (and it does have internal closed-loop capabilities), the
physical pins are multi-functional. They can act as generic PWM
outputs or even GPIOs. Because of this flexibility, tying the binding
to `fan-common.yaml` would be too restrictive.
On my specific hardware (Edgecore switches), the vendor bypassed the
ADT7470's internal temperature sensors entirely. The fans must be
controlled by the main SoC's thermal zone (or any other userland
daemon/script).
Regarding the architecture, while I looked at the `emc2305` approach,
delegating the actual fan management to the time-proven `pwm-fan`
driver allows us to avoid reinventing the wheel (like cooling device
registration and state management) inside the adt7470 driver. It also
keeps the standard PWM consumer/provider relationship clear in the DT.
It still feels strange that emc2305 declares #pwm-cells and its
subdriver fans pwm properties and they do not work as a pwm
controller. Other drivers, like aspeed-g6-pwm-tach (with similar
bindings) do both: use a fan subdriver controlled by hwmon sysfs and
register itself as pwmchip. But this is exactly what Guenter asked me
to avoid.
> > Since we cannot override the `$nodename` from an imported schema, what
> > is the preferred approach here? Should I skip the `$ref` to `pwm.yaml`
> > in this specific case, or is there an accepted workaround for sensors
> > acting as PWM providers?
>
> You can skip the pwm.yaml in such case.
OK. Thanks.
> >> You most likely miss ref to thermal-sensor.yaml as well, but that would
> >> change the ABI since hwmon would fail on missing cells, right?
> >
> > Yes, you are right. It would require #thermal-sensor-cells and the
> > device might not have a thermal sensor connected if it is used as a
> > pure fan controller. Likewise, it can also be used as a simple
> > analog-to-digital temperature adapter, with no fans connected (and
> > "#pwm-cells" might be missing).
> >
> > To address this without breaking the ABI, we could add the ref
> > conditionally if "#thermal-sensor-cells" is present.
> >
> > allOf:
> > - if:
> > required:
> > - "#thermal-sensor-cells"
> > then:
> > $ref: /schemas/thermal/thermal-sensor.yaml#
> >
> > I just don't know if it is ok to ref thermal-sensor but not pwm.
>
> Feels ok.
Thanks.
I'm sending v5 soon with the current approach. If needed I can revert
back to the subdriver/cooling device directly in the adt7470 (as in my
v1). In any case, both approaches share the same #pwm-cells but the
subdriver would require a new fans property.
Best Regards,
Luiz
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-30 21:11 ` Luiz Angelo Daros de Luca
@ 2026-07-30 21:37 ` Guenter Roeck
2026-07-31 5:39 ` Uwe Kleine-König
0 siblings, 1 reply; 15+ messages in thread
From: Guenter Roeck @ 2026-07-30 21:37 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Krzysztof Kozlowski, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chris Packham, Andrew Morton, Darrick J. Wong,
Uwe Kleine-König, linux-hwmon, devicetree, linux-kernel,
linux-pwm
On 7/30/26 14:11, Luiz Angelo Daros de Luca wrote:
the architecture, while I looked at the `emc2305` approach,
> delegating the actual fan management to the time-proven `pwm-fan`
> driver allows us to avoid reinventing the wheel (like cooling device
> registration and state management) inside the adt7470 driver. It also
> keeps the standard PWM consumer/provider relationship clear in the DT.
> It still feels strange that emc2305 declares #pwm-cells and its
> subdriver fans pwm properties and they do not work as a pwm
> controller. Other drivers, like aspeed-g6-pwm-tach (with similar
That is your opinion. #pwm-cells and pwms exists because it is mandated
by DT maintainers for configuring pwm properties. That does not have to
reflect the implementation: DT property guidance explicitly states
that properties must describe the hardware, not the implementation.
There is no mandate how to implement a specific driver (such as a fan
controller driver) because a specific binding exists. It is perfectly
valid to describe pwm properties of a fan controller using #pwm-cells
and pwms without modeling it as pwm controller (which actually mandates
support of the pwm subsystem or no good reason other than "because").
While you may consider the emc2305 approach inferior, I happen to
disagree. That is your personal opinion. For my part I consider it
inferior and overly complex having to involve another subsystem (pwm)
and another driver (pwm-fan) just to make the chip's pwm outputs
visible to the thermal subsystem as cooling devices.
Guenter
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470
2026-07-30 21:37 ` Guenter Roeck
@ 2026-07-31 5:39 ` Uwe Kleine-König
0 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2026-07-31 5:39 UTC (permalink / raw)
To: Guenter Roeck
Cc: Luiz Angelo Daros de Luca, Krzysztof Kozlowski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Chris Packham, Andrew Morton,
Darrick J. Wong, linux-hwmon, devicetree, linux-kernel, linux-pwm
[-- Attachment #1: Type: text/plain, Size: 3626 bytes --]
Hello Guenter,
On Thu, Jul 30, 2026 at 02:37:01PM -0700, Guenter Roeck wrote:
> On 7/30/26 14:11, Luiz Angelo Daros de Luca wrote:
> the architecture, while I looked at the `emc2305` approach,
> > delegating the actual fan management to the time-proven `pwm-fan`
> > driver allows us to avoid reinventing the wheel (like cooling device
> > registration and state management) inside the adt7470 driver. It also
> > keeps the standard PWM consumer/provider relationship clear in the DT.
> > It still feels strange that emc2305 declares #pwm-cells and its
> > subdriver fans pwm properties and they do not work as a pwm
> > controller. Other drivers, like aspeed-g6-pwm-tach (with similar
>
> That is your opinion. #pwm-cells and pwms exists because it is mandated
> by DT maintainers for configuring pwm properties. That does not have to
> reflect the implementation: DT property guidance explicitly states
> that properties must describe the hardware, not the implementation.
> There is no mandate how to implement a specific driver (such as a fan
> controller driver) because a specific binding exists. It is perfectly
> valid to describe pwm properties of a fan controller using #pwm-cells
> and pwms without modeling it as pwm controller (which actually mandates
> support of the pwm subsystem or no good reason other than "because").
>
> While you may consider the emc2305 approach inferior, I happen to
> disagree. That is your personal opinion. For my part I consider it
> inferior and overly complex having to involve another subsystem (pwm)
> and another driver (pwm-fan) just to make the chip's pwm outputs
> visible to the thermal subsystem as cooling devices.
Strange how opinions can differ. I'm with Luiz here. While I agree
that mixing subsystems is slightly inconvenient, hwmon uses i2c and spi
and clk and regmap and probably more, but pwm is a problem?
What you call "inferior and overly complex" is actually nice and elegant
in my view. There is code that handles PWMs, and by not using it you add
code duplication with all the downsides that comes with it (different
behaviours, maintenance overhead, wrong expectations).
So amc6821 and nct7363 only support #pwm-cells = <2> which is
non-standard for PWMs and I don't see where the period (cell 1 for
amc6821 and cell 2 for nct7363 *sigh*) is going into the driver.
For emc2305 uses #pwm-cells = <3> but cell 2 specifies something that
actually belongs to pinctrl and not pwm, and cell 0 is a frequency
instead of a time. And interpretation of cell 1 should better be done
using:
diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c
index eef3b021671b..c704fcd61356 100644
--- a/drivers/hwmon/emc2305.c
+++ b/drivers/hwmon/emc2305.c
@@ -571,12 +571,8 @@ static int emc2305_of_parse_pwm_child(struct device *dev,
}
if (args.args_count > 1) {
- if (args.args[1] == PWM_POLARITY_NORMAL || args.args[1] == PWM_POLARITY_INVERSED)
- data->pwm_polarity_mask |= args.args[1] << ch;
- else
- dev_err(dev, "Wrong PWM polarity config provided: %d\n", args.args[0]);
- } else {
- data->pwm_polarity_mask |= PWM_POLARITY_NORMAL << ch;
+ if (args.args[1] & PWM_POLARITY_INVERTED)
+ data->pwm_polarity_mask |= 1 << ch;
}
if (args.args_count > 2) {
(Yes, I agree that the difference between PWM_POLARITY_INVERSED and
PWM_POLARITY_INVERTED is annoying.)
And all of these seem to ignore the phandle.
So these all only somewhat look like standard pwm bindings, but actually
there are traps and surprises hidden for the device tree author.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-07-31 5:39 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 3:07 [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal sensor support Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 1/4] dt-bindings: hwmon: adi,adt7470 Luiz Angelo Daros de Luca
2026-07-28 8:14 ` Krzysztof Kozlowski
2026-07-28 8:19 ` Krzysztof Kozlowski
2026-07-29 4:45 ` Luiz Angelo Daros de Luca
2026-07-30 6:17 ` Krzysztof Kozlowski
2026-07-30 15:38 ` Guenter Roeck
2026-07-30 21:11 ` Luiz Angelo Daros de Luca
2026-07-30 21:37 ` Guenter Roeck
2026-07-31 5:39 ` Uwe Kleine-König
2026-07-28 3:07 ` [hwmon-next PATCH v3 2/4] hwmon: (adt7470) Add ADT7470_PWM_MAX macro Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 3/4] hwmon: (adt7470) Expose fan control via PWM framework Luiz Angelo Daros de Luca
2026-07-28 3:07 ` [hwmon-next PATCH v3 4/4] hwmon: (adt7470) Add thermal zone sensor support Luiz Angelo Daros de Luca
2026-07-28 3:21 ` [hwmon-next PATCH v3 0/4] hwmon: (adt7470) Add PWM provider and thermal " Luiz Angelo Daros de Luca
2026-07-28 3:52 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox