Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/loongson-htvec: Add suspend/resume support

Add suspend/resume support for HTVEC irqchip, which is needed for
upcoming suspend/hibernation.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221020073527.541845-2-chenhuacai@loongson.cn

authored by

Huacai Chen and committed by
Marc Zyngier
1be356c9 70f7b6c0

+27
+27
drivers/irqchip/irq-loongson-htvec.c
··· 16 16 #include <linux/of_address.h> 17 17 #include <linux/of_irq.h> 18 18 #include <linux/of_platform.h> 19 + #include <linux/syscore_ops.h> 19 20 20 21 /* Registers */ 21 22 #define HTVEC_EN_OFF 0x20 ··· 30 29 void __iomem *base; 31 30 struct irq_domain *htvec_domain; 32 31 raw_spinlock_t htvec_lock; 32 + u32 saved_vec_en[HTVEC_MAX_PARENT_IRQ]; 33 33 }; 34 34 35 35 static struct htvec *htvec_priv; ··· 158 156 } 159 157 } 160 158 159 + static int htvec_suspend(void) 160 + { 161 + int i; 162 + 163 + for (i = 0; i < htvec_priv->num_parents; i++) 164 + htvec_priv->saved_vec_en[i] = readl(htvec_priv->base + HTVEC_EN_OFF + 4 * i); 165 + 166 + return 0; 167 + } 168 + 169 + static void htvec_resume(void) 170 + { 171 + int i; 172 + 173 + for (i = 0; i < htvec_priv->num_parents; i++) 174 + writel(htvec_priv->saved_vec_en[i], htvec_priv->base + HTVEC_EN_OFF + 4 * i); 175 + } 176 + 177 + static struct syscore_ops htvec_syscore_ops = { 178 + .suspend = htvec_suspend, 179 + .resume = htvec_resume, 180 + }; 181 + 161 182 static int htvec_init(phys_addr_t addr, unsigned long size, 162 183 int num_parents, int parent_irq[], struct fwnode_handle *domain_handle) 163 184 { ··· 212 187 } 213 188 214 189 htvec_priv = priv; 190 + 191 + register_syscore_ops(&htvec_syscore_ops); 215 192 216 193 return 0; 217 194