[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <70d45f13-cf0d-4680-a501-181aead9abaf@roeck-us.net>
Date: Sun, 10 Aug 2025 16:48:40 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Chuande Chen <chenchuande@...il.com>, jdelvare@...e.com
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
chuachen@...co.com
Subject: Re: [PATCH] hwmon: sbtsi_temp: AMD CPU extended temperature range
support
On 8/10/25 01:43, Chuande Chen wrote:
> From: Chuande Chen <chuachen@...co.com>
>
> 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@...co.com>
> ---
> 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
Powered by blists - more mailing lists