[V3] pinctrl: mediatek: Fix trigger type setting follow for unexpected interrupt
diff mbox series

Message ID 20210125041753.2214-1-hailong.fan@mediatek.com
State Accepted
Commit b40b760aa2a9587cdcde62759642b4e99c40dedc
Headers show
Series
  • [V3] pinctrl: mediatek: Fix trigger type setting follow for unexpected interrupt
Related show

Commit Message

mtk15103 Jan. 25, 2021, 4:17 a.m. UTC
When flipping the polarity will be generated interrupt under certain
circumstances, but GPIO external signal has not changed.
Then, mask the interrupt before polarity setting, and clear the
unexpected interrupt after trigger type setting completed.

Remove mtk_eint_flip_edge: because mtk_eint_unmask already calls it.

Signed-off-by: Hailong Fan <hailong.fan@mediatek.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
---
 drivers/pinctrl/mediatek/mtk-eint.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Linus Walleij Jan. 25, 2021, 1:11 p.m. UTC | #1
On Mon, Jan 25, 2021 at 5:18 AM Hailong Fan <hailong.fan@mediatek.com> wrote:

> When flipping the polarity will be generated interrupt under certain
> circumstances, but GPIO external signal has not changed.
> Then, mask the interrupt before polarity setting, and clear the
> unexpected interrupt after trigger type setting completed.
>
> Remove mtk_eint_flip_edge: because mtk_eint_unmask already calls it.
>
> Signed-off-by: Hailong Fan <hailong.fan@mediatek.com>
> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>

Took out v2 and applied this v3 instead.
(No idea what the difference is, you don't say.)

Yours,
Linus Walleij
mtk15103 Jan. 26, 2021, 1:22 a.m. UTC | #2
On Mon, 2021-01-25 at 14:11 +0100, Linus Walleij wrote:
> On Mon, Jan 25, 2021 at 5:18 AM Hailong Fan <hailong.fan@mediatek.com> wrote:
> 
> > When flipping the polarity will be generated interrupt under certain
> > circumstances, but GPIO external signal has not changed.
> > Then, mask the interrupt before polarity setting, and clear the
> > unexpected interrupt after trigger type setting completed.
> >
> > Remove mtk_eint_flip_edge: because mtk_eint_unmask already calls it.
> >
> > Signed-off-by: Hailong Fan <hailong.fan@mediatek.com>
> > Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
> 
> Took out v2 and applied this v3 instead.
> (No idea what the difference is, you don't say.)
V3 only add commit message "Remove mtk_eint_flip_edge: because mtk_eint_unmask already calls it."
Compared to V2, the patch has not changed.
Thanks.

> Yours,
> Linus Walleij

Patch
diff mbox series

diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c
index 22736f60c16c..3b9b5dbd7968 100644
--- a/drivers/pinctrl/mediatek/mtk-eint.c
+++ b/drivers/pinctrl/mediatek/mtk-eint.c
@@ -157,6 +157,7 @@  static void mtk_eint_ack(struct irq_data *d)
 static int mtk_eint_set_type(struct irq_data *d, unsigned int type)
 {
 	struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
+	bool masked;
 	u32 mask = BIT(d->hwirq & 0x1f);
 	void __iomem *reg;
 
@@ -173,6 +174,13 @@  static int mtk_eint_set_type(struct irq_data *d, unsigned int type)
 	else
 		eint->dual_edge[d->hwirq] = 0;
 
+	if (!mtk_eint_get_mask(eint, d->hwirq)) {
+		mtk_eint_mask(d);
+		masked = false;
+	} else {
+		masked = true;
+	}
+
 	if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) {
 		reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->pol_clr);
 		writel(mask, reg);
@@ -189,8 +197,9 @@  static int mtk_eint_set_type(struct irq_data *d, unsigned int type)
 		writel(mask, reg);
 	}
 
-	if (eint->dual_edge[d->hwirq])
-		mtk_eint_flip_edge(eint, d->hwirq);
+	mtk_eint_ack(d);
+	if (!masked)
+		mtk_eint_unmask(d);
 
 	return 0;
 }