From: Ed Blake <ed.blake@sondrel.com>
To: tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com
Cc: linux-kernel@vger.kernel.org, Ed Blake <ed.blake@sondrel.com>
Subject: [PATCH 2/4] irqchip: imgpdc: Avoid immediate wake event during set_wake
Date: Mon, 2 Oct 2017 10:55:57 +0100 [thread overview]
Message-ID: <1506938159-466-3-git-send-email-ed.blake@sondrel.com> (raw)
In-Reply-To: <1506938159-466-1-git-send-email-ed.blake@sondrel.com>
When enabling sys wakes, an immediate power transition may occur if the
wake input has been active in the past. Work around this by doing the
following:
1) Set SYS_WAKE_CONFIG to the current value of SOC_POWER so that an
immediate power transition has no effect
2) Enable and disable the sys wake to flush the stale wake event
3) Set SYS_WAKE_CONFIG back to the original value
Signed-off-by: Ed Blake <ed.blake@sondrel.com>
---
drivers/irqchip/irq-imgpdc.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/irqchip/irq-imgpdc.c b/drivers/irqchip/irq-imgpdc.c
index 2ac3210..22d8f8a 100644
--- a/drivers/irqchip/irq-imgpdc.c
+++ b/drivers/irqchip/irq-imgpdc.c
@@ -8,6 +8,7 @@
*/
#include <linux/bitops.h>
+#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/irqdomain.h>
#include <linux/io.h>
@@ -18,6 +19,7 @@
/* PDC interrupt register numbers */
+#define PDC_SOC_POWER 0x300
#define PDC_IRQ_STATUS 0x310
#define PDC_IRQ_ENABLE 0x314
#define PDC_IRQ_CLEAR 0x318
@@ -204,6 +206,8 @@ static int pdc_irq_set_wake(struct irq_data *data, unsigned int on)
unsigned int mask = (1 << 16) << hw;
unsigned int dst_irq;
unsigned int *dst_irq_wake_depth;
+ unsigned int syswake, soc_sys_wake_cfg_regoff;
+ u32 soc_sys_wake_cfg, soc_power;
int ret;
/* control the destination IRQ wakeup too for standby mode */
@@ -216,6 +220,27 @@ static int pdc_irq_set_wake(struct irq_data *data, unsigned int on)
}
raw_spin_lock(&priv->lock);
+ /*
+ * When enabling sys wakes, an immediate power transition may occur if
+ * the wake input has been active in the past. Work around this:
+ * 1) Set SYS_WAKE_CONFIG to the current value of SOC_POWER so that an
+ * immediate power transition has no effect
+ * 2) Enable and disable the sys wake to flush the stale wake event
+ * 3) Set SYS_WAKE_CONFIG back to the original value
+ */
+ if (hwirq_is_syswake(hw) && on) {
+ syswake = hwirq_to_syswake(hw);
+ soc_sys_wake_cfg_regoff = PDC_SYS_WAKE_CONFIG_BASE +
+ syswake * PDC_SYS_WAKE_CONFIG_STRIDE;
+ soc_sys_wake_cfg = pdc_read(priv, soc_sys_wake_cfg_regoff);
+ soc_power = pdc_read(priv, PDC_SOC_POWER);
+ pdc_write(priv, soc_sys_wake_cfg_regoff, soc_power);
+ pdc_write(priv, PDC_IRQ_ROUTE, priv->irq_route | mask);
+ udelay(31);
+ pdc_write(priv, PDC_IRQ_ROUTE, priv->irq_route);
+ pdc_write(priv, soc_sys_wake_cfg_regoff, soc_sys_wake_cfg);
+ }
+
if (on)
priv->irq_route |= mask;
else
--
1.9.1
next prev parent reply other threads:[~2017-10-02 9:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-02 9:55 [PATCH 0/4] irqchip: imgpdc: Fix various issues Ed Blake
2017-10-02 9:55 ` [PATCH 1/4] irqchip: imgpdc: Avoid unbalanced irq wake disable Ed Blake
2017-10-02 9:55 ` Ed Blake [this message]
2017-10-02 9:55 ` [PATCH 3/4] irqchip: imgpdc: Set sys wake polarities to active high Ed Blake
2017-10-04 13:14 ` James Hogan
2017-10-05 14:37 ` Ed Blake
2017-10-02 9:55 ` [PATCH 4/4] irqchip: imgpdc: Pass on peripheral mask/unmasks to the parent Ed Blake
2017-10-04 14:03 ` James Hogan
2017-10-05 14:48 ` Ed Blake
2017-10-05 15:26 ` James Hogan
2017-10-05 15:43 ` Ed Blake
2017-10-05 16:42 ` Ed Blake
2017-10-03 20:32 ` [PATCH 0/4] irqchip: imgpdc: Fix various issues Thomas Gleixner
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=1506938159-466-3-git-send-email-ed.blake@sondrel.com \
--to=ed.blake@sondrel.com \
--cc=jason@lakedaemon.net \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--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: link
Be 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