Skip to content

Commit 4e5a04b

Browse files
nakatolinusw
authored andcommitted
pinctrl: amd: disable and mask interrupts on probe
Some systems such as the Microsoft Surface Laptop 4 leave interrupts enabled and configured for use in sleep states on boot, which cause unexpected behaviour such as spurious wakes and failed resumes in s2idle states. As interrupts should not be enabled until they are claimed and explicitly enabled, disabling any interrupts mistakenly left enabled by firmware should be safe. Signed-off-by: Sachi King <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent c370bb4 commit 4e5a04b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drivers/pinctrl/pinctrl-amd.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,34 @@ static const struct pinconf_ops amd_pinconf_ops = {
840840
.pin_config_group_set = amd_pinconf_group_set,
841841
};
842842

843+
static void amd_gpio_irq_init(struct amd_gpio *gpio_dev)
844+
{
845+
struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
846+
unsigned long flags;
847+
u32 pin_reg, mask;
848+
int i;
849+
850+
mask = BIT(WAKE_CNTRL_OFF_S0I3) | BIT(WAKE_CNTRL_OFF_S3) |
851+
BIT(INTERRUPT_MASK_OFF) | BIT(INTERRUPT_ENABLE_OFF) |
852+
BIT(WAKE_CNTRL_OFF_S4);
853+
854+
for (i = 0; i < desc->npins; i++) {
855+
int pin = desc->pins[i].number;
856+
const struct pin_desc *pd = pin_desc_get(gpio_dev->pctrl, pin);
857+
858+
if (!pd)
859+
continue;
860+
861+
raw_spin_lock_irqsave(&gpio_dev->lock, flags);
862+
863+
pin_reg = readl(gpio_dev->base + i * 4);
864+
pin_reg &= ~mask;
865+
writel(pin_reg, gpio_dev->base + i * 4);
866+
867+
raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
868+
}
869+
}
870+
843871
#ifdef CONFIG_PM_SLEEP
844872
static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
845873
{
@@ -976,6 +1004,9 @@ static int amd_gpio_probe(struct platform_device *pdev)
9761004
return PTR_ERR(gpio_dev->pctrl);
9771005
}
9781006

1007+
/* Disable and mask interrupts */
1008+
amd_gpio_irq_init(gpio_dev);
1009+
9791010
girq = &gpio_dev->gc.irq;
9801011
girq->chip = &amd_gpio_irqchip;
9811012
/* This will let us handle the parent IRQ in the driver */

0 commit comments

Comments
 (0)