From patchwork Mon Apr 23 09:14:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 8026 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6291423E23 for ; Mon, 23 Apr 2012 09:14:39 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2A51FA1822A for ; Mon, 23 Apr 2012 09:14:39 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so22452743iag.11 for ; Mon, 23 Apr 2012 02:14:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=7h87YC9WhgJEXeBsAq0QmJ9hDQwWZ4+KegUQZOwNQZM=; b=HNxFgU51YRxdvaZhVqQ+gDFCPb41tJCKzAbthVPs0QZ2Cu9YFOFCa8oIZoVFnGp+5s 7T/O2vGPK01v4Q35Iw6GLHwXvGEde8N4JB/JPC8auwsDZ1TwJpZ7yZ6h1Wit5WzFvZAz nXfrKfNmqeyw1S3vSK+nrQMDm3OtFoM+ekF0l8GhoHOmD7TiTKE+t1crbYAOs5SnR+KD q96KXBqU1R4+gNqHNmG2KWyihv64EN5/rb0/S1UltiefsvbFJ3jYuVQ2RPcp0ix2HSBa 3q154A/g2HYyyUSMBCH0z88B3B4MTwbm4UFfPzKSSgp+GPnIhe5BETIZMnMlelEQrIvb jT/A== Received: by 10.50.185.233 with SMTP id ff9mr5608824igc.55.1335172478940; Mon, 23 Apr 2012 02:14:38 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp97926ibt; Mon, 23 Apr 2012 02:14:38 -0700 (PDT) Received: by 10.213.29.6 with SMTP id o6mr638302ebc.107.1335172477769; Mon, 23 Apr 2012 02:14:37 -0700 (PDT) Received: from eu1sys200aog120.obsmtp.com (eu1sys200aog120.obsmtp.com. [207.126.144.149]) by mx.google.com with SMTP id c8si4197893eeo.94.2012.04.23.02.14.33 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 02:14:37 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.149 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.149; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.149 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob120.postini.com ([207.126.147.11]) with SMTP ID DSNKT5UdeJ9Ecvot9bhNS9brymrWs3S8i/s9@postini.com; Mon, 23 Apr 2012 09:14:37 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A67431AF; Mon, 23 Apr 2012 09:14:31 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 08E9824FD; Mon, 23 Apr 2012 09:14:31 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 8921224C07C; Mon, 23 Apr 2012 11:14:25 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 23 Apr 2012 11:14:30 +0200 From: Linus Walleij To: , Cc: Grant Likely , Philippe LANGLAIS , Rabin Vincent , Jonas Aberg , Lee Jones , Linus Walleij Subject: [PATCH 3/9] gpio/nomadik: fix spurious interrupts with SKE Date: Mon, 23 Apr 2012 11:14:27 +0200 Message-ID: <1335172467-27577-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlWpGafiWa0FhHUhbUILUD7+Mdw0zMPHRzPkqgrK1PMGk4VXihk2Y8DaihY3kw94d7mesAa From: Rabin Vincent If the pin is switching to altfunc, and there was an interrupt installed on it which has been lazy disabled, actually mask the interrupt to prevent spurious interrupts that would occur while the pin is under control of the peripheral. Only SKE does this. Signed-off-by: Rabin Vincent Reviewed-by: Srinidhi Kasagar Signed-off-by: Linus Walleij --- drivers/gpio/gpio-nomadik.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c index 45a0e0a..681daee 100644 --- a/drivers/gpio/gpio-nomadik.c +++ b/drivers/gpio/gpio-nomadik.c @@ -174,6 +174,36 @@ static void __nmk_gpio_set_mode_safe(struct nmk_gpio_chip *nmk_chip, } } +static void +nmk_gpio_disable_lazy_irq(struct nmk_gpio_chip *nmk_chip, unsigned offset) +{ + u32 falling = nmk_chip->fimsc & BIT(offset); + u32 rising = nmk_chip->rimsc & BIT(offset); + int gpio = nmk_chip->chip.base + offset; + int irq = NOMADIK_GPIO_TO_IRQ(gpio); + struct irq_data *d = irq_get_irq_data(irq); + + if (!rising && !falling) + return; + + if (!d || !irqd_irq_disabled(d)) + return; + + if (rising) { + nmk_chip->rimsc &= ~BIT(offset); + writel_relaxed(nmk_chip->rimsc, + nmk_chip->addr + NMK_GPIO_RIMSC); + } + + if (falling) { + nmk_chip->fimsc &= ~BIT(offset); + writel_relaxed(nmk_chip->fimsc, + nmk_chip->addr + NMK_GPIO_FIMSC); + } + + dev_dbg(nmk_chip->chip.dev, "%d: clearing interrupt mask\n", gpio); +} + static void __nmk_config_pin(struct nmk_gpio_chip *nmk_chip, unsigned offset, pin_cfg_t cfg, bool sleep, unsigned int *slpmregs) { @@ -240,6 +270,15 @@ static void __nmk_config_pin(struct nmk_gpio_chip *nmk_chip, unsigned offset, } /* + * If the pin is switching to altfunc, and there was an interrupt + * installed on it which has been lazy disabled, actually mask the + * interrupt to prevent spurious interrupts that would occur while the + * pin is under control of the peripheral. Only SKE does this. + */ + if (af != NMK_GPIO_ALT_GPIO) + nmk_gpio_disable_lazy_irq(nmk_chip, offset); + + /* * If we've backed up the SLPM registers (glitch workaround), modify * the backups since they will be restored. */