Received: by 10.223.176.46 with SMTP id f43csp2879774wra; Mon, 22 Jan 2018 05:04:39 -0800 (PST) X-Google-Smtp-Source: AH8x224N1r7r2RfP2Dc0nrekOMgJzDxvuuCCML2+4jeyIhwgtyD5QURp6EcYSvMS7SHlT/PB2UQq X-Received: by 10.98.87.201 with SMTP id i70mr8540652pfj.143.1516626279394; Mon, 22 Jan 2018 05:04:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516626279; cv=none; d=google.com; s=arc-20160816; b=dB4QJL9HvkxeY8v4i6L3WV93caKdzwN+fAmK48j7MBDcmDJ6Rnhh15AQgo3DzI5opc D2K0DWn7y76onpaTU+PHKHmDuTkHIP/5L0ybkSUAANrQS0fJ5oaSB0FbgjRsKdA+U+1i DIekGsZkNMLG9Jj1rlUfMfESYS5irL78M6I3Djwfm4lR2t0TOj3EL5TRtLAo6eO0YkbJ t4TtN37Kng4pr5EeBIUlSLzrYRqExtbUnakaRVeMDT01a6DZG5OnbHhWzV6z0U1pEPDn k7IcPQPPHjKfrRv7XnT34zaDHRlvvWOAp494/hk07DjzrsW9VWziye4X+JH1m0dG88kQ C8nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=l6/R6dk0/oTmNEcYV9B8stHa3pMdtNT0LTzGwthfNwk=; b=IiaW7GSH56SMtKEu4ZaoJGYRvSdNw9VLBo/XFTyRSDHpqT5JpoSin+cg0gHUH1mEBf VDIvuHr+EgVG3XOEShrkG0OvjCdcmuIU80IkuJrS3dG2Hbunvntf8AogPV+G2JZwBl5f A4OUDe+zLyL3xs2HpaNB/Pg6JWXlnlC7AMTJxwHS9kHsF42R540b+GU93C3sKqLxe6yv H/a14kpCTS5unoXw8T9INxf/RMhlobnQAxI6EtNGjOnZartoDK4IFUyVUrsC2Rg4xxHb 2F3wAFnwo4ik2lq6W5dml9rr9lm2DatGFgetCsedu2K1pybg9Se4VmofLlsP4c6F9w3C pPwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=j8keIzZS; dkim=pass header.i=@codeaurora.org header.s=default header.b=DFUA4xXU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x16si157147pfi.213.2018.01.22.05.04.25; Mon, 22 Jan 2018 05:04:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=j8keIzZS; dkim=pass header.i=@codeaurora.org header.s=default header.b=DFUA4xXU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751207AbeAVNEE (ORCPT + 99 others); Mon, 22 Jan 2018 08:04:04 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:56434 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbeAVNEC (ORCPT ); Mon, 22 Jan 2018 08:04:02 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 39F68607A4; Mon, 22 Jan 2018 13:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516626242; bh=+EM4JtulHA4A39GuPBR7zFc8iF3KI0UHadWF39e2p7w=; h=From:To:Cc:Subject:Date:From; b=j8keIzZSeLFuUiYJKJApjj9b7FWaFFAfMd6Dkor7mWrZQZuVy2vPVckExu76dw5H1 gMBgGUsxz0cu0UGerxDTvPfBpIOi4ggMDmClLaAcSz20wo4Bi5rc8mWNP4+Jn8Jaln TSso9CdYibR/4zW7I3DSrnFLHur+BR271A0/fd5Y= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from sramana-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sramana@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B0663601A1; Mon, 22 Jan 2018 13:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516626241; bh=+EM4JtulHA4A39GuPBR7zFc8iF3KI0UHadWF39e2p7w=; h=From:To:Cc:Subject:Date:From; b=DFUA4xXUYVUq9wq8Tn/iypQyu4qBaZ7NAJUftF6I8vsb9rn8UfqSEChcpKRC1baDT OoZ5pBo31xDyqaNsILU7x+Gu3c07/KQbG/07VKGdSNG0v9ZI2RuUAI26QnqMqOuVmc DM8mtstJldrdYfLCxiec8FoUgzt7FXf1qBKFlUcA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B0663601A1 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sramana@codeaurora.org From: Srinivas Ramana To: bjorn.andersson@linaro.org, linus.walleij@linaro.org, timur@codeaurora.org, sboyd@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Ramana Subject: [PATCH] pinctrl: qcom: Add irq_enable callback for msm gpio Date: Mon, 22 Jan 2018 18:33:28 +0530 Message-Id: <1516626208-5655-1-git-send-email-sramana@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce the irq_enable callback which will be same as irq_unmask except that it will also clear the status bit before unmask. This will help in clearing any erroneous interrupts that would have got latched when the interrupt is not in use. There may be devices like UART which can use the same gpio line for data rx as well as a wakeup gpio when in suspend. The data that was flowing on the line may latch the interrupt and when we enable the interrupt before going to suspend, this would trigger the unexpected interrupt. This change helps clearing the interrupt so that these unexpected interrupts gets cleared. Signed-off-by: Srinivas Ramana --- drivers/pinctrl/qcom/pinctrl-msm.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index 7a960590ecaa..de7c65c15f9e 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -610,6 +610,36 @@ static void msm_gpio_irq_mask(struct irq_data *d) raw_spin_unlock_irqrestore(&pctrl->lock, flags); } +static void msm_gpio_irq_enable(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct msm_pinctrl *pctrl = gpiochip_get_data(gc); + const struct msm_pingroup *g; + unsigned long flags; + u32 val; + + g = &pctrl->soc->groups[d->hwirq]; + + raw_spin_lock_irqsave(&pctrl->lock, flags); + + /* + * clear the interrupt status bit before unmask to avoid + * any erroneous interrupts that would have got latched + * when the intterupt is not in use. + */ + val = readl(pctrl->regs + g->intr_status_reg); + val &= ~BIT(g->intr_status_bit); + writel(val, pctrl->regs + g->intr_status_reg); + + val = readl(pctrl->regs + g->intr_cfg_reg); + val |= BIT(g->intr_enable_bit); + writel(val, pctrl->regs + g->intr_cfg_reg); + + set_bit(d->hwirq, pctrl->enabled_irqs); + + raw_spin_unlock_irqrestore(&pctrl->lock, flags); +} + static void msm_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); @@ -767,6 +797,7 @@ static int msm_gpio_irq_set_wake(struct irq_data *d, unsigned int on) static struct irq_chip msm_gpio_irq_chip = { .name = "msmgpio", + .irq_enable = msm_gpio_irq_enable, .irq_mask = msm_gpio_irq_mask, .irq_unmask = msm_gpio_irq_unmask, .irq_ack = msm_gpio_irq_ack, -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.