All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] hwmon: (lm75) Add support for Nuvoton NCT7715
@ 2026-09-15  5:20 hsyemail2
  2026-09-15  5:28 ` sashiko-bot
  2026-09-15 14:37 ` Guenter Roeck
  0 siblings, 2 replies; 5+ messages in thread
From: hsyemail2 @ 2026-09-15  5:20 UTC (permalink / raw)
  To: Guenter Roeck, linux-hwmon
  Cc: Sheng-Yuan Huang, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jonathan Corbet, Shuah Khan, Jean Delvare, devicetree,
	linux-kernel, linux-doc

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

The Nuvoton NCT7715 is compatible with the LM75 temperature and
limit register layout. Its 16-bit configuration register shares the
TMP112 configuration layout.

Signed-off-by: Sheng-Yuan Huang <syhuang3@nuvoton.com>
---
v3:
- Reuse the existing TMP112 handling for NCT7715 configuration,
  update intervals, and alarms.

v2:
- Use the standard SMBus word representation for the NCT7715
  configuration register, removing the NCT7715-specific byte swapping
  and updating its configuration masks accordingly.
  
 .../devicetree/bindings/hwmon/lm75.yaml       |  2 ++
 Documentation/hwmon/lm75.rst                  |  6 ++++++
 drivers/hwmon/lm75.c                          | 21 ++++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml
index b48bf3fd721f..d55b8b7e49c5 100644
--- a/Documentation/devicetree/bindings/hwmon/lm75.yaml
+++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml
@@ -31,6 +31,7 @@ properties:
       - nxp,p3t1750
       - nxp,p3t1755
       - nxp,pct2075
+      - nuvoton,nct7715
       - st,stds75
       - st,stlm75
       - microchip,tcn75
@@ -78,6 +79,7 @@ allOf:
                 - ti,tmp101
                 - ti,tmp112
                 - ti,tmp75
+                - nuvoton,nct7715
     then:
       properties:
         interrupts: false
diff --git a/Documentation/hwmon/lm75.rst b/Documentation/hwmon/lm75.rst
index ca46754e028b..fac0b8f29ddc 100644
--- a/Documentation/hwmon/lm75.rst
+++ b/Documentation/hwmon/lm75.rst
@@ -150,6 +150,12 @@ Supported chips:
 
                https://ams.com/documents/20143/36005/AS6200_DS000449_4-00.pdf
 
+  * Nuvoton NCT7715
+
+    Prefix: 'nct7715'
+
+    Addresses scanned: none
+
 Author: Frodo Looijaard <frodol@dds.nl>
 
 Description
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 2d2d752aeac9..1a98ecb142c9 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -39,6 +39,7 @@ enum lm75_type {		/* keep sorted in alphabetical order */
 	max6626,
 	max31725,
 	mcp980x,
+	nct7715,
 	p3t1750,
 	p3t1755,
 	pct2075,
@@ -259,6 +260,16 @@ static const struct lm75_params device_params[] = {
 		.sample_times = (unsigned int []){ 30, 60, 120, 240 },
 		.resolutions = (u8 []) {9, 10, 11, 12 },
 	},
+	[nct7715] = {
+		.config_reg_16bits = true,
+		.set_mask = 0x8060,	/* 12-bit mode, 4 samples / second */
+		.clr_mask = 1 << 7,	/* no one-shot mode */
+		.default_resolution = 12,
+		.default_sample_time = 250,
+		.num_sample_times = 4,
+		.sample_times = (unsigned int []){ 125, 250, 1000, 4000 },
+		.alarm = true,
+	},
 	[tmp100] = {
 		.set_mask = 3 << 5,	/* 12-bit mode */
 		.clr_mask = 1 << 7,	/* not one-shot mode */
@@ -417,6 +428,7 @@ static int lm75_read(struct device *dev, enum hwmon_sensor_types type,
 		if (attr == hwmon_temp_alarm) {
 			switch (data->kind) {
 			case as6200:
+			case nct7715:
 			case tmp112:
 				*val = !!(regval & BIT(13)) == !!(regval & BIT(2));
 				break;
@@ -486,6 +498,7 @@ static int lm75_update_interval(struct device *dev, long val)
 		if (data->params->resolutions)
 			data->resolution = data->params->resolutions[index];
 		break;
+	case nct7715:
 	case tmp112:
 	case as6200:
 		err = regmap_update_bits(data->regmap, LM75_REG_CONF,
@@ -848,6 +861,7 @@ static const struct i2c_device_id lm75_i2c_ids[] = {
 	{ .name = "max31725", .driver_data = max31725 },
 	{ .name = "max31726", .driver_data = max31725 },
 	{ .name = "mcp980x", .driver_data = mcp980x },
+	{ .name = "nct7715", .driver_data = nct7715 },
 	{ .name = "p3t1750", .driver_data = p3t1750 },
 	{ .name = "p3t1755", .driver_data = p3t1755 },
 	{ .name = "pct2075", .driver_data = pct2075 },
@@ -972,6 +986,10 @@ static const struct of_device_id lm75_of_match[] = {
 		.compatible = "nxp,pct2075",
 		.data = (void *)pct2075
 	},
+	{
+		.compatible = "nuvoton,nct7715",
+		.data = (void *)nct7715
+	},
 	{
 		.compatible = "st,stds75",
 		.data = (void *)stds75
@@ -1129,7 +1147,8 @@ static int lm75_suspend(struct device *dev)
 {
 	struct lm75_data *data = dev_get_drvdata(dev);
 
-	return regmap_update_bits(data->regmap, LM75_REG_CONF, LM75_SHUTDOWN, LM75_SHUTDOWN);
+	return regmap_update_bits(data->regmap, LM75_REG_CONF,
+				  LM75_SHUTDOWN, LM75_SHUTDOWN);
 }
 
 static int lm75_resume(struct device *dev)
-- 
2.43.0


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

* Re: [PATCH v3] hwmon: (lm75) Add support for Nuvoton NCT7715
  2026-09-15  5:20 [PATCH v3] hwmon: (lm75) Add support for Nuvoton NCT7715 hsyemail2
@ 2026-09-15  5:28 ` sashiko-bot
  2026-09-15  6:33   ` Sheng-Yuan Huang
  2026-09-15 14:37 ` Guenter Roeck
  1 sibling, 1 reply; 5+ messages in thread
From: sashiko-bot @ 2026-09-15  5:28 UTC (permalink / raw)
  To: hsyemail2; +Cc: robh, conor+dt, devicetree, linux-hwmon

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hwmon: lm75: NCT7715 initialization fails to clear bit 14 of config register
--

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

hwmon: (lm75) Add support for Nuvoton NCT7715

This commit adds support for the Nuvoton NCT7715 temperature sensor to the
lm75 hardware monitoring driver. It introduces a new device parameter entry
that reuses much of the TMP112 handling for configuration and alarms.

> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c

[ ... ]

> @@ -259,6 +260,16 @@ static const struct lm75_params device_params[] = {
>  		.sample_times = (unsigned int []){ 30, 60, 120, 240 },
>  		.resolutions = (u8 []) {9, 10, 11, 12 },
>  	},
> +	[nct7715] = {
> +		.config_reg_16bits = true,
> +		.set_mask = 0x8060,	/* 12-bit mode, 4 samples / second */
> +		.clr_mask = 1 << 7,	/* no one-shot mode */

[Severity: Medium]
Will this leave bit 14 unchanged if it was previously set by a bootloader or
left over from a warm reboot?

During driver probe, lm75_generic_probe() calls lm75_write_config() to
initialize LM75_REG_CONF. The regmap update mask used is:
clr_mask | set_mask | LM75_SHUTDOWN

For nct7715, set_mask is 0x8060 and clr_mask is 0x0080. Bit 14 (0x4000) is
missing from both masks. Because of this, regmap_update_bits() will
silently ignore the 0 in bit 14 of set_mask and preserve its prior value
from the hardware configuration register.

If bit 14 remains set, can the sensor operate at 8 Hz instead of the
intended 4 Hz, leading to a mismatch between the hardware state and the
driver state which expects and reports a 250ms interval?

Should 0x4000 be included in clr_mask to ensure the hardware is properly
initialized to 4 samples / second?

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

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

* Re: [PATCH v3] hwmon: (lm75) Add support for Nuvoton NCT7715
  2026-09-15  5:28 ` sashiko-bot
@ 2026-09-15  6:33   ` Sheng-Yuan Huang
  0 siblings, 0 replies; 5+ messages in thread
From: Sheng-Yuan Huang @ 2026-09-15  6:33 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: robh, conor+dt, devicetree, linux-hwmon

<sashiko-bot@kernel.org> 於 2026年9月15日週二 下午1:28寫道:

> > +     [nct7715] = {
> > +             .config_reg_16bits = true,
> > +             .set_mask = 0x8060,     /* 12-bit mode, 4 samples / second */
> > +             .clr_mask = 1 << 7,     /* no one-shot mode */
>
> [Severity: Medium]
> Will this leave bit 14 unchanged if it was previously set by a bootloader or
> left over from a warm reboot?
>
> During driver probe, lm75_generic_probe() calls lm75_write_config() to
> initialize LM75_REG_CONF. The regmap update mask used is:
> clr_mask | set_mask | LM75_SHUTDOWN
>
> For nct7715, set_mask is 0x8060 and clr_mask is 0x0080. Bit 14 (0x4000) is
> missing from both masks. Because of this, regmap_update_bits() will
> silently ignore the 0 in bit 14 of set_mask and preserve its prior value
> from the hardware configuration register.
>
> If bit 14 remains set, can the sensor operate at 8 Hz instead of the
> intended 4 Hz, leading to a mismatch between the hardware state and the
> driver state which expects and reports a 250ms interval?
>
> Should 0x4000 be included in clr_mask to ensure the hardware is properly
> initialized to 4 samples / second?
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260915052021.6959-1-syhuang3@nuvoton.com?part=1

I will update the patch in v4 to include bit 14 in the NCT7715 clear
mask, ensuring that the default conversion rate is initialized to 4 Hz.

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

* Re: [PATCH v3] hwmon: (lm75) Add support for Nuvoton NCT7715
  2026-09-15  5:20 [PATCH v3] hwmon: (lm75) Add support for Nuvoton NCT7715 hsyemail2
  2026-09-15  5:28 ` sashiko-bot
@ 2026-09-15 14:37 ` Guenter Roeck
  2026-09-17  1:20   ` Sheng-Yuan Huang
  1 sibling, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2026-09-15 14:37 UTC (permalink / raw)
  To: hsyemail2, linux-hwmon
  Cc: Sheng-Yuan Huang, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jonathan Corbet, Shuah Khan, Jean Delvare, devicetree,
	linux-kernel, linux-doc

On 9/14/26 22:20, hsyemail2@gmail.com wrote:
> From: Sheng-Yuan Huang <syhuang3@nuvoton.com>
> 
> The Nuvoton NCT7715 is compatible with the LM75 temperature and
> limit register layout. Its 16-bit configuration register shares the
> TMP112 configuration layout.
> 
> Signed-off-by: Sheng-Yuan Huang <syhuang3@nuvoton.com>
> ---
> v3:
> - Reuse the existing TMP112 handling for NCT7715 configuration,
>    update intervals, and alarms.
> 
> v2:
> - Use the standard SMBus word representation for the NCT7715
>    configuration register, removing the NCT7715-specific byte swapping
>    and updating its configuration masks accordingly.
>    
>   .../devicetree/bindings/hwmon/lm75.yaml       |  2 ++
>   Documentation/hwmon/lm75.rst                  |  6 ++++++
>   drivers/hwmon/lm75.c                          | 21 ++++++++++++++++++-
>   3 files changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml
> index b48bf3fd721f..d55b8b7e49c5 100644
> --- a/Documentation/devicetree/bindings/hwmon/lm75.yaml
> +++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml
> @@ -31,6 +31,7 @@ properties:
>         - nxp,p3t1750
>         - nxp,p3t1755
>         - nxp,pct2075
> +      - nuvoton,nct7715

Sorry, I did not notice this before. Devicetree changes have to be
made with a separate patch.

>         - st,stds75
>         - st,stlm75
>         - microchip,tcn75
> @@ -78,6 +79,7 @@ allOf:
>                   - ti,tmp101
>                   - ti,tmp112
>                   - ti,tmp75
> +                - nuvoton,nct7715
>       then:
>         properties:
>           interrupts: false
> diff --git a/Documentation/hwmon/lm75.rst b/Documentation/hwmon/lm75.rst
> index ca46754e028b..fac0b8f29ddc 100644
> --- a/Documentation/hwmon/lm75.rst
> +++ b/Documentation/hwmon/lm75.rst
> @@ -150,6 +150,12 @@ Supported chips:
>   
>                  https://ams.com/documents/20143/36005/AS6200_DS000449_4-00.pdf
>   
> +  * Nuvoton NCT7715
> +
> +    Prefix: 'nct7715'
> +
> +    Addresses scanned: none
> +
>   Author: Frodo Looijaard <frodol@dds.nl>
>   
>   Description
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index 2d2d752aeac9..1a98ecb142c9 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -39,6 +39,7 @@ enum lm75_type {		/* keep sorted in alphabetical order */
>   	max6626,
>   	max31725,
>   	mcp980x,
> +	nct7715,
>   	p3t1750,
>   	p3t1755,
>   	pct2075,
> @@ -259,6 +260,16 @@ static const struct lm75_params device_params[] = {
>   		.sample_times = (unsigned int []){ 30, 60, 120, 240 },
>   		.resolutions = (u8 []) {9, 10, 11, 12 },
>   	},
> +	[nct7715] = {
> +		.config_reg_16bits = true,
> +		.set_mask = 0x8060,	/* 12-bit mode, 4 samples / second */
> +		.clr_mask = 1 << 7,	/* no one-shot mode */
> +		.default_resolution = 12,
> +		.default_sample_time = 250,
> +		.num_sample_times = 4,
> +		.sample_times = (unsigned int []){ 125, 250, 1000, 4000 },
> +		.alarm = true,
> +	},
>   	[tmp100] = {
>   		.set_mask = 3 << 5,	/* 12-bit mode */
>   		.clr_mask = 1 << 7,	/* not one-shot mode */
> @@ -417,6 +428,7 @@ static int lm75_read(struct device *dev, enum hwmon_sensor_types type,
>   		if (attr == hwmon_temp_alarm) {
>   			switch (data->kind) {
>   			case as6200:
> +			case nct7715:
>   			case tmp112:
>   				*val = !!(regval & BIT(13)) == !!(regval & BIT(2));
>   				break;
> @@ -486,6 +498,7 @@ static int lm75_update_interval(struct device *dev, long val)
>   		if (data->params->resolutions)
>   			data->resolution = data->params->resolutions[index];
>   		break;
> +	case nct7715:
>   	case tmp112:
>   	case as6200:
>   		err = regmap_update_bits(data->regmap, LM75_REG_CONF,
> @@ -848,6 +861,7 @@ static const struct i2c_device_id lm75_i2c_ids[] = {
>   	{ .name = "max31725", .driver_data = max31725 },
>   	{ .name = "max31726", .driver_data = max31725 },
>   	{ .name = "mcp980x", .driver_data = mcp980x },
> +	{ .name = "nct7715", .driver_data = nct7715 },
>   	{ .name = "p3t1750", .driver_data = p3t1750 },
>   	{ .name = "p3t1755", .driver_data = p3t1755 },
>   	{ .name = "pct2075", .driver_data = pct2075 },
> @@ -972,6 +986,10 @@ static const struct of_device_id lm75_of_match[] = {
>   		.compatible = "nxp,pct2075",
>   		.data = (void *)pct2075
>   	},
> +	{
> +		.compatible = "nuvoton,nct7715",
> +		.data = (void *)nct7715
> +	},
>   	{
>   		.compatible = "st,stds75",
>   		.data = (void *)stds75
> @@ -1129,7 +1147,8 @@ static int lm75_suspend(struct device *dev)
>   {
>   	struct lm75_data *data = dev_get_drvdata(dev);
>   
> -	return regmap_update_bits(data->regmap, LM75_REG_CONF, LM75_SHUTDOWN, LM75_SHUTDOWN);
> +	return regmap_update_bits(data->regmap, LM75_REG_CONF,
> +				  LM75_SHUTDOWN, LM75_SHUTDOWN);

Drop this change.

Thanks,
Guenter

>   }
>   
>   static int lm75_resume(struct device *dev)


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

* Re: [PATCH v3] hwmon: (lm75) Add support for Nuvoton NCT7715
  2026-09-15 14:37 ` Guenter Roeck
@ 2026-09-17  1:20   ` Sheng-Yuan Huang
  0 siblings, 0 replies; 5+ messages in thread
From: Sheng-Yuan Huang @ 2026-09-17  1:20 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-hwmon, Sheng-Yuan Huang, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Jonathan Corbet, Shuah Khan, Jean Delvare,
	devicetree, linux-kernel, linux-doc

Guenter Roeck <linux@roeck-us.net> 於 2026年9月15日週二 下午10:37寫道:

> > @@ -1129,7 +1147,8 @@ static int lm75_suspend(struct device *dev)
> >   {
> >       struct lm75_data *data = dev_get_drvdata(dev);
> >
> > -     return regmap_update_bits(data->regmap, LM75_REG_CONF, LM75_SHUTDOWN, LM75_SHUTDOWN);
> > +     return regmap_update_bits(data->regmap, LM75_REG_CONF,
> > +                               LM75_SHUTDOWN, LM75_SHUTDOWN);
>
> Drop this change.
>

Thank you for pointing this out. I will address it in the next patch.

Thanks,
Sheng-Yuan Huang

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

end of thread, other threads:[~2026-09-17  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15  5:20 [PATCH v3] hwmon: (lm75) Add support for Nuvoton NCT7715 hsyemail2
2026-09-15  5:28 ` sashiko-bot
2026-09-15  6:33   ` Sheng-Yuan Huang
2026-09-15 14:37 ` Guenter Roeck
2026-09-17  1:20   ` Sheng-Yuan Huang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.