Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp515699pxb; Thu, 21 Jan 2021 12:38:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLzG7pQnRzdGaFQJyXGRmEKgrN6KYrk+oRDgWHFPAkcDWBrwFl2GyY2TKrTUyt4H6s/EJZ X-Received: by 2002:a17:906:80c9:: with SMTP id a9mr822106ejx.78.1611261512995; Thu, 21 Jan 2021 12:38:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611261512; cv=none; d=google.com; s=arc-20160816; b=dTZoRewnUu05h8EPPiWnvkEJj0toDpFrlpfN5d7ZjfswgdLXiwzN9JLR3jpk2Xlrph kyHrul8QAFhRHFILgVyaH7cGJkqNl3ICMIss1G9ogD+aiqM3DTzNqyglaj4xs03cKfdE WdF1zBHO/sRGmYYY1grkrNJqB7+njg3fXQoB4+9qAXeywP1tVRJuzBmHMv0QuQsVS1Bm OgnwvCTATfFNvrNUKKRltGltXd2l6Oz9SI6HQ5tEGOpacvi5NBxT6pfrA7LYHziG4DbF 06TPqMS5BZiKbyz3yQxFpvtSAjWlKT6ZNwBdtsA+U52+xF3U91kKPWnREHFRq89+DVay 2AAw== 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=WYgOE8wO5XuTGZO1NeXmYbFdpl9KbQb+/TfyPYq4FMM=; b=DLknT9u/rnA7G6z2Y2n1Oq3KuD/uD4TX8c7mwyVKS5TAiswAgVSYRTAKjir0tqPWgz 5o1zndGj00s6tuu4YdxgG64dJS8ynKeQV24pjOZBobFnzxXpP9c61/hS5Cra84ZoSqQg cd391HTvhQLQYF8DZV8/T+XC6mIbAmbAnDZVQSbK1/5cqr5HD6xL/f7XLoFxOsAKNHfz 8JgAI0mQooyL6WJRdoyTbbeUQTBSzYxT0S1rbbap/v8wuK/iWVOfGkyZvs5JIPp0nx8S 70WajEaKPm16TFe5+cUg+dKA19p+AvhiTBPp6wEDFXFd2MpCb8PlwhrFr6AbHKFlhTYG 0pnw== 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 pv8si2216789ejb.300.2021.01.21.12.38.08; Thu, 21 Jan 2021 12:38:32 -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 S1727248AbhAUUhB (ORCPT + 99 others); Thu, 21 Jan 2021 15:37:01 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:38762 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727738AbhAUHxB (ORCPT ); Thu, 21 Jan 2021 02:53:01 -0500 X-UUID: 8a517e9c67fd4e4d827d11f90b4bfc9d-20210121 X-UUID: 8a517e9c67fd4e4d827d11f90b4bfc9d-20210121 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] 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 213492092; Thu, 21 Jan 2021 15:52:00 +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; Thu, 21 Jan 2021 15:51:53 +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 15:51:53 +0800 From: Hailong Fan To: Sean Wang , Linus Walleij , Matthias Brugger CC: , , , , , Nicolas Boichat , , , , , , Hailong Fan Subject: [PATCH RESEND] pinctrl: mediatek: Fix trigger type setting follow for unexpected interrupt Date: Thu, 21 Jan 2021 15:51:49 +0800 Message-ID: <20210121075149.1310-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 --- Resend since some server reject. --- 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