Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1619999 > unrolled thread

[PATCH v2] irqchip/atmel-aic5: handle suspend to RAM

Started byAlexandre Belloni <alexandre.belloni@free-electrons.com>
First post2017-04-10 17:00 +0200
Last post2017-04-12 10:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] irqchip/atmel-aic5: handle suspend to RAM Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-04-10 17:00 +0200
    Re: [PATCH v2] irqchip/atmel-aic5: handle suspend to RAM Marc Zyngier <marc.zyngier@arm.com> - 2017-04-12 10:20 +0200

#1619999 — [PATCH v2] irqchip/atmel-aic5: handle suspend to RAM

FromAlexandre Belloni <alexandre.belloni@free-electrons.com>
Date2017-04-10 17:00 +0200
Subject[PATCH v2] irqchip/atmel-aic5: handle suspend to RAM
Message-ID<tuIXo-21C-13@gated-at.bofh.it>
On sama5d2, VDD core may be cut while suspending to RAM. This means the
AIC5 registers content is lost. Restore it at resume time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Changes in v2:
 - smr_cache is now static and is allocated at init time
 - saving SMR and restoring it only happens when smr_cache is allocated
   (limiting that to sama5d2 for now).

 drivers/irqchip/irq-atmel-aic5.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
index 2a624d87a035..c04ee9a23d09 100644
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -150,6 +150,8 @@ static int aic5_set_type(struct irq_data *d, unsigned type)
 }
 
 #ifdef CONFIG_PM
+static u32 *smr_cache;
+
 static void aic5_suspend(struct irq_data *d)
 {
 	struct irq_domain *domain = d->domain;
@@ -159,6 +161,12 @@ static void aic5_suspend(struct irq_data *d)
 	int i;
 	u32 mask;
 
+	if (smr_cache)
+		for (i = 0; i < domain->revmap_size; i++) {
+			irq_reg_writel(bgc, i, AT91_AIC5_SSR);
+			smr_cache[i] = irq_reg_readl(bgc, AT91_AIC5_SMR);
+		}
+
 	irq_gc_lock(bgc);
 	for (i = 0; i < dgc->irqs_per_chip; i++) {
 		mask = 1 << i;
@@ -184,9 +192,21 @@ static void aic5_resume(struct irq_data *d)
 	u32 mask;
 
 	irq_gc_lock(bgc);
+
+	if (smr_cache) {
+		irq_reg_writel(bgc, 0xffffffff, AT91_AIC5_SPU);
+		for (i = 0; i < domain->revmap_size; i++) {
+			irq_reg_writel(bgc, i, AT91_AIC5_SSR);
+			irq_reg_writel(bgc, i, AT91_AIC5_SVR);
+			irq_reg_writel(bgc, smr_cache[i], AT91_AIC5_SMR);
+		}
+	}
+
 	for (i = 0; i < dgc->irqs_per_chip; i++) {
 		mask = 1 << i;
-		if ((mask & gc->mask_cache) == (mask & gc->wake_active))
+
+		if (!smr_cache &&
+		    ((mask & gc->mask_cache) == (mask & gc->wake_active)))
 			continue;
 
 		irq_reg_writel(bgc, i + gc->irq_base, AT91_AIC5_SSR);
@@ -342,6 +362,13 @@ static int __init aic5_of_init(struct device_node *node,
 static int __init sama5d2_aic5_of_init(struct device_node *node,
 				       struct device_node *parent)
 {
+#ifdef CONFIG_PM
+	smr_cache = kcalloc(DIV_ROUND_UP(NR_SAMA5D2_IRQS, 32) * 32,
+			    sizeof(*smr_cache), GFP_KERNEL);
+	if (!smr_cache)
+		return -ENOMEM;
+#endif
+
 	return aic5_of_init(node, parent, NR_SAMA5D2_IRQS);
 }
 IRQCHIP_DECLARE(sama5d2_aic5, "atmel,sama5d2-aic", sama5d2_aic5_of_init);
-- 
2.11.0

[toc] | [next] | [standalone]


#1621909

FromMarc Zyngier <marc.zyngier@arm.com>
Date2017-04-12 10:20 +0200
Message-ID<tvlFo-284-11@gated-at.bofh.it>
In reply to#1619999
On 10/04/17 15:50, Alexandre Belloni wrote:
> On sama5d2, VDD core may be cut while suspending to RAM. This means the
> AIC5 registers content is lost. Restore it at resume time.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> Changes in v2:
>  - smr_cache is now static and is allocated at init time
>  - saving SMR and restoring it only happens when smr_cache is allocated
>    (limiting that to sama5d2 for now).
> 
>  drivers/irqchip/irq-atmel-aic5.c | 29 ++++++++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)

Applied to irqchip-4.12.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web