• Hans de Goede's avatar
    ACPI / LPSS: Resume Cherry Trail PWM controller in no-irq phase · 5e31ee84
    Hans de Goede authored
    The DSDTs on most Cherry Trail devices have an ugly clutch where the PWM
    controller gets poked from the _PS0 method of the graphics-card device:
    
    	Local0 = PSAT /* \_SB_.PCI0.GFX0.PSAT */
    	If (((Local0 & 0x03) == 0x03))
    	{
    	    PSAT &= 0xFFFFFFFC
    	    Local1 = PSAT /* \_SB_.PCI0.GFX0.PSAT */
    	    RSTA = Zero
    	    RSTF = Zero
    	    RSTA = One
    	    RSTF = One
    	    PWMB |= 0xC0000000
    	    PWMC = PWMB /* \_SB_.PCI0.GFX0.PWMB */
    	}
    
    Where PSAT is the power-status register of the PWM controller, so if it
    is in D3 when the GFX0 device's PS0 method runs then it will turn it on
    and restore the PWM ctrl register value it saved from its PS3 handler.
    Note not only does it restore it, it ors it with 0xC0000000 turning it
    on at a time where we may not want it to get turned on at all.
    
    The pwm_get call which the i915 driver does to get a reference to the
    PWM controller, already adds a device-link making the GFX0 device a
    consumer of the PWM device. So it should already have been resumed when
    the above AML runs and the AML should thus not do its undesirable poking
    of the PWM controller register.
    
    But the PCI core powers on PCI devices in the no-irq resume phase and
    thus calls the troublesome PS0 method in the no-irq resume phase.
    Where as LPSS devices by default are resumed in the early resume phase.
    
    This commit sets the resume_from_noirq flag in the bsw_pwm_dev_desc
    struct, so that Cherry Trail PWM controllers will be resumed in the
    no-irq phase. Together with the device-link added by the pwm-get this
    ensures that the PWM controller will be on when the troublesome PS0
    method runs, which stops it from poking the PWM controller.
    Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200903112337.4113-2-hdegoede@redhat.com
    5e31ee84
acpi_lpss.c 34.9 KB