mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: <linus.walleij@linaro.org>
Cc: <Shyam-sundar.S-k@amd.com>, <Basavaraj.Natikar@amd.com>,
	<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<regressions@lists.linux.dev>, <lucapgl2001@gmail.com>,
	Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH 1/3] pinctrl: amd: Clear `Less2secSts` and `Less10secSts` for GPIO0
Date: Tue, 29 Aug 2023 11:56:25 -0500	[thread overview]
Message-ID: <20230829165627.156542-2-mario.limonciello@amd.com> (raw)
In-Reply-To: <20230829165627.156542-1-mario.limonciello@amd.com>

On systems that don't program GPIO0 through _AEI may still control
the power button via this GPIO.  When the GPIO master controller
register has bit 15 configured for `EnWinBlueBtn` this will cause
GPIO 0 to behave differently. If the user presses the button for
less than 2 seconds or less than 10 seconds then it is expected
that interrupt status must be cleared by the GPIO driver.

Reported-by: Luca Pigliacampo <lucapgl2001@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217833
Fixes: a855724dc08b ("pinctrl: amd: Fix mistake in handling clearing pins at startup")
Link: https://www.amd.com/content/dam/amd/en/documents/archived-tech-docs/programmer-references/55072_AMD_Family_15h_Models_70h-7Fh_BKDG.pdf p948
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/pinctrl/pinctrl-amd.c | 9 +++++++++
 drivers/pinctrl/pinctrl-amd.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 74241b2ff21e..37d64fa55b66 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -590,6 +590,7 @@ static const struct irq_chip amd_gpio_irqchip = {
 	GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
+#define GPIO0_LESS_TIME	(BIT(GPIO0_LESS_2_OFF) | BIT(GPIO0_LESS_10_OFF))
 #define PIN_IRQ_PENDING	(BIT(INTERRUPT_STS_OFF) | BIT(WAKE_STS_OFF))
 
 static bool do_amd_gpio_irq_handler(int irq, void *dev_id)
@@ -610,6 +611,14 @@ static bool do_amd_gpio_irq_handler(int irq, void *dev_id)
 	status |= readl(gpio_dev->base + WAKE_INT_STATUS_REG0);
 	raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
 
+	/* check GPIO0 specifically for Less2 and Less10 */
+	regval = readl(gpio_dev->base);
+	if (regval & GPIO0_LESS_TIME) {
+		pm_pr_dbg("GPIO0 was pressed for less than %d seconds\n",
+			  regval & BIT(GPIO0_LESS_10_OFF) ? 10 : 2);
+		writel(regval | BIT(INTERRUPT_STS_OFF), gpio_dev->base);
+	}
+
 	/* Bit 0-45 contain the relevant status bits */
 	status &= (1ULL << 46) - 1;
 	regs = gpio_dev->base;
diff --git a/drivers/pinctrl/pinctrl-amd.h b/drivers/pinctrl/pinctrl-amd.h
index 34c5c3e71fb2..3ea9a5275845 100644
--- a/drivers/pinctrl/pinctrl-amd.h
+++ b/drivers/pinctrl/pinctrl-amd.h
@@ -45,6 +45,8 @@
 #define WAKECNTRL_Z_OFF			27
 #define INTERRUPT_STS_OFF		28
 #define WAKE_STS_OFF			29
+#define GPIO0_LESS_2_OFF		30
+#define GPIO0_LESS_10_OFF		31
 
 #define DB_TMR_OUT_MASK	0xFUL
 #define DB_CNTRl_MASK	0x3UL
-- 
2.34.1


  reply	other threads:[~2023-08-29 19:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 16:56 [PATCH 0/3] pinctrl-amd powerbtn handling regression Mario Limonciello
2023-08-29 16:56 ` Mario Limonciello [this message]
2023-08-29 16:56 ` [PATCH 2/3] pinctrl: amd: Add a module parameter to configure power button behavior Mario Limonciello
2023-08-29 16:56 ` [PATCH 3/3] pinctrl: amd: Add a quirk for Lenovo Ideapad 5 Mario Limonciello
2023-08-29 19:54   ` Hans de Goede
2023-08-29 21:37     ` Mario Limonciello
2023-08-30 15:37       ` Hans de Goede
2023-08-30 15:47         ` Mario Limonciello
2023-08-30 16:18           ` Hans de Goede
2023-08-31 17:53             ` Mario Limonciello
2023-09-12  7:08               ` Linus Walleij
2023-09-12  8:58                 ` Hans de Goede
2023-09-12 18:21                   ` Mario Limonciello
2023-09-13 21:21                     ` Mario Limonciello
2023-09-14  8:43                       ` Linus Walleij
2023-09-14  9:08                         ` Luca Pigliacampo
2023-09-14 14:38                           ` Mario Limonciello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230829165627.156542-2-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucapgl2001@gmail.com \
    --cc=regressions@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®