[PATCH 1/4] Input: rk805-pwrkey - enable the wakeup interrupt during system suspend
Jakob Unterwurzacher
jakob.unterwurzacher at cherry.de
Fri Nov 20 05:42:57 PST 2026
Hi,
On 11/12/26 01:25, Dmitry Torokhov wrote:
> [You don't often get email from dmitry.torokhov at gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Hi Jakob,
>
> On Thu, Oct 29, 2026 at 11:06:23AM +0100, Jakob Unterwurzacher wrote:
>> From: Jakob Unterwurzacher <jakob.unterwurzacher at cherry.de>
>>
>> The driver marks the device as wakeup capable, but never enables the
>> power key interrupt as a wakeup interrupt. As a consequence, the PMIC
>> interrupt line is masked during system suspend and the power key cannot
>> wake up the system, e.g. from suspend-to-ram on RK3588 with an RK806.
>>
>> Enable the interrupt as wakeup interrupt in the suspend callback if the
>> device may wake up the system, and disable it again on resume.
>>
>> This is done in the regular suspend phase on purpose, rather than with
>> dev_pm_set_wake_irq(), which arms the wakeup in the noirq phase: there,
>> enabling it updates the PMIC's interrupt registers through regmap-irq,
>> which fails when the PMIC is connected via SPI:
>>
>> spi_master spi2: Failed to power device: -13
>> rk8xx-spi spi2.0: Failed to sync masks in 7a
>
> Sounds like this needs to be solved in PM core rather than hacked around
> in individual driver? Let's CC Tony and Rafael.
How about something like this, copy-pasted below? If no immediate
objections I'll post it as a proper patch.
With this, rk805-pwrkey can use dev_pm_set_wake_irq with no issues
(tested on RK3588-Tiger).
Thanks,
Jakob
> commit ad2298eb4cf079b087a590231f09e7cb3ed594d1
> Author: Jakob Unterwurzacher <jakob.unterwurzacher at cherry.de>
> Date: Thu Nov 19 12:03:24 2026 +0100
>
> spi: rockchip: keep the controller active during system sleep transitions
>
> The controller is suspended in the noirq phase of system suspend, after
> its child devices. Runtime PM is disabled from the late suspend phase
> until the early resume phase, so a transfer in that window can only work
> if the controller is still runtime-active. If it has already been
> autosuspended, pm_runtime_get_sync() fails with -EACCES.
>
> Child devices do need the bus in that window. With an RK806 PMIC on SPI,
> arming its power key as a wakeup interrupt in the noirq phase (e.g. with
> dev_pm_set_wake_irq()) writes the PMIC's interrupt mask registers, and a
> wakeup by the power key is handled as soon as interrupts are re-enabled
> at the end of the noirq resume phase. On RK3588-Tiger we get this:
>
> spi_master spi2: Failed to power device: -13
> spi_master spi2: noqueue transfer failed
> rk8xx-spi spi2.0: Failed to read IRQ status: -13
>
> Take a runtime PM reference in the regular suspend phase and drop it on
> resume. This keeps the controller usable until its noirq suspend
> callback, and since it was active then, pm_runtime_force_resume()
> restores it in the noirq resume phase, before interrupts of child
> devices are handled again.
>
> Signed-off-by: Jakob Unterwurzacher <jakob.unterwurzacher at cherry.de>
>
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 1a81fd94b4396..504068b15c184 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -938,7 +938,27 @@ static void rockchip_spi_remove(struct platform_device *pdev)
> dma_release_channel(ctlr->dma_rx);
> }
>
> +/*
> + * Child devices (e.g. an RK806 PMIC with its interrupt controller and wakeup
> + * interrupts) can still need the bus during the late and noirq phases of
> + * system suspend and resume, while runtime PM is disabled. Keep the controller
> + * runtime-active from the regular suspend phase on, so that such transfers
> + * work and pm_runtime_force_resume() restores the controller in the noirq
> + * resume phase, before child device interrupts are handled again.
> + */
> static int rockchip_spi_suspend(struct device *dev)
> +{
> + return pm_runtime_resume_and_get(dev);
> +}
> +
> +static int rockchip_spi_resume(struct device *dev)
> +{
> + pm_runtime_put_autosuspend(dev);
> +
> + return 0;
> +}
> +
> +static int rockchip_spi_suspend_noirq(struct device *dev)
> {
> int ret;
> struct spi_controller *ctlr = dev_get_drvdata(dev);
> @@ -958,7 +978,7 @@ static int rockchip_spi_suspend(struct device *dev)
> return 0;
> }
>
> -static int rockchip_spi_resume(struct device *dev)
> +static int rockchip_spi_resume_noirq(struct device *dev)
> {
> int ret;
> struct spi_controller *ctlr = dev_get_drvdata(dev);
> @@ -1001,7 +1021,9 @@ static int rockchip_spi_runtime_resume(struct device *dev)
> }
>
> static const struct dev_pm_ops rockchip_spi_pm = {
> - NOIRQ_SYSTEM_SLEEP_PM_OPS(rockchip_spi_suspend, rockchip_spi_resume)
> + SYSTEM_SLEEP_PM_OPS(rockchip_spi_suspend, rockchip_spi_resume)
> + NOIRQ_SYSTEM_SLEEP_PM_OPS(rockchip_spi_suspend_noirq,
> + rockchip_spi_resume_noirq)
> RUNTIME_PM_OPS(rockchip_spi_runtime_suspend,
> rockchip_spi_runtime_resume, NULL)
> };
More information about the Linux-rockchip
mailing list