Devicetree
 help / color / mirror / Atom feed
* [PATCH v1 0/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W
@ 2026-12-03  8:46 hsyemail2
  2026-12-03  8:46 ` [PATCH v1 1/2] dt-bindings: hwmon: tmp401: Add " hsyemail2
  2026-12-03  8:46 ` [PATCH v1 2/2] hwmon: (tmp401) Add support for " hsyemail2
  0 siblings, 2 replies; 5+ messages in thread
From: hsyemail2 @ 2026-12-03  8:46 UTC (permalink / raw)
  To: Conor Dooley, Guenter Roeck, Jonathan Corbet, Krzysztof Kozlowski,
	Rob Herring
  Cc: devicetree, linux-doc, linux-hwmon, Randy Dunlap, Shuah Khan,
	Sheng-Yuan Huang

From: Sheng-Yuan Huang <syhuang3@nuvoton.com>

Add support for the Nuvoton NCT7719W, a temperature sensor with one
local and two remote channels.

The first patch updates the Device Tree binding. The second adds
driver support and updates the hwmon documentation.

Sheng-Yuan Huang (2):
  dt-bindings: hwmon: tmp401: Add Nuvoton NCT7719W
  hwmon: (tmp401) Add support for Nuvoton NCT7719W

 .../devicetree/bindings/hwmon/ti,tmp401.yaml  |  27 ++-
 Documentation/hwmon/tmp401.rst                |  14 ++
 drivers/hwmon/tmp401.c                        | 213 ++++++++++++++++--
 3 files changed, 227 insertions(+), 27 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1 1/2] dt-bindings: hwmon: tmp401: Add Nuvoton NCT7719W
  2026-12-03  8:46 [PATCH v1 0/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W hsyemail2
@ 2026-12-03  8:46 ` hsyemail2
  2026-12-03  8:57   ` sashiko-bot
  2026-12-03  8:46 ` [PATCH v1 2/2] hwmon: (tmp401) Add support for " hsyemail2
  1 sibling, 1 reply; 5+ messages in thread
From: hsyemail2 @ 2026-12-03  8:46 UTC (permalink / raw)
  To: Conor Dooley, Guenter Roeck, Jonathan Corbet, Krzysztof Kozlowski,
	Rob Herring
  Cc: devicetree, linux-doc, linux-hwmon, Randy Dunlap, Shuah Khan,
	Sheng-Yuan Huang

From: Sheng-Yuan Huang <syhuang3@nuvoton.com>

Add the Nuvoton NCT7719W compatible to the TMP401 hwmon binding.
Disallow TI-specific properties for this device.

Signed-off-by: Sheng-Yuan Huang <syhuang3@nuvoton.com>
---
 .../devicetree/bindings/hwmon/ti,tmp401.yaml  | 27 +++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml b/Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml
index f283b567d5b6..46f916c3a078 100644
--- a/Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml
+++ b/Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml
@@ -4,7 +4,7 @@
 $id: http://devicetree.org/schemas/hwmon/ti,tmp401.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: TMP401, TPM411 and TMP43x temperature sensor
+title: TMP401, TMP411, TMP43x, and NCT7719W temperature sensor
 
 maintainers:
   - Guenter Roeck <linux@roeck-us.net>
@@ -12,7 +12,7 @@ maintainers:
 description: |
   ±1°C Remote and Local temperature sensor
 
-  Datasheets:
+  Texas Instruments datasheets:
   https://www.ti.com/lit/ds/symlink/tmp401.pdf
   https://www.ti.com/lit/ds/symlink/tmp411.pdf
   https://www.ti.com/lit/ds/symlink/tmp431.pdf
@@ -26,6 +26,7 @@ properties:
       - ti,tmp431
       - ti,tmp432
       - ti,tmp435
+      - nuvoton,nct7719w
 
   reg:
     maxItems: 1
@@ -75,6 +76,18 @@ allOf:
       properties:
         ti,beta-compensation: false
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - nuvoton,nct7719w
+    then:
+      properties:
+        ti,extended-range-enable: false
+        ti,n-factor: false
+        ti,beta-compensation: false
+
 required:
   - compatible
   - reg
@@ -105,3 +118,13 @@ examples:
         ti,beta-compensation = <0x7>;
       };
     };
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      sensor@4d {
+        compatible = "nuvoton,nct7719w";
+        reg = <0x4d>;
+      };
+    };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 2/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W
  2026-12-03  8:46 [PATCH v1 0/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W hsyemail2
  2026-12-03  8:46 ` [PATCH v1 1/2] dt-bindings: hwmon: tmp401: Add " hsyemail2
@ 2026-12-03  8:46 ` hsyemail2
  2026-12-03  9:08   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: hsyemail2 @ 2026-12-03  8:46 UTC (permalink / raw)
  To: Conor Dooley, Guenter Roeck, Jonathan Corbet, Krzysztof Kozlowski,
	Rob Herring
  Cc: devicetree, linux-doc, linux-hwmon, Randy Dunlap, Shuah Khan,
	Sheng-Yuan Huang

From: Sheng-Yuan Huang <syhuang3@nuvoton.com>

The NCT7719W has one local and two remote temperature channels.
It uses signed temperature values and requires separate SMBus byte
accesses for the high and low bytes of remote temperatures and limits.

Signed-off-by: Sheng-Yuan Huang <syhuang3@nuvoton.com>
---
 Documentation/hwmon/tmp401.rst |  14 +++
 drivers/hwmon/tmp401.c         | 213 +++++++++++++++++++++++++++++----
 2 files changed, 202 insertions(+), 25 deletions(-)

diff --git a/Documentation/hwmon/tmp401.rst b/Documentation/hwmon/tmp401.rst
index 3aacf3d3bdf3..35ca055be7cf 100644
--- a/Documentation/hwmon/tmp401.rst
+++ b/Documentation/hwmon/tmp401.rst
@@ -3,6 +3,12 @@ Kernel driver tmp401
 
 Supported chips:
 
+  * Nuvoton NCT7719W
+
+    Prefix: 'nct7719w'
+
+    Addresses scanned: I2C 0x4d
+
   * Texas Instruments TMP401
 
     Prefix: 'tmp401'
@@ -61,6 +67,14 @@ sensor resolution can be set to 0.5, 0.25, 0.125 or 0.0625 degree (not
 supported by the driver so far, so using the default resolution of 0.5
 degree).
 
+It also supports the Nuvoton NCT7719W, which implements two remote and one
+local temperature sensors. Its remote temperature resolution is 0.125 degree
+and its local temperature resolution is 1 degree.
+
+The NCT7719W shares one critical temperature hysteresis offset across all
+three channels. Writing any ``tempX_crit_hyst`` attribute changes the
+offset used by all three.
+
 The driver provides the common sysfs-interface for temperatures (see
 Documentation/hwmon/sysfs-interface.rst under Temperatures).
 
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
index 2fceeacdc88c..352adedfe7d6 100644
--- a/drivers/hwmon/tmp401.c
+++ b/drivers/hwmon/tmp401.c
@@ -31,7 +31,7 @@
 static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c, 0x4d,
 	0x4e, 0x4f, I2C_CLIENT_END };
 
-enum chips { tmp401, tmp411, tmp431, tmp432, tmp435 };
+enum chips { tmp401, tmp411, tmp431, tmp432, tmp435, nct7719w };
 
 /*
  * The TMP401 registers, note some registers have different addresses for
@@ -84,6 +84,9 @@ static const u8 TMP432_STATUS_REG[] = {
 #define TMP431_DEVICE_ID			0x31
 #define TMP432_DEVICE_ID			0x32
 #define TMP435_DEVICE_ID			0x35
+#define NCT7719W_MANUFACTURER_ID		0x5c
+#define NCT7719W_DEVICE_ID			0x10
+#define NCT7719W_DEVICE_ID_MASK			0xf0
 
 /*
  * Driver data (common to all clients)
@@ -95,6 +98,7 @@ static const struct i2c_device_id tmp401_id[] = {
 	{ .name = "tmp431", .driver_data = tmp431 },
 	{ .name = "tmp432", .driver_data = tmp432 },
 	{ .name = "tmp435", .driver_data = tmp435 },
+	{ .name = "nct7719w", .driver_data = nct7719w },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, tmp401_id);
@@ -143,6 +147,55 @@ static int tmp401_reg_read(void *context, unsigned int reg, unsigned int *val)
 	struct tmp401_data *data = context;
 	struct i2c_client *client = data->client;
 	int regval;
+	int low_reg;
+	int low_val;
+
+	/* NCT7719W remote values and limits require separate byte accesses. */
+	if (data->kind == nct7719w) {
+		switch (reg) {
+		/* Local temperature and limits are one-byte fields. */
+		case 0x00:
+		case 0x05:
+		case 0x06:
+			regval = i2c_smbus_read_byte_data(client, reg);
+			if (regval < 0)
+				return regval;
+			*val = regval << 8;
+			return 0;
+		case 0x01:
+			low_reg = 0x10;
+			break;
+		case 0x07:
+			low_reg = 0x13;
+			break;
+		case 0x08:
+			low_reg = 0x14;
+			break;
+		case 0x15:
+			low_reg = 0x17;
+			break;
+		case 0x16:
+			low_reg = 0x18;
+			break;
+		case 0x23:
+			low_reg = 0x24;
+			break;
+		default:
+			low_reg = 0;
+			break;
+		}
+
+		if (low_reg) {
+			regval = i2c_smbus_read_byte_data(client, reg);
+			if (regval < 0)
+				return regval;
+			low_val = i2c_smbus_read_byte_data(client, low_reg);
+			if (low_val < 0)
+				return low_val;
+			*val = (regval << 8) | (low_val & GENMASK(7, 5));
+			return 0;
+		}
+	}
 
 	switch (reg) {
 	case 0:			/* local temp msb */
@@ -176,7 +229,7 @@ static int tmp401_reg_read(void *context, unsigned int reg, unsigned int *val)
 		break;
 	case 0x1b:
 	case 0x35 ... 0x37:
-		if (data->kind == tmp432) {
+		if (data->kind == tmp432 || data->kind == nct7719w) {
 			regval = i2c_smbus_read_byte_data(client, reg);
 			if (regval < 0)
 				return regval;
@@ -227,6 +280,44 @@ static int tmp401_reg_write(void *context, unsigned int reg, unsigned int val)
 {
 	struct tmp401_data *data = context;
 	struct i2c_client *client = data->client;
+	int low_reg;
+	int ret;
+
+	if (data->kind == nct7719w) {
+		switch (reg) {
+		/*
+		 * Local limits are one-byte fields with separate write
+		 * addresses.
+		 */
+		case 0x05:
+		case 0x06:
+			return i2c_smbus_write_byte_data(client, reg + 6, val >> 8);
+		case 0x07:
+			reg = 0x0d;
+			low_reg = 0x13;
+			break;
+		case 0x08:
+			reg = 0x0e;
+			low_reg = 0x14;
+			break;
+		case 0x15:
+			low_reg = 0x17;
+			break;
+		case 0x16:
+			low_reg = 0x18;
+			break;
+		default:
+			low_reg = 0;
+			break;
+		}
+
+		if (low_reg) {
+			ret = i2c_smbus_write_byte_data(client, reg, val >> 8);
+			if (ret < 0)
+				return ret;
+			return i2c_smbus_write_byte_data(client, low_reg, val);
+		}
+	}
 
 	switch (reg) {
 	case 0x05:		/* local temp high limit msb */
@@ -284,6 +375,26 @@ static u16 tmp401_temp_to_register(long temp, bool extended, int zbits)
 	return DIV_ROUND_CLOSEST(temp * (1 << (8 - zbits)), 1000) << zbits;
 }
 
+static int nct7719w_register_to_temp(u16 reg)
+{
+	return DIV_ROUND_CLOSEST((s16)reg * 125, 32);
+}
+
+static u16 nct7719w_temp_to_register(long temp, int resolution)
+{
+	s16 reg;
+
+	if (resolution == 8) {
+		temp = clamp_val(temp, -128000, 127000);
+		reg = DIV_ROUND_CLOSEST(temp, 1000);
+	} else {
+		temp = clamp_val(temp, -128000, 127875);
+		reg = DIV_ROUND_CLOSEST(temp * 8, 1000);
+	}
+
+	return (u16)reg << (16 - resolution);
+}
+
 /* hwmon API functions */
 
 static const u8 tmp401_temp_reg_index[] = {
@@ -322,13 +433,20 @@ static int tmp401_temp_read(struct device *dev, u32 attr, int channel, long *val
 		ret = regmap_read(regmap, reg, &regval);
 		if (ret < 0)
 			return ret;
-		*val = tmp401_register_to_temp(regval, data->extended_range);
+		if (data->kind == nct7719w)
+			*val = nct7719w_register_to_temp(regval);
+		else
+			*val = tmp401_register_to_temp(regval, data->extended_range);
 		break;
 	case hwmon_temp_crit_hyst:
 		ret = regmap_multi_reg_read(regmap, regs, regvals, 2);
 		if (ret < 0)
 			return ret;
-		*val = tmp401_register_to_temp(regvals[0], data->extended_range) -
+		if (data->kind == nct7719w)
+			*val = nct7719w_register_to_temp(regvals[0]) -
+				(regvals[1] * 1000);
+		else
+			*val = tmp401_register_to_temp(regvals[0], data->extended_range) -
 							(regvals[1] * 1000);
 		break;
 	case hwmon_temp_fault:
@@ -360,22 +478,32 @@ static int tmp401_temp_write(struct device *dev, u32 attr, int channel,
 	case hwmon_temp_max:
 	case hwmon_temp_crit:
 		reg = TMP401_TEMP_MSB[tmp401_temp_reg_index[attr]][channel];
-		regval = tmp401_temp_to_register(val, data->extended_range,
+		if (data->kind == nct7719w)
+			regval = nct7719w_temp_to_register(val,
+				attr == hwmon_temp_crit || channel == 0 ? 8 : 11);
+		else
+			regval = tmp401_temp_to_register(val, data->extended_range,
 						 attr == hwmon_temp_crit ? 8 : 4);
 		ret = regmap_write(regmap, reg, regval);
 		break;
 	case hwmon_temp_crit_hyst:
-		if (data->extended_range)
-			val = clamp_val(val, -64000, 191000);
-		else
-			val = clamp_val(val, 0, 127000);
+		if (data->kind != nct7719w) {
+			if (data->extended_range)
+				val = clamp_val(val, -64000, 191000);
+			else
+				val = clamp_val(val, 0, 127000);
+		}
 
 		reg = TMP401_TEMP_MSB[3][channel];
 		ret = regmap_read(regmap, reg, &regval);
 		if (ret < 0)
 			break;
-		temp = tmp401_register_to_temp(regval, data->extended_range);
-		val = clamp_val(val, temp - 255000, temp);
+		if (data->kind == nct7719w)
+			temp = nct7719w_register_to_temp(regval);
+		else
+			temp = tmp401_register_to_temp(regval, data->extended_range);
+		val = clamp_val(val, temp - (data->kind == nct7719w ?
+					     31000 : 255000), temp);
 		regval = ((temp - val) + 500) / 1000;
 		ret = regmap_write(regmap, TMP401_TEMP_CRIT_HYST, regval);
 		break;
@@ -397,7 +525,10 @@ static int tmp401_chip_read(struct device *dev, u32 attr, int channel, long *val
 		ret = regmap_read(data->regmap, TMP401_CONVERSION_RATE, &regval);
 		if (ret < 0)
 			return ret;
-		*val = (1 << (7 - min(regval, 7))) * 125;
+		if (data->kind == nct7719w)
+			*val = DIV_ROUND_CLOSEST(16000, 1 << min(regval, 8));
+		else
+			*val = (1 << (7 - min(regval, 7))) * 125;
 		break;
 	case hwmon_chip_temp_reset_history:
 		*val = 0;
@@ -409,6 +540,19 @@ static int tmp401_chip_read(struct device *dev, u32 attr, int channel, long *val
 	return 0;
 }
 
+static int nct7719w_set_convrate(struct regmap *regmap, long val)
+{
+	int rate;
+	int interval;
+
+	val = clamp_val(val, 63, 16000);
+	interval = 16000;
+	for (rate = 0; rate < 8 && val < interval; rate++)
+		interval /= 2;
+
+	return regmap_write(regmap, TMP401_CONVERSION_RATE, rate);
+}
+
 static int tmp401_set_convrate(struct regmap *regmap, long val)
 {
 	int rate;
@@ -434,7 +578,10 @@ static int tmp401_chip_write(struct device *dev, u32 attr, int channel, long val
 
 	switch (attr) {
 	case hwmon_chip_update_interval:
-		err = tmp401_set_convrate(regmap, val);
+		if (data->kind == nct7719w)
+			err = nct7719w_set_convrate(regmap, val);
+		else
+			err = tmp401_set_convrate(regmap, val);
 		break;
 	case hwmon_chip_temp_reset_history:
 		if (val != 1) {
@@ -547,13 +694,15 @@ static int tmp401_init_client(struct tmp401_data *data)
 	config_orig = config;
 	config &= ~TMP401_CONFIG_SHUTDOWN;
 
-	if (of_property_read_bool(data->client->dev.of_node, "ti,extended-range-enable")) {
-		/* Enable measurement over extended temperature range */
-		config |= TMP401_CONFIG_RANGE;
+	if (data->kind != nct7719w) {
+		if (of_property_read_bool(data->client->dev.of_node,
+					  "ti,extended-range-enable")) {
+			/* Enable measurement over extended temperature range */
+			config |= TMP401_CONFIG_RANGE;
+		}
+		data->extended_range = !!(config & TMP401_CONFIG_RANGE);
 	}
 
-	data->extended_range = !!(config & TMP401_CONFIG_RANGE);
-
 	if (config != config_orig) {
 		ret = regmap_write(regmap, TMP401_CONFIG, config);
 		if (ret < 0)
@@ -562,8 +711,8 @@ static int tmp401_init_client(struct tmp401_data *data)
 
 	ret = of_property_read_s32(data->client->dev.of_node, "ti,n-factor", &nfactor);
 	if (!ret) {
-		if (data->kind == tmp401) {
-			dev_err(&data->client->dev, "ti,tmp401 does not support n-factor correction\n");
+		if (data->kind == tmp401 || data->kind == nct7719w) {
+			dev_err(&data->client->dev, "device does not support n-factor correction\n");
 			return -EINVAL;
 		}
 		if (nfactor < -128 || nfactor > 127) {
@@ -577,8 +726,9 @@ static int tmp401_init_client(struct tmp401_data *data)
 
 	ret = of_property_read_u32(data->client->dev.of_node, "ti,beta-compensation", &val);
 	if (!ret) {
-		if (data->kind == tmp401 || data->kind == tmp411) {
-			dev_err(&data->client->dev, "ti,tmp401 or ti,tmp411 does not support beta compensation\n");
+		if (data->kind == tmp401 || data->kind == tmp411 ||
+		    data->kind == nct7719w) {
+			dev_err(&data->client->dev, "device does not support beta compensation\n");
 			return -EINVAL;
 		}
 		if (val > 15) {
@@ -605,6 +755,15 @@ static int tmp401_detect(struct i2c_client *client,
 
 	/* Detect and identify the chip */
 	reg = i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG);
+	if (reg == NCT7719W_MANUFACTURER_ID) {
+		if (client->addr != 0x4d)
+			return -ENODEV;
+		reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG);
+		if ((reg & NCT7719W_DEVICE_ID_MASK) != NCT7719W_DEVICE_ID)
+			return -ENODEV;
+		strscpy(info->type, "nct7719w", I2C_NAME_SIZE);
+		return 0;
+	}
 	if (reg != TMP401_MANUFACTURER_ID)
 		return -ENODEV;
 
@@ -665,7 +824,7 @@ static int tmp401_detect(struct i2c_client *client,
 static int tmp401_probe(struct i2c_client *client)
 {
 	static const char * const names[] = {
-		"TMP401", "TMP411", "TMP431", "TMP432", "TMP435"
+		"TMP401", "TMP411", "TMP431", "TMP432", "TMP435", "NCT7719W"
 	};
 	struct device *dev = &client->dev;
 	struct hwmon_channel_info *info;
@@ -714,7 +873,7 @@ static int tmp401_probe(struct i2c_client *client)
 		data->chip_channel_config[0] |= HWMON_C_TEMP_RESET_HISTORY;
 	}
 
-	if (data->kind == tmp432) {
+	if (data->kind == tmp432 || data->kind == nct7719w) {
 		data->temp_channel_config[2] = HWMON_T_INPUT | HWMON_T_MIN | HWMON_T_MAX |
 			HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM |
 			HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM | HWMON_T_FAULT;
@@ -730,7 +889,10 @@ static int tmp401_probe(struct i2c_client *client)
 	if (IS_ERR(hwmon_dev))
 		return PTR_ERR(hwmon_dev);
 
-	dev_info(dev, "Detected TI %s chip\n", names[data->kind]);
+	if (data->kind == nct7719w)
+		dev_info(dev, "Detected Nuvoton %s chip\n", names[data->kind]);
+	else
+		dev_info(dev, "Detected TI %s chip\n", names[data->kind]);
 
 	return 0;
 }
@@ -741,6 +903,7 @@ static const struct of_device_id __maybe_unused tmp4xx_of_match[] = {
 	{ .compatible = "ti,tmp431", },
 	{ .compatible = "ti,tmp432", },
 	{ .compatible = "ti,tmp435", },
+	{ .compatible = "nuvoton,nct7719w", },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, tmp4xx_of_match);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/2] dt-bindings: hwmon: tmp401: Add Nuvoton NCT7719W
  2026-12-03  8:46 ` [PATCH v1 1/2] dt-bindings: hwmon: tmp401: Add " hsyemail2
@ 2026-12-03  8:57   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-03  8:57 UTC (permalink / raw)
  To: hsyemail2; +Cc: devicetree, linux-hwmon, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dt-bindings: hwmon: commit message omits hardware rationale for
  NCT7719W
--

commit 782cd51dbfd8f7b51e1b7efeb1c1bc6d065413b1
Author: Sheng-Yuan Huang <syhuang3@nuvoton.com>

> dt-bindings: hwmon: tmp401: Add Nuvoton NCT7719W
>
> Add the Nuvoton NCT7719W compatible to the TMP401 hwmon binding.
> Disallow TI-specific properties for this device.
>
> Signed-off-by: Sheng-Yuan Huang <syhuang3@nuvoton.com>

[Severity: Low]
Could the commit message explain the hardware rationale for adding
nuvoton,nct7719w to ti,tmp401.yaml without a fallback compatible?

Sibling Nuvoton sensors (nct7716, nct7717, nct7718) are documented in
Documentation/devicetree/bindings/hwmon/national,lm90.yaml.  Without
context, it is unclear why NCT7719W belongs in ti,tmp401.yaml instead
or why it cannot fall back to a TMP43x compatible.

It would also help to note that NCT7719W shares the TMP432 channel
layout with different register and encoding details, and lacks
extended-range, n-factor, and beta-compensation support in hardware
rather than merely in the driver.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203084635.5694-1-syhuang3@nuvoton.com?part=1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W
  2026-12-03  8:46 ` [PATCH v1 2/2] hwmon: (tmp401) Add support for " hsyemail2
@ 2026-12-03  9:08   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-03  9:08 UTC (permalink / raw)
  To: hsyemail2; +Cc: devicetree, linux-hwmon, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] hwmon: (tmp401) unguarded split byte reads in
  tmp401_reg_read() for NCT7719W
- [Medium] hwmon: (tmp401) tmp401_detect() skips register checks for
  NCT7719W
- [Low] hwmon: (tmp401) missing NCT7719W entry in SENSORS_TMP401 Kconfig
  help text
- [Low] hwmon: (tmp401) nct7719w_set_convrate() floors update_interval
  values
- [Low] hwmon: (tmp401) missing .data in tmp4xx_of_match for
  nuvoton,nct7719w
- [Low] hwmon: (tmp401) tmp401_detect() truncates s32 SMBus errors into
  u8 reg
--

commit f864dd6c74364eb055ac2dd4bb06ee2eab5a2c95
Author: Sheng-Yuan Huang <syhuang3@nuvoton.com>

hwmon: (tmp401) Add support for Nuvoton NCT7719W

This commit adds support for the Nuvoton NCT7719W temperature sensor to
the tmp401 driver and its documentation, using separate SMBus byte
accesses for remote temperatures and limits and signed temperature
conversion.

> diff --git a/Documentation/hwmon/tmp401.rst b/Documentation/hwmon/tmp401.rst
> index 3aacf3d3bdf33..35ca055be7cf8 100644
> --- a/Documentation/hwmon/tmp401.rst
> +++ b/Documentation/hwmon/tmp401.rst
> @@ -3,6 +3,12 @@ Kernel driver tmp401
>  
>  Supported chips:
>  
> +  * Nuvoton NCT7719W
> +
> +    Prefix: 'nct7719w'
> +
> +    Addresses scanned: I2C 0x4d
> +

[Severity: Low]
Should SENSORS_TMP401 in drivers/hwmon/Kconfig also be updated to list the
Nuvoton NCT7719W?  Documentation/hwmon/submitting-patches.rst asks that
Kconfig stay in sync with the driver documentation when adding a new chip.

[ ... ]

> diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
> index 83aafe4bd3e72..745494acae0f2 100644
> --- a/drivers/hwmon/tmp401.c
> +++ b/drivers/hwmon/tmp401.c

[ ... ]

> @@ -143,6 +147,55 @@ static int tmp401_reg_read(void *context, unsigned int reg, unsigned int *val)
>  	struct tmp401_data *data = context;
>  	struct i2c_client *client = data->client;
>  	int regval;
> +	int low_reg;
> +	int low_val;
> +
> +	/* NCT7719W remote values and limits require separate byte accesses. */
> +	if (data->kind == nct7719w) {

[ ... ]

> +		if (low_reg) {
> +			regval = i2c_smbus_read_byte_data(client, reg);
> +			if (regval < 0)
> +				return regval;
> +			low_val = i2c_smbus_read_byte_data(client, low_reg);
> +			if (low_val < 0)
> +				return low_val;
> +			*val = (regval << 8) | (low_val & GENMASK(7, 5));
> +			return 0;
> +		}
> +	}

[Severity: Medium]
Can reading the remote temperature high and low bytes (0x01/0x10 and
0x23/0x24) in two separate SMBus byte transactions return a torn value if
an ADC conversion completes between them?

If the NCT7719W does not latch the low byte on a high-byte read, an
integer rollover between the two reads can skew readings by up to 0.875 C
for sysfs and thermal zone consumers.  Re-reading the high byte (and low
byte if it changed), as lm90_read16() does, avoids tearing either way.

[ ... ]

> @@ -409,6 +540,19 @@ static int tmp401_chip_read(struct device *dev, u32 attr, int channel, long *val
>  	return 0;
>  }
>  
> +static int nct7719w_set_convrate(struct regmap *regmap, long val)
> +{
> +	int rate;
> +	int interval;
> +
> +	val = clamp_val(val, 63, 16000);
> +	interval = 16000;
> +	for (rate = 0; rate < 8 && val < interval; rate++)
> +		interval /= 2;
> +
> +	return regmap_write(regmap, TMP401_CONVERSION_RATE, rate);
> +}

[Severity: Low]
Does nct7719w_set_convrate() floor non-exact update_interval values
instead of rounding to the nearest supported rate?

Comparing val < interval rather than the midpoint means writing 15999 ms
selects 8000 ms (or 124 ms selects 63 ms), doubling the sampling rate
compared to tmp401_set_convrate() right below it.

[ ... ]

> @@ -605,6 +755,15 @@ static int tmp401_detect(struct i2c_client *client,
>  
>  	/* Detect and identify the chip */
>  	reg = i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG);
> +	if (reg == NCT7719W_MANUFACTURER_ID) {
> +		if (client->addr != 0x4d)
> +			return -ENODEV;
> +		reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG);
> +		if ((reg & NCT7719W_DEVICE_ID_MASK) != NCT7719W_DEVICE_ID)
> +			return -ENODEV;

[Severity: Low]
Can truncating the signed return value of i2c_smbus_read_byte_data() into
u8 reg cause a false positive on an SMBus error?

On PA-RISC, -ETIMEDOUT (-238) truncates to 0x12, so a timeout reading
TMP401_DEVICE_ID_REG matches NCT7719W_DEVICE_ID and probes nct7719w.  The
same u8 reg lets -ERESTARTSYS (0x00) bypass the TI checks below; making
reg an int and checking reg < 0 fixes both paths.

> +		strscpy(info->type, "nct7719w", I2C_NAME_SIZE);
> +		return 0;
> +	}

[Severity: Medium]
Is matching only 12 ID bits at address 0x4d enough to detect the NCT7719W
reliably without checking any other registers?

Unlike the TI path below (and lm90_detect_nuvoton()), this skips checking
TMP401_CONVERSION_RATE (0..8), reserved TMP401_CONFIG bits, or unused LSB
and hysteresis bits.  A false positive on an I2C_CLASS_HWMON bus causes
tmp401_init_client() to write to an unrelated chip at 0x4d.

[ ... ]

> @@ -741,6 +903,7 @@ static const struct of_device_id __maybe_unused tmp4xx_of_match[] = {
>  	{ .compatible = "ti,tmp431", },
>  	{ .compatible = "ti,tmp432", },
>  	{ .compatible = "ti,tmp435", },
> +	{ .compatible = "nuvoton,nct7719w", },
>  	{ },
>  };

[Severity: Low]
Should this entry set .data = (void *)nct7719w instead of relying on the
i2c_match_id() fallback?

With .data omitted, i2c_get_match_data() falls back to case-sensitive
matching on client->name from index 0 of the compatible list.  If a DT or
ACPI PRP0001 table puts a more specific compatible first with
nuvoton,nct7719w as a fallback, i2c_match_id() returns NULL.

tmp401_probe() then silently sets data->kind to tmp401, issuing
unsupported SMBus word accesses and misdecoding temperatures.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203084635.5694-1-syhuang3@nuvoton.com?part=2

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-03  9:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  8:46 [PATCH v1 0/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W hsyemail2
2026-12-03  8:46 ` [PATCH v1 1/2] dt-bindings: hwmon: tmp401: Add " hsyemail2
2026-12-03  8:57   ` sashiko-bot
2026-12-03  8:46 ` [PATCH v1 2/2] hwmon: (tmp401) Add support for " hsyemail2
2026-12-03  9:08   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox