LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Huacai Chen <chenhuacai@loongson.cn> To: Thomas Gleixner <tglx@linutronix.de>, Marc Zyngier <maz@kernel.org> Cc: linux-kernel@vger.kernel.org, Xuefeng Li <lixuefeng@loongson.cn>, Huacai Chen <chenhuacai@gmail.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Huacai Chen <chenhuacai@loongson.cn> Subject: [PATCH V2 03/10] irqchip/loongson-pch-pic: Add suspend/resume support Date: Mon, 16 Aug 2021 15:52:45 +0800 [thread overview] Message-ID: <20210816075252.4003406-4-chenhuacai@loongson.cn> (raw) In-Reply-To: <20210816075252.4003406-1-chenhuacai@loongson.cn> Add suspend/resume support for PCH-PIC irqchip, which is needed for suspend/hibernation. Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> --- drivers/irqchip/irq-loongson-pch-pic.c | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/irqchip/irq-loongson-pch-pic.c b/drivers/irqchip/irq-loongson-pch-pic.c index 476a00f11480..d78c36a55593 100644 --- a/drivers/irqchip/irq-loongson-pch-pic.c +++ b/drivers/irqchip/irq-loongson-pch-pic.c @@ -15,6 +15,7 @@ #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/of_platform.h> +#include <linux/syscore_ops.h> /* Registers */ #define PCH_PIC_MASK 0x20 @@ -41,6 +42,9 @@ struct pch_pic { struct fwnode_handle *domain_handle; u32 ht_vec_base; raw_spinlock_t pic_lock; + u32 saved_vec_en[PIC_REG_COUNT]; + u32 saved_vec_pol[PIC_REG_COUNT]; + u32 saved_vec_edge[PIC_REG_COUNT]; }; struct pch_pic *pch_pic_priv[4]; @@ -142,6 +146,7 @@ static struct irq_chip pch_pic_irq_chip = { .irq_ack = pch_pic_ack_irq, .irq_set_affinity = irq_chip_set_affinity_parent, .irq_set_type = pch_pic_set_type, + .flags = IRQCHIP_SKIP_SET_WAKE, }; static int pch_pic_alloc(struct irq_domain *domain, unsigned int virq, @@ -203,6 +208,46 @@ static void pch_pic_reset(struct pch_pic *priv) } } +static int pch_pic_suspend(void) +{ + int i, j; + + for (i = 0; i < nr_pch_pics; i++) { + for (j = 0; j < PIC_REG_COUNT; j++) { + pch_pic_priv[i]->saved_vec_pol[j] = + readl(pch_pic_priv[i]->base + PCH_PIC_POL + 4 * j); + pch_pic_priv[i]->saved_vec_edge[j] = + readl(pch_pic_priv[i]->base + PCH_PIC_EDGE + 4 * j); + pch_pic_priv[i]->saved_vec_en[j] = + readl(pch_pic_priv[i]->base + PCH_PIC_MASK + 4 * j); + } + } + + return 0; +} + +static void pch_pic_resume(void) +{ + int i, j; + + for (i = 0; i < nr_pch_pics; i++) { + pch_pic_reset(pch_pic_priv[i]); + for (j = 0; j < PIC_REG_COUNT; j++) { + writel(pch_pic_priv[i]->saved_vec_pol[j], + pch_pic_priv[i]->base + PCH_PIC_POL + 4 * j); + writel(pch_pic_priv[i]->saved_vec_edge[j], + pch_pic_priv[i]->base + PCH_PIC_EDGE + 4 * j); + writel(pch_pic_priv[i]->saved_vec_en[j], + pch_pic_priv[i]->base + PCH_PIC_MASK + 4 * j); + } + } +} + +static struct syscore_ops pch_pic_syscore_ops = { + .suspend = pch_pic_suspend, + .resume = pch_pic_resume, +}; + static int pch_pic_init(phys_addr_t addr, unsigned long size, int vec_base, struct irq_domain *parent_domain, struct fwnode_handle *domain_handle) { @@ -235,6 +280,8 @@ static int pch_pic_init(phys_addr_t addr, unsigned long size, int vec_base, pch_pic_reset(priv); pch_pic_priv[nr_pch_pics++] = priv; + register_syscore_ops(&pch_pic_syscore_ops); + return 0; iounmap_base: -- 2.27.0
next prev parent reply other threads:[~2021-08-16 7:55 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-16 7:52 [PATCH V2 00/10] irqchip: Add LoongArch-related irqchip drivers Huacai Chen 2021-08-16 7:52 ` [PATCH V2 01/10] irqchip: Adjust Kconfig for Loongson Huacai Chen 2021-08-16 7:52 ` [PATCH V2 02/10] irqchip/loongson-pch-pic: Add ACPI init support Huacai Chen 2021-08-16 7:52 ` Huacai Chen [this message] 2021-08-16 7:52 ` [PATCH V2 04/10] irqchip/loongson-pch-msi: " Huacai Chen 2021-08-16 7:52 ` [PATCH V2 05/10] irqchip/loongson-htvec: " Huacai Chen 2021-08-16 7:52 ` [PATCH V2 06/10] irqchip/loongson-htvec: Add suspend/resume support Huacai Chen 2021-08-16 7:52 ` [PATCH V2 07/10] irqchip/loongson-liointc: Add ACPI init support Huacai Chen 2021-08-16 7:52 ` [PATCH V2 08/10] irqchip: Add LoongArch CPU interrupt controller support Huacai Chen 2021-08-16 7:52 ` [PATCH V2 09/10] irqchip: Add Loongson Extended I/O " Huacai Chen 2021-08-16 7:52 ` [PATCH V2 10/10] irqchip: Add Loongson PCH LPC " Huacai Chen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210816075252.4003406-4-chenhuacai@loongson.cn \ --to=chenhuacai@loongson.cn \ --cc=chenhuacai@gmail.com \ --cc=jiaxun.yang@flygoat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=lixuefeng@loongson.cn \ --cc=maz@kernel.org \ --cc=tglx@linutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).