Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[deliverable/linux.git] / drivers / hwmon / coretemp.c
index 03b1f650d1c47d04d7cb2b9b3ca140f50f25b30d..6f66551d9e51ab00f787dfe5c2d5d9182affd4bc 100644 (file)
@@ -47,7 +47,7 @@ typedef enum { SHOW_TEMP, SHOW_TJMAX, SHOW_LABEL, SHOW_NAME } SHOW;
 static struct coretemp_data *coretemp_update_device(struct device *dev);
 
 struct coretemp_data {
-       struct class_device *class_dev;
+       struct device *hwmon_dev;
        struct mutex update_lock;
        const char *name;
        u32 id;
@@ -58,8 +58,6 @@ struct coretemp_data {
        u8 alarm;
 };
 
-static struct coretemp_data *coretemp_update_device(struct device *dev);
-
 /*
  * Sysfs stuff
  */
@@ -176,6 +174,23 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
                goto exit_free;
        }
 
+       /* Check if we have problem with errata AE18 of Core processors:
+          Readings might stop update when processor visited too deep sleep,
+          fixed for stepping D0 (6EC).
+       */
+
+       if ((c->x86_model == 0xe) && (c->x86_mask < 0xc)) {
+               /* check for microcode update */
+               rdmsr_on_cpu(data->id, MSR_IA32_UCODE_REV, &eax, &edx);
+               if (edx < 0x39) {
+                       err = -ENODEV;
+                       dev_err(&pdev->dev,
+                               "Errata AE18 not fixed, update BIOS or "
+                               "microcode of the CPU!\n");
+                       goto exit_free;
+               }
+       }
+
        /* Some processors have Tjmax 85 following magic should detect it
           Intel won't disclose the information without signed NDA, but
           individuals cannot sign it. Catch(ed) 22.
@@ -193,14 +208,27 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
                }
        }
 
+       /* Intel says that above should not work for desktop Core2 processors,
+          but it seems to work. There is no other way how get the absolute
+          readings. Warn the user about this. First check if are desktop,
+          bit 50 of MSR_IA32_PLATFORM_ID should be 0.
+       */
+
+       rdmsr_safe_on_cpu(data->id, MSR_IA32_PLATFORM_ID, &eax, &edx);
+
+       if ((c->x86_model == 0xf) && (!(edx & 0x00040000))) {
+               dev_warn(&pdev->dev, "Using undocumented features, absolute "
+                        "temperature might be wrong!\n");
+       }
+
        platform_set_drvdata(pdev, data);
 
        if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group)))
                goto exit_free;
 
-       data->class_dev = hwmon_device_register(&pdev->dev);
-       if (IS_ERR(data->class_dev)) {
-               err = PTR_ERR(data->class_dev);
+       data->hwmon_dev = hwmon_device_register(&pdev->dev);
+       if (IS_ERR(data->hwmon_dev)) {
+               err = PTR_ERR(data->hwmon_dev);
                dev_err(&pdev->dev, "Class registration failed (%d)\n",
                        err);
                goto exit_class;
@@ -220,7 +248,7 @@ static int __devexit coretemp_remove(struct platform_device *pdev)
 {
        struct coretemp_data *data = platform_get_drvdata(pdev);
 
-       hwmon_device_unregister(data->class_dev);
+       hwmon_device_unregister(data->hwmon_dev);
        sysfs_remove_group(&pdev->dev.kobj, &coretemp_group);
        platform_set_drvdata(pdev, NULL);
        kfree(data);
@@ -288,7 +316,7 @@ exit:
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-void coretemp_device_remove(unsigned int cpu)
+static void coretemp_device_remove(unsigned int cpu)
 {
        struct pdev_entry *p, *n;
        mutex_lock(&pdev_list_mutex);
@@ -309,16 +337,18 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
 
        switch (action) {
        case CPU_ONLINE:
+       case CPU_ONLINE_FROZEN:
                coretemp_device_add(cpu);
                break;
        case CPU_DEAD:
+       case CPU_DEAD_FROZEN:
                coretemp_device_remove(cpu);
                break;
        }
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata coretemp_cpu_notifier = {
+static struct notifier_block coretemp_cpu_notifier = {
        .notifier_call = coretemp_cpu_callback,
 };
 #endif                         /* !CONFIG_HOTPLUG_CPU */
@@ -328,9 +358,6 @@ static int __init coretemp_init(void)
        int i, err = -ENODEV;
        struct pdev_entry *p, *n;
 
-       printk(KERN_NOTICE DRVNAME ": This driver uses undocumented features "
-               "of Core CPU. Temperature might be wrong!\n");
-
        /* quick check if we run Intel */
        if (cpu_data[0].x86_vendor != X86_VENDOR_INTEL)
                goto exit;
@@ -342,9 +369,10 @@ static int __init coretemp_init(void)
        for_each_online_cpu(i) {
                struct cpuinfo_x86 *c = &(cpu_data)[i];
 
-               /* check if family 6, models e, f */
+               /* check if family 6, models e, f, 16 */
                if ((c->cpuid_level < 0) || (c->x86 != 0x6) ||
-                   !((c->x86_model == 0xe) || (c->x86_model == 0xf))) {
+                   !((c->x86_model == 0xe) || (c->x86_model == 0xf) ||
+                       (c->x86_model == 0x16))) {
 
                        /* supported CPU not found, but report the unknown
                           family 6 CPU */
This page took 0.028913 seconds and 5 git commands to generate.