Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
hwmon: Make PCI device ids constant
hwmon: (coretemp) Fix TjMax for Atom N450/D410/D510 CPUs
hwmon: (k10temp) Blacklist more family 10h processors
hwmon: (asus_atk0110) Add debugfs interface
hwmon: (asus_atk0110) Refactor interface probe code
hwmon: (adt7462) Fix pin 28 monitoring

+299 -75
+11 -6
Documentation/hwmon/k10temp
··· 3 3 4 4 Supported chips: 5 5 * AMD Family 10h processors: 6 - Socket F: Quad-Core/Six-Core/Embedded Opteron 7 - Socket AM2+: Opteron, Phenom (II) X3/X4 6 + Socket F: Quad-Core/Six-Core/Embedded Opteron (but see below) 7 + Socket AM2+: Quad-Core Opteron, Phenom (II) X3/X4, Athlon X2 (but see below) 8 8 Socket AM3: Quad-Core Opteron, Athlon/Phenom II X2/X3/X4, Sempron II 9 9 Socket S1G3: Athlon II, Sempron, Turion II 10 10 * AMD Family 11h processors: ··· 36 36 This driver permits reading of the internal temperature sensor of AMD 37 37 Family 10h and 11h processors. 38 38 39 - All these processors have a sensor, but on older revisions of Family 10h 40 - processors, the sensor may return inconsistent values (erratum 319). The 41 - driver will refuse to load on these revisions unless you specify the 42 - "force=1" module parameter. 39 + All these processors have a sensor, but on those for Socket F or AM2+, 40 + the sensor may return inconsistent values (erratum 319). The driver 41 + will refuse to load on these revisions unless you specify the "force=1" 42 + module parameter. 43 + 44 + Due to technical reasons, the driver can detect only the mainboard's 45 + socket type, not the processor's actual capabilities. Therefore, if you 46 + are using an AM3 processor on an AM2+ mainboard, you can safely use the 47 + "force=1" parameter. 43 48 44 49 There is one temperature measurement value, available as temp1_input in 45 50 sysfs. It is measured in degrees Celsius with a resolution of 1/8th degree.
+1 -1
drivers/hwmon/Kconfig
··· 392 392 393 393 config SENSORS_CORETEMP 394 394 tristate "Intel Core/Core2/Atom temperature sensor" 395 - depends on X86 && EXPERIMENTAL 395 + depends on X86 && PCI && EXPERIMENTAL 396 396 help 397 397 If you say yes here you get support for the temperature 398 398 sensor inside your CPU. Most of the family 6 CPUs
+1 -1
drivers/hwmon/adt7462.c
··· 94 94 #define ADT7462_PIN24_SHIFT 6 95 95 #define ADT7462_PIN26_VOLT_INPUT 0x08 96 96 #define ADT7462_PIN25_VOLT_INPUT 0x20 97 - #define ADT7462_PIN28_SHIFT 6 /* cfg3 */ 97 + #define ADT7462_PIN28_SHIFT 4 /* cfg3 */ 98 98 #define ADT7462_PIN28_VOLT 0x5 99 99 100 100 #define ADT7462_REG_ALARM1 0xB8
+235 -54
drivers/hwmon/asus_atk0110.c
··· 5 5 * See COPYING in the top level directory of the kernel tree. 6 6 */ 7 7 8 + #include <linux/debugfs.h> 8 9 #include <linux/kernel.h> 9 10 #include <linux/hwmon.h> 10 11 #include <linux/list.h> ··· 102 101 int temperature_count; 103 102 int fan_count; 104 103 struct list_head sensor_list; 104 + 105 + struct { 106 + struct dentry *root; 107 + u32 id; 108 + } debugfs; 105 109 }; 106 110 107 111 ··· 630 624 return err; 631 625 } 632 626 627 + #ifdef CONFIG_DEBUG_FS 628 + static int atk_debugfs_gitm_get(void *p, u64 *val) 629 + { 630 + struct atk_data *data = p; 631 + union acpi_object *ret; 632 + struct atk_acpi_ret_buffer *buf; 633 + int err = 0; 634 + 635 + if (!data->read_handle) 636 + return -ENODEV; 637 + 638 + if (!data->debugfs.id) 639 + return -EINVAL; 640 + 641 + ret = atk_gitm(data, data->debugfs.id); 642 + if (IS_ERR(ret)) 643 + return PTR_ERR(ret); 644 + 645 + buf = (struct atk_acpi_ret_buffer *)ret->buffer.pointer; 646 + if (buf->flags) 647 + *val = buf->value; 648 + else 649 + err = -EIO; 650 + 651 + return err; 652 + } 653 + 654 + DEFINE_SIMPLE_ATTRIBUTE(atk_debugfs_gitm, 655 + atk_debugfs_gitm_get, 656 + NULL, 657 + "0x%08llx\n") 658 + 659 + static int atk_acpi_print(char *buf, size_t sz, union acpi_object *obj) 660 + { 661 + int ret = 0; 662 + 663 + switch (obj->type) { 664 + case ACPI_TYPE_INTEGER: 665 + ret = snprintf(buf, sz, "0x%08llx\n", obj->integer.value); 666 + break; 667 + case ACPI_TYPE_STRING: 668 + ret = snprintf(buf, sz, "%s\n", obj->string.pointer); 669 + break; 670 + } 671 + 672 + return ret; 673 + } 674 + 675 + static void atk_pack_print(char *buf, size_t sz, union acpi_object *pack) 676 + { 677 + int ret; 678 + int i; 679 + 680 + for (i = 0; i < pack->package.count; i++) { 681 + union acpi_object *obj = &pack->package.elements[i]; 682 + 683 + ret = atk_acpi_print(buf, sz, obj); 684 + if (ret >= sz) 685 + break; 686 + buf += ret; 687 + sz -= ret; 688 + } 689 + } 690 + 691 + static int atk_debugfs_ggrp_open(struct inode *inode, struct file *file) 692 + { 693 + struct atk_data *data = inode->i_private; 694 + char *buf = NULL; 695 + union acpi_object *ret; 696 + u8 cls; 697 + int i; 698 + 699 + if (!data->enumerate_handle) 700 + return -ENODEV; 701 + if (!data->debugfs.id) 702 + return -EINVAL; 703 + 704 + cls = (data->debugfs.id & 0xff000000) >> 24; 705 + ret = atk_ggrp(data, cls); 706 + if (IS_ERR(ret)) 707 + return PTR_ERR(ret); 708 + 709 + for (i = 0; i < ret->package.count; i++) { 710 + union acpi_object *pack = &ret->package.elements[i]; 711 + union acpi_object *id; 712 + 713 + if (pack->type != ACPI_TYPE_PACKAGE) 714 + continue; 715 + if (!pack->package.count) 716 + continue; 717 + id = &pack->package.elements[0]; 718 + if (id->integer.value == data->debugfs.id) { 719 + /* Print the package */ 720 + buf = kzalloc(512, GFP_KERNEL); 721 + if (!buf) { 722 + ACPI_FREE(ret); 723 + return -ENOMEM; 724 + } 725 + atk_pack_print(buf, 512, pack); 726 + break; 727 + } 728 + } 729 + ACPI_FREE(ret); 730 + 731 + if (!buf) 732 + return -EINVAL; 733 + 734 + file->private_data = buf; 735 + 736 + return nonseekable_open(inode, file); 737 + } 738 + 739 + static ssize_t atk_debugfs_ggrp_read(struct file *file, char __user *buf, 740 + size_t count, loff_t *pos) 741 + { 742 + char *str = file->private_data; 743 + size_t len = strlen(str); 744 + 745 + return simple_read_from_buffer(buf, count, pos, str, len); 746 + } 747 + 748 + static int atk_debugfs_ggrp_release(struct inode *inode, struct file *file) 749 + { 750 + kfree(file->private_data); 751 + return 0; 752 + } 753 + 754 + static const struct file_operations atk_debugfs_ggrp_fops = { 755 + .read = atk_debugfs_ggrp_read, 756 + .open = atk_debugfs_ggrp_open, 757 + .release = atk_debugfs_ggrp_release, 758 + }; 759 + 760 + static void atk_debugfs_init(struct atk_data *data) 761 + { 762 + struct dentry *d; 763 + struct dentry *f; 764 + 765 + data->debugfs.id = 0; 766 + 767 + d = debugfs_create_dir("asus_atk0110", NULL); 768 + if (!d || IS_ERR(d)) 769 + return; 770 + 771 + f = debugfs_create_x32("id", S_IRUSR | S_IWUSR, d, &data->debugfs.id); 772 + if (!f || IS_ERR(f)) 773 + goto cleanup; 774 + 775 + f = debugfs_create_file("gitm", S_IRUSR, d, data, 776 + &atk_debugfs_gitm); 777 + if (!f || IS_ERR(f)) 778 + goto cleanup; 779 + 780 + f = debugfs_create_file("ggrp", S_IRUSR, d, data, 781 + &atk_debugfs_ggrp_fops); 782 + if (!f || IS_ERR(f)) 783 + goto cleanup; 784 + 785 + data->debugfs.root = d; 786 + 787 + return; 788 + cleanup: 789 + debugfs_remove_recursive(d); 790 + } 791 + 792 + static void atk_debugfs_cleanup(struct atk_data *data) 793 + { 794 + debugfs_remove_recursive(data->debugfs.root); 795 + } 796 + 797 + #else /* CONFIG_DEBUG_FS */ 798 + 799 + static void atk_debugfs_init(struct atk_data *data) 800 + { 801 + } 802 + 803 + static void atk_debugfs_cleanup(struct atk_data *data) 804 + { 805 + } 806 + #endif 807 + 633 808 static int atk_add_sensor(struct atk_data *data, union acpi_object *obj) 634 809 { 635 810 struct device *dev = &data->acpi_dev->dev; ··· 1234 1047 return err; 1235 1048 } 1236 1049 1237 - static int atk_check_old_if(struct atk_data *data) 1050 + static int atk_probe_if(struct atk_data *data) 1238 1051 { 1239 1052 struct device *dev = &data->acpi_dev->dev; 1240 1053 acpi_handle ret; 1241 1054 acpi_status status; 1055 + int err = 0; 1242 1056 1243 1057 /* RTMP: read temperature */ 1244 1058 status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_TMP, &ret); 1245 - if (status != AE_OK) { 1059 + if (ACPI_SUCCESS(status)) 1060 + data->rtmp_handle = ret; 1061 + else 1246 1062 dev_dbg(dev, "method " METHOD_OLD_READ_TMP " not found: %s\n", 1247 1063 acpi_format_exception(status)); 1248 - return -ENODEV; 1249 - } 1250 - data->rtmp_handle = ret; 1251 1064 1252 1065 /* RVLT: read voltage */ 1253 1066 status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_VLT, &ret); 1254 - if (status != AE_OK) { 1067 + if (ACPI_SUCCESS(status)) 1068 + data->rvlt_handle = ret; 1069 + else 1255 1070 dev_dbg(dev, "method " METHOD_OLD_READ_VLT " not found: %s\n", 1256 1071 acpi_format_exception(status)); 1257 - return -ENODEV; 1258 - } 1259 - data->rvlt_handle = ret; 1260 1072 1261 1073 /* RFAN: read fan status */ 1262 1074 status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_FAN, &ret); 1263 - if (status != AE_OK) { 1075 + if (ACPI_SUCCESS(status)) 1076 + data->rfan_handle = ret; 1077 + else 1264 1078 dev_dbg(dev, "method " METHOD_OLD_READ_FAN " not found: %s\n", 1265 1079 acpi_format_exception(status)); 1266 - return -ENODEV; 1267 - } 1268 - data->rfan_handle = ret; 1269 - 1270 - return 0; 1271 - } 1272 - 1273 - static int atk_check_new_if(struct atk_data *data) 1274 - { 1275 - struct device *dev = &data->acpi_dev->dev; 1276 - acpi_handle ret; 1277 - acpi_status status; 1278 1080 1279 1081 /* Enumeration */ 1280 1082 status = acpi_get_handle(data->atk_handle, METHOD_ENUMERATE, &ret); 1281 - if (status != AE_OK) { 1083 + if (ACPI_SUCCESS(status)) 1084 + data->enumerate_handle = ret; 1085 + else 1282 1086 dev_dbg(dev, "method " METHOD_ENUMERATE " not found: %s\n", 1283 1087 acpi_format_exception(status)); 1284 - return -ENODEV; 1285 - } 1286 - data->enumerate_handle = ret; 1287 1088 1288 1089 /* De-multiplexer (read) */ 1289 1090 status = acpi_get_handle(data->atk_handle, METHOD_READ, &ret); 1290 - if (status != AE_OK) { 1091 + if (ACPI_SUCCESS(status)) 1092 + data->read_handle = ret; 1093 + else 1291 1094 dev_dbg(dev, "method " METHOD_READ " not found: %s\n", 1292 1095 acpi_format_exception(status)); 1293 - return -ENODEV; 1294 - } 1295 - data->read_handle = ret; 1296 1096 1297 1097 /* De-multiplexer (write) */ 1298 1098 status = acpi_get_handle(data->atk_handle, METHOD_WRITE, &ret); 1299 - if (status != AE_OK) { 1300 - dev_dbg(dev, "method " METHOD_READ " not found: %s\n", 1099 + if (ACPI_SUCCESS(status)) 1100 + data->write_handle = ret; 1101 + else 1102 + dev_dbg(dev, "method " METHOD_WRITE " not found: %s\n", 1301 1103 acpi_format_exception(status)); 1302 - return -ENODEV; 1303 - } 1304 - data->write_handle = ret; 1305 1104 1306 - return 0; 1105 + /* Check for hwmon methods: first check "old" style methods; note that 1106 + * both may be present: in this case we stick to the old interface; 1107 + * analysis of multiple DSDTs indicates that when both interfaces 1108 + * are present the new one (GGRP/GITM) is not functional. 1109 + */ 1110 + if (data->rtmp_handle && data->rvlt_handle && data->rfan_handle) 1111 + data->old_interface = true; 1112 + else if (data->enumerate_handle && data->read_handle && 1113 + data->write_handle) 1114 + data->old_interface = false; 1115 + else 1116 + err = -ENODEV; 1117 + 1118 + return err; 1307 1119 } 1308 1120 1309 1121 static int atk_add(struct acpi_device *device) ··· 1341 1155 } 1342 1156 ACPI_FREE(buf.pointer); 1343 1157 1344 - /* Check for hwmon methods: first check "old" style methods; note that 1345 - * both may be present: in this case we stick to the old interface; 1346 - * analysis of multiple DSDTs indicates that when both interfaces 1347 - * are present the new one (GGRP/GITM) is not functional. 1348 - */ 1349 - err = atk_check_old_if(data); 1350 - if (!err) { 1351 - dev_dbg(&device->dev, "Using old hwmon interface\n"); 1352 - data->old_interface = true; 1353 - } else { 1354 - err = atk_check_new_if(data); 1355 - if (err) 1356 - goto out; 1357 - 1358 - dev_dbg(&device->dev, "Using new hwmon interface\n"); 1359 - data->old_interface = false; 1158 + err = atk_probe_if(data); 1159 + if (err) { 1160 + dev_err(&device->dev, "No usable hwmon interface detected\n"); 1161 + goto out; 1360 1162 } 1361 1163 1362 - if (data->old_interface) 1164 + if (data->old_interface) { 1165 + dev_dbg(&device->dev, "Using old hwmon interface\n"); 1363 1166 err = atk_enumerate_old_hwmon(data); 1364 - else 1167 + } else { 1168 + dev_dbg(&device->dev, "Using new hwmon interface\n"); 1365 1169 err = atk_enumerate_new_hwmon(data); 1170 + } 1366 1171 if (err < 0) 1367 1172 goto out; 1368 1173 if (err == 0) { ··· 1366 1189 err = atk_register_hwmon(data); 1367 1190 if (err) 1368 1191 goto cleanup; 1192 + 1193 + atk_debugfs_init(data); 1369 1194 1370 1195 device->driver_data = data; 1371 1196 return 0; ··· 1386 1207 dev_dbg(&device->dev, "removing...\n"); 1387 1208 1388 1209 device->driver_data = NULL; 1210 + 1211 + atk_debugfs_cleanup(data); 1389 1212 1390 1213 atk_remove_files(data); 1391 1214 atk_free_sensors(data);
+14 -2
drivers/hwmon/coretemp.c
··· 33 33 #include <linux/list.h> 34 34 #include <linux/platform_device.h> 35 35 #include <linux/cpu.h> 36 + #include <linux/pci.h> 36 37 #include <asm/msr.h> 37 38 #include <asm/processor.h> 38 39 ··· 162 161 int usemsr_ee = 1; 163 162 int err; 164 163 u32 eax, edx; 164 + struct pci_dev *host_bridge; 165 165 166 166 /* Early chips have no MSR for TjMax */ 167 167 ··· 170 168 usemsr_ee = 0; 171 169 } 172 170 173 - /* Atoms seems to have TjMax at 90C */ 171 + /* Atom CPUs */ 174 172 175 173 if (c->x86_model == 0x1c) { 176 174 usemsr_ee = 0; 177 - tjmax = 90000; 175 + 176 + host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0)); 177 + 178 + if (host_bridge && host_bridge->vendor == PCI_VENDOR_ID_INTEL 179 + && (host_bridge->device == 0xa000 /* NM10 based nettop */ 180 + || host_bridge->device == 0xa010)) /* NM10 based netbook */ 181 + tjmax = 100000; 182 + else 183 + tjmax = 90000; 184 + 185 + pci_dev_put(host_bridge); 178 186 } 179 187 180 188 if ((c->x86_model > 0xe) && (usemsr_ee)) {
+33 -7
drivers/hwmon/k10temp.c
··· 33 33 module_param(force, bool, 0444); 34 34 MODULE_PARM_DESC(force, "force loading on processors with erratum 319"); 35 35 36 + /* CPUID function 0x80000001, ebx */ 37 + #define CPUID_PKGTYPE_MASK 0xf0000000 38 + #define CPUID_PKGTYPE_F 0x00000000 39 + #define CPUID_PKGTYPE_AM2R2_AM3 0x10000000 40 + 41 + /* DRAM controller (PCI function 2) */ 42 + #define REG_DCT0_CONFIG_HIGH 0x094 43 + #define DDR3_MODE 0x00000100 44 + 45 + /* miscellaneous (PCI function 3) */ 36 46 #define REG_HARDWARE_THERMAL_CONTROL 0x64 37 47 #define HTC_ENABLE 0x00000001 38 48 ··· 95 85 static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, show_temp_crit, NULL, 1); 96 86 static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 97 87 98 - static bool __devinit has_erratum_319(void) 88 + static bool __devinit has_erratum_319(struct pci_dev *pdev) 99 89 { 90 + u32 pkg_type, reg_dram_cfg; 91 + 92 + if (boot_cpu_data.x86 != 0x10) 93 + return false; 94 + 100 95 /* 101 - * Erratum 319: The thermal sensor of older Family 10h processors 102 - * (B steppings) may be unreliable. 96 + * Erratum 319: The thermal sensor of Socket F/AM2+ processors 97 + * may be unreliable. 103 98 */ 104 - return boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model <= 2; 99 + pkg_type = cpuid_ebx(0x80000001) & CPUID_PKGTYPE_MASK; 100 + if (pkg_type == CPUID_PKGTYPE_F) 101 + return true; 102 + if (pkg_type != CPUID_PKGTYPE_AM2R2_AM3) 103 + return false; 104 + 105 + /* Differentiate between AM2+ (bad) and AM3 (good) */ 106 + pci_bus_read_config_dword(pdev->bus, 107 + PCI_DEVFN(PCI_SLOT(pdev->devfn), 2), 108 + REG_DCT0_CONFIG_HIGH, &reg_dram_cfg); 109 + return !(reg_dram_cfg & DDR3_MODE); 105 110 } 106 111 107 112 static int __devinit k10temp_probe(struct pci_dev *pdev, ··· 124 99 { 125 100 struct device *hwmon_dev; 126 101 u32 reg_caps, reg_htc; 102 + int unreliable = has_erratum_319(pdev); 127 103 int err; 128 104 129 - if (has_erratum_319() && !force) { 105 + if (unreliable && !force) { 130 106 dev_err(&pdev->dev, 131 107 "unreliable CPU thermal sensor; monitoring disabled\n"); 132 108 err = -ENODEV; ··· 165 139 } 166 140 dev_set_drvdata(&pdev->dev, hwmon_dev); 167 141 168 - if (has_erratum_319() && force) 142 + if (unreliable && force) 169 143 dev_warn(&pdev->dev, 170 144 "unreliable CPU thermal sensor; check erratum 319\n"); 171 145 return 0; ··· 195 169 dev_set_drvdata(&pdev->dev, NULL); 196 170 } 197 171 198 - static struct pci_device_id k10temp_id_table[] = { 172 + static const struct pci_device_id k10temp_id_table[] = { 199 173 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) }, 200 174 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) }, 201 175 {}
+1 -1
drivers/hwmon/k8temp.c
··· 136 136 static SENSOR_DEVICE_ATTR_2(temp4_input, S_IRUGO, show_temp, NULL, 1, 1); 137 137 static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 138 138 139 - static struct pci_device_id k8temp_ids[] = { 139 + static const struct pci_device_id k8temp_ids[] = { 140 140 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) }, 141 141 { 0 }, 142 142 };
+1 -1
drivers/hwmon/sis5595.c
··· 697 697 return data; 698 698 } 699 699 700 - static struct pci_device_id sis5595_pci_ids[] = { 700 + static const struct pci_device_id sis5595_pci_ids[] = { 701 701 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) }, 702 702 { 0, } 703 703 };
+1 -1
drivers/hwmon/via686a.c
··· 767 767 return data; 768 768 } 769 769 770 - static struct pci_device_id via686a_pci_ids[] = { 770 + static const struct pci_device_id via686a_pci_ids[] = { 771 771 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, 772 772 { 0, } 773 773 };
+1 -1
drivers/hwmon/vt8231.c
··· 697 697 .remove = __devexit_p(vt8231_remove), 698 698 }; 699 699 700 - static struct pci_device_id vt8231_pci_ids[] = { 700 + static const struct pci_device_id vt8231_pci_ids[] = { 701 701 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4) }, 702 702 { 0, } 703 703 };