Commit c7c75e32 authored by Huacai Chen's avatar Huacai Chen Committed by Marc Zyngier

irqchip/loongson-pch-lpc: Add suspend/resume support

Add suspend/resume support for PCH-LPC irqchip, which is needed for
upcoming suspend/hibernation.
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221020073527.541845-5-chenhuacai@loongson.cn
parent 1ed008a2
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/irqchip/chained_irq.h> #include <linux/irqchip/chained_irq.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/syscore_ops.h>
/* Registers */ /* Registers */
#define LPC_INT_CTL 0x00 #define LPC_INT_CTL 0x00
...@@ -34,6 +35,7 @@ struct pch_lpc { ...@@ -34,6 +35,7 @@ struct pch_lpc {
u32 saved_reg_pol; u32 saved_reg_pol;
}; };
static struct pch_lpc *pch_lpc_priv;
struct fwnode_handle *pch_lpc_handle; struct fwnode_handle *pch_lpc_handle;
static void lpc_irq_ack(struct irq_data *d) static void lpc_irq_ack(struct irq_data *d)
...@@ -147,6 +149,26 @@ static int pch_lpc_disabled(struct pch_lpc *priv) ...@@ -147,6 +149,26 @@ static int pch_lpc_disabled(struct pch_lpc *priv)
(readl(priv->base + LPC_INT_STS) == 0xffffffff); (readl(priv->base + LPC_INT_STS) == 0xffffffff);
} }
static int pch_lpc_suspend(void)
{
pch_lpc_priv->saved_reg_ctl = readl(pch_lpc_priv->base + LPC_INT_CTL);
pch_lpc_priv->saved_reg_ena = readl(pch_lpc_priv->base + LPC_INT_ENA);
pch_lpc_priv->saved_reg_pol = readl(pch_lpc_priv->base + LPC_INT_POL);
return 0;
}
static void pch_lpc_resume(void)
{
writel(pch_lpc_priv->saved_reg_ctl, pch_lpc_priv->base + LPC_INT_CTL);
writel(pch_lpc_priv->saved_reg_ena, pch_lpc_priv->base + LPC_INT_ENA);
writel(pch_lpc_priv->saved_reg_pol, pch_lpc_priv->base + LPC_INT_POL);
}
static struct syscore_ops pch_lpc_syscore_ops = {
.suspend = pch_lpc_suspend,
.resume = pch_lpc_resume,
};
int __init pch_lpc_acpi_init(struct irq_domain *parent, int __init pch_lpc_acpi_init(struct irq_domain *parent,
struct acpi_madt_lpc_pic *acpi_pchlpc) struct acpi_madt_lpc_pic *acpi_pchlpc)
{ {
...@@ -191,7 +213,10 @@ int __init pch_lpc_acpi_init(struct irq_domain *parent, ...@@ -191,7 +213,10 @@ int __init pch_lpc_acpi_init(struct irq_domain *parent,
parent_irq = irq_create_fwspec_mapping(&fwspec); parent_irq = irq_create_fwspec_mapping(&fwspec);
irq_set_chained_handler_and_data(parent_irq, lpc_irq_dispatch, priv); irq_set_chained_handler_and_data(parent_irq, lpc_irq_dispatch, priv);
pch_lpc_priv = priv;
pch_lpc_handle = irq_handle; pch_lpc_handle = irq_handle;
register_syscore_ops(&pch_lpc_syscore_ops);
return 0; return 0;
free_irq_handle: free_irq_handle:
......
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