From 38d42bd66effb64eea4268c8a0ded2afc055afa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=85=E6=AC=A2?= Date: Mon, 18 Mar 2024 10:34:21 +0800 Subject: [PATCH] [PATCH] driver:gpio:fix edge interrupt miss after str the Senario is gpio is config as both egde trigger and wakeup interrupt, the system entry suspend and this gpio wakeup the system, and the polarity will be toggle in dwapb_do_irq, but after that dwapb_gpio_resume will overwirte the polarity, make toggle miss, so if as wakeup int ,should not do resum --- drivers/gpio/gpio-dwapb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 3a9037055..e1438955d 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -775,6 +775,7 @@ static int dwapb_gpio_suspend(struct device *dev) static int dwapb_gpio_resume(struct device *dev) { struct dwapb_gpio *gpio = dev_get_drvdata(dev); + struct dwapb_context *ctx = gpio->ports[0].ctx; struct gpio_chip *gc = &gpio->ports[0].gc; unsigned long flags; int i, err; @@ -788,6 +789,7 @@ static int dwapb_gpio_resume(struct device *dev) spin_lock_irqsave(&gc->bgpio_lock, flags); for (i = 0; i < gpio->nr_ports; i++) { unsigned int offset; + unsigned int int_pol,preserve_bit,resume_bit; unsigned int idx = gpio->ports[i].idx; struct dwapb_context *ctx = gpio->ports[i].ctx; @@ -803,7 +805,11 @@ static int dwapb_gpio_resume(struct device *dev) /* Only port A can provide interrupts */ if (idx == 0) { dwapb_write(gpio, GPIO_INTTYPE_LEVEL, ctx->int_type); - dwapb_write(gpio, GPIO_INT_POLARITY, ctx->int_pol); + int_pol = dwapb_read(gpio, GPIO_INT_POLARITY); + preserve_bit = int_pol & ctx->wake_en; + resume_bit = ctx->int_pol & (~ctx->wake_en); + int_pol = preserve_bit | resume_bit; + dwapb_write(gpio, GPIO_INT_POLARITY, int_pol); dwapb_write(gpio, GPIO_PORTA_DEBOUNCE, ctx->int_deb); dwapb_write(gpio, GPIO_INTEN, ctx->int_en); dwapb_write(gpio, GPIO_INTMASK, ctx->int_mask);