Re: [PATCH v7 08/26] gpio/omap: further cleanup using wkup_en register

2011-09-21 Thread Tony Lindgren
* Tarun Kanti DebBarma tarun.ka...@ti.com [110913 05:29]:
 Wakeup enable register offset initialized according to OMAP versions
 during device registration. Use this to avoid version checks.
 Starting with OMAP4, legacy registers should not be used in combination
 with the updated regsiters. Use wkup_en register consistently for
 all SoCs wherever applicable.
 
 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Signed-off-by: Charulatha V ch...@ti.com
 Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com

Acked-by: Tony Lindgren t...@atomide.com
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 08/26] gpio/omap: further cleanup using wkup_en register

2011-09-13 Thread Tarun Kanti DebBarma
Wakeup enable register offset initialized according to OMAP versions
during device registration. Use this to avoid version checks.
Starting with OMAP4, legacy registers should not be used in combination
with the updated regsiters. Use wkup_en register consistently for
all SoCs wherever applicable.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Signed-off-by: Charulatha V ch...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap1/gpio16xx.c |1 +
 arch/arm/mach-omap2/gpio.c |2 +
 arch/arm/plat-omap/include/plat/gpio.h |1 +
 drivers/gpio/gpio-omap.c   |  108 ++--
 4 files changed, 23 insertions(+), 89 deletions(-)

diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
index df4bb44..1eb47e2 100644
--- a/arch/arm/mach-omap1/gpio16xx.c
+++ b/arch/arm/mach-omap1/gpio16xx.c
@@ -89,6 +89,7 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
.irqenable  = OMAP1610_GPIO_IRQENABLE1,
.set_irqenable  = OMAP1610_GPIO_SET_IRQENABLE1,
.clr_irqenable  = OMAP1610_GPIO_CLEAR_IRQENABLE1,
+   .wkup_en= OMAP1610_GPIO_WAKEUPENABLE,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 72a640d..b1364b6 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -99,6 +99,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void 
*unused)
pdata-regs-debounce = OMAP24XX_GPIO_DEBOUNCE_VAL;
pdata-regs-debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
pdata-regs-ctrl = OMAP24XX_GPIO_CTRL;
+   pdata-regs-wkup_en = OMAP24XX_GPIO_WAKE_EN;
break;
case 2:
pdata-bank_type = METHOD_GPIO_44XX;
@@ -116,6 +117,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void 
*unused)
pdata-regs-debounce = OMAP4_GPIO_DEBOUNCINGTIME;
pdata-regs-debounce_en = OMAP4_GPIO_DEBOUNCENABLE;
pdata-regs-ctrl = OMAP4_GPIO_CTRL;
+   pdata-regs-wkup_en = OMAP4_GPIO_IRQWAKEN0;
break;
default:
WARN(1, Invalid gpio bank_type\n);
diff --git a/arch/arm/plat-omap/include/plat/gpio.h 
b/arch/arm/plat-omap/include/plat/gpio.h
index eaa6de3..7ea1608 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -189,6 +189,7 @@ struct omap_gpio_reg_offs {
u16 debounce;
u16 debounce_en;
u16 ctrl;
+   u16 wkup_en;
 
bool irqenable_inv;
 };
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 84cd934..82707e3 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -50,10 +50,8 @@ struct gpio_bank {
u16 irq;
u16 virtual_irq_start;
int method;
-#if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS)
u32 suspend_wakeup;
u32 saved_wakeup;
-#endif
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
@@ -598,30 +596,15 @@ static int omap_gpio_request(struct gpio_chip *chip, 
unsigned offset)
 static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
 {
struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
+   void __iomem *base = bank-base;
unsigned long flags;
 
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) {
+
+   if (bank-regs-wkup_en)
/* Disable wake-up during idle for dynamic tick */
-   void __iomem *reg = bank-base + OMAP4_GPIO_IRQWAKEN0;
-   __raw_writel(1  offset, reg);
-   }
-#endif
+   _gpio_rmw(base, bank-regs-wkup_en, 1  offset, 0);
+
bank-mod_usage = ~(1  offset);
 
if (bank-regs-ctrl  !bank-mod_usage) {
@@ -1071,8 +1054,8 @@ omap_mpuio_alloc_gc(struct gpio_bank *bank, unsigned int 
irq_start,
ct-chip.irq_mask = irq_gc_mask_set_bit;
ct-chip.irq_unmask = irq_gc_mask_clr_bit;
ct-chip.irq_set_type = gpio_irq_type;
-   /* REVISIT: assuming only 16xx supports MPUIO wake events */
-   if (cpu_is_omap16xx())
+
+   if (bank-regs-wkup_en)