On 07/24/2017 12:37 PM, Maciej S. Szmigiero wrote:
After a suspend / resume cycle we possibly need to reapply chip registers
settings that we had set or fixed in a probe path, since they might have
been reset to default values or set incorrectly by a BIOS again.
Tested on a Gigabyte M720-US3 board, which requires routing internal VCCH5V
to in7 (and had it wrong again on resume from S3).
Signed-off-by: Maciej S. Szmigiero <mail@xxxxxxxxxxxxxxxxxxxxx>
---
Changes from v1: Move code of common probe / resume steps to new functions
so we don't need to make large parts of probe function conditional on a
newly added 'resume' parameter.
Much better. Please split cleanup and pm functionality addition into two patches
to simplify review.
@@ -2986,8 +3027,6 @@ static int it87_check_pwm(struct device *dev)
"PWM configuration is too broken to be fixed\n");
}
- dev_info(dev,
- "Detected broken BIOS defaults, disabling PWM interface\n");
I don't think this is a good idea. Besides, it only removes one message.
I would suggest to check for enable_pwm_interface in the resume function.
If it is not set, don't bother calling it87_check_pwm() again.
@@ -3140,9 +3183,77 @@ static int it87_probe(struct platform_device *pdev)I don't think this message provides any real value.
return PTR_ERR_OR_ZERO(hwmon_dev);
}
+static int it87_resume_sio(struct platform_device *pdev)
+{
+ struct it87_data *data = dev_get_drvdata(&pdev->dev);
+ int err;
+ int reg2c;
+
+ if (!(data->in_internal & BIT(1)))
+ return 0;
+
+ if (has_in7_internal(data))
+ return 0;
+
+ err = superio_enter(data->sioaddr);
+ if (err)
+ return err;
+
+ superio_select(data->sioaddr, GPIO);
+
+ reg2c = superio_inb(data->sioaddr, IT87_SIO_PINX2_REG);
+ if (!(reg2c & BIT(1))) {
+ dev_notice(&pdev->dev,
+ "Routing internal VCCH5V to in7 again");
+
Besides, it isn't always VCCH5V.
+ reg2c |= BIT(1);
+ superio_outb(data->sioaddr, IT87_SIO_PINX2_REG,
+ reg2c);
+ }
+
Problem with this code is that it applies to _all_ chips.
The original code only applied to it8783 (this message), and
only if bit 2 of register 0x27 was set, or to it8720 and it8782
under certain conditions (though there the message is about VCCH).
I understand you try to cover that condition with the checks above,
but there is no guarantee that this works for all chips (and that
it will continue to work going forward as new chips are added).
Please consider adding a flag such as "need_in7_reroute" instead.
That would simplify the checks here and make it more explicit.