]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
OMAP3: GPIO: Enable debounce clock only when debounce is enabled v3.
authorJouni Hogander <jouni.hogander@nokia.com>
Thu, 25 Sep 2008 12:35:47 +0000 (15:35 +0300)
committerTony Lindgren <tony@atomide.com>
Thu, 25 Sep 2008 12:37:44 +0000 (15:37 +0300)
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 <jouni.hogander@nokia.com>
Acked-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/clock34xx.h
arch/arm/plat-omap/gpio.c

index 8ce7097544f52063ed61fb54bf222b80ad8ea52f..4adf78e2201ad70b55b61536f18b8cf78430207f 100644 (file)
@@ -2519,8 +2519,8 @@ static struct clk wkup_32k_fck = {
        .recalc         = &followparent_recalc,
 };
 
-static struct clk gpio1_fck = {
-       .name           = "gpio1_fck",
+static struct clk gpio1_dbck = {
+       .name           = "gpio1_dbck",
        .parent         = &wkup_32k_fck,
        .prcm_mod       = WKUP_MOD,
        .enable_reg     = CM_FCLKEN,
@@ -2797,8 +2797,8 @@ static struct clk per_32k_alwon_fck = {
        .recalc         = &followparent_recalc,
 };
 
-static struct clk gpio6_fck = {
-       .name           = "gpio6_fck",
+static struct clk gpio6_dbck = {
+       .name           = "gpio6_dbck",
        .parent         = &per_32k_alwon_fck,
        .prcm_mod       = OMAP3430_PER_MOD,
        .enable_reg     = CM_FCLKEN,
@@ -2809,8 +2809,8 @@ static struct clk gpio6_fck = {
        .recalc         = &followparent_recalc,
 };
 
-static struct clk gpio5_fck = {
-       .name           = "gpio5_fck",
+static struct clk gpio5_dbck = {
+       .name           = "gpio5_dbck",
        .parent         = &per_32k_alwon_fck,
        .prcm_mod       = OMAP3430_PER_MOD,
        .enable_reg     = CM_FCLKEN,
@@ -2821,8 +2821,8 @@ static struct clk gpio5_fck = {
        .recalc         = &followparent_recalc,
 };
 
-static struct clk gpio4_fck = {
-       .name           = "gpio4_fck",
+static struct clk gpio4_dbck = {
+       .name           = "gpio4_dbck",
        .parent         = &per_32k_alwon_fck,
        .prcm_mod       = OMAP3430_PER_MOD,
        .enable_reg     = CM_FCLKEN,
@@ -2833,8 +2833,8 @@ static struct clk gpio4_fck = {
        .recalc         = &followparent_recalc,
 };
 
-static struct clk gpio3_fck = {
-       .name           = "gpio3_fck",
+static struct clk gpio3_dbck = {
+       .name           = "gpio3_dbck",
        .parent         = &per_32k_alwon_fck,
        .prcm_mod       = OMAP3430_PER_MOD,
        .enable_reg     = CM_FCLKEN,
@@ -2845,8 +2845,8 @@ static struct clk gpio3_fck = {
        .recalc         = &followparent_recalc,
 };
 
-static struct clk gpio2_fck = {
-       .name           = "gpio2_fck",
+static struct clk gpio2_dbck = {
+       .name           = "gpio2_dbck",
        .parent         = &per_32k_alwon_fck,
        .prcm_mod       = OMAP3430_PER_MOD,
        .enable_reg     = CM_FCLKEN,
@@ -3545,7 +3545,7 @@ static struct clk *onchip_34xx_clks[] __initdata = {
        &usim_fck,
        &gpt1_fck,
        &wkup_32k_fck,
-       &gpio1_fck,
+       &gpio1_dbck,
        &wdt2_fck,
        &wkup_l4_ick,
        &usim_ick,
@@ -3567,11 +3567,11 @@ static struct clk *onchip_34xx_clks[] __initdata = {
        &gpt8_fck,
        &gpt9_fck,
        &per_32k_alwon_fck,
-       &gpio6_fck,
-       &gpio5_fck,
-       &gpio4_fck,
-       &gpio3_fck,
-       &gpio2_fck,
+       &gpio6_dbck,
+       &gpio5_dbck,
+       &gpio4_dbck,
+       &gpio3_dbck,
+       &gpio2_dbck,
        &wdt3_fck,
        &per_l4_ick,
        &gpio6_ick,
index ac5561657d7a7b3dfbec1137c577b752dfba7818..2d630230fcffe290d17ee623edba275880859159 100644 (file)
@@ -151,6 +151,7 @@ struct gpio_bank {
        u32 level_mask;
        spinlock_t lock;
        struct gpio_chip chip;
+       struct clk *dbck;
 };
 
 #define METHOD_MPUIO           0
@@ -483,10 +484,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);
 }
@@ -1298,7 +1304,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
 
@@ -1312,9 +1317,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;
 
@@ -1369,12 +1372,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
@@ -1513,6 +1510,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.