]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/hwmon/w83627ehf.c
pci: use pci_ioremap_bar() in drivers/ide
[linux-2.6-omap-h63xx.git] / drivers / hwmon / w83627ehf.c
index b15c6a998b7271aeb0f45ce21fa21be75be2cf2f..075164dd65a7a6716965538ac56d7b0320e14541 100644 (file)
@@ -59,6 +59,10 @@ static const char * w83627ehf_device_names[] = {
        "w83627dhg",
 };
 
+static unsigned short force_id;
+module_param(force_id, ushort, 0);
+MODULE_PARM_DESC(force_id, "Override the detected device ID");
+
 #define DRVNAME "w83627ehf"
 
 /*
@@ -1198,8 +1202,7 @@ static void w83627ehf_device_remove_files(struct device *dev)
                device_remove_file(dev, &sda_temp[i].dev_attr);
 
        device_remove_file(dev, &dev_attr_name);
-       if (data->vid != 0x3f)
-               device_remove_file(dev, &dev_attr_cpu0_vid);
+       device_remove_file(dev, &dev_attr_cpu0_vid);
 }
 
 /* Get the monitoring functions started */
@@ -1276,26 +1279,39 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
 
        data->vrm = vid_which_vrm();
        superio_enter(sio_data->sioreg);
-       /* Set VID input sensibility if needed. In theory the BIOS should
-          have set it, but in practice it's not always the case. */
-       en_vrm10 = superio_inb(sio_data->sioreg, SIO_REG_EN_VRM10);
-       if ((en_vrm10 & 0x08) && data->vrm != 100) {
-               dev_warn(dev, "Setting VID input voltage to TTL\n");
-               superio_outb(sio_data->sioreg, SIO_REG_EN_VRM10,
-                            en_vrm10 & ~0x08);
-       } else if (!(en_vrm10 & 0x08) && data->vrm == 100) {
-               dev_warn(dev, "Setting VID input voltage to VRM10\n");
-               superio_outb(sio_data->sioreg, SIO_REG_EN_VRM10,
-                            en_vrm10 | 0x08);
-       }
        /* Read VID value */
        superio_select(sio_data->sioreg, W83627EHF_LD_HWM);
-       if (superio_inb(sio_data->sioreg, SIO_REG_VID_CTRL) & 0x80)
-               data->vid = superio_inb(sio_data->sioreg, SIO_REG_VID_DATA) & 0x3f;
-       else {
+       if (superio_inb(sio_data->sioreg, SIO_REG_VID_CTRL) & 0x80) {
+               /* Set VID input sensibility if needed. In theory the BIOS
+                  should have set it, but in practice it's not always the
+                  case. We only do it for the W83627EHF/EHG because the
+                  W83627DHG is more complex in this respect. */
+               if (sio_data->kind == w83627ehf) {
+                       en_vrm10 = superio_inb(sio_data->sioreg,
+                                              SIO_REG_EN_VRM10);
+                       if ((en_vrm10 & 0x08) && data->vrm == 90) {
+                               dev_warn(dev, "Setting VID input voltage to "
+                                        "TTL\n");
+                               superio_outb(sio_data->sioreg, SIO_REG_EN_VRM10,
+                                            en_vrm10 & ~0x08);
+                       } else if (!(en_vrm10 & 0x08) && data->vrm == 100) {
+                               dev_warn(dev, "Setting VID input voltage to "
+                                        "VRM10\n");
+                               superio_outb(sio_data->sioreg, SIO_REG_EN_VRM10,
+                                            en_vrm10 | 0x08);
+                       }
+               }
+
+               data->vid = superio_inb(sio_data->sioreg, SIO_REG_VID_DATA);
+               if (sio_data->kind == w83627ehf) /* 6 VID pins only */
+                       data->vid &= 0x3f;
+
+               err = device_create_file(dev, &dev_attr_cpu0_vid);
+               if (err)
+                       goto exit_release;
+       } else {
                dev_info(dev, "VID pins in output mode, CPU VID not "
                         "available\n");
-               data->vid = 0x3f;
        }
 
        /* fan4 and fan5 share some pins with the GPIO and serial flash */
@@ -1378,12 +1394,6 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
        if (err)
                goto exit_remove;
 
-       if (data->vid != 0x3f) {
-               err = device_create_file(dev, &dev_attr_cpu0_vid);
-               if (err)
-                       goto exit_remove;
-       }
-
        data->hwmon_dev = hwmon_device_register(dev);
        if (IS_ERR(data->hwmon_dev)) {
                err = PTR_ERR(data->hwmon_dev);
@@ -1437,8 +1447,11 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
 
        superio_enter(sioaddr);
 
-       val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8)
-           | superio_inb(sioaddr, SIO_REG_DEVID + 1);
+       if (force_id)
+               val = force_id;
+       else
+               val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8)
+                   | superio_inb(sioaddr, SIO_REG_DEVID + 1);
        switch (val & SIO_ID_MASK) {
        case SIO_W83627EHF_ID:
                sio_data->kind = w83627ehf;