diff mbox

[RFC,09/10] OMAP: GPIO: cleanup omap_gpio_free and triggering functions

Message ID 1305546104-1511-10-git-send-email-tarun.kanti@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tarun Kanti DebBarma May 16, 2011, 11:41 a.m. UTC
We can get rid of ifdef / if checks of OMAP revision in set_24xx_gpio_triggering()
and omap_gpio_free().

Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Charulatha V <charu@ti.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/gpio.c |   38 ++++++++------------------------------
 1 files changed, 8 insertions(+), 30 deletions(-)

Comments

charu@ti.com May 18, 2011, 11:03 a.m. UTC | #1
Tarun,

On Mon, May 16, 2011 at 17:11, Tarun Kanti DebBarma <tarun.kanti@ti.com> wrote:
> We can get rid of ifdef / if checks of OMAP revision in set_24xx_gpio_triggering()
> and omap_gpio_free().
>
> Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> Cc: Charulatha V <charu@ti.com>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Kevin Hilman <khilman@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> ---
>  arch/arm/plat-omap/gpio.c |   38 ++++++++------------------------------
>  1 files changed, 8 insertions(+), 30 deletions(-)
>
> diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
> index 714626a..bc07559 100644
> --- a/arch/arm/plat-omap/gpio.c
> +++ b/arch/arm/plat-omap/gpio.c
> @@ -269,15 +269,9 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
>                        bank->enabled_non_wakeup_gpios &= ~gpio_bit;
>        }
>
> -       if (cpu_is_omap44xx()) {
> -               bank->level_mask =
> -                       __raw_readl(bank->base + OMAP4_GPIO_LEVELDETECT0) |
> -                       __raw_readl(bank->base + OMAP4_GPIO_LEVELDETECT1);
> -       } else {
> -               bank->level_mask =
> -                       __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0) |
> -                       __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
> -       }
> +       bank->level_mask =
> +               __raw_readl(bank->base + bank->regs->leveldetect0) |
> +               __raw_readl(bank->base + bank->regs->leveldetect1);
>  }
>  #endif
>
> @@ -609,29 +603,13 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
>  {
>        struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
>        unsigned long flags;
> +       void __iomem *reg;
>
>        spin_lock_irqsave(&bank->lock, flags);
> -#ifdef CONFIG_ARCH_OMAP16XX
> -       if (bank->method == METHOD_GPIO_1610) {
> -               /* Disable wake-up during idle for dynamic tick */
> -               void __iomem *reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
> -               __raw_writel(1 << offset, reg);
> -       }
> -#endif
> -#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
> -       if (bank->method == METHOD_GPIO_24XX) {
> -               /* Disable wake-up during idle for dynamic tick */
> -               void __iomem *reg = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
> -               __raw_writel(1 << offset, reg);
> -       }
> -#endif
> -#ifdef CONFIG_ARCH_OMAP4
> -       if (bank->method == METHOD_GPIO_44XX) {
> -               /* Disable wake-up during idle for dynamic tick */
> -               void __iomem *reg = bank->base + OMAP4_GPIO_IRQWAKEN0;
> -               __raw_writel(1 << offset, reg);
> -       }
> -#endif
> +       /* Disable wake-up during idle for dynamic tick */
> +       reg = bank->base + bank->regs->wkupclear;

Consider using bank->wake_clear instead of extracting reg here.

> +
> +       __raw_writel(1 << offset, reg);

This is wrong on OMAP15xx & OMAP7xx as wkupclear is NULL.

-V Charulatha

>        bank->mod_usage &= ~(1 << offset);
>
>        if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {
> --
> 1.6.0.4
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kevin Hilman May 19, 2011, 4:06 p.m. UTC | #2
Tarun Kanti DebBarma <tarun.kanti@ti.com> writes:

> We can get rid of ifdef / if checks of OMAP revision in set_24xx_gpio_triggering()
> and omap_gpio_free().
>
> Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> Cc: Charulatha V <charu@ti.com>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Kevin Hilman <khilman@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> ---
>  arch/arm/plat-omap/gpio.c |   38 ++++++++------------------------------
>  1 files changed, 8 insertions(+), 30 deletions(-)
>
> diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
> index 714626a..bc07559 100644
> --- a/arch/arm/plat-omap/gpio.c
> +++ b/arch/arm/plat-omap/gpio.c
> @@ -269,15 +269,9 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
>  			bank->enabled_non_wakeup_gpios &= ~gpio_bit;
>  	}
>  
> -	if (cpu_is_omap44xx()) {
> -		bank->level_mask =
> -			__raw_readl(bank->base + OMAP4_GPIO_LEVELDETECT0) |
> -			__raw_readl(bank->base + OMAP4_GPIO_LEVELDETECT1);
> -	} else {
> -		bank->level_mask =
> -			__raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0) |
> -			__raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
> -	}
> +	bank->level_mask =
> +		__raw_readl(bank->base + bank->regs->leveldetect0) |
> +		__raw_readl(bank->base + bank->regs->leveldetect1);

Please fold this part into patch 8/10 where the leveldetect* is
initially added.

>  }
>  #endif
>  
> @@ -609,29 +603,13 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
>  {
>  	struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
>  	unsigned long flags;
> +	void __iomem *reg;
>  
>  	spin_lock_irqsave(&bank->lock, flags);
> -#ifdef CONFIG_ARCH_OMAP16XX
> -	if (bank->method == METHOD_GPIO_1610) {
> -		/* Disable wake-up during idle for dynamic tick */
> -		void __iomem *reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
> -		__raw_writel(1 << offset, reg);
> -	}
> -#endif
> -#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
> -	if (bank->method == METHOD_GPIO_24XX) {
> -		/* Disable wake-up during idle for dynamic tick */
> -		void __iomem *reg = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
> -		__raw_writel(1 << offset, reg);
> -	}
> -#endif
> -#ifdef CONFIG_ARCH_OMAP4
> -	if (bank->method == METHOD_GPIO_44XX) {
> -		/* Disable wake-up during idle for dynamic tick */
> -		void __iomem *reg = bank->base + OMAP4_GPIO_IRQWAKEN0;
> -		__raw_writel(1 << offset, reg);
> -	}
> -#endif
> +	/* Disable wake-up during idle for dynamic tick */
> +	reg = bank->base + bank->regs->wkupclear;
> +
> +	__raw_writel(1 << offset, reg);


In addition to Charu's comments, please fold this into the patch where
wake_clear etc. are added.

Kevin


>  	bank->mod_usage &= ~(1 << offset);
>  
>  	if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 714626a..bc07559 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -269,15 +269,9 @@  static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
 			bank->enabled_non_wakeup_gpios &= ~gpio_bit;
 	}
 
-	if (cpu_is_omap44xx()) {
-		bank->level_mask =
-			__raw_readl(bank->base + OMAP4_GPIO_LEVELDETECT0) |
-			__raw_readl(bank->base + OMAP4_GPIO_LEVELDETECT1);
-	} else {
-		bank->level_mask =
-			__raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0) |
-			__raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
-	}
+	bank->level_mask =
+		__raw_readl(bank->base + bank->regs->leveldetect0) |
+		__raw_readl(bank->base + bank->regs->leveldetect1);
 }
 #endif
 
@@ -609,29 +603,13 @@  static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
 	unsigned long flags;
+	void __iomem *reg;
 
 	spin_lock_irqsave(&bank->lock, flags);
-#ifdef CONFIG_ARCH_OMAP16XX
-	if (bank->method == METHOD_GPIO_1610) {
-		/* Disable wake-up during idle for dynamic tick */
-		void __iomem *reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
-		__raw_writel(1 << offset, reg);
-	}
-#endif
-#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
-	if (bank->method == METHOD_GPIO_24XX) {
-		/* Disable wake-up during idle for dynamic tick */
-		void __iomem *reg = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
-		__raw_writel(1 << offset, reg);
-	}
-#endif
-#ifdef CONFIG_ARCH_OMAP4
-	if (bank->method == METHOD_GPIO_44XX) {
-		/* Disable wake-up during idle for dynamic tick */
-		void __iomem *reg = bank->base + OMAP4_GPIO_IRQWAKEN0;
-		__raw_writel(1 << offset, reg);
-	}
-#endif
+	/* Disable wake-up during idle for dynamic tick */
+	reg = bank->base + bank->regs->wkupclear;
+
+	__raw_writel(1 << offset, reg);
 	bank->mod_usage &= ~(1 << offset);
 
 	if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {