Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'hwmon-for-v5.11-take2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull another hwmon update from Guenter Roeck:
"The only patch in this series is removal of voltage and current
reporting for AMD Zen CPUs.

Turns out that was not worth the trouble, because it's all
undocumented and not maintainable"

* tag 'hwmon-for-v5.11-take2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
hwmon: (k10temp) Remove support for displaying voltage and current on Zen CPUs

-98
-98
drivers/hwmon/k10temp.c
··· 11 11 * convert raw register values is from https://github.com/ocerman/zenpower. 12 12 * The information is not confirmed from chip datasheets, but experiments 13 13 * suggest that it provides reasonable temperature values. 14 - * - Register addresses to read chip voltage and current are also from 15 - * https://github.com/ocerman/zenpower, and not confirmed from chip 16 - * datasheets. Current calibration is board specific and not typically 17 - * shared by board vendors. For this reason, current values are 18 - * normalized to report 1A/LSB for core current and and 0.25A/LSB for SoC 19 - * current. Reported values can be adjusted using the sensors configuration 20 - * file. 21 14 */ 22 15 23 16 #include <linux/bitops.h> ··· 102 109 int temp_offset; 103 110 u32 temp_adjust_mask; 104 111 u32 show_temp; 105 - u32 svi_addr[2]; 106 112 bool is_zen; 107 - bool show_current; 108 - int cfactor[2]; 109 113 }; 110 114 111 115 #define TCTL_BIT 0 ··· 126 136 { 0x17, "AMD Ryzen Threadripper 19", 27000 }, /* 19{00,20,50}X */ 127 137 { 0x17, "AMD Ryzen Threadripper 29", 27000 }, /* 29{20,50,70,90}[W]X */ 128 138 }; 129 - 130 - static bool is_threadripper(void) 131 - { 132 - return strstr(boot_cpu_data.x86_model_id, "Threadripper"); 133 - } 134 - 135 - static bool is_epyc(void) 136 - { 137 - return strstr(boot_cpu_data.x86_model_id, "EPYC"); 138 - } 139 139 140 140 static void read_htcreg_pci(struct pci_dev *pdev, u32 *regval) 141 141 { ··· 191 211 "Tccd8", 192 212 }; 193 213 194 - static const char *k10temp_in_label[] = { 195 - "Vcore", 196 - "Vsoc", 197 - }; 198 - 199 - static const char *k10temp_curr_label[] = { 200 - "Icore", 201 - "Isoc", 202 - }; 203 - 204 214 static int k10temp_read_labels(struct device *dev, 205 215 enum hwmon_sensor_types type, 206 216 u32 attr, int channel, const char **str) ··· 198 228 switch (type) { 199 229 case hwmon_temp: 200 230 *str = k10temp_temp_label[channel]; 201 - break; 202 - case hwmon_in: 203 - *str = k10temp_in_label[channel]; 204 - break; 205 - case hwmon_curr: 206 - *str = k10temp_curr_label[channel]; 207 - break; 208 - default: 209 - return -EOPNOTSUPP; 210 - } 211 - return 0; 212 - } 213 - 214 - static int k10temp_read_curr(struct device *dev, u32 attr, int channel, 215 - long *val) 216 - { 217 - struct k10temp_data *data = dev_get_drvdata(dev); 218 - u32 regval; 219 - 220 - switch (attr) { 221 - case hwmon_curr_input: 222 - amd_smn_read(amd_pci_dev_to_node_id(data->pdev), 223 - data->svi_addr[channel], &regval); 224 - *val = DIV_ROUND_CLOSEST(data->cfactor[channel] * 225 - (regval & 0xff), 226 - 1000); 227 - break; 228 - default: 229 - return -EOPNOTSUPP; 230 - } 231 - return 0; 232 - } 233 - 234 - static int k10temp_read_in(struct device *dev, u32 attr, int channel, long *val) 235 - { 236 - struct k10temp_data *data = dev_get_drvdata(dev); 237 - u32 regval; 238 - 239 - switch (attr) { 240 - case hwmon_in_input: 241 - amd_smn_read(amd_pci_dev_to_node_id(data->pdev), 242 - data->svi_addr[channel], &regval); 243 - regval = (regval >> 16) & 0xff; 244 - *val = DIV_ROUND_CLOSEST(155000 - regval * 625, 100); 245 231 break; 246 232 default: 247 233 return -EOPNOTSUPP; ··· 257 331 switch (type) { 258 332 case hwmon_temp: 259 333 return k10temp_read_temp(dev, attr, channel, val); 260 - case hwmon_in: 261 - return k10temp_read_in(dev, attr, channel, val); 262 - case hwmon_curr: 263 - return k10temp_read_curr(dev, attr, channel, val); 264 334 default: 265 335 return -EOPNOTSUPP; 266 336 } ··· 304 382 default: 305 383 return 0; 306 384 } 307 - break; 308 - case hwmon_in: 309 - case hwmon_curr: 310 - if (!data->show_current) 311 - return 0; 312 385 break; 313 386 default: 314 387 return 0; ··· 434 517 case 0x8: /* Zen+ */ 435 518 case 0x11: /* Zen APU */ 436 519 case 0x18: /* Zen+ APU */ 437 - data->show_current = !is_threadripper() && !is_epyc(); 438 - data->svi_addr[0] = F17H_M01H_SVI_TEL_PLANE0; 439 - data->svi_addr[1] = F17H_M01H_SVI_TEL_PLANE1; 440 - data->cfactor[0] = F17H_M01H_CFACTOR_ICORE; 441 - data->cfactor[1] = F17H_M01H_CFACTOR_ISOC; 442 520 k10temp_get_ccd_support(pdev, data, 4); 443 521 break; 444 522 case 0x31: /* Zen2 Threadripper */ 445 523 case 0x71: /* Zen2 */ 446 - data->show_current = !is_threadripper() && !is_epyc(); 447 - data->cfactor[0] = F17H_M31H_CFACTOR_ICORE; 448 - data->cfactor[1] = F17H_M31H_CFACTOR_ISOC; 449 - data->svi_addr[0] = F17H_M31H_SVI_TEL_PLANE0; 450 - data->svi_addr[1] = F17H_M31H_SVI_TEL_PLANE1; 451 524 k10temp_get_ccd_support(pdev, data, 8); 452 525 break; 453 526 } ··· 449 542 450 543 switch (boot_cpu_data.x86_model) { 451 544 case 0x0 ... 0x1: /* Zen3 */ 452 - data->show_current = true; 453 - data->svi_addr[0] = F19H_M01_SVI_TEL_PLANE0; 454 - data->svi_addr[1] = F19H_M01_SVI_TEL_PLANE1; 455 - data->cfactor[0] = F19H_M01H_CFACTOR_ICORE; 456 - data->cfactor[1] = F19H_M01H_CFACTOR_ISOC; 457 545 k10temp_get_ccd_support(pdev, data, 8); 458 546 break; 459 547 }