Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3117736pxm; Mon, 28 Feb 2022 12:23:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwprv5Vp3g0sb72fFRh5Cqg1KZxvLbvNCYtDoissaZDUDyQ/y2p97eJy3RodxcDePitfPr9 X-Received: by 2002:a17:90b:2347:b0:1bc:5def:eaaa with SMTP id ms7-20020a17090b234700b001bc5defeaaamr18401495pjb.130.1646079819688; Mon, 28 Feb 2022 12:23:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079819; cv=none; d=google.com; s=arc-20160816; b=Yn6yZHQTAma3ROAPuz8OLZGneq4fZvdJX80R0ISF2BemrI3ECL05jfha8loHdTi6Az PT4bLB9gf0mqCol4B2vGLT5socXmvI8tqaLa3nrdxPtBvw9LTCd84L4Z3DnbjO1HQjnM ACu5sr3Z+lf41LrddcMDbQmeELgmBh7WzGX26OrWFk/wPaAxeukQ839/1Whp7MWcs0GY 5TqE9yjSdaD8eUmL9DbYOOztgaCgPEyWPounboLH8NnMXTJBPY1QD8fj+rxOkOe3/Rf6 1vnLb3YMwc7dOZO5qeg2lcTk8T9R7b7/yumZeaIu5xwzxCalvmTYo6B7r28Mu6S1BMAh cwzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7Lo8FzuW/zoi/xPX6nhuXRXNKKBPz4/DBXRcpwodY0Y=; b=IwZKRc0cAktwLS9pwislD6sRcbm1yDWTDUdvPQSMfdtnl2xaSz+PHu1JcnEcYKp/fK suWcJzoaukDC8J+264A3KqAknCPZ75LSlSLDgC8GHMaJWZHajGHAdbCNQtn1N15UcUc8 ZBz8FN7NZDJgcH1eVzkTeZU5Rcw9cPJyt+6Ya9lB4cuamlNShcrYkHLn93pMCSQNrHV+ c6uP27qsr2H0Uf1X+xZEb9bQSdEWRiDmnzN4EX5EGzYozX0UPBkVMdOnd/o5GKA2KMXz Ju9gbIgHyYmMknVsZBcCDzUdlr11Qo2YhgSAkPi+rhEwz7Fh124L6mrzVJwniqMtww8N zjQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aQzvYMVf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w18-20020a1709027b9200b001516b8bdb16si3369909pll.365.2022.02.28.12.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:23:39 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aQzvYMVf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8EC251A39D7; Mon, 28 Feb 2022 11:42:38 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240493AbiB1SDh (ORCPT + 99 others); Mon, 28 Feb 2022 13:03:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239784AbiB1Rxc (ORCPT ); Mon, 28 Feb 2022 12:53:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23DBEAC068; Mon, 28 Feb 2022 09:40:57 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DDC48B815AB; Mon, 28 Feb 2022 17:40:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41D2FC340E7; Mon, 28 Feb 2022 17:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646070039; bh=urQX6y50ENfkDfckR2XgPPLuEaOQejttoMPgSiW3WW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aQzvYMVfptxAMrb/TWomR0D7fDydFlyjxt6knVd9Ghc4liJu47rAiz7mq8uqhnl/w lqI24Umd+KwYomiKg+dCJbRxRSlT9bfd9F4q80e05S51+0+FtFC8qDHxVqJJgD/kjZ wNx/rQIhci+pshCs/mCEeY4oYN/0nn3ryx2hs1b4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guillaume Savaton , Samuel Holland , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.15 086/139] gpio: rockchip: Reset int_bothedge when changing trigger Date: Mon, 28 Feb 2022 18:24:20 +0100 Message-Id: <20220228172356.701598093@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172347.614588246@linuxfoundation.org> References: <20220228172347.614588246@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Samuel Holland [ Upstream commit 7920af5c826cb4a7ada1ae26fdd317642805adc2 ] With v2 hardware, an IRQ can be configured to trigger on both edges via a bit in the int_bothedge register. Currently, the driver sets this bit when changing the trigger type to IRQ_TYPE_EDGE_BOTH, but fails to reset this bit if the trigger type is later changed to something else. This causes spurious IRQs, and when using gpio-keys with wakeup-event-action set to EV_ACT_(DE)ASSERTED, those IRQs translate into spurious wakeups. Fixes: 3bcbd1a85b68 ("gpio/rockchip: support next version gpio controller") Reported-by: Guillaume Savaton Tested-by: Guillaume Savaton Signed-off-by: Samuel Holland Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpio-rockchip.c | 56 +++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index ce63cbd14d69a..24155c038f6d0 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -410,10 +410,8 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) level = rockchip_gpio_readl(bank, bank->gpio_regs->int_type); polarity = rockchip_gpio_readl(bank, bank->gpio_regs->int_polarity); - switch (type) { - case IRQ_TYPE_EDGE_BOTH: + if (type == IRQ_TYPE_EDGE_BOTH) { if (bank->gpio_type == GPIO_TYPE_V2) { - bank->toggle_edge_mode &= ~mask; rockchip_gpio_writel_bit(bank, d->hwirq, 1, bank->gpio_regs->int_bothedge); goto out; @@ -431,30 +429,34 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) else polarity |= mask; } - break; - case IRQ_TYPE_EDGE_RISING: - bank->toggle_edge_mode &= ~mask; - level |= mask; - polarity |= mask; - break; - case IRQ_TYPE_EDGE_FALLING: - bank->toggle_edge_mode &= ~mask; - level |= mask; - polarity &= ~mask; - break; - case IRQ_TYPE_LEVEL_HIGH: - bank->toggle_edge_mode &= ~mask; - level &= ~mask; - polarity |= mask; - break; - case IRQ_TYPE_LEVEL_LOW: - bank->toggle_edge_mode &= ~mask; - level &= ~mask; - polarity &= ~mask; - break; - default: - ret = -EINVAL; - goto out; + } else { + if (bank->gpio_type == GPIO_TYPE_V2) { + rockchip_gpio_writel_bit(bank, d->hwirq, 0, + bank->gpio_regs->int_bothedge); + } else { + bank->toggle_edge_mode &= ~mask; + } + switch (type) { + case IRQ_TYPE_EDGE_RISING: + level |= mask; + polarity |= mask; + break; + case IRQ_TYPE_EDGE_FALLING: + level |= mask; + polarity &= ~mask; + break; + case IRQ_TYPE_LEVEL_HIGH: + level &= ~mask; + polarity |= mask; + break; + case IRQ_TYPE_LEVEL_LOW: + level &= ~mask; + polarity &= ~mask; + break; + default: + ret = -EINVAL; + goto out; + } } rockchip_gpio_writel(bank, level, bank->gpio_regs->int_type); -- 2.34.1