Skip to content

Commit e146503

Browse files
baski-kannangroeck
authored andcommitted
hwmon: (k10temp) Enable AMD3255 Proc to show negative temperature
Industrial processor i3255 supports temperatures -40 deg celcius to 105 deg Celcius. The current implementation of k10temp_read_temp rounds off any negative temperatures to '0'. To fix this, the following changes have been made. A flag 'disp_negative' is added to struct k10temp_data to support AMD i3255 processors. Flag 'disp_negative' is set if 3255 processor is found during k10temp_probe. Flag 'disp_negative' is used to determine whether to round off negative temperatures to '0' in k10temp_read_temp. Signed-off-by: Baskaran Kannan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: aef17ca ("hwmon: (k10temp) Only apply temperature offset if result is positive") Cc: [email protected] [groeck: Fixed multi-line comment] Signed-off-by: Guenter Roeck <[email protected]>
1 parent b84000f commit e146503

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/hwmon/k10temp.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
7777
#define ZEN_CUR_TEMP_RANGE_SEL_MASK BIT(19)
7878
#define ZEN_CUR_TEMP_TJ_SEL_MASK GENMASK(17, 16)
7979

80+
/*
81+
* AMD's Industrial processor 3255 supports temperature from -40 deg to 105 deg Celsius.
82+
* Use the model name to identify 3255 CPUs and set a flag to display negative temperature.
83+
* Do not round off to zero for negative Tctl or Tdie values if the flag is set
84+
*/
85+
#define AMD_I3255_STR "3255"
86+
8087
struct k10temp_data {
8188
struct pci_dev *pdev;
8289
void (*read_htcreg)(struct pci_dev *pdev, u32 *regval);
@@ -86,6 +93,7 @@ struct k10temp_data {
8693
u32 show_temp;
8794
bool is_zen;
8895
u32 ccd_offset;
96+
bool disp_negative;
8997
};
9098

9199
#define TCTL_BIT 0
@@ -204,12 +212,12 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
204212
switch (channel) {
205213
case 0: /* Tctl */
206214
*val = get_raw_temp(data);
207-
if (*val < 0)
215+
if (*val < 0 && !data->disp_negative)
208216
*val = 0;
209217
break;
210218
case 1: /* Tdie */
211219
*val = get_raw_temp(data) - data->temp_offset;
212-
if (*val < 0)
220+
if (*val < 0 && !data->disp_negative)
213221
*val = 0;
214222
break;
215223
case 2 ... 13: /* Tccd{1-12} */
@@ -405,6 +413,11 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
405413
data->pdev = pdev;
406414
data->show_temp |= BIT(TCTL_BIT); /* Always show Tctl */
407415

416+
if (boot_cpu_data.x86 == 0x17 &&
417+
strstr(boot_cpu_data.x86_model_id, AMD_I3255_STR)) {
418+
data->disp_negative = true;
419+
}
420+
408421
if (boot_cpu_data.x86 == 0x15 &&
409422
((boot_cpu_data.x86_model & 0xf0) == 0x60 ||
410423
(boot_cpu_data.x86_model & 0xf0) == 0x70)) {

0 commit comments

Comments
 (0)