All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tarun Kanti DebBarma <tarun.kanti@ti.com>
To: linux-omap@vger.kernel.org
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>,
	Charulatha V <charu@ti.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Kevin Hilman <khilman@ti.com>, Tony Lindgren <tony@atomide.com>
Subject: [RFC PATCH 08/10] OMAP: GPIO: cleanup prepare-for and resume-after idle functions
Date: Mon, 16 May 2011 17:11:42 +0530	[thread overview]
Message-ID: <1305546104-1511-9-git-send-email-tarun.kanti@ti.com> (raw)
In-Reply-To: <1305546104-1511-1-git-send-email-tarun.kanti@ti.com>

By adding level and edge detection register offsets and then initializing them
correctly according to OMAP versions during device registrations we can now remove
lot of revision checks in these functions.

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/mach-omap2/gpio.c             |    8 +++
 arch/arm/plat-omap/gpio.c              |   91 ++++++++------------------------
 arch/arm/plat-omap/include/plat/gpio.h |    4 ++
 3 files changed, 35 insertions(+), 68 deletions(-)

diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 7e79999..0f8782f 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -111,6 +111,10 @@ 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->leveldetect0 = OMAP24XX_GPIO_LEVELDETECT0;
+		pdata->regs->leveldetect1 = OMAP24XX_GPIO_LEVELDETECT1;
+		pdata->regs->risingdetect = OMAP24XX_GPIO_RISINGDETECT;
+		pdata->regs->fallingdetect = OMAP24XX_GPIO_FALLINGDETECT;
 		pdata->regs->wkupstatus = OMAP24XX_GPIO_WAKE_EN;
 		pdata->regs->wkupclear = OMAP24XX_GPIO_CLEARWKUENA;
 		pdata->regs->wkupset = OMAP24XX_GPIO_SETWKUENA;
@@ -131,6 +135,10 @@ 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->leveldetect0 = OMAP4_GPIO_LEVELDETECT0;
+		pdata->regs->leveldetect1 = OMAP4_GPIO_LEVELDETECT1;
+		pdata->regs->risingdetect = OMAP4_GPIO_RISINGDETECT;
+		pdata->regs->fallingdetect = OMAP4_GPIO_FALLINGDETECT;
 		pdata->regs->wkupstatus = OMAP4_GPIO_IRQWAKEN0;
 		pdata->regs->wkupclear = OMAP4_GPIO_IRQWAKEN0;
 		pdata->regs->wkupset = OMAP4_GPIO_IRQWAKEN0;
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 1a6789d..da72856 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -1291,6 +1291,7 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 	list_for_each_entry(bank, &omap_gpio_list, node) {
 		u32 l1 = 0, l2 = 0;
 		int j;
+		struct omap_gpio_reg_offs *offset = bank->regs;
 
 		if (!bank->loses_context)
 			continue;
@@ -1307,40 +1308,17 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 		if (!(bank->enabled_non_wakeup_gpios))
 			continue;
 
-		if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-			bank->saved_datain = __raw_readl(bank->base +
-					OMAP24XX_GPIO_DATAIN);
-			l1 = __raw_readl(bank->base +
-					OMAP24XX_GPIO_FALLINGDETECT);
-			l2 = __raw_readl(bank->base +
-					OMAP24XX_GPIO_RISINGDETECT);
-		}
-
-		if (cpu_is_omap44xx()) {
-			bank->saved_datain = __raw_readl(bank->base +
-						OMAP4_GPIO_DATAIN);
-			l1 = __raw_readl(bank->base +
-						OMAP4_GPIO_FALLINGDETECT);
-			l2 = __raw_readl(bank->base +
-						OMAP4_GPIO_RISINGDETECT);
-		}
+		bank->saved_datain = __raw_readl(bank->base + offset->datain);
+		l1 = __raw_readl(bank->base + offset->fallingdetect);
+		l2 = __raw_readl(bank->base + offset->risingdetect);
 
 		bank->saved_fallingdetect = l1;
 		bank->saved_risingdetect = l2;
 		l1 &= ~bank->enabled_non_wakeup_gpios;
 		l2 &= ~bank->enabled_non_wakeup_gpios;
 
-		if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-			__raw_writel(l1, bank->base +
-					OMAP24XX_GPIO_FALLINGDETECT);
-			__raw_writel(l2, bank->base +
-					OMAP24XX_GPIO_RISINGDETECT);
-		}
-
-		if (cpu_is_omap44xx()) {
-			__raw_writel(l1, bank->base + OMAP4_GPIO_FALLINGDETECT);
-			__raw_writel(l2, bank->base + OMAP4_GPIO_RISINGDETECT);
-		}
+		__raw_writel(l1, bank->base + offset->fallingdetect);
+		__raw_writel(l2, bank->base + offset->risingdetect);
 
 		c++;
 	}
@@ -1358,6 +1336,7 @@ void omap2_gpio_resume_after_idle(void)
 	list_for_each_entry(bank, &omap_gpio_list, node) {
 		u32 l = 0, gen, gen0, gen1;
 		int j;
+		struct omap_gpio_reg_offs *offset = bank->regs;
 
 		if (!bank->loses_context)
 			continue;
@@ -1371,21 +1350,11 @@ void omap2_gpio_resume_after_idle(void)
 		if (!(bank->enabled_non_wakeup_gpios))
 			continue;
 
-		if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-			__raw_writel(bank->saved_fallingdetect,
-				 bank->base + OMAP24XX_GPIO_FALLINGDETECT);
-			__raw_writel(bank->saved_risingdetect,
-				 bank->base + OMAP24XX_GPIO_RISINGDETECT);
-			l = __raw_readl(bank->base + OMAP24XX_GPIO_DATAIN);
-		}
-
-		if (cpu_is_omap44xx()) {
-			__raw_writel(bank->saved_fallingdetect,
-				 bank->base + OMAP4_GPIO_FALLINGDETECT);
-			__raw_writel(bank->saved_risingdetect,
-				 bank->base + OMAP4_GPIO_RISINGDETECT);
-			l = __raw_readl(bank->base + OMAP4_GPIO_DATAIN);
-		}
+		__raw_writel(bank->saved_fallingdetect,
+				bank->base + offset->fallingdetect);
+		__raw_writel(bank->saved_risingdetect,
+				bank->base + offset->risingdetect);
+		l = __raw_readl(bank->base + offset->datain);
 
 		/* Check if any of the non-wakeup interrupt GPIOs have changed
 		 * state.  If so, generate an IRQ by software.  This is
@@ -1413,38 +1382,24 @@ void omap2_gpio_resume_after_idle(void)
 		if (gen) {
 			u32 old0, old1;
 
+			old0 = __raw_readl(bank->base + offset->leveldetect0);
+			old1 = __raw_readl(bank->base + offset->leveldetect1);
+
+			__raw_writel(old0, bank->base + offset->leveldetect0);
+			__raw_writel(old1, bank->base + offset->leveldetect1);
 			if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-				old0 = __raw_readl(bank->base +
-					OMAP24XX_GPIO_LEVELDETECT0);
-				old1 = __raw_readl(bank->base +
-					OMAP24XX_GPIO_LEVELDETECT1);
-				__raw_writel(old0 | gen, bank->base +
-					OMAP24XX_GPIO_LEVELDETECT0);
-				__raw_writel(old1 | gen, bank->base +
-					OMAP24XX_GPIO_LEVELDETECT1);
-				__raw_writel(old0, bank->base +
-					OMAP24XX_GPIO_LEVELDETECT0);
-				__raw_writel(old1, bank->base +
-					OMAP24XX_GPIO_LEVELDETECT1);
+				old0 |= gen;
+				old1 |= gen;
 			}
 
 			if (cpu_is_omap44xx()) {
-				old0 = __raw_readl(bank->base +
-						OMAP4_GPIO_LEVELDETECT0);
-				old1 = __raw_readl(bank->base +
-						OMAP4_GPIO_LEVELDETECT1);
-				__raw_writel(old0 | l, bank->base +
-						OMAP4_GPIO_LEVELDETECT0);
-				__raw_writel(old1 | l, bank->base +
-						OMAP4_GPIO_LEVELDETECT1);
-				__raw_writel(old0, bank->base +
-						OMAP4_GPIO_LEVELDETECT0);
-				__raw_writel(old1, bank->base +
-						OMAP4_GPIO_LEVELDETECT1);
+				old0 |= l;
+				old1 |= l;
 			}
+			__raw_writel(old0, bank->base + offset->leveldetect0);
+			__raw_writel(old1, bank->base + offset->leveldetect1);
 		}
 	}
-
 }
 
 #endif
diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h
index 81ba1f0..d4e9f3c 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -189,6 +189,10 @@ struct omap_gpio_reg_offs {
 	u16 debounce;
 	u16 debounce_en;
 	u16 ctrl;
+	u16 leveldetect0;
+	u16 leveldetect1;
+	u16 risingdetect;
+	u16 fallingdetect;
 	u16 wkupstatus;
 	u16 wkupclear;
 	u16 wkupset;
-- 
1.6.0.4

  parent reply	other threads:[~2011-05-16 11:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-16 11:41 [RFC PATCH 00/10] OMAP: GPIO: cleanup GPIO driver Tarun Kanti DebBarma
2011-05-16 11:41 ` [RFC PATCH 01/10] OMAP: GPIO: Avoid cpu_is checks during module ena/disable Tarun Kanti DebBarma
2011-05-16 11:41 ` [RFC PATCH 02/10] ZOOM: QUART: Request reset GPIO Tarun Kanti DebBarma
2011-05-19 16:11   ` Kevin Hilman
2011-05-20  8:23     ` Varadarajan, Charulatha
2011-05-16 11:41 ` [RFC PATCH 03/10] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids Tarun Kanti DebBarma
2011-05-16 11:41 ` [RFC PATCH 04/10] OMAP: GPIO: Remove dependency on gpio_bank_count Tarun Kanti DebBarma
2011-05-19 15:42   ` Kevin Hilman
2011-05-20  8:27     ` Varadarajan, Charulatha
2011-05-19 16:39   ` Kevin Hilman
2011-05-20  8:30     ` Varadarajan, Charulatha
2011-05-16 11:41 ` [RFC PATCH 05/10] OMAP2PLUS: GPIO: Use flag to identify wkup dmn GPIO Tarun Kanti DebBarma
2011-05-19 16:34   ` Kevin Hilman
2011-05-16 11:41 ` [RFC PATCH 06/10] OMAP: GPIO: Use USHRT_MAX for rev offset instead of -1 Tarun Kanti DebBarma
2011-05-19 15:59   ` Kevin Hilman
2011-05-20  8:31     ` Varadarajan, Charulatha
2011-05-20  9:30       ` Kevin Hilman
2011-05-16 11:41 ` [RFC PATCH 07/10] OMAP: GPIO: cleanup suspend and resume functions Tarun Kanti DebBarma
2011-05-19 16:08   ` Kevin Hilman
2011-05-20  9:20   ` Varadarajan, Charulatha
2011-05-16 11:41 ` Tarun Kanti DebBarma [this message]
2011-05-19 16:10   ` [RFC PATCH 08/10] OMAP: GPIO: cleanup prepare-for and resume-after idle functions Kevin Hilman
2011-05-16 11:41 ` [RFC PATCH 09/10] OMAP: GPIO: cleanup omap_gpio_free and triggering functions Tarun Kanti DebBarma
2011-05-18 11:03   ` Varadarajan, Charulatha
2011-05-19 16:06   ` Kevin Hilman
2011-05-16 11:41 ` [RFC PATCH 10/10] OMAP: GPIO: remove harcoded offsets in context save and restore Tarun Kanti DebBarma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305546104-1511-9-git-send-email-tarun.kanti@ti.com \
    --to=tarun.kanti@ti.com \
    --cc=charu@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.