Linux Documentation
 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; 3+ 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] 3+ 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:46 ` [PATCH v1 2/2] hwmon: (tmp401) Add support for " hsyemail2
  1 sibling, 0 replies; 3+ 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] 3+ 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
  1 sibling, 0 replies; 3+ 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] 3+ messages in thread

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

Thread overview: 3+ 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:46 ` [PATCH v1 2/2] hwmon: (tmp401) Add support for " hsyemail2

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