Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2745055pxb; Sun, 24 Jan 2021 19:19:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKHV30o5sD7hmFu+xU0g3XogXmAZ9dSsdOXXRZVTq/ST1GQGp78RC82dwnrQMeNGwR67B7 X-Received: by 2002:a50:ed97:: with SMTP id h23mr541764edr.278.1611544758601; Sun, 24 Jan 2021 19:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611544758; cv=none; d=google.com; s=arc-20160816; b=b9S1Mtxs1hFDblJ2IBarx1BHgeHfNqjIRQ0mBij/ayTUgkWbvwY6e0osMiK4/yTfwS bE8Hxa1IQUrxrznks4C+XWkPKWjiADpozgkia5DuELMLeOQ1EoxYvDkHqJ1hmz6wT1Zp oMKuSeKTvmSZZabEK3Nic4vFl5qZZtGodN0OzRZv9apTVVdYdBvMQinNm4b3asqMsyJW SA8ksaoDqpXvpmRuS6jmLw3Jf+2vW6Vs9GtmGZFyUuFExvnbnlzUIeX3C0njCb6SxLWZ H0Z96PTF7BNYLHUHqdWBWkWfyz9JHXpae8qyWSOqZcukPY4GSwBazmXsbsXgKoMIlQ6x IwyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=h1NBhSVGk3S1pKP392uwgXMtXcp98skQsJvXDO/aDlE=; b=r1LZaLcEGzXMX0uNy1WjBOY8VuMhcoQRq4N9JiFJJOaWaljgYOPE68zWoGEHQRX9Dv MOiKe2SQ9Zx8dyCtjkXvjPT91gsjE3QScReSSfbfLTWcJvcRy6TtHfPVjGXySkan0kUX 7v7LTq5FKu/wld5t0ly3+8jq5oeICAiNCh+5oDNm7cYzGJ2y2PxxdJPuX3d3BNfpZZOc QPXwCPI9Do3IxcedNraLsrEZtE4ALruU8NSIWRQuUYDX8OdruyyznOo+tbrPNntadDBB soQmgcBPsx2FGUfrSRVbuG7GGx6gt4D9e6ieZYUWAoyPgraQDfHW8eMDN4T7fpiSHtxd /RXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u6si6375087edo.225.2021.01.24.19.18.55; Sun, 24 Jan 2021 19:19:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727040AbhAYDRK (ORCPT + 99 others); Sun, 24 Jan 2021 22:17:10 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:41538 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727003AbhAYDQM (ORCPT ); Sun, 24 Jan 2021 22:16:12 -0500 X-UUID: 398615451dfb4218851be9acf96b5b01-20210125 X-UUID: 398615451dfb4218851be9acf96b5b01-20210125 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 387554124; Mon, 25 Jan 2021 11:15:21 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 25 Jan 2021 11:15:18 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 25 Jan 2021 11:15:17 +0800 From: Hailong Fan To: Sean Wang , Linus Walleij , Matthias Brugger CC: , , , , , Nicolas Boichat , , , , , , Hailong Fan Subject: [PATCH] pinctrl: mediatek: Fix trigger type setting follow for unexpected interrupt Date: Mon, 25 Jan 2021 11:15:13 +0800 Message-ID: <20210125031513.1741-1-hailong.fan@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Hailong Fan --- [V2] --- drivers/pinctrl/mediatek/mtk-eint.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c index 22736f60c16c..0042f32c7e7e 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 unmasked; 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); + unmasked = true; + } else { + unmasked = false; + } + 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 (unmasked) + mtk_eint_unmask(d); return 0; } -- 2.18.0