diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-12-25 07:25:59 -0800 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-01-14 21:36:53 -0800 |
commit | f5776cc3b55b9b2412df5008bfd7a98075a4891d (patch) | |
tree | 734a35dac22fe309ebacb68094ea85f565ad1a02 /drivers/hwmon | |
parent | 2ac1dfc52dc862eabf30d5ece51f3422e6df561a (diff) | |
download | lwn-f5776cc3b55b9b2412df5008bfd7a98075a4891d.tar.gz lwn-f5776cc3b55b9b2412df5008bfd7a98075a4891d.zip |
hwmon: (nct6775) Re-enable logical device mapping for NCT6791 during resume
After a suspend/resume cycle, the NCT6791 is back to its original BIOS
programming. In this state, HWMON IO access may be locked.
Re-enable it during resume.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/nct6775.c | 38 |
1 files changed, 27 insertions, 11 deletions
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) return PTR_ERR_OR_ZERO(hwmon_dev); } +static void nct6791_enable_io_mapping(int sioaddr) +{ + int val; + + val = superio_inb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE); + if (val & 0x10) { + pr_info("Enabling hardware monitor logical device mappings.\n"); + superio_outb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE, + val & ~0x10); + } +} + #ifdef CONFIG_PM static int nct6775_suspend(struct device *dev) { @@ -3955,11 +3967,20 @@ static int nct6775_suspend(struct device *dev) static int nct6775_resume(struct device *dev) { struct nct6775_data *data = dev_get_drvdata(dev); - int i, j; + int i, j, err = 0; mutex_lock(&data->update_lock); data->bank = 0xff; /* Force initial bank selection */ + if (data->kind == nct6791) { + err = superio_enter(data->sioreg); + if (err) + goto abort; + + nct6791_enable_io_mapping(data->sioreg); + superio_exit(data->sioreg); + } + /* Restore limits */ for (i = 0; i < data->in_num; i++) { if (!(data->have_in & (1 << i))) @@ -3996,11 +4017,12 @@ static int nct6775_resume(struct device *dev) nct6775_write_value(data, NCT6775_REG_FANDIV2, data->fandiv2); } +abort: /* Force re-reading all values */ data->valid = false; mutex_unlock(&data->update_lock); - return 0; + return err; } static 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) pr_warn("Forcibly enabling Super-I/O. Sensor is probably unusable.\n"); superio_outb(sioaddr, SIO_REG_ENABLE, val | 0x01); } - if (sio_data->kind == nct6791) { - val = superio_inb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE); - if (val & 0x10) { - pr_info("Enabling hardware monitor logical device mappings.\n"); - superio_outb(sioaddr, - NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE, - val & ~0x10); - } - } + + if (sio_data->kind == nct6791) + nct6791_enable_io_mapping(sioaddr); superio_exit(sioaddr); pr_info("Found %s or compatible chip at %#x:%#x\n", |