Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp712335pxb; Wed, 20 Jan 2021 19:36:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJycy4eSuNVN5a63FjqPDvIr/I3qfV2aSJ/xFCoGoq5P9xXoBRyifIm8nH+6QPiTJ7jnoNRz X-Received: by 2002:a17:906:b047:: with SMTP id bj7mr8095680ejb.335.1611200178539; Wed, 20 Jan 2021 19:36:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611200178; cv=none; d=google.com; s=arc-20160816; b=j6QkxP90V7b0ltTaW9zz6/gZOJ3Mn4geiIwn6/xc2r1i/R2ZzRwB1g1Sv7hHkNOARK JZ04vwP73ENFr6LebKL4gO4R4CXFL19JxNY7olq6sughEs1ZSbQqECXLO6vFvrK8zK5l BFBrNt9I1J09WMOKOhiYpDTrQU4gbXt4T/SZL4MmPiM14d9fBZ7vbLWNuhL5v5r5ixqn 3cLqRCQBPTVdiwhG5eTPI50iYsRethmlJ56F+QdnlYcBap8QQ2AmLfovknYNzg580j28 UccO9tVMoHzYsiy16ySag2HBYfLSusPhNlWVzG3QwIHHgFXC6jgkBGqJT6kUedclB6Ar lo/Q== 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=SIMExQ5YlJnJIWI24QeNU/bF1IH2cOtkC/uRpr/+3S4=; b=ur4rk1OgLoT9u5WHw8QH8djPr6K+BA8ySdY1UOssrAgcqvkPiIvZ9bPqIZNiC7lyU5 8F2waHGCnz5lOSdy1iDkpPswQD4XhvI2DEk9+38TnMXfZGa5UltlB6fhQxXZoBCy0q/m NUSfH2Vz+BdZktxHSRkb8IK43uiuRM9y78GnF19NjbS+bU+tjvApQVlivw5lW5fdBOT7 wtZanz9ZYe3QXAvmzzwIi1fKrwHSi6e3AGkgQUqSAPOsNfdvFBf5uwsLeULGOe5g4Okb VKNhD8tPUdjwhAfY8uNO+f+1HZVV52krKklaXRiJX/32pXPPKgJZAf16lsaPQCCrc/C5 cxkQ== 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 24si1804731edv.406.2021.01.20.19.35.55; Wed, 20 Jan 2021 19:36: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 S1732429AbhAUDXN (ORCPT + 99 others); Wed, 20 Jan 2021 22:23:13 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:48355 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729173AbhAUDSg (ORCPT ); Wed, 20 Jan 2021 22:18:36 -0500 X-UUID: 849cb445311248f7b2e1f92df2a8b6f1-20210121 X-UUID: 849cb445311248f7b2e1f92df2a8b6f1-20210121 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.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 49097106; Thu, 21 Jan 2021 11:17:45 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 21 Jan 2021 11:17:43 +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; Thu, 21 Jan 2021 11:17:43 +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: Thu, 21 Jan 2021 11:17:40 +0800 Message-ID: <20210121031740.25282-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 Version: 5.11-rc1 --- 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..3acda6bb401e 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); + unsigned int unmask; 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); + unmask = 1; + } else { + unmask = 0; + } + 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 (unmask == 1) + mtk_eint_unmask(d); return 0; } -- 2.18.0