Skip to content

Commit 4743765

Browse files
jwrdegoedethierryreding
authored andcommitted
pwm: lpss: Force runtime-resume on suspend on Cherry Trail
On Cherry Trail devices under Windows the PWM controller used for the backlight is considered part of the GPU even though it is part of the LPSS block and thus is an entirely different independent hardware unit. Because of this on Cherry Trail the GPU's (GFX0 ACPI node) _PS3 and _PS0 methods save and restore the PWM controller registers. If userspace blanks the screen before suspending, such as e.g. GNOME does, then the PWM controller will be runtime-suspended when the suspend starts. This causes the GFX0 _PS? methods to save a value of 0xffffffff for the PWM control register and to restore this value on resume. 0xffffffff is not a valid value for the register and writing this causes problems such as e.g. a flickering backlight. This commit adds a prepare method to the dev_pm_ops and makes it return 0 on Cherry Trail devices forcing a runtime-resume before other device's suspend methods run. This fixes the reading and writing back of 0xffffffff. Since we now always runtime-resume the device on suspend, it will be resumed on resume too and we no longer need to check for the GFX0 _PS0 method having resumed it underneath us, so this commit removes the now no longer necessary complete dev_pm_op. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
1 parent 6f37709 commit 4743765

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

drivers/pwm/pwm-lpss-platform.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = {
3030
.clk_rate = 19200000,
3131
.npwm = 1,
3232
.base_unit_bits = 16,
33-
.check_power_on_resume = true,
33+
.other_devices_aml_touches_pwm_regs = true,
3434
};
3535

3636
/* Broxton */
@@ -61,6 +61,7 @@ static int pwm_lpss_probe_platform(struct platform_device *pdev)
6161

6262
platform_set_drvdata(pdev, lpwm);
6363

64+
dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_SMART_PREPARE);
6465
pm_runtime_set_active(&pdev->dev);
6566
pm_runtime_enable(&pdev->dev);
6667

@@ -75,25 +76,22 @@ static int pwm_lpss_remove_platform(struct platform_device *pdev)
7576
return pwm_lpss_remove(lpwm);
7677
}
7778

78-
static void pwm_lpss_complete(struct device *dev)
79+
static int pwm_lpss_prepare(struct device *dev)
7980
{
8081
struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev);
81-
int ret, state;
8282

83-
/* The PWM may be turned on by AML code, update our state to match */
84-
if (pm_runtime_suspended(dev) && lpwm->info->check_power_on_resume) {
85-
pm_runtime_disable(dev);
83+
/*
84+
* If other device's AML code touches the PWM regs on suspend/resume
85+
* force runtime-resume the PWM controller to allow this.
86+
*/
87+
if (lpwm->info->other_devices_aml_touches_pwm_regs)
88+
return 0; /* Force runtime-resume */
8689

87-
ret = acpi_device_get_power(ACPI_COMPANION(dev), &state);
88-
if (ret == 0 && state == ACPI_STATE_D0)
89-
pm_runtime_set_active(dev);
90-
91-
pm_runtime_enable(dev);
92-
}
90+
return 1; /* If runtime-suspended leave as is */
9391
}
9492

9593
static const struct dev_pm_ops pwm_lpss_platform_pm_ops = {
96-
.complete = pwm_lpss_complete,
94+
.prepare = pwm_lpss_prepare,
9795
SET_SYSTEM_SLEEP_PM_OPS(pwm_lpss_suspend, pwm_lpss_resume)
9896
};
9997

drivers/pwm/pwm-lpss.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ struct pwm_lpss_boardinfo {
3030
unsigned int npwm;
3131
unsigned long base_unit_bits;
3232
bool bypass;
33-
/* Some devices have AML code messing with the state underneath us */
34-
bool check_power_on_resume;
33+
/*
34+
* On some devices the _PS0/_PS3 AML code of the GPU (GFX0) device
35+
* messes with the PWM0 controllers state,
36+
*/
37+
bool other_devices_aml_touches_pwm_regs;
3538
};
3639

3740
struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,

0 commit comments

Comments
 (0)