Skip to content

Commit 01220c1

Browse files
maciejsszmigierogregkh
authored andcommitted
pinctrl: amd: Take suspend type into consideration which pins are non-wake
[ Upstream commit f31f33d ] Some laptops have pins which are a wake source for S0i3/S3 but which aren't a wake source for S4/S5 and which cause issues when left unmasked during hibernation (S4). For example HP EliteBook 855 G7 has pin #24 that causes instant wakeup (hibernation failure) if left unmasked (it is a wake source only for S0i3/S3). GPIO pin #24 on this platform is likely dedicated to WWAN XMM7360 modem since this pin triggers wake notify to WWAN modem's parent PCIe port. Fix this by considering a pin a wake source only if it is marked as one for the current suspend type (S0i3/S3 vs S4/S5). Since Z-wake pins only make sense at runtime these were excluded from both of suspend categories, so pins with only the Z-wake flag set are effectively treated as non-wake pins. Fixes: 2fff0b5 ("pinctrl: amd: Mask non-wake source pins with interrupt enabled at suspend") Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/d4b2d076366fdd08a0c1cd9b7ecd91dc95e07269.1736184752.git.mail@maciej.szmigiero.name Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3872b4e commit 01220c1

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

Diff for: drivers/pinctrl/pinctrl-amd.c

+21-6
Original file line numberDiff line numberDiff line change
@@ -908,12 +908,13 @@ static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
908908
return false;
909909
}
910910

911-
static int amd_gpio_suspend(struct device *dev)
911+
static int amd_gpio_suspend_hibernate_common(struct device *dev, bool is_suspend)
912912
{
913913
struct amd_gpio *gpio_dev = dev_get_drvdata(dev);
914914
struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
915915
unsigned long flags;
916916
int i;
917+
u32 wake_mask = is_suspend ? WAKE_SOURCE_SUSPEND : WAKE_SOURCE_HIBERNATE;
917918

918919
for (i = 0; i < desc->npins; i++) {
919920
int pin = desc->pins[i].number;
@@ -925,11 +926,11 @@ static int amd_gpio_suspend(struct device *dev)
925926
gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin * 4) & ~PIN_IRQ_PENDING;
926927

927928
/* mask any interrupts not intended to be a wake source */
928-
if (!(gpio_dev->saved_regs[i] & WAKE_SOURCE)) {
929+
if (!(gpio_dev->saved_regs[i] & wake_mask)) {
929930
writel(gpio_dev->saved_regs[i] & ~BIT(INTERRUPT_MASK_OFF),
930931
gpio_dev->base + pin * 4);
931-
pm_pr_dbg("Disabling GPIO #%d interrupt for suspend.\n",
932-
pin);
932+
pm_pr_dbg("Disabling GPIO #%d interrupt for %s.\n",
933+
pin, is_suspend ? "suspend" : "hibernate");
933934
}
934935

935936
raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
@@ -938,6 +939,16 @@ static int amd_gpio_suspend(struct device *dev)
938939
return 0;
939940
}
940941

942+
static int amd_gpio_suspend(struct device *dev)
943+
{
944+
return amd_gpio_suspend_hibernate_common(dev, true);
945+
}
946+
947+
static int amd_gpio_hibernate(struct device *dev)
948+
{
949+
return amd_gpio_suspend_hibernate_common(dev, false);
950+
}
951+
941952
static int amd_gpio_resume(struct device *dev)
942953
{
943954
struct amd_gpio *gpio_dev = dev_get_drvdata(dev);
@@ -961,8 +972,12 @@ static int amd_gpio_resume(struct device *dev)
961972
}
962973

963974
static const struct dev_pm_ops amd_gpio_pm_ops = {
964-
SET_LATE_SYSTEM_SLEEP_PM_OPS(amd_gpio_suspend,
965-
amd_gpio_resume)
975+
.suspend_late = amd_gpio_suspend,
976+
.resume_early = amd_gpio_resume,
977+
.freeze_late = amd_gpio_hibernate,
978+
.thaw_early = amd_gpio_resume,
979+
.poweroff_late = amd_gpio_hibernate,
980+
.restore_early = amd_gpio_resume,
966981
};
967982
#endif
968983

Diff for: drivers/pinctrl/pinctrl-amd.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@
8080
#define FUNCTION_MASK GENMASK(1, 0)
8181
#define FUNCTION_INVALID GENMASK(7, 0)
8282

83-
#define WAKE_SOURCE (BIT(WAKE_CNTRL_OFF_S0I3) | \
84-
BIT(WAKE_CNTRL_OFF_S3) | \
85-
BIT(WAKE_CNTRL_OFF_S4) | \
86-
BIT(WAKECNTRL_Z_OFF))
83+
#define WAKE_SOURCE_SUSPEND (BIT(WAKE_CNTRL_OFF_S0I3) | \
84+
BIT(WAKE_CNTRL_OFF_S3))
85+
#define WAKE_SOURCE_HIBERNATE BIT(WAKE_CNTRL_OFF_S4)
8786

8887
struct amd_function {
8988
const char *name;

0 commit comments

Comments
 (0)