Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2746863pxb; Sun, 24 Jan 2021 19:23:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXNhO78ujwdQi+LLbBcLOrQJWSq7Ro8E4O18Whh7A7telZ7auyIAUJZiowE/N/p0BwfY6+ X-Received: by 2002:a05:6402:22e9:: with SMTP id dn9mr550501edb.61.1611544983292; Sun, 24 Jan 2021 19:23:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611544983; cv=none; d=google.com; s=arc-20160816; b=Am8v4df8oeibKAOgOI8EJ5//8oYmua6L5gsraNlO4y+B7+bPlqzC83Ao3mYOL2CHMa lorswgsaTHcL1udXkyFpKk47hH0hHQUreXnK0uvZWUu39HcmRdpjCDZ1IWcsJuY9eHH7 LpcHOtFwgS/IpoQanzeieLq6KZDUsCCnRZHy0D9MnycWZcqsaEFmk7EPs1MX6ssHnJQZ SYEhsBp+jj6R098LYhmUXX4vNU+lO/MsDJqfRibFfSFgY12ZLXBzqd3bvlY0XUx+QQuv HZFymsw9ImoAIQmR9t0zgKvSxT4u39hcVF8NnxbHeJxx87UyOPf7uPdkN6O39qLMRLdG 9ivg== 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=RP2FDZ6MbkDyNos4OcHZtMxPdcAnTMSv91ha//g6Zv8=; b=gUEzGw0RkfvlcRDnMt0IoxKgmYUyM5mhQIJVTMR3UKIHiCQM3yEUnZfyDo9IZ/l/K/ cFIgStqaAoxVpnxo8XfG/Cxlx75VT5HpKUFTWTnAvvbemNKX6ziyQgsYq/w4isrEzKXL +REkJVpsY68T5z80yQWv7M1/JxzcH9xSjpLBeXRgGWXwXLweCd7X6AjP+4bYKhWxoS+o aBK+SijAj1k2Un2Ie+61KRl9H1AE34ExrT4h+66p6XqgFAsJFNgayuYS3DggEiPPGj8U 8RaO9KL3PzlQTnOnOv4BfGJyfIfJIU2mM6cX8Ua5gHafovaqng66SXXKcupt8lXadA6H irvw== 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 f12si6876492edx.584.2021.01.24.19.22.40; Sun, 24 Jan 2021 19:23:03 -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 S1726873AbhAYDUp (ORCPT + 99 others); Sun, 24 Jan 2021 22:20:45 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:44797 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726692AbhAYDUi (ORCPT ); Sun, 24 Jan 2021 22:20:38 -0500 X-UUID: 9df3b9b45e5240e1a1c1f28f0a7a4257-20210125 X-UUID: 9df3b9b45e5240e1a1c1f28f0a7a4257-20210125 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] 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 333410447; Mon, 25 Jan 2021 11:19:52 +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; Mon, 25 Jan 2021 11:19:51 +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:19:51 +0800 From: Hailong Fan To: Sean Wang , Linus Walleij , Matthias Brugger CC: , , , , , Nicolas Boichat , , , , , , Hailong Fan Subject: [PATCH v2] pinctrl: mediatek: Fix trigger type setting follow for unexpected interrupt Date: Mon, 25 Jan 2021 11:19:46 +0800 Message-ID: <20210125031946.1882-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 Reviewed-by: Nicolas Boichat --- 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