]> git.sur5r.net Git - groeck-nct6775/commitdiff
Merge pull request #34 from graysky2/master
authorGuenter Roeck <linux@roeck-us.net>
Sat, 29 Aug 2015 20:34:10 +0000 (13:34 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sat, 29 Aug 2015 20:34:10 +0000 (13:34 -0700)
Merge pull request #1 from groeck/master

README
compat.h
nct6775.c

diff --git a/README b/README
index 7bfbab4a3102fc7cb1f26190bbf607ac31e5e7ab..87d58265549bf9b6c6b44ba7040a658221a706bf 100644 (file)
--- a/README
+++ b/README
@@ -2,12 +2,13 @@ Note
 ====
 
 This driver supercedes the NCT6775F and NCT6776F support in the W83627EHF
-driver. It supports NCT6106D, NCT6775F, NCT6776F, NCT6779D, and NCT6791D.
+driver. It supports NCT6106D, NCT6775F, NCT6776F, NCT6779D, NCT6791D, and
+NCT6792D.
 
 The driver is also available in the upstream kernel. This version is maintained
 for backward compatibility with older kernels. I am trying to keep it buildable
 for older kernels, but may miss a problem once in a while. If you have a problem
-compiling this driver with any kernel version 2.6.16 or later, please let me
+compiling this driver with any kernel version 2.6.32 or later, please let me
 know. 
 
 Kernel driver NCT6775
@@ -34,6 +35,10 @@ Supported chips:
     Prefix: 'nct6791'
     Addresses scanned: ISA address retrieved from Super I/O registers
     Datasheet: Available from Nuvoton upon request
+  * Nuvoton NCT6792D
+    Prefix: 'nct6792'
+    Addresses scanned: ISA address retrieved from Super I/O registers
+    Datasheet: Available from Nuvoton upon request
 
 Authors:
         Guenter Roeck <linux@roeck-us.net>
@@ -43,8 +48,8 @@ Description
 -----------
 
 This driver implements support for the Nuvoton NCT6106D, NCT6775F, NCT6776F,
-NCT6779D, and NCT6791D super I/O chips. We will refer to them collectively as
-Nuvoton chips.
+NCT6779D, NCT6791D, and NCT6792D super I/O chips. We will refer to them
+collectively as Nuvoton chips.
 
 The chips implement up to 8 temperature sensors depending on the chip type and
 configuration. Temperatures used to control fan speed are reported separately.
index b670e5ce78bc400af3f8331ed6883b6f3c1238f4..72cea8c67cbeca0200df7f2bcd49d2fec8a01296 100644 (file)
--- a/compat.h
+++ b/compat.h
@@ -3,8 +3,8 @@
 
 #include <linux/version.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
-#error This driver is for kernel versions 2.6.16 and later
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
+#error This driver is for kernel versions 2.6.32 and later
 #endif
 
 #if !defined (CONFIG_HWMON_VID) && !defined(CONFIG_HWMON_VID_MODULE)
@@ -20,6 +20,7 @@ u8 vid_which_vrm(void)
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
+#if !(defined RHEL_MAJOR && RHEL_MAJOR == 6 && RHEL_MINOR >= 7)
 static int sysfs_create_groups(struct kobject *kobj,
                               const struct attribute_group **groups)
 {
@@ -39,6 +40,7 @@ static int sysfs_create_groups(struct kobject *kobj,
        }
        return error;
 }
+#endif
 
 static void sysfs_remove_groups(struct kobject *kobj,
                                const struct attribute_group **groups)
@@ -51,6 +53,7 @@ static void sysfs_remove_groups(struct kobject *kobj,
                sysfs_remove_group(kobj, groups[i]);
 }
 
+#if !(defined RHEL_MAJOR && RHEL_MAJOR == 6 && RHEL_MINOR >= 7)
 static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
 {
        if (IS_ERR(ptr))
@@ -58,7 +61,7 @@ static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
        else
                return 0;
 }
-
+#endif
 #endif
 
 #ifdef __NEED_I2C__
index 3272356015af5478fda2d31588cb2056c05156cf..cbf086e7fe4ef79f351481a75cbe591796843f72 100644 (file)
--- a/nct6775.c
+++ b/nct6775.c
@@ -57,6 +57,7 @@
 #include <linux/err.h>
 #include <linux/mutex.h>
 #include <linux/acpi.h>
+#include <linux/dmi.h>
 #include <linux/io.h>
 #include "lm75.h"
 #include "compat.h"
@@ -885,12 +886,12 @@ struct nct6775_data {
        u16 have_temp;
        u16 have_temp_fixed;
        u16 have_in;
-#ifdef CONFIG_PM
+
        /* Remember extra register values over suspend/resume */
        u8 vbat;
        u8 fandiv1;
        u8 fandiv2;
-#endif
+       u8 sio_reg_enable;
 };
 
 struct nct6775_sio_data {
@@ -3197,6 +3198,10 @@ nct6775_check_fan_inputs(struct nct6775_data *data)
        int sioreg = data->sioreg;
        int regval;
 
+       /* Store SIO_REG_ENABLE for use during resume */
+       superio_select(sioreg, NCT6775_LD_HWM);
+       data->sio_reg_enable = superio_inb(sioreg, SIO_REG_ENABLE);
+
        /* fan4 and fan5 share some pins with the GPIO and serial flash */
        if (data->kind == nct6775) {
                regval = superio_inb(sioreg, 0x2c);
@@ -3214,21 +3219,38 @@ nct6775_check_fan_inputs(struct nct6775_data *data)
                pwm6pin = false;
        } else if (data->kind == nct6776) {
                bool gpok = superio_inb(sioreg, 0x27) & 0x80;
+               const char *board_vendor, *board_name;
 
-               superio_select(sioreg, NCT6775_LD_HWM);
-               regval = superio_inb(sioreg, SIO_REG_ENABLE);
+               board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+               board_name = dmi_get_system_info(DMI_BOARD_NAME);
 
-               if (regval & 0x80)
+               if (board_name && board_vendor &&
+                   !strcmp(board_vendor, "ASRock")) {
+                       /*
+                        * Auxiliary fan monitoring is not enabled on ASRock
+                        * Z77 Pro4-M if booted in UEFI Ultra-FastBoot mode.
+                        * Observed with BIOS version 2.00.
+                        */
+                       if (!strcmp(board_name, "Z77 Pro4-M")) {
+                               if ((data->sio_reg_enable & 0xe0) != 0xe0) {
+                                       data->sio_reg_enable |= 0xe0;
+                                       superio_outb(sioreg, SIO_REG_ENABLE,
+                                                    data->sio_reg_enable);
+                               }
+                       }
+               }
+
+               if (data->sio_reg_enable & 0x80)
                        fan3pin = gpok;
                else
                        fan3pin = !(superio_inb(sioreg, 0x24) & 0x40);
 
-               if (regval & 0x40)
+               if (data->sio_reg_enable & 0x40)
                        fan4pin = gpok;
                else
                        fan4pin = superio_inb(sioreg, 0x1C) & 0x01;
 
-               if (regval & 0x20)
+               if (data->sio_reg_enable & 0x20)
                        fan5pin = gpok;
                else
                        fan5pin = superio_inb(sioreg, 0x1C) & 0x02;
@@ -4031,8 +4053,7 @@ static void nct6791_enable_io_mapping(int sioaddr)
        }
 }
 
-#ifdef CONFIG_PM
-static int nct6775_suspend(struct device *dev)
+static int __maybe_unused nct6775_suspend(struct device *dev)
 {
        struct nct6775_data *data = nct6775_update_device(dev);
 
@@ -4047,22 +4068,29 @@ static int nct6775_suspend(struct device *dev)
        return 0;
 }
 
-static int nct6775_resume(struct device *dev)
+static int __maybe_unused nct6775_resume(struct device *dev)
 {
        struct nct6775_data *data = dev_get_drvdata(dev);
+       int sioreg = data->sioreg;
        int i, j, err = 0;
+       u8 reg;
 
        mutex_lock(&data->update_lock);
        data->bank = 0xff;              /* Force initial bank selection */
 
-       if (data->kind == nct6791 || data->kind == nct6792) {
-               err = superio_enter(data->sioreg);
-               if (err)
-                       goto abort;
+       err = superio_enter(sioreg);
+       if (err)
+               goto abort;
 
-               nct6791_enable_io_mapping(data->sioreg);
-               superio_exit(data->sioreg);
-       }
+       superio_select(sioreg, NCT6775_LD_HWM);
+       reg = superio_inb(sioreg, SIO_REG_ENABLE);
+       if (reg != data->sio_reg_enable)
+               superio_outb(sioreg, SIO_REG_ENABLE, data->sio_reg_enable);
+
+       if (data->kind == nct6791 || data->kind == nct6792)
+               nct6791_enable_io_mapping(sioreg);
+
+       superio_exit(sioreg);
 
        /* Restore limits */
        for (i = 0; i < data->in_num; i++) {
@@ -4108,23 +4136,13 @@ abort:
        return err;
 }
 
-static const struct dev_pm_ops nct6775_dev_pm_ops = {
-       .suspend = nct6775_suspend,
-       .resume = nct6775_resume,
-       .freeze = nct6775_suspend,
-       .restore = nct6775_resume,
-};
-
-#define NCT6775_DEV_PM_OPS     (&nct6775_dev_pm_ops)
-#else
-#define NCT6775_DEV_PM_OPS     NULL
-#endif /* CONFIG_PM */
+static SIMPLE_DEV_PM_OPS(nct6775_dev_pm_ops, nct6775_suspend, nct6775_resume);
 
 static struct platform_driver nct6775_driver = {
        .driver = {
                .owner  = THIS_MODULE,
                .name   = DRVNAME,
-               .pm     = NCT6775_DEV_PM_OPS,
+               .pm     = &nct6775_dev_pm_ops,
        },
        .probe          = nct6775_probe,
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)