public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] OMAP3: GPIO: Enable debounce clock only when debounce is enabled
@ 2008-09-12 10:51 Jouni Hogander
  2008-09-12 11:11 ` Daniel Stone
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Jouni Hogander @ 2008-09-12 10:51 UTC (permalink / raw)
  To: linux-omap

This patch changes gpio "driver" to enable debounce clock for
gpio-bank only when debounce is enabled for some gpio in that bank.

This patch obsoletes "PM: Dynamic GPIO clock handling" patch. Nasty
side effect is that gpios in per domain aren't capable to generate
wake-up if per domain is in sleep state. Anyway keeping dbcks enabled
all the time isn't either good way to workaround this problem. For
this we need to use iopad wake-up. Currently enabling iopad wakeup
mechanism for gpio pads is left for bootloader or kernel (depending
which one does the configuration)

Signed-off-by: Jouni Hogander <jouni.hogander@nokia.com>
---
 arch/arm/plat-omap/gpio.c |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 0e74103..da164d8 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -152,6 +152,9 @@ struct gpio_bank {
 	u32 level_mask;
 	spinlock_t lock;
 	struct gpio_chip chip;
+#if defined(CONFIG_ARCH_OMAP3)
+	struct clk *dbck
+#endif
 };
 
 #define METHOD_MPUIO		0
@@ -500,11 +503,16 @@ void omap_set_gpio_debounce(int gpio, int enable)
 	reg += OMAP24XX_GPIO_DEBOUNCE_EN;
 	val = __raw_readl(reg);
 
-	if (enable)
+	if (enable && !(val & l))
 		val |= l;
-	else
+	else if (!enable && val & l)
 		val &= ~l;
+	else
+		return;
 
+#if defined(CONFIG_ARCH_OMAP3)
+	enable ? clk_enable(bank->dbck) : clk_disable(bank->dbck);
+#endif
 	__raw_writel(val, reg);
 }
 EXPORT_SYMBOL(omap_set_gpio_debounce);
@@ -1315,7 +1323,6 @@ static struct clk * gpio5_fck;
 #endif
 
 #if defined(CONFIG_ARCH_OMAP3)
-static struct clk *gpio_fclks[OMAP34XX_NR_GPIOS];
 static struct clk *gpio_iclks[OMAP34XX_NR_GPIOS];
 #endif
 
@@ -1386,12 +1393,6 @@ static int __init _omap_gpio_init(void)
 				printk(KERN_ERR "Could not get %s\n", clk_name);
 			else
 				clk_enable(gpio_iclks[i]);
-			sprintf(clk_name, "gpio%d_fck", i + 1);
-			gpio_fclks[i] = clk_get(NULL, clk_name);
-			if (IS_ERR(gpio_fclks[i]))
-				printk(KERN_ERR "Could not get %s\n", clk_name);
-			else
-				clk_enable(gpio_fclks[i]);
 		}
 	}
 #endif
@@ -1531,6 +1532,13 @@ static int __init _omap_gpio_init(void)
 		}
 		set_irq_chained_handler(bank->irq, gpio_irq_handler);
 		set_irq_data(bank->irq, bank);
+
+#if defined(CONFIG_ARCH_OMAP3)
+		sprintf(clk_name, "gpio%d_fck", i + 1);
+		bank->dbck = clk_get(NULL, clk_name);
+		if (IS_ERR(bank->dbck))
+			printk(KERN_ERR "Could not get %s\n", clk_name);
+#endif
 	}
 
 	/* Enable system clock for GPIO module.
-- 
1.5.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-09-25 10:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-12 10:51 [RFC] OMAP3: GPIO: Enable debounce clock only when debounce is enabled Jouni Hogander
2008-09-12 11:11 ` Daniel Stone
2008-09-12 14:34 ` Paul Walmsley
2008-09-15  8:52 ` [PATCH] " Jouni Hogander
2008-09-16 10:58   ` Kevin Hilman
2008-09-16 12:16     ` [PATCH] OMAP3: GPIO: Enable debounce clock only when debounce is enabled v2 Jouni Hogander
2008-09-16 12:19       ` Paul Walmsley
2008-09-16 12:32         ` Högander Jouni
2008-09-16 12:36           ` Paul Walmsley
2008-09-16 12:51             ` [PATCH] OMAP3: GPIO: Enable debounce clock only when debounce is enabled v3 Jouni Hogander
2008-09-16 12:59               ` Paul Walmsley
2008-09-25 10:28                 ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox