gpio: tegra: enable bank irq for wakeup based on wake depth
Laxman Dewangan [Fri, 8 Feb 2013 15:15:06 +0000 (20:15 +0530)]
Eanble/disable the bank irq wakes based on wake-depth which
directly related to the number of gpios on that bank are
wake enabled/disabled.

bug 1230573

Change-Id: I94fc8cb8dac890bdd3a07e82ad9d5a58004d6b82
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/198804
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>

drivers/gpio/gpio-tegra.c

index 72107bf..59beb13 100644 (file)
@@ -80,6 +80,7 @@ struct tegra_gpio_bank {
        u32 int_enb[4];
        u32 int_lvl[4];
        u32 wake_enb[4];
+       int wake_depth;
 #endif
 };
 
@@ -424,7 +425,21 @@ static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
        }
 
        /* LP1 enable for bank interrupt */
-       ret = tegra_update_lp1_irq_wake(bank->irq, enable);
+       if (enable) {
+               if (bank->wake_depth++ == 0) {
+                       ret = tegra_update_lp1_irq_wake(bank->irq, enable);
+                       if (ret)
+                               bank->wake_depth = 0;
+               }
+       } else {
+               if (bank->wake_depth == 0) {
+                       WARN(1, "Unbalanced IRQ %d wake disable\n", bank->irq);
+               } else if (--bank->wake_depth == 0) {
+                       ret = tegra_update_lp1_irq_wake(bank->irq, enable);
+                       if (ret)
+                               bank->wake_depth = 1;
+               }
+       }
        if (ret)
                pr_err("Failed gpio lp1 %s for irq=%d, error=%d\n",
                        (enable ? "enable" : "disable"), bank->irq, ret);