Re: [PATCH] hwmon: sbtsi_temp: AMD CPU extended temperature range support

From: Guenter Roeck
Date: Sun Aug 10 2025 - 19:48:54 EST


On 8/10/25 01:43, Chuande Chen wrote:
From: Chuande Chen <chuachen@xxxxxxxxx>

Many AMD CPUs can support this feature now.
We would get a wrong CPU DIE temp if don't consider this.
In low-temperature environments, the CPU die temperature
can drop below zero.
So many platform would like to make extended temperature range
as their default configuration.
Default temperature range (0C to 255.875C) degree celsius.
Extended temperature range (-49C to +206.875C) degree celsius.
Ref Doc: AMD V3000 PPR (Doc ID #56558).

Signed-off-by: Chuande Chen <chuachen@xxxxxxxxx>
---
drivers/hwmon/sbtsi_temp.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/sbtsi_temp.c b/drivers/hwmon/sbtsi_temp.c
index 3c839f56c..15e49c2a0 100644
--- a/drivers/hwmon/sbtsi_temp.c
+++ b/drivers/hwmon/sbtsi_temp.c
@@ -30,6 +30,14 @@
#define SBTSI_REG_TEMP_LOW_DEC 0x14 /* RW */
#define SBTSI_CONFIG_READ_ORDER_SHIFT 5
+/*
+ * Bit for temperature measurement range.
+ * Value=0: Use default temperature range (0C to 255.875C) for reporting temperature.
+ * Value=1: Use extended temperature range (-49C to +206.875C) for reporting temperature.
+ */
+#define SBTSI_CONFIG_EXT_RAGE_SHIFT 2
+
+#define SBTSI_TEMP_EXT_RAGE_ADJ 49000

Lower bits first, please. Also, I am quite sure that this should be "RANGE",
not "RAGE".

#define SBTSI_TEMP_MIN 0
#define SBTSI_TEMP_MAX 255875
@@ -74,7 +82,12 @@ static int sbtsi_read(struct device *dev, enum hwmon_sensor_types type,
{
struct sbtsi_data *data = dev_get_drvdata(dev);
s32 temp_int, temp_dec;
- int err;
+ int err, cfg;
+
+ err = i2c_smbus_read_byte_data(data->client, SBTSI_REG_CONFIG);
+ if (err < 0)
+ return err;
+ cfg = err;

Since the configuration byte is now needed in two functions, and since it is
not expected to change dynamically, please store the configuration in struct
sbtsi_data in the probe function and read it from there.

Thanks,
Guenter