spin_lock_irqsave(&bank->lock, flags);
 
+       if (!bank->enabled_non_wakeup_gpios)
+               goto update_gpio_context_count;
+
        /*
         * Only edges can generate a wakeup event to the PRCM.
         *
        __raw_writel(bank->context.risingdetect,
                     bank->base + bank->regs->risingdetect);
 
-       if (!bank->workaround_enabled) {
-               spin_unlock_irqrestore(&bank->lock, flags);
-               return 0;
-       }
-
        if (bank->get_context_loss_count) {
                context_lost_cnt_after =
                        bank->get_context_loss_count(bank->dev);
                }
        }
 
+       if (!bank->workaround_enabled) {
+               spin_unlock_irqrestore(&bank->lock, flags);
+               return 0;
+       }
+
        __raw_writel(bank->context.fallingdetect,
                        bank->base + bank->regs->fallingdetect);
        __raw_writel(bank->context.risingdetect,