Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: linus.walleij@linaro.org (Linus Walleij)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4 v2] irqchip: faraday: fix the trigger types
Date: Sat, 18 Mar 2017 17:53:25 +0100	[thread overview]
Message-ID: <20170318165326.20450-3-linus.walleij@linaro.org> (raw)
In-Reply-To: <20170318165326.20450-1-linus.walleij@linaro.org>

The triggers in the driver were right for high level triggered
IRQs but the edge detection on edge triggered IRQs was wrong.
After studying a proper driver from Po-Yu Chuang I now know how
to handle these right, and we can properly implement low level
IRQs as well.

The device trees for the Gemini had polarity switched around
so these have been fixed to conform to the right polarity as
well.

Cc: Greentime Hu <green.hu@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- No changes, just resending with the rest.
---
 drivers/irqchip/irq-ftintc010.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-ftintc010.c b/drivers/irqchip/irq-ftintc010.c
index 81929aa33990..0cc81df6f743 100644
--- a/drivers/irqchip/irq-ftintc010.c
+++ b/drivers/irqchip/irq-ftintc010.c
@@ -26,7 +26,9 @@
 #define FT010_IRQ_SOURCE(base_addr)	(base_addr + 0x00)
 #define FT010_IRQ_MASK(base_addr)	(base_addr + 0x04)
 #define FT010_IRQ_CLEAR(base_addr)	(base_addr + 0x08)
+/* Selects level- or edge-triggered */
 #define FT010_IRQ_MODE(base_addr)	(base_addr + 0x0C)
+/* Selects active low/high or falling/rising edge */
 #define FT010_IRQ_POLARITY(base_addr)	(base_addr + 0x10)
 #define FT010_IRQ_STATUS(base_addr)	(base_addr + 0x14)
 #define FT010_FIQ_SOURCE(base_addr)	(base_addr + 0x20)
@@ -84,22 +86,25 @@ static int ft010_irq_set_type(struct irq_data *d, unsigned int trigger)
 	mode = readl(FT010_IRQ_MODE(f->base));
 	polarity = readl(FT010_IRQ_POLARITY(f->base));
 
-	if (trigger & (IRQ_TYPE_LEVEL_HIGH)) {
+	if (trigger & (IRQ_TYPE_LEVEL_LOW)) {
+		irq_set_handler_locked(d, handle_level_irq);
+		mode &= ~BIT(offset);
+		polarity |= BIT(offset);
+	} else if (trigger & (IRQ_TYPE_LEVEL_HIGH)) {
 		irq_set_handler_locked(d, handle_level_irq);
-		/* Disable edge detection */
 		mode &= ~BIT(offset);
 		polarity &= ~BIT(offset);
-	} else if (trigger & IRQ_TYPE_EDGE_RISING) {
+	} else if (trigger & IRQ_TYPE_EDGE_FALLING) {
 		irq_set_handler_locked(d, handle_edge_irq);
 		mode |= BIT(offset);
 		polarity |= BIT(offset);
-	} else if (trigger & IRQ_TYPE_EDGE_FALLING) {
+	} else if (trigger & IRQ_TYPE_EDGE_RISING) {
 		irq_set_handler_locked(d, handle_edge_irq);
 		mode |= BIT(offset);
 		polarity &= ~BIT(offset);
 	} else {
 		irq_set_handler_locked(d, handle_bad_irq);
-		pr_warn("GEMINI IRQ: no supported trigger selected for line %d\n",
+		pr_warn("Faraday IRQ: no supported trigger selected for line %d\n",
 			offset);
 	}
 
-- 
2.9.3

  parent reply	other threads:[~2017-03-18 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-18 16:53 [PATCH 1/4 v2] irqchip: augment Gemini bindings to reflect Faraday origin Linus Walleij
2017-03-18 16:53 ` [PATCH 2/4 v2] irqchip: refactor Gemini driver " Linus Walleij
2017-03-18 16:53 ` Linus Walleij [this message]
2017-03-18 16:53 ` [PATCH 4/4 v2] irqchip: replace moxa with ftintc010 Linus Walleij
2017-03-19 10:21 ` [PATCH 1/4 v2] irqchip: augment Gemini bindings to reflect Faraday origin Hans Ulli Kroll
2017-03-24  9:29 ` Marc Zyngier

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=20170318165326.20450-3-linus.walleij@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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