From 89db94825447a03f17e03c0a6c8840a0a22cf155 Mon Sep 17 00:00:00 2001 From: Jouni Hogander Date: Wed, 10 Dec 2008 17:35:24 -0800 Subject: ARM: OMAP: Enable GPIO debounce clock only when debounce is enabled v3 This patch changes gpio "driver" to enable debounce clock for gpio-bank only when debounce is enabled for some gpio in that bank. Gpio functional clocks are also renamed in clock tree, gpioX_fck -> gpioX_dbck. This patch triggers problem with gpio wake-up and Omap3. Gpios in PER domain aren't capable to generate wake-up if PER domain is in sleep state. For this iopad wake-up should be used and needed pad configuration should be done. Enabling iopad wake-up for gpio pads is left for bootloader or omap mux configuration in kernel. Signed-off-by: Jouni Hogander Acked-by: Paul Walmsley Signed-off-by: Tony Lindgren --- arch/arm/plat-omap/gpio.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'arch/arm/plat-omap/gpio.c') diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c index 424049d83fb..66e364738fb 100644 --- a/arch/arm/plat-omap/gpio.c +++ b/arch/arm/plat-omap/gpio.c @@ -152,6 +152,7 @@ struct gpio_bank { u32 level_mask; spinlock_t lock; struct gpio_chip chip; + struct clk *dbck; }; #define METHOD_MPUIO 0 @@ -484,10 +485,15 @@ 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 (cpu_is_omap34xx()) + enable ? clk_enable(bank->dbck) : clk_disable(bank->dbck); __raw_writel(val, reg); } @@ -1296,7 +1302,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 @@ -1310,9 +1315,7 @@ static int __init _omap_gpio_init(void) int i; int gpio = 0; struct gpio_bank *bank; -#if defined(CONFIG_ARCH_OMAP3) char clk_name[11]; -#endif initialized = 1; @@ -1367,12 +1370,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 @@ -1511,6 +1508,13 @@ static int __init _omap_gpio_init(void) } set_irq_chained_handler(bank->irq, gpio_irq_handler); set_irq_data(bank->irq, bank); + + if (cpu_is_omap34xx()) { + sprintf(clk_name, "gpio%d_dbck", i + 1); + bank->dbck = clk_get(NULL, clk_name); + if (IS_ERR(bank->dbck)) + printk(KERN_ERR "Could not get %s\n", clk_name); + } } /* Enable system clock for GPIO module. -- cgit v1.2.3