hwmon: driver for Texas Instruments amc6821 chip
[safe/jmp/linux-2.6] / drivers / hwmon / k8temp.c
index ca56f2e..1fe9951 100644 (file)
@@ -48,6 +48,8 @@ struct k8temp_data {
        /* registers values */
        u8 sensorsp;            /* sensor presence bits - SEL_CORE & SEL_PLACE */
        u32 temp[2][2];         /* core, place */
+       u8 swap_core_select;    /* meaning of SEL_CORE is inverted */
+       u32 temp_offset;
 };
 
 static struct k8temp_data *k8temp_update_device(struct device *dev)
@@ -115,10 +117,15 @@ static ssize_t show_temp(struct device *dev,
            to_sensor_dev_attr_2(devattr);
        int core = attr->nr;
        int place = attr->index;
+       int temp;
        struct k8temp_data *data = k8temp_update_device(dev);
 
-       return sprintf(buf, "%d\n",
-                      TEMP_FROM_REG(data->temp[core][place]));
+       if (data->swap_core_select)
+               core = core ? 0 : 1;
+
+       temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
+
+       return sprintf(buf, "%d\n", temp);
 }
 
 /* core, place */
@@ -162,11 +169,26 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
                        goto exit_free;
                }
 
+               /*
+                * AMD NPT family 0fh, i.e. RevF and RevG:
+                * meaning of SEL_CORE bit is inverted
+                */
                if (model >= 0x40) {
+                       data->swap_core_select = 1;
                        dev_warn(&pdev->dev, "Temperature readouts might be "
                                 "wrong - check erratum #141\n");
                }
 
+               if ((model >= 0x69) &&
+                   !(model == 0xc1 || model == 0x6c || model == 0x7c)) {
+                       /*
+                        * RevG desktop CPUs (i.e. no socket S1G1 parts)
+                        * need additional offset, otherwise reported
+                        * temperature is below ambient temperature
+                        */
+                       data->temp_offset = 21000;
+               }
+
                break;
        }