diff options
author | Guenter Roeck <linux@roeck-us.net> | 2017-09-05 03:33:53 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2017-10-30 02:36:03 +0100 |
commit | 1b50b776355fa6c6d7b3281a63c275d5c18d629d (patch) | |
tree | e8621e268de948955cb7df61a912ba9d3340761b /drivers/hwmon | |
parent | hwmon: (k10temp) Add support for family 17h (diff) | |
download | linux-1b50b776355fa6c6d7b3281a63c275d5c18d629d.tar.xz linux-1b50b776355fa6c6d7b3281a63c275d5c18d629d.zip |
hwmon: (k10temp) Add support for temperature offsets
Add support for handling temperature offset values for various AMD CPUs,
similar to the code used in the coretemp driver for Intel CPUs. This is
primarily for Ryzen CPUs (which has documented temperature offsets),
but the code is kept generic to simplify adding additional CPUs.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/k10temp.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index c4dac53206c3..46a54ed23410 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -71,6 +71,24 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); struct k10temp_data { struct pci_dev *pdev; void (*read_tempreg)(struct pci_dev *pdev, u32 *regval); + int temp_offset; +}; + +struct tctl_offset { + u8 model; + char const *id; + int offset; +}; + +static const struct tctl_offset tctl_offset_table[] = { + { 0x17, "AMD Ryzen 7 1600X", 20000 }, + { 0x17, "AMD Ryzen 7 1700X", 20000 }, + { 0x17, "AMD Ryzen 7 1800X", 20000 }, + { 0x17, "AMD Ryzen Threadripper 1950X", 27000 }, + { 0x17, "AMD Ryzen Threadripper 1920X", 27000 }, + { 0x17, "AMD Ryzen Threadripper 1950", 10000 }, + { 0x17, "AMD Ryzen Threadripper 1920", 10000 }, + { 0x17, "AMD Ryzen Threadripper 1910", 10000 }, }; static void read_tempreg_pci(struct pci_dev *pdev, u32 *regval) @@ -110,6 +128,7 @@ static ssize_t temp1_input_show(struct device *dev, data->read_tempreg(data->pdev, ®val); temp = (regval >> 21) * 125; + temp -= data->temp_offset; return sprintf(buf, "%u\n", temp); } @@ -217,6 +236,7 @@ static int k10temp_probe(struct pci_dev *pdev, struct device *dev = &pdev->dev; struct k10temp_data *data; struct device *hwmon_dev; + int i; if (unreliable) { if (!force) { @@ -242,6 +262,16 @@ static int k10temp_probe(struct pci_dev *pdev, else data->read_tempreg = read_tempreg_pci; + for (i = 0; i < ARRAY_SIZE(tctl_offset_table); i++) { + const struct tctl_offset *entry = &tctl_offset_table[i]; + + if (boot_cpu_data.x86 == entry->model && + strstr(boot_cpu_data.x86_model_id, entry->id)) { + data->temp_offset = entry->offset; + break; + } + } + hwmon_dev = devm_hwmon_device_register_with_groups(dev, "k10temp", data, k10temp_groups); return PTR_ERR_OR_ZERO(hwmon_dev); |