aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/coretemp.c60
-rw-r--r--drivers/hwmon/da9052-hwmon.c4
-rw-r--r--drivers/hwmon/fam15h_power.c2
-rw-r--r--drivers/hwmon/k10temp.c3
-rw-r--r--drivers/hwmon/k8temp.c2
-rw-r--r--drivers/hwmon/nct6775.c38
-rw-r--r--drivers/hwmon/sis5595.c2
-rw-r--r--drivers/hwmon/via686a.c2
-rw-r--r--drivers/hwmon/vt8231.c2
9 files changed, 79 insertions, 36 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 78be66176840..bbb0b0d463f7 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -36,6 +36,7 @@
36#include <linux/cpu.h> 36#include <linux/cpu.h>
37#include <linux/smp.h> 37#include <linux/smp.h>
38#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
39#include <linux/pci.h>
39#include <asm/msr.h> 40#include <asm/msr.h>
40#include <asm/processor.h> 41#include <asm/processor.h>
41#include <asm/cpu_device_id.h> 42#include <asm/cpu_device_id.h>
@@ -52,7 +53,7 @@ MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
52 53
53#define BASE_SYSFS_ATTR_NO 2 /* Sysfs Base attr no for coretemp */ 54#define BASE_SYSFS_ATTR_NO 2 /* Sysfs Base attr no for coretemp */
54#define NUM_REAL_CORES 32 /* Number of Real cores per cpu */ 55#define NUM_REAL_CORES 32 /* Number of Real cores per cpu */
55#define CORETEMP_NAME_LENGTH 17 /* String Length of attrs */ 56#define CORETEMP_NAME_LENGTH 19 /* String Length of attrs */
56#define MAX_CORE_ATTRS 4 /* Maximum no of basic attrs */ 57#define MAX_CORE_ATTRS 4 /* Maximum no of basic attrs */
57#define TOTAL_ATTRS (MAX_CORE_ATTRS + 1) 58#define TOTAL_ATTRS (MAX_CORE_ATTRS + 1)
58#define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO) 59#define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO)
@@ -176,20 +177,33 @@ static ssize_t show_temp(struct device *dev,
176 /* Check whether the time interval has elapsed */ 177 /* Check whether the time interval has elapsed */
177 if (!tdata->valid || time_after(jiffies, tdata->last_updated + HZ)) { 178 if (!tdata->valid || time_after(jiffies, tdata->last_updated + HZ)) {
178 rdmsr_on_cpu(tdata->cpu, tdata->status_reg, &eax, &edx); 179 rdmsr_on_cpu(tdata->cpu, tdata->status_reg, &eax, &edx);
179 tdata->valid = 0; 180 /*
180 /* Check whether the data is valid */ 181 * Ignore the valid bit. In all observed cases the register
181 if (eax & 0x80000000) { 182 * value is either low or zero if the valid bit is 0.
182 tdata->temp = tdata->tjmax - 183 * Return it instead of reporting an error which doesn't
183 ((eax >> 16) & 0x7f) * 1000; 184 * really help at all.
184 tdata->valid = 1; 185 */
185 } 186 tdata->temp = tdata->tjmax - ((eax >> 16) & 0x7f) * 1000;
187 tdata->valid = 1;
186 tdata->last_updated = jiffies; 188 tdata->last_updated = jiffies;
187 } 189 }
188 190
189 mutex_unlock(&tdata->update_lock); 191 mutex_unlock(&tdata->update_lock);
190 return tdata->valid ? sprintf(buf, "%d\n", tdata->temp) : -EAGAIN; 192 return sprintf(buf, "%d\n", tdata->temp);
191} 193}
192 194
195struct tjmax_pci {
196 unsigned int device;
197 int tjmax;
198};
199
200static const struct tjmax_pci tjmax_pci_table[] = {
201 { 0x0708, 110000 }, /* CE41x0 (Sodaville ) */
202 { 0x0c72, 102000 }, /* Atom S1240 (Centerton) */
203 { 0x0c73, 95000 }, /* Atom S1220 (Centerton) */
204 { 0x0c75, 95000 }, /* Atom S1260 (Centerton) */
205};
206
193struct tjmax { 207struct tjmax {
194 char const *id; 208 char const *id;
195 int tjmax; 209 int tjmax;
@@ -198,9 +212,6 @@ struct tjmax {
198static const struct tjmax tjmax_table[] = { 212static const struct tjmax tjmax_table[] = {
199 { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */ 213 { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */
200 { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */ 214 { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */
201 { "CPU CE4110", 110000 }, /* Model 0x1c, stepping 10 Sodaville */
202 { "CPU CE4150", 110000 }, /* Model 0x1c, stepping 10 */
203 { "CPU CE4170", 110000 }, /* Model 0x1c, stepping 10 */
204}; 215};
205 216
206struct tjmax_model { 217struct tjmax_model {
@@ -222,8 +233,11 @@ static const struct tjmax_model tjmax_model_table[] = {
222 * is undetectable by software 233 * is undetectable by software
223 */ 234 */
224 { 0x27, ANY, 90000 }, /* Atom Medfield (Z2460) */ 235 { 0x27, ANY, 90000 }, /* Atom Medfield (Z2460) */
225 { 0x35, ANY, 90000 }, /* Atom Clover Trail/Cloverview (Z2760) */ 236 { 0x35, ANY, 90000 }, /* Atom Clover Trail/Cloverview (Z27x0) */
226 { 0x36, ANY, 100000 }, /* Atom Cedar Trail/Cedarview (N2xxx, D2xxx) */ 237 { 0x36, ANY, 100000 }, /* Atom Cedar Trail/Cedarview (N2xxx, D2xxx)
238 * Also matches S12x0 (stepping 9), covered by
239 * PCI table
240 */
227}; 241};
228 242
229static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) 243static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
@@ -236,8 +250,20 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
236 int err; 250 int err;
237 u32 eax, edx; 251 u32 eax, edx;
238 int i; 252 int i;
253 struct pci_dev *host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
254
255 /*
256 * Explicit tjmax table entries override heuristics.
257 * First try PCI host bridge IDs, followed by model ID strings
258 * and model/stepping information.
259 */
260 if (host_bridge && host_bridge->vendor == PCI_VENDOR_ID_INTEL) {
261 for (i = 0; i < ARRAY_SIZE(tjmax_pci_table); i++) {
262 if (host_bridge->device == tjmax_pci_table[i].device)
263 return tjmax_pci_table[i].tjmax;
264 }
265 }
239 266
240 /* explicit tjmax table entries override heuristics */
241 for (i = 0; i < ARRAY_SIZE(tjmax_table); i++) { 267 for (i = 0; i < ARRAY_SIZE(tjmax_table); i++) {
242 if (strstr(c->x86_model_id, tjmax_table[i].id)) 268 if (strstr(c->x86_model_id, tjmax_table[i].id))
243 return tjmax_table[i].tjmax; 269 return tjmax_table[i].tjmax;
@@ -343,12 +369,12 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
343 if (cpu_has_tjmax(c)) 369 if (cpu_has_tjmax(c))
344 dev_warn(dev, "Unable to read TjMax from CPU %u\n", id); 370 dev_warn(dev, "Unable to read TjMax from CPU %u\n", id);
345 } else { 371 } else {
346 val = (eax >> 16) & 0xff; 372 val = (eax >> 16) & 0x7f;
347 /* 373 /*
348 * If the TjMax is not plausible, an assumption 374 * If the TjMax is not plausible, an assumption
349 * will be used 375 * will be used
350 */ 376 */
351 if (val) { 377 if (val >= 85) {
352 dev_dbg(dev, "TjMax is %d degrees C\n", val); 378 dev_dbg(dev, "TjMax is %d degrees C\n", val);
353 return val * 1000; 379 return val * 1000;
354 } 380 }
diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
index 960fac3fb166..afd31042b452 100644
--- a/drivers/hwmon/da9052-hwmon.c
+++ b/drivers/hwmon/da9052-hwmon.c
@@ -45,7 +45,7 @@ static const char * const input_names[] = {
45/* Conversion function for VDDOUT and VBAT */ 45/* Conversion function for VDDOUT and VBAT */
46static inline int volt_reg_to_mv(int value) 46static inline int volt_reg_to_mv(int value)
47{ 47{
48 return DIV_ROUND_CLOSEST(value * 1000, 512) + 2500; 48 return DIV_ROUND_CLOSEST(value * 2000, 1023) + 2500;
49} 49}
50 50
51/* Conversion function for ADC channels 4, 5 and 6 */ 51/* Conversion function for ADC channels 4, 5 and 6 */
@@ -57,7 +57,7 @@ static inline int input_reg_to_mv(int value)
57/* Conversion function for VBBAT */ 57/* Conversion function for VBBAT */
58static inline int vbbat_reg_to_mv(int value) 58static inline int vbbat_reg_to_mv(int value)
59{ 59{
60 return DIV_ROUND_CLOSEST(value * 2500, 512); 60 return DIV_ROUND_CLOSEST(value * 5000, 1023);
61} 61}
62 62
63static inline int da9052_enable_vddout_channel(struct da9052 *da9052) 63static inline int da9052_enable_vddout_channel(struct da9052 *da9052)
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index dff841085baf..6040121a405a 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -249,7 +249,7 @@ static void fam15h_power_remove(struct pci_dev *pdev)
249 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group); 249 sysfs_remove_group(&dev->kobj, &fam15h_power_attr_group);
250} 250}
251 251
252static DEFINE_PCI_DEVICE_TABLE(fam15h_power_id_table) = { 252static const struct pci_device_id fam15h_power_id_table[] = {
253 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, 253 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
254 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, 254 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) },
255 {} 255 {}
diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
index d65f3fd895dd..baf375b5ab0d 100644
--- a/drivers/hwmon/k10temp.c
+++ b/drivers/hwmon/k10temp.c
@@ -204,12 +204,13 @@ static void k10temp_remove(struct pci_dev *pdev)
204 &sensor_dev_attr_temp1_crit_hyst.dev_attr); 204 &sensor_dev_attr_temp1_crit_hyst.dev_attr);
205} 205}
206 206
207static DEFINE_PCI_DEVICE_TABLE(k10temp_id_table) = { 207static const struct pci_device_id k10temp_id_table[] = {
208 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) }, 208 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
209 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) }, 209 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
210 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) }, 210 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
211 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) }, 211 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) },
212 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M10H_F3) }, 212 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M10H_F3) },
213 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F3) },
213 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) }, 214 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
214 {} 215 {}
215}; 216};
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index 5b50e9e4f96b..734d55d48cc8 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -135,7 +135,7 @@ static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 1, 0);
135static SENSOR_DEVICE_ATTR_2(temp4_input, S_IRUGO, show_temp, NULL, 1, 1); 135static SENSOR_DEVICE_ATTR_2(temp4_input, S_IRUGO, show_temp, NULL, 1, 1);
136static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 136static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
137 137
138static DEFINE_PCI_DEVICE_TABLE(k8temp_ids) = { 138static const struct pci_device_id k8temp_ids[] = {
139 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) }, 139 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
140 { 0 }, 140 { 0 },
141}; 141};
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index cf811c1a1475..8686e966fa28 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -3936,6 +3936,18 @@ static int nct6775_probe(struct platform_device *pdev)
3936 return PTR_ERR_OR_ZERO(hwmon_dev); 3936 return PTR_ERR_OR_ZERO(hwmon_dev);
3937} 3937}
3938 3938
3939static void nct6791_enable_io_mapping(int sioaddr)
3940{
3941 int val;
3942
3943 val = superio_inb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE);
3944 if (val & 0x10) {
3945 pr_info("Enabling hardware monitor logical device mappings.\n");
3946 superio_outb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE,
3947 val & ~0x10);
3948 }
3949}
3950
3939#ifdef CONFIG_PM 3951#ifdef CONFIG_PM
3940static int nct6775_suspend(struct device *dev) 3952static int nct6775_suspend(struct device *dev)
3941{ 3953{
@@ -3955,11 +3967,20 @@ static int nct6775_suspend(struct device *dev)
3955static int nct6775_resume(struct device *dev) 3967static int nct6775_resume(struct device *dev)
3956{ 3968{
3957 struct nct6775_data *data = dev_get_drvdata(dev); 3969 struct nct6775_data *data = dev_get_drvdata(dev);
3958 int i, j; 3970 int i, j, err = 0;
3959 3971
3960 mutex_lock(&data->update_lock); 3972 mutex_lock(&data->update_lock);
3961 data->bank = 0xff; /* Force initial bank selection */ 3973 data->bank = 0xff; /* Force initial bank selection */
3962 3974
3975 if (data->kind == nct6791) {
3976 err = superio_enter(data->sioreg);
3977 if (err)
3978 goto abort;
3979
3980 nct6791_enable_io_mapping(data->sioreg);
3981 superio_exit(data->sioreg);
3982 }
3983
3963 /* Restore limits */ 3984 /* Restore limits */
3964 for (i = 0; i < data->in_num; i++) { 3985 for (i = 0; i < data->in_num; i++) {
3965 if (!(data->have_in & (1 << i))) 3986 if (!(data->have_in & (1 << i)))
@@ -3996,11 +4017,12 @@ static int nct6775_resume(struct device *dev)
3996 nct6775_write_value(data, NCT6775_REG_FANDIV2, data->fandiv2); 4017 nct6775_write_value(data, NCT6775_REG_FANDIV2, data->fandiv2);
3997 } 4018 }
3998 4019
4020abort:
3999 /* Force re-reading all values */ 4021 /* Force re-reading all values */
4000 data->valid = false; 4022 data->valid = false;
4001 mutex_unlock(&data->update_lock); 4023 mutex_unlock(&data->update_lock);
4002 4024
4003 return 0; 4025 return err;
4004} 4026}
4005 4027
4006static const struct dev_pm_ops nct6775_dev_pm_ops = { 4028static const struct dev_pm_ops nct6775_dev_pm_ops = {
@@ -4088,15 +4110,9 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
4088 pr_warn("Forcibly enabling Super-I/O. Sensor is probably unusable.\n"); 4110 pr_warn("Forcibly enabling Super-I/O. Sensor is probably unusable.\n");
4089 superio_outb(sioaddr, SIO_REG_ENABLE, val | 0x01); 4111 superio_outb(sioaddr, SIO_REG_ENABLE, val | 0x01);
4090 } 4112 }
4091 if (sio_data->kind == nct6791) { 4113
4092 val = superio_inb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE); 4114 if (sio_data->kind == nct6791)
4093 if (val & 0x10) { 4115 nct6791_enable_io_mapping(sioaddr);
4094 pr_info("Enabling hardware monitor logical device mappings.\n");
4095 superio_outb(sioaddr,
4096 NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE,
4097 val & ~0x10);
4098 }
4099 }
4100 4116
4101 superio_exit(sioaddr); 4117 superio_exit(sioaddr);
4102 pr_info("Found %s or compatible chip at %#x:%#x\n", 4118 pr_info("Found %s or compatible chip at %#x:%#x\n",
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 72a889702f0d..e74bd7e620e8 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -754,7 +754,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev)
754 return data; 754 return data;
755} 755}
756 756
757static DEFINE_PCI_DEVICE_TABLE(sis5595_pci_ids) = { 757static const struct pci_device_id sis5595_pci_ids[] = {
758 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) }, 758 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) },
759 { 0, } 759 { 0, }
760}; 760};
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index c9dcce8c3dc3..babd732b4e18 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -824,7 +824,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
824 return data; 824 return data;
825} 825}
826 826
827static DEFINE_PCI_DEVICE_TABLE(via686a_pci_ids) = { 827static const struct pci_device_id via686a_pci_ids[] = {
828 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, 828 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) },
829 { } 829 { }
830}; 830};
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index aee14e2192f8..b3babe3326fb 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -766,7 +766,7 @@ static struct platform_driver vt8231_driver = {
766 .remove = vt8231_remove, 766 .remove = vt8231_remove,
767}; 767};
768 768
769static DEFINE_PCI_DEVICE_TABLE(vt8231_pci_ids) = { 769static const struct pci_device_id vt8231_pci_ids[] = {
770 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4) }, 770 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4) },
771 { 0, } 771 { 0, }
772}; 772};