Commit f5776cc3 authored by Guenter Roeck's avatar Guenter Roeck

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: default avatarGuenter Roeck <linux@roeck-us.net>
parent 2ac1dfc5
...@@ -3936,6 +3936,18 @@ static int nct6775_probe(struct platform_device *pdev) ...@@ -3936,6 +3936,18 @@ static int nct6775_probe(struct platform_device *pdev)
return PTR_ERR_OR_ZERO(hwmon_dev); 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 #ifdef CONFIG_PM
static int nct6775_suspend(struct device *dev) static int nct6775_suspend(struct device *dev)
{ {
...@@ -3955,11 +3967,20 @@ 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) static int nct6775_resume(struct device *dev)
{ {
struct nct6775_data *data = dev_get_drvdata(dev); struct nct6775_data *data = dev_get_drvdata(dev);
int i, j; int i, j, err = 0;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->bank = 0xff; /* Force initial bank selection */ 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 */ /* Restore limits */
for (i = 0; i < data->in_num; i++) { for (i = 0; i < data->in_num; i++) {
if (!(data->have_in & (1 << i))) if (!(data->have_in & (1 << i)))
...@@ -3996,11 +4017,12 @@ static int nct6775_resume(struct device *dev) ...@@ -3996,11 +4017,12 @@ static int nct6775_resume(struct device *dev)
nct6775_write_value(data, NCT6775_REG_FANDIV2, data->fandiv2); nct6775_write_value(data, NCT6775_REG_FANDIV2, data->fandiv2);
} }
abort:
/* Force re-reading all values */ /* Force re-reading all values */
data->valid = false; data->valid = false;
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return 0; return err;
} }
static const struct dev_pm_ops nct6775_dev_pm_ops = { 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) ...@@ -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"); pr_warn("Forcibly enabling Super-I/O. Sensor is probably unusable.\n");
superio_outb(sioaddr, SIO_REG_ENABLE, val | 0x01); 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 (sio_data->kind == nct6791)
if (val & 0x10) { nct6791_enable_io_mapping(sioaddr);
pr_info("Enabling hardware monitor logical device mappings.\n");
superio_outb(sioaddr,
NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE,
val & ~0x10);
}
}
superio_exit(sioaddr); superio_exit(sioaddr);
pr_info("Found %s or compatible chip at %#x:%#x\n", pr_info("Found %s or compatible chip at %#x:%#x\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment