gpio/omap: disable debounce on idle
authorGrazvydas Ignotas <notasas@gmail.com>
Wed, 1 Feb 2012 13:10:52 +0000 (15:10 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Wed, 1 Feb 2012 22:14:16 +0000 (00:14 +0200)
After omap2_gpio_prepare_for_idle call it's not guaranteed that given
GPIO module will hit idle, so it might end up in active state but with
debounce clock disabled, which will break input functionality.

Disable debounce feature on idle to avoid this problem.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
drivers/gpio/gpio-omap.c

index 0b05629..4f8e8ba 100644 (file)
@@ -1347,9 +1347,19 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 
        for (i = min; i < gpio_bank_count; i++) {
                struct gpio_bank *bank = &gpio_bank[i];
+               void __iomem *reg;
                u32 l1 = 0, l2 = 0;
                int j;
 
+               /*
+                * Disable debounce since clock disable below will cause
+                * problems if GPIO module doesn't go idle for some reason.
+                */
+               if (bank->dbck_enable_mask != 0) {
+                       reg = bank->base + bank->regs->debounce_en;
+                       __raw_writel(0, reg);
+               }
+
                for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
                        clk_disable(bank->dbck);
 
@@ -1415,12 +1425,18 @@ void omap2_gpio_resume_after_idle(void)
                min = 1;
        for (i = min; i < gpio_bank_count; i++) {
                struct gpio_bank *bank = &gpio_bank[i];
+               void __iomem *reg;
                u32 l = 0, gen, gen0, gen1;
                int j;
 
                for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
                        clk_enable(bank->dbck);
 
+               if (bank->dbck_enable_mask != 0) {
+                       reg = bank->base + bank->regs->debounce_en;
+                       __raw_writel(bank->dbck_enable_mask, reg);
+               }
+
                if (!workaround_enabled)
                        continue;