Skip to contentSkip to conversation

OMAP: GPIO: Cleanup OMAP GPIO driver

PATCH Superseded Tarun Kanti DebBarma 6 participants 59 messages May 24, 2011 – Jun 3, 2011

Subsystems (7)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

cover OMAP: GPIO: Cleanup OMAP GPIO driver

Do some more cleanup of OMAP GPIO driver and avoid usage of gpio_bank_count and gpio_bank pointer array by means of maintaining a list.

Patch series is on following commit of linux-omap-pm (branch: wip/gpio-cleanup):
commit d04952091a3b9b4b47696cee48e92a9173fd9ffb
GPIO: OMAP: cleanup show revision, remove cpu_is checks, display only once

Diff summary between RFC(prev version) and this version:
*Patches 0012*-0015* are added to the series
*Call gpio_save(restore)_context from OMAP GPIO driver instead
of calling them from PM sepcific funcs
-For this, few more patches (patches 0004*-8*) are added
to the series
*Move mpuio_init() from probe() to omap_gpio_mod_init()
*Correctly add the wake set/clear/status regs offsets at omap16xx_gpio_regs *Remove usage of unnecessary variable "offset" locally inside prepare_for_idle() *wake_set/clear related access is done only after validity check

Links to previous version (RFC) of this series:
https://patchwork.kernel.org/patch/787692/
https://patchwork.kernel.org/patch/787742/
https://patchwork.kernel.org/patch/787762/
https://patchwork.kernel.org/patch/787722/
https://patchwork.kernel.org/patch/787712/
https://patchwork.kernel.org/patch/787732/
http://permalink.gmane.org/gmane.linux.ports.arm.omap/57524

Test Details:
Compile tested for omap1_defconfig and omap2plus_defconfig. Bootup success on OMAP1710-H3.
Functional testing success on OMAP2430-SDP, OMAP3430-SDP, OMAP4430-SDP. PM Testing success on OMAP3430-SDP: retention, off_mode, system_wide suspend and gpio wakeup.

Charulatha V (12):
OMAP: GPIO: Avoid cpu_is checks during module ena/disable
OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids
OMAP: GPIO: Remove dependency on gpio_bank_count
OMAP2PLUS: GPIO: Use flag to identify wkup dmn GPIO
OMAP: GPIO: Make gpio_context part of gpio_bank structure
OMAP4: GPIO: Save/restore context
OMAP: GPIO: handle save/restore ctx in GPIO driver OMAP2+: GPIO: make workaround_enabled bank specific
OMAP: GPIO: Fix: use wake set/clear regs
OMAP: GPIO: clean set_gpio_triggering function
OMAP: GPIO: Use memset for omap_gpio_reg_offs
OMAP: GPIO: clean omap_gpio_mod_init function

Tarun Kanti DebBarma (3):
OMAP: GPIO: cleanup suspend and resume functions
OMAP: GPIO: cleanup prepare/resume idle functions
OMAP: GPIO: Remove hardcoded offsets in ctxt save/restore

 arch/arm/mach-omap1/gpio15xx.c             |   42 +-
 arch/arm/mach-omap1/gpio16xx.c             |   55 ++-
 arch/arm/mach-omap1/gpio7xx.c              |   42 +-
 arch/arm/mach-omap2/gpio.c                 |   53 ++-
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |    2 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    2 +-
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    2 +-
 arch/arm/mach-omap2/pm34xx.c               |   22 +-
 arch/arm/plat-omap/include/plat/gpio.h     |   20 +-
 drivers/gpio/gpio_omap.c                   |  797 ++++++++++------------------
 10 files changed, 438 insertions(+), 599 deletions(-)
#1 lore raw

PATCH 1/15 OMAP: GPIO: Avoid cpu_is checks during module ena/disable

From: Charulatha V <[email protected]>

Remove cpu-is checks while enabling/disabling OMAP GPIO module during a gpio request/free.

---
 arch/arm/mach-omap1/gpio15xx.c         |    2 +
 arch/arm/mach-omap1/gpio16xx.c         |    2 +
 arch/arm/mach-omap1/gpio7xx.c          |    2 +
 arch/arm/mach-omap2/gpio.c             |    2 +
 arch/arm/plat-omap/include/plat/gpio.h |    1 +
 drivers/gpio/gpio_omap.c               |   53 ++++++++++++++------------------
 6 files changed, 32 insertions(+), 30 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +2 -0
index f79c6ae..6d83e0a 100644
@@ -42,6 +42,7 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 	.irqstatus	= OMAP_MPUIO_GPIO_INT,
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -83,6 +84,7 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 	.irqstatus	= OMAP1510_GPIO_INT_STATUS,
 	.irqenable	= OMAP1510_GPIO_INT_MASK,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +2 -0
index c69b3b1..6bba196 100644
@@ -45,6 +45,7 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 	.irqstatus	= OMAP_MPUIO_GPIO_INT,
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -89,6 +90,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,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +2 -0
index d7f2ad3..0fc2557 100644
@@ -47,6 +47,7 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 	.irqstatus	= OMAP_MPUIO_GPIO_INT / 2,
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT / 2,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -88,6 +89,7 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 	.irqstatus	= OMAP7XX_GPIO_INT_STATUS,
 	.irqenable	= OMAP7XX_GPIO_INT_MASK,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +2 -0
index 9a46d77..0446bd1 100644
@@ -84,6 +84,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1;
 		pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL;
 		pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
+		pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
 		break;
 	case 2:
 		pdata->bank_type = METHOD_GPIO_44XX;
@@ -100,6 +101,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0;
 		pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME;
 		pdata->regs->debounce_en = OMAP4_GPIO_DEBOUNCENABLE;
+		pdata->regs->ctrl = OMAP4_GPIO_CTRL;
 		break;
 	default:
 		WARN(1, "Invalid gpio bank_type\n");
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index 91e8de3..caf432c 100644
@@ -188,6 +188,7 @@ struct omap_gpio_reg_offs {
 	u16 clr_irqenable;
 	u16 debounce;
 	u16 debounce_en;
+	u16 ctrl;
 
 	bool irqenable_inv;
 };
drivers/gpio/gpio_omap.c +23 -30

73 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#2 lore raw

PATCH 1/15 OMAP: GPIO: Avoid cpu_is checks during module ena/disable

Quoted 6 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Remove cpu-is checks while enabling/disabling OMAP GPIO module during a gpio request/free.

This looks mostly OK, but one nitpick about the usage of USHRT_MAX.

For most registers, you should just test for a non-zero register offset to determine if it's present or not instead of USHRT_MAX.

I used USHRT_MAX for the revision register because it is at offset zero on most SoCs, so testing for non-zero wouldn't work there.

Other than that, the approach looks fine.

Thanks,

Kevin

Quoted 181 lines
---
 arch/arm/mach-omap1/gpio15xx.c         |    2 +
 arch/arm/mach-omap1/gpio16xx.c         |    2 +
 arch/arm/mach-omap1/gpio7xx.c          |    2 +
 arch/arm/mach-omap2/gpio.c             |    2 +
 arch/arm/plat-omap/include/plat/gpio.h |    1 +
 drivers/gpio/gpio_omap.c               |   53 ++++++++++++++------------------
 6 files changed, 32 insertions(+), 30 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +2 -0
index f79c6ae..6d83e0a 100644
@@ -42,6 +42,7 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 	.irqstatus	= OMAP_MPUIO_GPIO_INT,
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -83,6 +84,7 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 	.irqstatus	= OMAP1510_GPIO_INT_STATUS,
 	.irqenable	= OMAP1510_GPIO_INT_MASK,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +2 -0
index c69b3b1..6bba196 100644
@@ -45,6 +45,7 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 	.irqstatus	= OMAP_MPUIO_GPIO_INT,
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -89,6 +90,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,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +2 -0
index d7f2ad3..0fc2557 100644
@@ -47,6 +47,7 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 	.irqstatus	= OMAP_MPUIO_GPIO_INT / 2,
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT / 2,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -88,6 +89,7 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 	.irqstatus	= OMAP7XX_GPIO_INT_STATUS,
 	.irqenable	= OMAP7XX_GPIO_INT_MASK,
 	.irqenable_inv	= true,
+	.ctrl		= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +2 -0
index 9a46d77..0446bd1 100644
@@ -84,6 +84,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1;
 		pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL;
 		pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
+		pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
 		break;
 	case 2:
 		pdata->bank_type = METHOD_GPIO_44XX;
@@ -100,6 +101,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0;
 		pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME;
 		pdata->regs->debounce_en = OMAP4_GPIO_DEBOUNCENABLE;
+		pdata->regs->ctrl = OMAP4_GPIO_CTRL;
 		break;
 	default:
 		WARN(1, "Invalid gpio bank_type\n");
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index 91e8de3..caf432c 100644
@@ -188,6 +188,7 @@ struct omap_gpio_reg_offs {
 	u16 clr_irqenable;
 	u16 debounce;
 	u16 debounce_en;
+	u16 ctrl;
 
 	bool irqenable_inv;
 };
drivers/gpio/gpio_omap.c +23 -30
index a490cb1..dfdc45e 100644
@@ -89,6 +89,7 @@ int gpio_bank_count;
 
 #define GPIO_INDEX(bank, gpio) (gpio % bank->width)
 #define GPIO_BIT(bank, gpio) (1 << GPIO_INDEX(bank, gpio))
+#define GPIO_MOD_CTRL_BIT	BIT(0)
 
 static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input)
 {
@@ -586,22 +587,18 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
 		__raw_writel(__raw_readl(reg) | (1 << offset), reg);
 	}
 #endif
-	if (!cpu_class_is_omap1()) {
-		if (!bank->mod_usage) {
-			void __iomem *reg = bank->base;
-			u32 ctrl;
-
-			if (cpu_is_omap24xx() || cpu_is_omap34xx())
-				reg += OMAP24XX_GPIO_CTRL;
-			else if (cpu_is_omap44xx())
-				reg += OMAP4_GPIO_CTRL;
-			ctrl = __raw_readl(reg);
-			/* Module is enabled, clocks are not gated */
-			ctrl &= 0xFFFFFFFE;
-			__raw_writel(ctrl, reg);
-		}
-		bank->mod_usage |= 1 << offset;
+	if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {
+		void __iomem *reg = bank->base + bank->regs->ctrl;
+		u32 ctrl;
+
+		ctrl = __raw_readl(reg);
+		/* Module is enabled, clocks are not gated */
+		ctrl &= ~GPIO_MOD_CTRL_BIT;
+		__raw_writel(ctrl, reg);
 	}
+
+	bank->mod_usage |= 1 << offset;
+
 	spin_unlock_irqrestore(&bank->lock, flags);
 
 	return 0;
@@ -634,22 +631,18 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
 		__raw_writel(1 << offset, reg);
 	}
 #endif
-	if (!cpu_class_is_omap1()) {
-		bank->mod_usage &= ~(1 << offset);
-		if (!bank->mod_usage) {
-			void __iomem *reg = bank->base;
-			u32 ctrl;
-
-			if (cpu_is_omap24xx() || cpu_is_omap34xx())
-				reg += OMAP24XX_GPIO_CTRL;
-			else if (cpu_is_omap44xx())
-				reg += OMAP4_GPIO_CTRL;
-			ctrl = __raw_readl(reg);
-			/* Module is disabled, clocks are gated */
-			ctrl |= 1;
-			__raw_writel(ctrl, reg);
-		}
+	bank->mod_usage &= ~(1 << offset);
+
+	if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {
+		void __iomem *reg = bank->base + bank->regs->ctrl;
+		u32 ctrl;
+
+		ctrl = __raw_readl(reg);
+		/* Module is disabled, clocks are gated */
+		ctrl |= GPIO_MOD_CTRL_BIT;
+		__raw_writel(ctrl, reg);
 	}
+
 	_reset_gpio(bank, bank->chip.base + offset);
 	spin_unlock_irqrestore(&bank->lock, flags);
 }
#3 lore raw

PATCH 1/15 OMAP: GPIO: Avoid cpu_is checks during module ena/disable

Quoted 7 lines · Kevin Hilman
Quoted 5 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Remove cpu-is checks while enabling/disabling OMAP GPIO module during a gpio request/free.

Quoted 6 lines
Quoted 1 line

This looks mostly OK, but one nitpick about the usage of USHRT_MAX.

For most registers, you should just test for a non-zero register offset to determine if it's present or not instead of USHRT_MAX.

Is it safe to assume that zero offset is always for revision register only? IMHO I feel that it is safe to assume an offset of 0xFFFF as invalid. Pls add your thoughts on this.

Quoted 192 lines

I used USHRT_MAX for the revision register because it is at offset zero on most SoCs, so testing for non-zero wouldn't work there.

Other than that, the approach looks fine.

Thanks,

Kevin

Quoted 181 lines

---

?arch/arm/mach-omap1/gpio15xx.c ? ? ? ? | ? ?2 +
?arch/arm/mach-omap1/gpio16xx.c ? ? ? ? | ? ?2 +
?arch/arm/mach-omap1/gpio7xx.c ? ? ? ? ?| ? ?2 +
?arch/arm/mach-omap2/gpio.c ? ? ? ? ? ? | ? ?2 +
?arch/arm/plat-omap/include/plat/gpio.h | ? ?1 +
?drivers/gpio/gpio_omap.c ? ? ? ? ? ? ? | ? 53 ++++++++++++++------------------

?6 files changed, 32 insertions(+), 30 deletions(-)

arch/arm/mach-omap1/gpio15xx.c +2 -0
index f79c6ae..6d83e0a 100644
@@ -42,6 +42,7 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 ? ? ? .irqstatus ? ? ?= OMAP_MPUIO_GPIO_INT,
 ? ? ? .irqenable ? ? ?= OMAP_MPUIO_GPIO_MASKIT,
 ? ? ? .irqenable_inv ?= true,
+ ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -83,6 +84,7 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 ? ? ? .irqstatus ? ? ?= OMAP1510_GPIO_INT_STATUS,
 ? ? ? .irqenable ? ? ?= OMAP1510_GPIO_INT_MASK,
 ? ? ? .irqenable_inv ?= true,
+ ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +2 -0
index c69b3b1..6bba196 100644
@@ -45,6 +45,7 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 ? ? ? .irqstatus ? ? ?= OMAP_MPUIO_GPIO_INT,
 ? ? ? .irqenable ? ? ?= OMAP_MPUIO_GPIO_MASKIT,
 ? ? ? .irqenable_inv ?= true,
+ ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -89,6 +90,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,
+ ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +2 -0
index d7f2ad3..0fc2557 100644
@@ -47,6 +47,7 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 ? ? ? .irqstatus ? ? ?= OMAP_MPUIO_GPIO_INT / 2,
 ? ? ? .irqenable ? ? ?= OMAP_MPUIO_GPIO_MASKIT / 2,
 ? ? ? .irqenable_inv ?= true,
+ ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -88,6 +89,7 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 ? ? ? .irqstatus ? ? ?= OMAP7XX_GPIO_INT_STATUS,
 ? ? ? .irqenable ? ? ?= OMAP7XX_GPIO_INT_MASK,
 ? ? ? .irqenable_inv ?= true,
+ ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +1 -0
index 9a46d77..0446bd1 100644
@@ -84,6 +84,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 ? ? ? ? ? ? ? pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1;
 ? ? ? ? ? ? ? pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL;
 ? ? ? ? ? ? ? pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
+ ? ? ? ? ? ? pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
 ? ? ? ? ? ? ? break;

? ? ? case 2:
? ? ? ? ? ? ? pdata->bank_type = METHOD_GPIO_44XX;

arch/arm/mach-omap2/gpio.c +1 -0
@@ -100,6 +101,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 ? ? ? ? ? ? ? pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0;
 ? ? ? ? ? ? ? pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME;
 ? ? ? ? ? ? ? pdata->regs->debounce_en = OMAP4_GPIO_DEBOUNCENABLE;
+ ? ? ? ? ? ? pdata->regs->ctrl = OMAP4_GPIO_CTRL;
 ? ? ? ? ? ? ? break;

? ? ? default:
? ? ? ? ? ? ? WARN(1, "Invalid gpio bank_type\n");

arch/arm/plat-omap/include/plat/gpio.h +1 -0
index 91e8de3..caf432c 100644
@@ -188,6 +188,7 @@ struct omap_gpio_reg_offs {
 ? ? ? u16 clr_irqenable;
 ? ? ? u16 debounce;
 ? ? ? u16 debounce_en;
+ ? ? u16 ctrl;
 
 ? ? ? bool irqenable_inv;
 ?};
drivers/gpio/gpio_omap.c +1 -0
index a490cb1..dfdc45e 100644
@@ -89,6 +89,7 @@ int gpio_bank_count;
 
 ?#define GPIO_INDEX(bank, gpio) (gpio % bank->width)
 ?#define GPIO_BIT(bank, gpio) (1 << GPIO_INDEX(bank, gpio))
+#define GPIO_MOD_CTRL_BIT ? ?BIT(0)
 
 ?static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input)
 ?{
@@ -586,22 +587,18 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
 ? ? ? ? ? ? ? __raw_writel(__raw_readl(reg) | (1 << offset), reg);
 ? ? ? }

?#endif
- ? ? if (!cpu_class_is_omap1()) {
- ? ? ? ? ? ? if (!bank->mod_usage) {
- ? ? ? ? ? ? ? ? ? ? void __iomem *reg = bank->base;
- ? ? ? ? ? ? ? ? ? ? u32 ctrl;

drivers/gpio/gpio_omap.c +8 -11
-
- ? ? ? ? ? ? ? ? ? ? if (cpu_is_omap24xx() || cpu_is_omap34xx())
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? reg += OMAP24XX_GPIO_CTRL;
- ? ? ? ? ? ? ? ? ? ? else if (cpu_is_omap44xx())
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? reg += OMAP4_GPIO_CTRL;
- ? ? ? ? ? ? ? ? ? ? ctrl = __raw_readl(reg);
- ? ? ? ? ? ? ? ? ? ? /* Module is enabled, clocks are not gated */
- ? ? ? ? ? ? ? ? ? ? ctrl &= 0xFFFFFFFE;
- ? ? ? ? ? ? ? ? ? ? __raw_writel(ctrl, reg);
- ? ? ? ? ? ? }
- ? ? ? ? ? ? bank->mod_usage |= 1 << offset;
+ ? ? if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {
+ ? ? ? ? ? ? void __iomem *reg = bank->base + bank->regs->ctrl;
+ ? ? ? ? ? ? u32 ctrl;
+
+ ? ? ? ? ? ? ctrl = __raw_readl(reg);
+ ? ? ? ? ? ? /* Module is enabled, clocks are not gated */
+ ? ? ? ? ? ? ctrl &= ~GPIO_MOD_CTRL_BIT;
+ ? ? ? ? ? ? __raw_writel(ctrl, reg);

? ? ? }

drivers/gpio/gpio_omap.c +3 -0
+
+ ? ? bank->mod_usage |= 1 << offset;
+

? ? ? spin_unlock_irqrestore(&bank->lock, flags);

? ? ? return 0;

drivers/gpio/gpio_omap.c +0 -0
@@ -634,22 +631,18 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
 ? ? ? ? ? ? ? __raw_writel(1 << offset, reg);
 ? ? ? }

?#endif
- ? ? if (!cpu_class_is_omap1()) {
- ? ? ? ? ? ? bank->mod_usage &= ~(1 << offset);
- ? ? ? ? ? ? if (!bank->mod_usage) {
- ? ? ? ? ? ? ? ? ? ? void __iomem *reg = bank->base;
- ? ? ? ? ? ? ? ? ? ? u32 ctrl;

drivers/gpio/gpio_omap.c +10 -10
-
- ? ? ? ? ? ? ? ? ? ? if (cpu_is_omap24xx() || cpu_is_omap34xx())
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? reg += OMAP24XX_GPIO_CTRL;
- ? ? ? ? ? ? ? ? ? ? else if (cpu_is_omap44xx())
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? reg += OMAP4_GPIO_CTRL;
- ? ? ? ? ? ? ? ? ? ? ctrl = __raw_readl(reg);
- ? ? ? ? ? ? ? ? ? ? /* Module is disabled, clocks are gated */
- ? ? ? ? ? ? ? ? ? ? ctrl |= 1;
- ? ? ? ? ? ? ? ? ? ? __raw_writel(ctrl, reg);
- ? ? ? ? ? ? }
+ ? ? bank->mod_usage &= ~(1 << offset);
+
+ ? ? if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {
+ ? ? ? ? ? ? void __iomem *reg = bank->base + bank->regs->ctrl;
+ ? ? ? ? ? ? u32 ctrl;
+
+ ? ? ? ? ? ? ctrl = __raw_readl(reg);
+ ? ? ? ? ? ? /* Module is disabled, clocks are gated */
+ ? ? ? ? ? ? ctrl |= GPIO_MOD_CTRL_BIT;
+ ? ? ? ? ? ? __raw_writel(ctrl, reg);

? ? ? }
+
? ? ? _reset_gpio(bank, bank->chip.base + offset); ? ? ? spin_unlock_irqrestore(&bank->lock, flags); ?}

#4 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430) & not for OMAP3 which is incorrect.

Fix the above by providing non-wakeup GPIO information through pdata specific to the SoC.

The GPIO rev id provided in the hwmod database is the same for OMAP2420 and OMAP2430. Change the GPIO rev ids in hwmod database as given below so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/gpio.c                 |   26 ++++++++++++++++++++++++--
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |    2 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    2 +-
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    2 +-
 arch/arm/plat-omap/include/plat/gpio.h     |    1 +
 drivers/gpio/gpio_omap.c                   |   11 +++--------
 6 files changed, 31 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/gpio.c +24 -2
index 0446bd1..6cd26b4 100644
@@ -56,6 +56,28 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		return -ENOMEM;
 	}
 
+	switch (oh->class->rev) {
+	case 0:
+		if (id == 1)
+			/* non-wakeup GPIO pins for OMAP2420 Bank1 */
+			pdata->non_wakeup_gpios = 0xe203ffc0;
+		else if (id == 2)
+			/* non-wakeup GPIO pins for OMAP2420 Bank2 */
+			pdata->non_wakeup_gpios = 0x08700040;
+		break;
+	case 2:
+		if (id == 2)
+			/* non-wakeup GPIO pins for OMAP3 Bank2 */
+			pdata->non_wakeup_gpios = 0x00000001;
+		else if (id == 6)
+			/* non-wakeup GPIO pins for OMAP3 Bank6 */
+			pdata->non_wakeup_gpios = 0x08000000;
+		break;
+	default:
+		/* No non-wakeup GPIO pins for other SoCs */
+		break;
+	}
+
 	dev_attr = (struct omap_gpio_dev_attr *)oh->dev_attr;
 	pdata->bank_width = dev_attr->bank_width;
 	pdata->dbck_flag = dev_attr->dbck_flag;
@@ -70,6 +92,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 	switch (oh->class->rev) {
 	case 0:
 	case 1:
+	case 2:
 		pdata->bank_type = METHOD_GPIO_24XX;
 		pdata->regs->revision = OMAP24XX_GPIO_REVISION;
 		pdata->regs->direction = OMAP24XX_GPIO_OE;
@@ -86,7 +109,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
 		pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
 		break;
-	case 2:
+	case 3:
 		pdata->bank_type = METHOD_GPIO_44XX;
 		pdata->regs->revision = OMAP4_GPIO_REVISION;
 		pdata->regs->direction = OMAP4_GPIO_OE;
@@ -108,7 +131,6 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		kfree(pdata);
 		return -EINVAL;
 	}
-
 	od = omap_device_build(name, id - 1, oh, pdata,
 				sizeof(*pdata),	omap_gpio_latency,
 				ARRAY_SIZE(omap_gpio_latency),
arch/arm/mach-omap2/omap_hwmod_2430_data.c +1 -1
index 9682dd5..ae702b5 100644
@@ -1728,7 +1728,7 @@ static struct omap_hwmod_class_sysconfig omap243x_gpio_sysc = {
 static struct omap_hwmod_class omap243x_gpio_hwmod_class = {
 	.name = "gpio",
 	.sysc = &omap243x_gpio_sysc,
-	.rev = 0,
+	.rev = 1,
 };
 
 /* gpio1 */
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +1 -1
index 909a84d..05e7005 100644
@@ -2117,7 +2117,7 @@ static struct omap_hwmod_class_sysconfig omap3xxx_gpio_sysc = {
 static struct omap_hwmod_class omap3xxx_gpio_hwmod_class = {
 	.name = "gpio",
 	.sysc = &omap3xxx_gpio_sysc,
-	.rev = 1,
+	.rev = 2,
 };
 
 /* gpio_dev_attr*/
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +1 -1
index abc548a..ea30752 100644
@@ -1703,7 +1703,7 @@ static struct omap_hwmod_class_sysconfig omap44xx_gpio_sysc = {
 static struct omap_hwmod_class omap44xx_gpio_hwmod_class = {
 	.name	= "gpio",
 	.sysc	= &omap44xx_gpio_sysc,
-	.rev	= 2,
+	.rev	= 3,
 };
 
 /* gpio dev_attr */
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index caf432c..8014a8a 100644
@@ -199,6 +199,7 @@ struct omap_gpio_platform_data {
 	int bank_width;		/* GPIO bank width */
 	int bank_stride;	/* Only needed for omap1 MPUIO */
 	bool dbck_flag;		/* dbck required or not - True for OMAP3&4 */
+	u32 non_wakeup_gpios;
 
 	struct omap_gpio_reg_offs *regs;
 };
drivers/gpio/gpio_omap.c +3 -8
index dfdc45e..0ba4cdb 100644
@@ -1008,7 +1008,7 @@ static inline int init_gpio_info(struct platform_device *pdev)
 }
 
 /* TODO: Cleanup cpu_is_* checks */
-static void omap_gpio_mod_init(struct gpio_bank *bank, int id)
+static void omap_gpio_mod_init(struct gpio_bank *bank)
 {
 	if (cpu_class_is_omap2()) {
 		if (cpu_is_omap44xx()) {
@@ -1028,12 +1028,6 @@ static void omap_gpio_mod_init(struct gpio_bank *bank, int id)
 
 			/* Initialize interface clk ungated, module enabled */
 			__raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
-		} else if (cpu_is_omap24xx()) {
-			static const u32 non_wakeup_gpios[] = {
-				0xe203ffc0, 0x08700040
-			};
-			if (id < ARRAY_SIZE(non_wakeup_gpios))
-				bank->non_wakeup_gpios = non_wakeup_gpios[id];
 		}
 	} else if (cpu_class_is_omap1()) {
 		if (bank_is_mpuio(bank))
@@ -1179,6 +1173,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	bank->dbck_flag = pdata->dbck_flag;
 	bank->stride = pdata->bank_stride;
 	bank->width = pdata->bank_width;
+	bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
 
 	bank->regs = pdata->regs;
 
@@ -1205,7 +1200,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	pm_runtime_enable(bank->dev);
 	pm_runtime_get_sync(bank->dev);
 
-	omap_gpio_mod_init(bank, id);
+	omap_gpio_mod_init(bank);
 	omap_gpio_chip_init(bank);
 	omap_gpio_show_rev(bank);
 
Signature · 1 line
1.6.0.4
#5 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 5 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430) & not for OMAP3 which is incorrect.

Can you cite the documentation you're using for the OMAP3 non-wakeup GPIOs?

This is a change of functionality from current code, where all OMAP3 GPIOs are considered wakeup capable.

I'd like this to be tackled in two patches. One for the cleanup/consolidation, and one for change in behavior.

For this cleanup/consolidation (this series), please keep existing functionality and focus on the cleanup. Then, in an additional patch (on top of the cleanup/conslidation), change the functionality with a detailed changelog.

Thanks,

Kevin

Quoted 174 lines

Fix the above by providing non-wakeup GPIO information through pdata specific to the SoC.

The GPIO rev id provided in the hwmod database is the same for OMAP2420 and OMAP2430. Change the GPIO rev ids in hwmod database as given below so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/gpio.c                 |   26 ++++++++++++++++++++++++--
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |    2 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    2 +-
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    2 +-
 arch/arm/plat-omap/include/plat/gpio.h     |    1 +
 drivers/gpio/gpio_omap.c                   |   11 +++--------
 6 files changed, 31 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/gpio.c +24 -2
index 0446bd1..6cd26b4 100644
@@ -56,6 +56,28 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		return -ENOMEM;
 	}
 
+	switch (oh->class->rev) {
+	case 0:
+		if (id == 1)
+			/* non-wakeup GPIO pins for OMAP2420 Bank1 */
+			pdata->non_wakeup_gpios = 0xe203ffc0;
+		else if (id == 2)
+			/* non-wakeup GPIO pins for OMAP2420 Bank2 */
+			pdata->non_wakeup_gpios = 0x08700040;
+		break;
+	case 2:
+		if (id == 2)
+			/* non-wakeup GPIO pins for OMAP3 Bank2 */
+			pdata->non_wakeup_gpios = 0x00000001;
+		else if (id == 6)
+			/* non-wakeup GPIO pins for OMAP3 Bank6 */
+			pdata->non_wakeup_gpios = 0x08000000;
+		break;
+	default:
+		/* No non-wakeup GPIO pins for other SoCs */
+		break;
+	}
+
 	dev_attr = (struct omap_gpio_dev_attr *)oh->dev_attr;
 	pdata->bank_width = dev_attr->bank_width;
 	pdata->dbck_flag = dev_attr->dbck_flag;
@@ -70,6 +92,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 	switch (oh->class->rev) {
 	case 0:
 	case 1:
+	case 2:
 		pdata->bank_type = METHOD_GPIO_24XX;
 		pdata->regs->revision = OMAP24XX_GPIO_REVISION;
 		pdata->regs->direction = OMAP24XX_GPIO_OE;
@@ -86,7 +109,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
 		pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
 		break;
-	case 2:
+	case 3:
 		pdata->bank_type = METHOD_GPIO_44XX;
 		pdata->regs->revision = OMAP4_GPIO_REVISION;
 		pdata->regs->direction = OMAP4_GPIO_OE;
@@ -108,7 +131,6 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		kfree(pdata);
 		return -EINVAL;
 	}
-
 	od = omap_device_build(name, id - 1, oh, pdata,
 				sizeof(*pdata),	omap_gpio_latency,
 				ARRAY_SIZE(omap_gpio_latency),
arch/arm/mach-omap2/omap_hwmod_2430_data.c +1 -1
index 9682dd5..ae702b5 100644
@@ -1728,7 +1728,7 @@ static struct omap_hwmod_class_sysconfig omap243x_gpio_sysc = {
 static struct omap_hwmod_class omap243x_gpio_hwmod_class = {
 	.name = "gpio",
 	.sysc = &omap243x_gpio_sysc,
-	.rev = 0,
+	.rev = 1,
 };
 
 /* gpio1 */
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +1 -1
index 909a84d..05e7005 100644
@@ -2117,7 +2117,7 @@ static struct omap_hwmod_class_sysconfig omap3xxx_gpio_sysc = {
 static struct omap_hwmod_class omap3xxx_gpio_hwmod_class = {
 	.name = "gpio",
 	.sysc = &omap3xxx_gpio_sysc,
-	.rev = 1,
+	.rev = 2,
 };
 
 /* gpio_dev_attr*/
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +1 -1
index abc548a..ea30752 100644
@@ -1703,7 +1703,7 @@ static struct omap_hwmod_class_sysconfig omap44xx_gpio_sysc = {
 static struct omap_hwmod_class omap44xx_gpio_hwmod_class = {
 	.name	= "gpio",
 	.sysc	= &omap44xx_gpio_sysc,
-	.rev	= 2,
+	.rev	= 3,
 };
 
 /* gpio dev_attr */
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index caf432c..8014a8a 100644
@@ -199,6 +199,7 @@ struct omap_gpio_platform_data {
 	int bank_width;		/* GPIO bank width */
 	int bank_stride;	/* Only needed for omap1 MPUIO */
 	bool dbck_flag;		/* dbck required or not - True for OMAP3&4 */
+	u32 non_wakeup_gpios;
 
 	struct omap_gpio_reg_offs *regs;
 };
drivers/gpio/gpio_omap.c +3 -8
index dfdc45e..0ba4cdb 100644
@@ -1008,7 +1008,7 @@ static inline int init_gpio_info(struct platform_device *pdev)
 }
 
 /* TODO: Cleanup cpu_is_* checks */
-static void omap_gpio_mod_init(struct gpio_bank *bank, int id)
+static void omap_gpio_mod_init(struct gpio_bank *bank)
 {
 	if (cpu_class_is_omap2()) {
 		if (cpu_is_omap44xx()) {
@@ -1028,12 +1028,6 @@ static void omap_gpio_mod_init(struct gpio_bank *bank, int id)
 
 			/* Initialize interface clk ungated, module enabled */
 			__raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
-		} else if (cpu_is_omap24xx()) {
-			static const u32 non_wakeup_gpios[] = {
-				0xe203ffc0, 0x08700040
-			};
-			if (id < ARRAY_SIZE(non_wakeup_gpios))
-				bank->non_wakeup_gpios = non_wakeup_gpios[id];
 		}
 	} else if (cpu_class_is_omap1()) {
 		if (bank_is_mpuio(bank))
@@ -1179,6 +1173,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	bank->dbck_flag = pdata->dbck_flag;
 	bank->stride = pdata->bank_stride;
 	bank->width = pdata->bank_width;
+	bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
 
 	bank->regs = pdata->regs;
 
@@ -1205,7 +1200,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	pm_runtime_enable(bank->dev);
 	pm_runtime_get_sync(bank->dev);
 
-	omap_gpio_mod_init(bank, id);
+	omap_gpio_mod_init(bank);
 	omap_gpio_chip_init(bank);
 	omap_gpio_show_rev(bank);
#6 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 10 lines · Kevin Hilman
Quoted 5 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430) & not for OMAP3 which is incorrect.

Can you cite the documentation you're using for the OMAP3 non-wakeup GPIOs?

I am referring to Table 25-5. GPIO Channel Description at page no 3354 OMAP3430 public TRM Version P.

Quoted 6 lines

This is a change of functionality from current code, where all OMAP3 GPIOs are considered wakeup capable.

I'd like this to be tackled in two patches. ?One for the cleanup/consolidation, and one for change in behavior.

Okay.

Quoted 5 lines

For this cleanup/consolidation (this series), please keep existing functionality and focus on the cleanup. ?Then, in an additional patch (on top of the cleanup/conslidation), change the functionality with a detailed changelog.

Okay.

Quoted 180 lines

Thanks,

Kevin

Quoted 174 lines

Fix the above by providing non-wakeup GPIO information through pdata specific to the SoC.

The GPIO rev id provided in the hwmod database is the same for OMAP2420 and OMAP2430. Change the GPIO rev ids in hwmod database as given below so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 ? ?- 2
OMAP4 ? ?- 3

Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>

---

?arch/arm/mach-omap2/gpio.c ? ? ? ? ? ? ? ? | ? 26 ++++++++++++++++++++++++--
?arch/arm/mach-omap2/omap_hwmod_2430_data.c | ? ?2 +-
?arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | ? ?2 +-
?arch/arm/mach-omap2/omap_hwmod_44xx_data.c | ? ?2 +-
?arch/arm/plat-omap/include/plat/gpio.h ? ? | ? ?1 +
?drivers/gpio/gpio_omap.c ? ? ? ? ? ? ? ? ? | ? 11 +++--------

?6 files changed, 31 insertions(+), 13 deletions(-)

arch/arm/mach-omap2/gpio.c +22 -0
index 0446bd1..6cd26b4 100644
@@ -56,6 +56,28 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 ? ? ? ? ? ? ? return -ENOMEM;
 ? ? ? }
 
+ ? ? switch (oh->class->rev) {
+ ? ? case 0:
+ ? ? ? ? ? ? if (id == 1)
+ ? ? ? ? ? ? ? ? ? ? /* non-wakeup GPIO pins for OMAP2420 Bank1 */
+ ? ? ? ? ? ? ? ? ? ? pdata->non_wakeup_gpios = 0xe203ffc0;
+ ? ? ? ? ? ? else if (id == 2)
+ ? ? ? ? ? ? ? ? ? ? /* non-wakeup GPIO pins for OMAP2420 Bank2 */
+ ? ? ? ? ? ? ? ? ? ? pdata->non_wakeup_gpios = 0x08700040;
+ ? ? ? ? ? ? break;
+ ? ? case 2:
+ ? ? ? ? ? ? if (id == 2)
+ ? ? ? ? ? ? ? ? ? ? /* non-wakeup GPIO pins for OMAP3 Bank2 */
+ ? ? ? ? ? ? ? ? ? ? pdata->non_wakeup_gpios = 0x00000001;
+ ? ? ? ? ? ? else if (id == 6)
+ ? ? ? ? ? ? ? ? ? ? /* non-wakeup GPIO pins for OMAP3 Bank6 */
+ ? ? ? ? ? ? ? ? ? ? pdata->non_wakeup_gpios = 0x08000000;
+ ? ? ? ? ? ? break;
+ ? ? default:
+ ? ? ? ? ? ? /* No non-wakeup GPIO pins for other SoCs */
+ ? ? ? ? ? ? break;
+ ? ? }
+
 ? ? ? dev_attr = (struct omap_gpio_dev_attr *)oh->dev_attr;
 ? ? ? pdata->bank_width = dev_attr->bank_width;
 ? ? ? pdata->dbck_flag = dev_attr->dbck_flag;
@@ -70,6 +92,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 ? ? ? switch (oh->class->rev) {

? ? ? case 0:
? ? ? case 1:
+ ? ? case 2:
? ? ? ? ? ? ? pdata->bank_type = METHOD_GPIO_24XX; ? ? ? ? ? ? ? pdata->regs->revision = OMAP24XX_GPIO_REVISION; ? ? ? ? ? ? ? pdata->regs->direction = OMAP24XX_GPIO_OE;

arch/arm/mach-omap2/gpio.c +1 -2
@@ -86,7 +109,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 ? ? ? ? ? ? ? pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
 ? ? ? ? ? ? ? pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
 ? ? ? ? ? ? ? break;
- ? ? case 2:
+ ? ? case 3:
 ? ? ? ? ? ? ? pdata->bank_type = METHOD_GPIO_44XX;
 ? ? ? ? ? ? ? pdata->regs->revision = OMAP4_GPIO_REVISION;
 ? ? ? ? ? ? ? pdata->regs->direction = OMAP4_GPIO_OE;
@@ -108,7 +131,6 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 ? ? ? ? ? ? ? kfree(pdata);
 ? ? ? ? ? ? ? return -EINVAL;
 ? ? ? }
-
 ? ? ? od = omap_device_build(name, id - 1, oh, pdata,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sizeof(*pdata), omap_gpio_latency,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ARRAY_SIZE(omap_gpio_latency),
arch/arm/mach-omap2/omap_hwmod_2430_data.c +1 -1
index 9682dd5..ae702b5 100644
@@ -1728,7 +1728,7 @@ static struct omap_hwmod_class_sysconfig omap243x_gpio_sysc = {
 ?static struct omap_hwmod_class omap243x_gpio_hwmod_class = {
 ? ? ? .name = "gpio",
 ? ? ? .sysc = &omap243x_gpio_sysc,
- ? ? .rev = 0,
+ ? ? .rev = 1,
 ?};
 

?/* gpio1 */

arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +1 -1
index 909a84d..05e7005 100644
@@ -2117,7 +2117,7 @@ static struct omap_hwmod_class_sysconfig omap3xxx_gpio_sysc = {
 ?static struct omap_hwmod_class omap3xxx_gpio_hwmod_class = {
 ? ? ? .name = "gpio",
 ? ? ? .sysc = &omap3xxx_gpio_sysc,
- ? ? .rev = 1,
+ ? ? .rev = 2,
 ?};
 

?/* gpio_dev_attr*/

arch/arm/mach-omap2/omap_hwmod_44xx_data.c +1 -1
index abc548a..ea30752 100644
@@ -1703,7 +1703,7 @@ static struct omap_hwmod_class_sysconfig omap44xx_gpio_sysc = {
 ?static struct omap_hwmod_class omap44xx_gpio_hwmod_class = {
 ? ? ? .name ? = "gpio",
 ? ? ? .sysc ? = &omap44xx_gpio_sysc,
- ? ? .rev ? ?= 2,
+ ? ? .rev ? ?= 3,
 ?};
 

?/* gpio dev_attr */

arch/arm/plat-omap/include/plat/gpio.h +0 -0
index caf432c..8014a8a 100644
@@ -199,6 +199,7 @@ struct omap_gpio_platform_data {

? ? ? int bank_width; ? ? ? ? /* GPIO bank width */
? ? ? int bank_stride; ? ? ? ?/* Only needed for omap1 MPUIO */ ? ? ? bool dbck_flag; ? ? ? ? /* dbck required or not - True for OMAP3&4 */
+ ? ? u32 non_wakeup_gpios;

? ? ? struct omap_gpio_reg_offs *regs;
?};

drivers/gpio/gpio_omap.c +0 -0
index dfdc45e..0ba4cdb 100644
@@ -1008,7 +1008,7 @@ static inline int init_gpio_info(struct platform_device *pdev)
 ?}
 

?/* TODO: Cleanup cpu_is_* checks */

drivers/gpio/gpio_omap.c +1 -1
-static void omap_gpio_mod_init(struct gpio_bank *bank, int id)
+static void omap_gpio_mod_init(struct gpio_bank *bank)

?{
? ? ? if (cpu_class_is_omap2()) {
? ? ? ? ? ? ? if (cpu_is_omap44xx()) {

drivers/gpio/gpio_omap.c +0 -0
@@ -1028,12 +1028,6 @@ static void omap_gpio_mod_init(struct gpio_bank *bank, int id)
 

? ? ? ? ? ? ? ? ? ? ? /* Initialize interface clk ungated, module enabled */ ? ? ? ? ? ? ? ? ? ? ? __raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
- ? ? ? ? ? ? } else if (cpu_is_omap24xx()) {
- ? ? ? ? ? ? ? ? ? ? static const u32 non_wakeup_gpios[] = {
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0xe203ffc0, 0x08700040
- ? ? ? ? ? ? ? ? ? ? };
- ? ? ? ? ? ? ? ? ? ? if (id < ARRAY_SIZE(non_wakeup_gpios))
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->non_wakeup_gpios = non_wakeup_gpios[id]; ? ? ? ? ? ? ? }
? ? ? } else if (cpu_class_is_omap1()) {
? ? ? ? ? ? ? if (bank_is_mpuio(bank))

drivers/gpio/gpio_omap.c +2 -1
@@ -1179,6 +1173,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 ? ? ? bank->dbck_flag = pdata->dbck_flag;
 ? ? ? bank->stride = pdata->bank_stride;
 ? ? ? bank->width = pdata->bank_width;
+ ? ? bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
 
 ? ? ? bank->regs = pdata->regs;
 
@@ -1205,7 +1200,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 ? ? ? pm_runtime_enable(bank->dev);
 ? ? ? pm_runtime_get_sync(bank->dev);
 
- ? ? omap_gpio_mod_init(bank, id);
+ ? ? omap_gpio_mod_init(bank);
 ? ? ? omap_gpio_chip_init(bank);
 ? ? ? omap_gpio_show_rev(bank);
#7 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 9 lines · Charulatha
Quoted 8 lines · Kevin Hilman
Quoted 5 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430) & not for OMAP3 which is incorrect.

Quoted 6 lines
Quoted 2 lines

Can you cite the documentation you're using for the OMAP3 non-wakeup GPIOs?

I am referring to Table 25-5. GPIO Channel Description at page no 3354 OMAP3430 public TRM Version P.

Based on how I understand that, those non-wakeup GPIOs are non-wakeup because they're not actually mapped anywhere, and not available on external pins. Therefore, they should not need any special case handling for this triggering workaround.

Kevin

#8 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Kevin,

Quoted 14 lines · Kevin Hilman
Quoted 12 lines · Charulatha
Quoted 10 lines · Kevin Hilman
Quoted 5 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430) & not for OMAP3 which is incorrect.

Can you cite the documentation you're using for the OMAP3 non-wakeup GPIOs?

Quoted 8 lines
Quoted 3 lines

I am referring to Table 25-5. GPIO Channel Description at page no 3354 OMAP3430 public TRM Version P.

Based on how I understand that, those non-wakeup GPIOs are non-wakeup because they're not actually mapped anywhere, and not available on external pins. ?Therefore, they should not need any special case handling for this triggering workaround.

Okay. Thanks for clarifying. I will not do this for OMAP3. The special case would be only for OMAP2420 against the current code which is handling for OMAP24xx.

-V Charulatha

Quoted 4 lines

Kevin

#9 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 21 lines · Charulatha

Kevin,

Quoted 18 lines · Kevin Hilman
Quoted 15 lines · Charulatha
Quoted 10 lines · Kevin Hilman
Quoted 5 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430) & not for OMAP3 which is incorrect.

Can you cite the documentation you're using for the OMAP3 non-wakeup GPIOs?

I am referring to Table 25-5. GPIO Channel Description at page no 3354 OMAP3430 public TRM Version P.

Quoted 9 lines
Quoted 4 lines

Based on how I understand that, those non-wakeup GPIOs are non-wakeup because they're not actually mapped anywhere, and not available on external pins. ?Therefore, they should not need any special case handling for this triggering workaround.

Okay. Thanks for clarifying. I will not do this for OMAP3. The special case would be only for OMAP2420 against the current code which is handling for OMAP24xx.

Great, thanks.

Kevin

#10 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

In reply to Tarun Kanti DebBarma
Quoted 23 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM
To: linux-omap at vger.kernel.org
Cc: Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Cousson, Benoit; Paul Walmsley
Subject: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

From: Charulatha V <[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430) & not for OMAP3 which is incorrect.

Fix the above by providing non-wakeup GPIO information through pdata specific to the SoC.

Quoted 8 lines

The GPIO rev id provided in the hwmod database is the same for OMAP2420
and OMAP2430. Change the GPIO rev ids in hwmod database as given below so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

[sp] Magic numbers should be avoided.
Suggest using something like:
#define GPIO_REV_2420 0
#define GPIO_REV_2430 1
#define GPIO_REV_34XX 2
#define GPIO_REV_44xx 3

We don't have to refer back to this comment while reading the code. I also believed that HWMODs were auto generated.
Can the changes to structures in this patch recreated using current scripts?

~sanjeev

Quoted 30 lines
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/gpio.c                 |   26 
++++++++++++++++++++++++--
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |    2 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    2 +-
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    2 +-
 arch/arm/plat-omap/include/plat/gpio.h     |    1 +
 drivers/gpio/gpio_omap.c                   |   11 +++--------
 6 files changed, 31 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/gpio.c +7 -0
index 0446bd1..6cd26b4 100644
@@ -56,6 +56,28 @@ static int omap2_gpio_dev_init(struct 
 omap_hwmod *oh, void *unused)
 		return -ENOMEM;
 	}
 
+	switch (oh->class->rev) {
+	case 0:
+		if (id == 1)
+			/* non-wakeup GPIO pins for OMAP2420 Bank1 */
+			pdata->non_wakeup_gpios = 0xe203ffc0;
+		else if (id == 2)
+			/* non-wakeup GPIO pins for OMAP2420 Bank2 */

arch/arm/mach-omap2/gpio.c static int omap2_gpio_dev_init(struct · line 76

Quoted 10 lines
arch/arm/mach-omap2/gpio.c +10 -0
+			pdata->non_wakeup_gpios = 0x08700040;
+		break;
+	case 2:
+		if (id == 2)
+			/* non-wakeup GPIO pins for OMAP3 Bank2 */
+			pdata->non_wakeup_gpios = 0x00000001;
+		else if (id == 6)
+			/* non-wakeup GPIO pins for OMAP3 Bank6 */
+			pdata->non_wakeup_gpios = 0x08000000;
+		break;

[sp] Where is the description on non-wakeup GPIOs in OMAP3?
Here is text from AM37x TRM:
[quote ...only relevant text]
Each GPIO module provides 32 dedicated general-purpose pins with input and output capabilities; .... These pins can be configured for the following applications:
- Data input (capture)/output (drive)
- Keyboard interface with a debounce cell
- Interrupt generation in ....
- Wake-up request generation in idle mode
[/quote]
Otherwise, what are the GPIO2_WAKEUPENABLE (0x4905 0020) and GPIO6_WAKEUPENABLE (0x4905 8020) meant for?

arch/arm/mach-omap2/gpio.c static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) · line 80

Quoted 5 lines
arch/arm/mach-omap2/gpio.c +5 -0
+	default:
+		/* No non-wakeup GPIO pins for other SoCs */
+		break;
+	}
+

~sanjeev

[snip]...[snip]

#11 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Sanjeev,

Thanks for the comments.

Quoted 33 lines · Sanjeev
Quoted 23 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM
To: linux-omap at vger.kernel.org
Cc: Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Cousson, Benoit; Paul Walmsley
Subject: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

From: Charulatha V <[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430) & not for OMAP3 which is incorrect.

Fix the above by providing non-wakeup GPIO information through pdata specific to the SoC.

Quoted 8 lines

The GPIO rev id provided in the hwmod database is the same for OMAP2420
and OMAP2430. Change the GPIO rev ids in hwmod database as given below so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 ? ?- 2
OMAP4 ? ?- 3

Quoted 8 lines

[sp] Magic numbers should be avoided.
? ? Suggest using something like:
? ? #define GPIO_REV_2420 ? ? ?0
? ? #define GPIO_REV_2430 ? ? ?1
? ? #define GPIO_REV_34XX ? ? ?2
? ? #define GPIO_REV_44xx ? ? ?3

? ? We don't have to refer back to this comment while reading the code.

Okay.

Quoted 3 lines

? ? I also believed that HWMODs were auto generated.
? ? Can the changes to structures in this patch recreated using current ? ? scripts?

Benoit's and Paul's ack is required for this change.

Quoted 37 lines

~sanjeev

Quoted 34 lines
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>

---
?arch/arm/mach-omap2/gpio.c ? ? ? ? ? ? ? ? | ? 26
++++++++++++++++++++++++--

?arch/arm/mach-omap2/omap_hwmod_2430_data.c | ? ?2 +-
?arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | ? ?2 +-
?arch/arm/mach-omap2/omap_hwmod_44xx_data.c | ? ?2 +-
?arch/arm/plat-omap/include/plat/gpio.h ? ? | ? ?1 +
?drivers/gpio/gpio_omap.c ? ? ? ? ? ? ? ? ? | ? 11 +++--------

?6 files changed, 31 insertions(+), 13 deletions(-)

arch/arm/mach-omap2/gpio.c +11 -0
index 0446bd1..6cd26b4 100644
@@ -56,6 +56,28 @@ static int omap2_gpio_dev_init(struct
 omap_hwmod *oh, void *unused)
 ? ? ? ? ? ? ? return -ENOMEM;
 ? ? ? }
 
+ ? ? switch (oh->class->rev) {
+ ? ? case 0:
+ ? ? ? ? ? ? if (id == 1)
+ ? ? ? ? ? ? ? ? ? ? /* non-wakeup GPIO pins for OMAP2420 Bank1 */
+ ? ? ? ? ? ? ? ? ? ? pdata->non_wakeup_gpios = 0xe203ffc0;
+ ? ? ? ? ? ? else if (id == 2)
+ ? ? ? ? ? ? ? ? ? ? /* non-wakeup GPIO pins for OMAP2420 Bank2 */
+ ? ? ? ? ? ? ? ? ? ? pdata->non_wakeup_gpios = 0x08700040;
+ ? ? ? ? ? ? break;
+ ? ? case 2:
+ ? ? ? ? ? ? if (id == 2)
Quoted 8 lines

arch/arm/mach-omap2/gpio.c static int omap2_gpio_dev_init(struct · line 76

Quoted 6 lines
arch/arm/mach-omap2/gpio.c +6 -0
+ ? ? ? ? ? ? ? ? ? ? /* non-wakeup GPIO pins for OMAP3 Bank2 */
+ ? ? ? ? ? ? ? ? ? ? pdata->non_wakeup_gpios = 0x00000001;
+ ? ? ? ? ? ? else if (id == 6)
+ ? ? ? ? ? ? ? ? ? ? /* non-wakeup GPIO pins for OMAP3 Bank6 */
+ ? ? ? ? ? ? ? ? ? ? pdata->non_wakeup_gpios = 0x08000000;
+ ? ? ? ? ? ? break;

[sp] Where is the description on non-wakeup GPIOs in OMAP3?

As mentioned in other reply, I am referring to
Table 25-5. GPIO Channel Description at page no 3354 OMAP3430 public TRM Version P. Please correct me if I am wrong.

Quoted 23 lines

? ? Here is text from AM37x TRM:
? ? [quote ...only relevant text]
? ? Each GPIO module provides 32 dedicated general-purpose pins with input ? ? and output capabilities; .... These pins can be configured for the ? ? following applications:
? ? - Data input (capture)/output (drive)
? ? - Keyboard interface with a debounce cell
? ? - Interrupt generation in ....
? ? - Wake-up request generation in idle mode
? ? [/quote]
? ? Otherwise, what are the GPIO2_WAKEUPENABLE (0x4905 0020) and ? ? GPIO6_WAKEUPENABLE (0x4905 8020) meant for?

arch/arm/mach-omap2/gpio.c static int omap2_gpio_dev_init(struct · line 81

Quoted 5 lines
arch/arm/mach-omap2/gpio.c +5 -0
+ ? ? default:
+ ? ? ? ? ? ? /* No non-wakeup GPIO pins for other SoCs */
+ ? ? ? ? ? ? break;
+ ? ? }
+

~sanjeev

[snip]...[snip]

#12 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

In reply to Premi, Sanjeev
Quoted 23 lines · Sanjeev
Quoted 14 lines

From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM

From: Charulatha V<[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430)& not for OMAP3 which is incorrect.

Fix the above by providing non-wakeup GPIO information through pdata specific to the SoC.

Quoted 8 lines

The GPIO rev id provided in the hwmod database is the same for OMAP2420
and OMAP2430. Change the GPIO rev ids in hwmod database as given below so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

Quoted 6 lines

[sp] Magic numbers should be avoided.

      Suggest using something like:
      #define GPIO_REV_2420	0
      #define GPIO_REV_2430	1
      #define GPIO_REV_34XX	2
      #define GPIO_REV_44xx	3

Well, it is not a magic number, it is a revision id that is incremented each time there is a difference in the IP.
The OMAP version -> IP version link is done at hwmod level. The driver does not have to know it is an OMAP3 or OMAP4. In that case we did change the IP version for every revisions, but OMAP5 will use the OMAP4 revision.
I'm not even considering all the Davinci variants that are not named OMAP but do use OMAP IPs... as you already know...
That can provide a rather confusing information for my point of view.

Whereas a comment like that will give you the exhaustive information.

0: OMAP2420
1: OMAP2430
2: OMAP3, DMxxx
3: OMAP4, OMAP5, DM816x

That being said, some drivers already did that, so I'm not opposed to such change. I just think it is not the best approach.
At least it gives a pointer to the TRM that contains the IP doc.

Quoted 4 lines

We don't have to refer back to this comment while reading the code. I also believed that HWMODs were auto generated.
Can the changes to structures in this patch recreated using current scripts?

Only OMAP4 & 5 are generated today, and in anycase this information is some custom data added by driver owner. So we just have to update that information.
I cannot really use the real HW IP version because it is irrelevant most of the time. Maybe in the future we will be able to force the HW team to provide relevant data in that field :-)

Regards,
Benoit

Quoted 67 lines

~sanjeev

Quoted 30 lines
Cc Cousson, Benoit<[email protected]>
Cc Paul Walmsley<[email protected]>
---
  arch/arm/mach-omap2/gpio.c                 |   26
++++++++++++++++++++++++--
  arch/arm/mach-omap2/omap_hwmod_2430_data.c |    2 +-
  arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    2 +-
  arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    2 +-
  arch/arm/plat-omap/include/plat/gpio.h     |    1 +
  drivers/gpio/gpio_omap.c                   |   11 +++--------
  6 files changed, 31 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/gpio.c +7 -0
index 0446bd1..6cd26b4 100644
@@ -56,6 +56,28 @@ static int omap2_gpio_dev_init(struct
 omap_hwmod *oh, void *unused)
  		return -ENOMEM;
  	}
 
+	switch (oh->class->rev) {
+	case 0:
+		if (id == 1)
+			/* non-wakeup GPIO pins for OMAP2420 Bank1 */
+			pdata->non_wakeup_gpios = 0xe203ffc0;
+		else if (id == 2)
+			/* non-wakeup GPIO pins for OMAP2420 Bank2 */

arch/arm/mach-omap2/gpio.c static int omap2_gpio_dev_init(struct · line 76

Quoted 10 lines
arch/arm/mach-omap2/gpio.c +10 -0
+			pdata->non_wakeup_gpios = 0x08700040;
+		break;
+	case 2:
+		if (id == 2)
+			/* non-wakeup GPIO pins for OMAP3 Bank2 */
+			pdata->non_wakeup_gpios = 0x00000001;
+		else if (id == 6)
+			/* non-wakeup GPIO pins for OMAP3 Bank6 */
+			pdata->non_wakeup_gpios = 0x08000000;
+		break;

[sp] Where is the description on non-wakeup GPIOs in OMAP3?
Here is text from AM37x TRM:
[quote ...only relevant text]
Each GPIO module provides 32 dedicated general-purpose pins with input and output capabilities; .... These pins can be configured for the following applications:
- Data input (capture)/output (drive)
- Keyboard interface with a debounce cell
- Interrupt generation in ....
- Wake-up request generation in idle mode
[/quote]
Otherwise, what are the GPIO2_WAKEUPENABLE (0x4905 0020) and GPIO6_WAKEUPENABLE (0x4905 8020) meant for?

arch/arm/mach-omap2/gpio.c static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) · line 80

Quoted 5 lines
arch/arm/mach-omap2/gpio.c +5 -0
+	default:
+		/* No non-wakeup GPIO pins for other SoCs */
+		break;
+	}
+

~sanjeev

[snip]...[snip]

#13 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 59 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 3:41 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 5 lines · Sanjeev
Quoted 5 lines

From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM

Quoted 7 lines
Quoted 7 lines

From: Charulatha V<[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx (bothe OMAP 2420 and 2430)& not for OMAP3 which is incorrect.

Fix the above by providing non-wakeup GPIO information

through pdata

Quoted 5 lines
Quoted 5 lines

specific to the SoC.

The GPIO rev id provided in the hwmod database is the same for OMAP2420
and OMAP2430. Change the GPIO rev ids in hwmod database as

given below

Quoted 6 lines
Quoted 5 lines

so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

Quoted 6 lines

[sp] Magic numbers should be avoided.

      Suggest using something like:
      #define GPIO_REV_2420	0
      #define GPIO_REV_2430	1
      #define GPIO_REV_34XX	2
      #define GPIO_REV_44xx	3

Well, it is not a magic number, it is a revision id that is incremented
each time there is a difference in the IP.
The OMAP version -> IP version link is done at hwmod level. The driver
does not have to know it is an OMAP3 or OMAP4. In that case we did change the IP version for every revisions, but OMAP5 will use the OMAP4
revision.
I'm not even considering all the Davinci variants that are not named OMAP but do use OMAP IPs... as you already know...
That can provide a rather confusing information for my point of view.

Whereas a comment like that will give you the exhaustive information.

Quoted 8 lines

0: OMAP2420
1: OMAP2430
2: OMAP3, DMxxx
3: OMAP4, OMAP5, DM816x

That being said, some drivers already did that, so I'm not opposed to such change. I just think it is not the best approach.
At least it gives a pointer to the TRM that contains the IP doc.

[sp] Benoit, your are right from generation perspectove where the
it is easier to increment numbers but when we use comparison code - as in this patch, comparison against a number isn't readable.

As example:

+ switch (oh->class->rev) { ## This is auto-generated.
+ case 0: ## But this is our code.

I am recommending this to read as:

+ switch (oh->class->rev) { ## This is auto-generated.
+ case GPIO_REV_2420: ## More readable.

~sanjeev

Quoted 95 lines
Quoted 2 lines

We don't have to refer back to this comment while

reading the code.

Quoted 2 lines

I also believed that HWMODs were auto generated. Can the changes to structures in this patch recreated

using current

Quoted 1 line

scripts?

Only OMAP4 & 5 are generated today, and in anycase this information is
some custom data added by driver owner. So we just have to update that
information.
I cannot really use the real HW IP version because it is irrelevant most
of the time. Maybe in the future we will be able to force the HW team to
provide relevant data in that field :-)

Regards,
Benoit

Quoted 17 lines

~sanjeev

Quoted 14 lines
Cc Cousson, Benoit<[email protected]>
Cc Paul Walmsley<[email protected]>
---
  arch/arm/mach-omap2/gpio.c                 |   26
++++++++++++++++++++++++--
  arch/arm/mach-omap2/omap_hwmod_2430_data.c |    2 +-
  arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |    2 +-
  arch/arm/mach-omap2/omap_hwmod_44xx_data.c |    2 +-
  arch/arm/plat-omap/include/plat/gpio.h     |    1 +
  drivers/gpio/gpio_omap.c                   |   11 +++--------
  6 files changed, 31 insertions(+), 13 deletions(-)
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/mach-omap2/gpio.c

Quoted 22 lines
Quoted 22 lines

index 0446bd1..6cd26b4 100644

arch/arm/mach-omap2/gpio.c +14 -0
@@ -56,6 +56,28 @@ static int omap2_gpio_dev_init(struct
 omap_hwmod *oh, void *unused)
  		return -ENOMEM;
  	}
 
+	switch (oh->class->rev) {
+	case 0:
+		if (id == 1)
+			/* non-wakeup GPIO pins for OMAP2420 Bank1 */
+			pdata->non_wakeup_gpios = 0xe203ffc0;
+		else if (id == 2)
+			/* non-wakeup GPIO pins for OMAP2420 Bank2 */
+			pdata->non_wakeup_gpios = 0x08700040;
+		break;
+	case 2:
+		if (id == 2)
+			/* non-wakeup GPIO pins for OMAP3 Bank2 */
+			pdata->non_wakeup_gpios = 0x00000001;
+		else if (id == 6)
Quoted 8 lines

arch/arm/mach-omap2/gpio.c static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) · line 75

Quoted 3 lines
arch/arm/mach-omap2/gpio.c +3 -0
+			/* non-wakeup GPIO pins for OMAP3 Bank6 */
+			pdata->non_wakeup_gpios = 0x08000000;
+		break;

[sp] Where is the description on non-wakeup GPIOs in OMAP3?
Here is text from AM37x TRM:
[quote ...only relevant text]
Each GPIO module provides 32 dedicated

general-purpose pins with input

Quoted 1 line

and output capabilities; .... These pins can be

configured for the

Quoted 18 lines

following applications:
- Data input (capture)/output (drive)
- Keyboard interface with a debounce cell
- Interrupt generation in ....
- Wake-up request generation in idle mode [/quote]
Otherwise, what are the GPIO2_WAKEUPENABLE (0x4905 0020) and GPIO6_WAKEUPENABLE (0x4905 8020) meant for?

arch/arm/mach-omap2/gpio.c static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) · line 80

Quoted 5 lines
arch/arm/mach-omap2/gpio.c +5 -0
+	default:
+		/* No non-wakeup GPIO pins for other SoCs */
+		break;
+	}
+

~sanjeev

[snip]...[snip]

#14 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 64 lines · Sanjeev
Quoted 64 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 3:41 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 5 lines · Sanjeev
Quoted 5 lines

From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM

Quoted 7 lines
Quoted 7 lines

From: Charulatha V<[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx
(bothe OMAP 2420 and 2430)& not for OMAP3 which is incorrect.

Fix the above by providing non-wakeup GPIO information

through pdata

Quoted 5 lines
Quoted 5 lines

specific to the SoC.

The GPIO rev id provided in the hwmod database is the same for OMAP2420
and OMAP2430. Change the GPIO rev ids in hwmod database as

given below

Quoted 6 lines
Quoted 5 lines

so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

Quoted 6 lines

[sp] Magic numbers should be avoided.

       Suggest using something like:
       #define GPIO_REV_2420	0
       #define GPIO_REV_2430	1
       #define GPIO_REV_34XX	2
       #define GPIO_REV_44xx	3

Well, it is not a magic number, it is a revision id that is incremented
each time there is a difference in the IP.
The OMAP version -> IP version link is done at hwmod level. The driver
does not have to know it is an OMAP3 or OMAP4. In that case we did change the IP version for every revisions, but OMAP5 will use the OMAP4
revision.
I'm not even considering all the Davinci variants that are not named OMAP but do use OMAP IPs... as you already know...
That can provide a rather confusing information for my point of view.

Whereas a comment like that will give you the exhaustive information.

0: OMAP2420
1: OMAP2430
2: OMAP3, DMxxx
3: OMAP4, OMAP5, DM816x

Quoted 6 lines
Quoted 3 lines

That being said, some drivers already did that, so I'm not opposed to such change. I just think it is not the best approach.
At least it gives a pointer to the TRM that contains the IP doc.

[sp] Benoit, your are right from generation perspectove where the
it is easier to increment numbers but when we use comparison

This is not even related to generation. A version number is a number. If OMAP2 is using GPIO v1.6 and OMAP3 the version v2.2, only that IP version is relevant for the driver.
For the documentation point of view, since we do not have a per IP TRM, then it can make sense to know where that IP is documented. But as I said a comment is enough and will allow a much more relevant level of details information than a define.

Quoted 5 lines

code - as in this patch, comparison against a number isn't readable.

As example:

Quoted 7 lines

+ switch (oh->class->rev) { ## This is auto-generated.
+ case 0: ## But this is our code.

I am recommending this to read as:

+ switch (oh->class->rev) { ## This is auto-generated.
+ case GPIO_REV_2420: ## More readable.

More readable, maybe, but not necessarily relevant nor accurate if the same IP version is used in another chip or revision.

What IP version is used in a DM816x? GPIO_REV_3430, GPIO_REV_4430?

Benoit

#15 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 106 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 5:41 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 44 lines · Sanjeev
Quoted 44 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 3:41 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 5 lines · Sanjeev
Quoted 5 lines

From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM

Quoted 7 lines
Quoted 7 lines

From: Charulatha V<[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx
(bothe OMAP 2420 and 2430)& not for OMAP3 which is incorrect.

Fix the above by providing non-wakeup GPIO information

through pdata

Quoted 5 lines
Quoted 5 lines

specific to the SoC.

The GPIO rev id provided in the hwmod database is the same for OMAP2420
and OMAP2430. Change the GPIO rev ids in hwmod database as

given below

Quoted 12 lines
Quoted 5 lines

so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

[sp] Magic numbers should be avoided.

       Suggest using something like:
       #define GPIO_REV_2420	0
       #define GPIO_REV_2430	1
       #define GPIO_REV_34XX	2
       #define GPIO_REV_44xx	3
Quoted 10 lines
Quoted 10 lines

Well, it is not a magic number, it is a revision id that is incremented
each time there is a difference in the IP.
The OMAP version -> IP version link is done at hwmod level. The driver
does not have to know it is an OMAP3 or OMAP4. In that case we did change the IP version for every revisions, but OMAP5 will use the OMAP4
revision.
I'm not even considering all the Davinci variants that are

not named

Quoted 2 lines
Quoted 2 lines

OMAP but do use OMAP IPs... as you already know... That can provide a rather confusing information for my

point of view.

Quoted 2 lines
Quoted 2 lines

Whereas a comment like that will give you the exhaustive

information.

Quoted 7 lines
Quoted 7 lines

0: OMAP2420
1: OMAP2430
2: OMAP3, DMxxx
3: OMAP4, OMAP5, DM816x

That being said, some drivers already did that, so I'm not

opposed to

Quoted 5 lines
Quoted 2 lines

such change. I just think it is not the best approach. At least it gives a pointer to the TRM that contains the IP doc.

[sp] Benoit, your are right from generation perspectove where the
it is easier to increment numbers but when we use comparison

This is not even related to generation. A version number is a number. If OMAP2 is using GPIO v1.6 and OMAP3 the version v2.2, only that IP version is relevant for the driver.
For the documentation point of view, since we do not have a per IP TRM,
then it can make sense to know where that IP is documented. But as I said a comment is enough and will allow a much more relevant level of details information than a define.

Quoted 10 lines

code - as in this patch, comparison against a number isn't readable.

As example:

+ switch (oh->class->rev) { ## This is auto-generated.
+ case 0: ## But this is our code.

I am recommending this to read as:

Quoted 8 lines
Quoted 2 lines

+ switch (oh->class->rev) { ## This is auto-generated.
+ case GPIO_REV_2420: ## More readable.

More readable, maybe, but not necessarily relevant nor accurate if the
same IP version is used in another chip or revision.

What IP version is used in a DM816x? GPIO_REV_3430, GPIO_REV_4430?

How is value 0 accurate?

Quoted 3 lines

Benoit

#16 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 109 lines · Sanjeev
Quoted 109 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 5:41 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 44 lines · Sanjeev
Quoted 44 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 3:41 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 5 lines · Sanjeev
Quoted 5 lines

From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM

Quoted 7 lines
Quoted 7 lines

From: Charulatha V<[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and OMAP3430. But the GPIO driver initializes the non-wakeup GPIO bits for OMAP24xx
(bothe OMAP 2420 and 2430)& not for OMAP3 which is incorrect.

Fix the above by providing non-wakeup GPIO information

through pdata

Quoted 5 lines
Quoted 5 lines

specific to the SoC.

The GPIO rev id provided in the hwmod database is the same for OMAP2420
and OMAP2430. Change the GPIO rev ids in hwmod database as

given below

Quoted 12 lines
Quoted 5 lines

so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

[sp] Magic numbers should be avoided.

        Suggest using something like:
        #define GPIO_REV_2420	0
        #define GPIO_REV_2430	1
        #define GPIO_REV_34XX	2
        #define GPIO_REV_44xx	3
Quoted 10 lines
Quoted 10 lines

Well, it is not a magic number, it is a revision id that is incremented
each time there is a difference in the IP.
The OMAP version -> IP version link is done at hwmod level.
The driver
does not have to know it is an OMAP3 or OMAP4. In that case we did change the IP version for every revisions, but OMAP5 will use the OMAP4
revision.
I'm not even considering all the Davinci variants that are

not named

Quoted 2 lines
Quoted 2 lines

OMAP but do use OMAP IPs... as you already know... That can provide a rather confusing information for my

point of view.

Quoted 2 lines
Quoted 2 lines

Whereas a comment like that will give you the exhaustive

information.

Quoted 7 lines
Quoted 7 lines

0: OMAP2420
1: OMAP2430
2: OMAP3, DMxxx
3: OMAP4, OMAP5, DM816x

That being said, some drivers already did that, so I'm not

opposed to

Quoted 5 lines
Quoted 2 lines

such change. I just think it is not the best approach. At least it gives a pointer to the TRM that contains the IP doc.

[sp] Benoit, your are right from generation perspectove where the
it is easier to increment numbers but when we use comparison

This is not even related to generation. A version number is a number. If OMAP2 is using GPIO v1.6 and OMAP3 the version v2.2, only that IP version is relevant for the driver.
For the documentation point of view, since we do not have a per IP TRM,
then it can make sense to know where that IP is documented. But as I said a comment is enough and will allow a much more relevant level of details information than a define.

Quoted 12 lines

code - as in this patch, comparison against a number isn't readable.

As example:

   +	switch (oh->class->rev) {     ## This is auto-generated.
   +	case 0:				## But this is our code.

       I am recommending this to read as:

   +	switch (oh->class->rev) {     ## This is auto-generated.
   +	case GPIO_REV_2420:		## More readable.
Quoted 7 lines
Quoted 5 lines

More readable, maybe, but not necessarily relevant nor accurate if the
same IP version is used in another chip or revision.

What IP version is used in a DM816x? GPIO_REV_3430, GPIO_REV_4430?

How is value 0 accurate?

0 is just the revision number that can give you the exact list of Soc that does use that IP. Thanks to an exhaustive comment.

0: OMAP2420
1: OMAP2430
2: OMAP3, DMxxx
3: OMAP4, OMAP5, DM816x

BTW, I'm still waiting the answer for previous question...

Regards,
Benoit

#17 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 41 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 6:17 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 29 lines · Sanjeev
Quoted 29 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 5:41 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 17 lines · Sanjeev
Quoted 17 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Thursday, May 26, 2011 3:41 PM
To: Premi, Sanjeev
Cc: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org; Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha; Paul Walmsley
Subject: Re: [PATCH 02/15] OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 5 lines · Sanjeev
Quoted 5 lines

From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM

Quoted 33 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

From: Charulatha V<[email protected]>

Non-wakeup GPIOs are available only in OMAP2420 and

OMAP3430. But

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the GPIO driver initializes the non-wakeup GPIO bits

for OMAP24xx

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(bothe OMAP 2420 and 2430)& not for OMAP3 which is

incorrect.

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 2 lines
Quoted 2 lines

Fix the above by providing non-wakeup GPIO information

through pdata

Quoted 5 lines
Quoted 5 lines

specific to the SoC.

The GPIO rev id provided in the hwmod database is the same for OMAP2420
and OMAP2430. Change the GPIO rev ids in hwmod database as

given below

Quoted 6 lines
Quoted 5 lines

so that it can be used to identify OMAP2420 and OMAP2430. OMAP2420 - 0
OMAP2430 - 1
OMAP3 - 2
OMAP4 - 3

Quoted 6 lines

[sp] Magic numbers should be avoided.

        Suggest using something like:
        #define GPIO_REV_2420	0
        #define GPIO_REV_2430	1
        #define GPIO_REV_34XX	2
        #define GPIO_REV_44xx	3

Well, it is not a magic number, it is a revision id that is incremented
each time there is a difference in the IP.

[sp] Just to quote a definition:
[quote]The term magic number or magic constant also refers to the programming practice of using numbers directly in source code. [/quote]

It has no relation to whether/how it can signify something important.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The OMAP version -> IP version link is done at hwmod level.
The driver
does not have to know it is an OMAP3 or OMAP4. In that

case we did

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

change the IP version for every revisions, but OMAP5 will use the OMAP4
revision.

[sp] I don't understand the confusion because IPs are anyways
going to be used across. Many macros originally created for OMAP34XX are true/valid for OMAP36XX. And same holds good (probably) for OMAP24XX as well.

But in each context, we are aware of the intended usage and can relate to the use and reuse better because it is quite evident. Use of OMAP2_CONTROL_GENERAL in OMAP34xx specific function is not accurate by your example below, but we all know the meaning and need for the same.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

I'm not even considering all the Davinci variants that are

not named

Quoted 2 lines
Quoted 2 lines

OMAP but do use OMAP IPs... as you already know... That can provide a rather confusing information for my

point of view.

[sp] So now what happens when existing IP gets changed to fix
an issue in existing OMAP3 design. Going by same logic will we add another id for the same?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Whereas a comment like that will give you the exhaustive

information.

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

0: OMAP2420
1: OMAP2430
2: OMAP3, DMxxx
3: OMAP4, OMAP5, DM816x

That being said, some drivers already did that, so I'm not

opposed to

Quoted 1 line
Quoted 1 line

such change. I just think it is not the best approach.

[sp] Taking same point further, if the IP from OMAP4 above
gets used to create OMAP3699 (for example). How does this case get handled? OR we expect users to know about exceptions each time they read code?

Leaving aside the fact the situation is hypothetical; design should be generic to handle such situations.

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

At least it gives a pointer to the TRM that contains the IP doc.

[sp] Benoit, your are right from generation perspectove where the
it is easier to increment numbers but when we use

comparison

Quoted 2 lines
Quoted 2 lines

This is not even related to generation. A version number

is a number.

Quoted 1 line
Quoted 1 line

If OMAP2 is using GPIO v1.6 and OMAP3 the version v2.2,

Quoted 9 lines

only that IP

Quoted 4 lines
Quoted 4 lines

version is relevant for the driver.
For the documentation point of view, since we do not have a per IP TRM,
then it can make sense to know where that IP is

documented. But as I

Quoted 1 line
Quoted 1 line

said a comment is enough and will allow a much more

relevant level of

Quoted 1 line
Quoted 1 line

details information than a define.

[sp] Based on what I have read, it makes more sense is to have
the IP version used in this field verbatim. Then there is no pollution with processor containing the IP.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 6 lines

code - as in this patch, comparison against a number isn't readable.

As example:

Quoted 7 lines
   +	switch (oh->class->rev) {     ## This is auto-generated.
   +	case 0:				## But this is our code.

       I am recommending this to read as:

   +	switch (oh->class->rev) {     ## This is auto-generated.
   +	case GPIO_REV_2420:		## More readable.

More readable, maybe, but not necessarily relevant nor accurate if the
same IP version is used in another chip or revision.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

What IP version is used in a DM816x? GPIO_REV_3430, GPIO_REV_4430?

How is value 0 accurate?

0 is just the revision number that can give you the exact list of Soc that does use that IP. Thanks to an exhaustive comment.

[sp] The exhaustive comment will not accompany every place the field
"rev" is used in the code. So someone needs to find this comment and then get the meaning of a revision.

Otherwise why do we define so many macros in files like control.h? Exhaustive comments would have served well!

Quoted 8 lines

0: OMAP2420
1: OMAP2430
2: OMAP3, DMxxx
3: OMAP4, OMAP5, DM816x

BTW, I'm still waiting the answer for previous question...

[sp] I didn't find a question - but responsded to what I appeared to
me as question(s).
I will be offline for few days. Futher responses will be delayed.

~sanjeev

Quoted 4 lines

Regards,
Benoit

#18 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

In reply to Cousson, Benoit

Why not do the following:

       #define OMAP_GPIO_REV_0	0
       #define OMAP_GPIO_REV_1	1
       #define OMAP_GPIO_REV_2	2
       #define OMAP_GPIO_REV_3	3
/*
	OMAP_GPIO_REV_0:	OMAP2420
	OMAP_GPIO_REV_1:	OMAP2430
	OMAP_GPIO_REV_2:	OMAP3, DMxxx
	OMAP_GPIO_REV_3:	OMAP4, OMAP5, DM816x

*/

+ switch (oh->class->rev) { ## This is auto-generated.
+ case 0: ## But this is our code.

I am recommending this to read as:

+ switch (oh->class->rev) { ## This is auto-generated.
+ case OMAP_GPIO_REV_0: ## More readable.

That approach solves both issues -- Revision -> Chip mapping in comment, no magic numbers in the code, and no implied restriction of the rev number to a specific SoC. Using the defines makes it easier to search the code for a specific revision, since you would no longer get false positives for all the other '0' and '1' constants that appear in the code. It also makes it indexible by tools like LXR.

B.J. Buchalter
Metric Halo
http://www.mhlabs.com

#19 lore raw

PATCH 2/15 OMAP2PLUS: GPIO: Fix non-wakeup GPIO and rev_ids

Quoted 21 lines · B.J. Buchalter

Why not do the following:

        #define OMAP_GPIO_REV_0	0
        #define OMAP_GPIO_REV_1	1
        #define OMAP_GPIO_REV_2	2
        #define OMAP_GPIO_REV_3	3
/*
	OMAP_GPIO_REV_0:	OMAP2420
	OMAP_GPIO_REV_1:	OMAP2430
	OMAP_GPIO_REV_2:	OMAP3, DMxxx
	OMAP_GPIO_REV_3:	OMAP4, OMAP5, DM816x

*/

   +	switch (oh->class->rev) {     ## This is auto-generated.
   +	case 0:				## But this is our code.

       I am recommending this to read as:

   +	switch (oh->class->rev) {     ## This is auto-generated.
   +	case OMAP_GPIO_REV_0:		## More readable.
Quoted 1 line

That approach solves both issues -- Revision -> Chip mapping in comment, no magic numbers in the code, and no implied restriction of the rev number to a specific SoC. Using the defines makes it easier to search the code for a specific revision, since you would no longer get false positives for all the other '0' and '1' constants that appear in the code. It also makes it indexible by tools like LXR.

This is indeed what was done for I2C recently.
The point is that this kind of define does not bring a lot of semantic. But on the other hand it will definitively help the search aspect.

Thanks,
Benoit

#20 lore raw

PATCH 3/15 OMAP: GPIO: Remove dependency on gpio_bank_count

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

gpio_bank_count is the count of number of GPIO devices in a SoC. Remove this dependency from the driver. Also remove the dependency on array of pointers to gpio_bank struct of all GPIO devices.

TODO:
The save_context/ restore_context need to be modified to be called from the prepare_for_/resume_after_ idle, only for the specific banks and remove the gpio_save_context call from pm34xx.c. This would be handled in one of the later patches in this series.

---
 arch/arm/mach-omap1/gpio15xx.c         |    1 -
 arch/arm/mach-omap1/gpio16xx.c         |    2 -
 arch/arm/mach-omap1/gpio7xx.c          |    2 -
 arch/arm/mach-omap2/gpio.c             |    1 -
 arch/arm/plat-omap/include/plat/gpio.h |    3 -
 drivers/gpio/gpio_omap.c               |  156 ++++++++++++++++----------------
 6 files changed, 76 insertions(+), 89 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +0 -1
index 6d83e0a..f18a4a9 100644
@@ -117,7 +117,6 @@ static int __init omap15xx_gpio_init(void)
 	platform_device_register(&omap15xx_mpu_gpio);
 	platform_device_register(&omap15xx_gpio);
 
-	gpio_bank_count = 2;
 	return 0;
 }
 postcore_initcall(omap15xx_gpio_init);
arch/arm/mach-omap1/gpio16xx.c +0 -2
index 6bba196..d886b88 100644
@@ -223,8 +223,6 @@ static int __init omap16xx_gpio_init(void)
 	for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
 		platform_device_register(omap16xx_gpio_dev[i]);
 
-	gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev);
-
 	return 0;
 }
 postcore_initcall(omap16xx_gpio_init);
arch/arm/mach-omap1/gpio7xx.c +0 -2
index 0fc2557..c7684ce 100644
@@ -284,8 +284,6 @@ static int __init omap7xx_gpio_init(void)
 	for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
 		platform_device_register(omap7xx_gpio_dev[i]);
 
-	gpio_bank_count = ARRAY_SIZE(omap7xx_gpio_dev);
-
 	return 0;
 }
 postcore_initcall(omap7xx_gpio_init);
arch/arm/mach-omap2/gpio.c +0 -1
index 6cd26b4..487b49a 100644
@@ -143,7 +143,6 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		return PTR_ERR(od);
 	}
 
-	gpio_bank_count++;
 	return 0;
 }
 
arch/arm/plat-omap/include/plat/gpio.h +0 -3
index 8014a8a..ad9e668 100644
@@ -204,9 +204,6 @@ struct omap_gpio_platform_data {
 	struct omap_gpio_reg_offs *regs;
 };
 
-/* TODO: Analyze removing gpio_bank_count usage from driver code */
-extern int gpio_bank_count;
-
 extern void omap2_gpio_prepare_for_idle(int off_mode);
 extern void omap2_gpio_resume_after_idle(void);
 extern void omap_set_gpio_debounce(int gpio, int enable);
drivers/gpio/gpio_omap.c +76 -80

306 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#21 lore raw

PATCH 4/15 OMAP2PLUS: GPIO: Use flag to identify wkup dmn GPIO

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

In omap3, save/restore context is implemented for GPIO banks 2-6 as GPIO bank1 is in wakeup domain. Instead of identifying bank's power domain by bank id, make use of a flag "loses_context" which is filled by pwrdm_can_ever_lose_context() during dev_init.

For getting the powerdomain pointer, omap_hwmod_get_pwrdm() is used. omap_device_get_pwrdm() could not be used as the pwrdm information needs to be filled in pdata, whereas omap_device_get_pwrdm() could be used only after omap_device_build() call.

---
 arch/arm/mach-omap2/gpio.c             |    7 +++++++
 arch/arm/plat-omap/include/plat/gpio.h |    1 +
 drivers/gpio/gpio_omap.c               |   12 ++++++------
 3 files changed, 14 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/gpio.c +7 -0
index 487b49a..0782e06 100644
@@ -24,6 +24,8 @@
 #include <plat/omap_hwmod.h>
 #include <plat/omap_device.h>
 
+#include "powerdomain.h"
+
 static struct omap_device_pm_latency omap_gpio_latency[] = {
 	[0] = {
 		.deactivate_func = omap_device_idle_hwmods,
@@ -39,6 +41,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 	struct omap_gpio_dev_attr *dev_attr;
 	char *name = "omap_gpio";
 	int id;
+	struct powerdomain *pwrdm;
 
 	/*
 	 * extract the device id from name field available in the
@@ -131,6 +134,10 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		kfree(pdata);
 		return -EINVAL;
 	}
+
+	pwrdm = omap_hwmod_get_pwrdm(oh);
+	pdata->loses_context = pwrdm_can_ever_lose_context(pwrdm);
+
 	od = omap_device_build(name, id - 1, oh, pdata,
 				sizeof(*pdata),	omap_gpio_latency,
 				ARRAY_SIZE(omap_gpio_latency),
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index ad9e668..64b1ee7 100644
@@ -199,6 +199,7 @@ struct omap_gpio_platform_data {
 	int bank_width;		/* GPIO bank width */
 	int bank_stride;	/* Only needed for omap1 MPUIO */
 	bool dbck_flag;		/* dbck required or not - True for OMAP3&4 */
+	bool loses_context;	/* whether the bank would ever lose context */
 	u32 non_wakeup_gpios;
 
 	struct omap_gpio_reg_offs *regs;
drivers/gpio/gpio_omap.c +6 -6
index c6a1ec9..3f1c932 100644
@@ -56,6 +56,7 @@ struct gpio_bank {
 	u32 dbck_enable_mask;
 	struct device *dev;
 	bool dbck_flag;
+	bool loses_context;
 	int stride;
 	u32 width;
 	u16 id;
@@ -1159,6 +1160,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	bank->stride = pdata->bank_stride;
 	bank->width = pdata->bank_width;
 	bank->non_wakeup_gpios = pdata->non_wakeup_gpios;
+	bank->loses_context = pdata->loses_context;
 
 	bank->regs = pdata->regs;
 
@@ -1323,8 +1325,7 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 		u32 l1 = 0, l2 = 0;
 		int j;
 
-		/* TODO: Do not use cpu_is_omap34xx */
-		if ((cpu_is_omap34xx()) && (bank->id == 0))
+		if (!bank->loses_context)
 			continue;
 
 		for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
@@ -1391,8 +1392,7 @@ void omap2_gpio_resume_after_idle(void)
 		u32 l = 0, gen, gen0, gen1;
 		int j;
 
-		/* TODO: Do not use cpu_is_omap34xx */
-		if ((cpu_is_omap34xx()) && (bank->id == 0))
+		if (!bank->loses_context)
 			continue;
 
 		for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
@@ -1491,7 +1491,7 @@ void omap_gpio_save_context(void)
 	list_for_each_entry(bank, &omap_gpio_list, node) {
 		i++;
 
-		if (bank->id == 0)
+		if (!bank->loses_context)
 			continue;
 
 		gpio_context[i].irqenable1 =
@@ -1525,7 +1525,7 @@ void omap_gpio_restore_context(void)
 	list_for_each_entry(bank, &omap_gpio_list, node) {
 		i++;
 
-		if (bank->id == 0)
+		if (!bank->loses_context)
 			continue;
 
 		__raw_writel(gpio_context[i].irqenable1,
Signature · 1 line
1.6.0.4
#22 lore raw

PATCH 4/15 OMAP2PLUS: GPIO: Use flag to identify wkup dmn GPIO

Quoted 8 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

In omap3, save/restore context is implemented for GPIO banks 2-6 as GPIO bank1 is in wakeup domain. Instead of identifying bank's power domain by bank id, make use of a flag "loses_context" which is filled by pwrdm_can_ever_lose_context() during dev_init.

Quoted 7 lines

For getting the powerdomain pointer, omap_hwmod_get_pwrdm() is used. omap_device_get_pwrdm() could not be used as the pwrdm information needs to be filled in pdata, whereas omap_device_get_pwrdm() could be used only after omap_device_build() call.

Looks good.

Kevin

#23 lore raw

PATCH 5/15 OMAP: GPIO: Make gpio_context part of gpio_bank structure

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

gpio_context array, which is used to save gpio bank's context, is used only for OMAP3 architecture.

Move gpio_context as part of gpio_bank structure so that it can be specific to each gpio bank and can be used for any OMAP architecture

TODO: extend the gpio save/restore context function for OMAP4 architecture. This is done in one of the next patches in this series

---
 drivers/gpio/gpio_omap.c |   76 ++++++++++++++++++++-------------------------
 1 files changed, 34 insertions(+), 42 deletions(-)
drivers/gpio/gpio_omap.c +34 -42
index 3f1c932..5673951 100644
@@ -30,6 +30,19 @@
 
 static LIST_HEAD(omap_gpio_list);
 
+struct gpio_regs {
+	u32 irqenable1;
+	u32 irqenable2;
+	u32 wake_en;
+	u32 ctrl;
+	u32 oe;
+	u32 leveldetect0;
+	u32 leveldetect1;
+	u32 risingdetect;
+	u32 fallingdetect;
+	u32 dataout;
+};
+
 struct gpio_bank {
 	struct list_head node;
 	unsigned long pbase;
@@ -43,7 +56,7 @@ struct gpio_bank {
 #endif
 	u32 non_wakeup_gpios;
 	u32 enabled_non_wakeup_gpios;
-
+	struct gpio_regs context;
 	u32 saved_datain;
 	u32 saved_fallingdetect;
 	u32 saved_risingdetect;
@@ -66,23 +79,6 @@ struct gpio_bank {
 	struct omap_gpio_reg_offs *regs;
 };
 
-#ifdef CONFIG_ARCH_OMAP3
-struct omap3_gpio_regs {
-	u32 irqenable1;
-	u32 irqenable2;
-	u32 wake_en;
-	u32 ctrl;
-	u32 oe;
-	u32 leveldetect0;
-	u32 leveldetect1;
-	u32 risingdetect;
-	u32 fallingdetect;
-	u32 dataout;
-};
-
-static struct omap3_gpio_regs gpio_context[OMAP34XX_NR_GPIOS];
-#endif
-
 #define GPIO_INDEX(bank, gpio) (gpio % bank->width)
 #define GPIO_BIT(bank, gpio) (1 << GPIO_INDEX(bank, gpio))
 #define GPIO_MOD_CTRL_BIT	BIT(0)
@@ -1486,33 +1482,31 @@ void omap2_gpio_resume_after_idle(void)
 void omap_gpio_save_context(void)
 {
 	struct gpio_bank *bank;
-	int i = 0;
 
 	list_for_each_entry(bank, &omap_gpio_list, node) {
-		i++;
 
 		if (!bank->loses_context)
 			continue;
 
-		gpio_context[i].irqenable1 =
+		bank->context.irqenable1 =
 			__raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE1);
-		gpio_context[i].irqenable2 =
+		bank->context.irqenable2 =
 			__raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE2);
-		gpio_context[i].wake_en =
+		bank->context.wake_en =
 			__raw_readl(bank->base + OMAP24XX_GPIO_WAKE_EN);
-		gpio_context[i].ctrl =
+		bank->context.ctrl =
 			__raw_readl(bank->base + OMAP24XX_GPIO_CTRL);
-		gpio_context[i].oe =
+		bank->context.oe =
 			__raw_readl(bank->base + OMAP24XX_GPIO_OE);
-		gpio_context[i].leveldetect0 =
+		bank->context.leveldetect0 =
 			__raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0);
-		gpio_context[i].leveldetect1 =
+		bank->context.leveldetect1 =
 			__raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
-		gpio_context[i].risingdetect =
+		bank->context.risingdetect =
 			__raw_readl(bank->base + OMAP24XX_GPIO_RISINGDETECT);
-		gpio_context[i].fallingdetect =
+		bank->context.fallingdetect =
 			__raw_readl(bank->base + OMAP24XX_GPIO_FALLINGDETECT);
-		gpio_context[i].dataout =
+		bank->context.dataout =
 			__raw_readl(bank->base + OMAP24XX_GPIO_DATAOUT);
 	}
 }
@@ -1520,33 +1514,31 @@ void omap_gpio_save_context(void)
 void omap_gpio_restore_context(void)
 {
 	struct gpio_bank *bank;
-	int i = 0;
 
 	list_for_each_entry(bank, &omap_gpio_list, node) {
-		i++;
 
 		if (!bank->loses_context)
 			continue;
 
-		__raw_writel(gpio_context[i].irqenable1,
+		__raw_writel(bank->context.irqenable1,
 				bank->base + OMAP24XX_GPIO_IRQENABLE1);
-		__raw_writel(gpio_context[i].irqenable2,
+		__raw_writel(bank->context.irqenable2,
 				bank->base + OMAP24XX_GPIO_IRQENABLE2);
-		__raw_writel(gpio_context[i].wake_en,
+		__raw_writel(bank->context.wake_en,
 				bank->base + OMAP24XX_GPIO_WAKE_EN);
-		__raw_writel(gpio_context[i].ctrl,
+		__raw_writel(bank->context.ctrl,
 				bank->base + OMAP24XX_GPIO_CTRL);
-		__raw_writel(gpio_context[i].oe,
+		__raw_writel(bank->context.oe,
 				bank->base + OMAP24XX_GPIO_OE);
-		__raw_writel(gpio_context[i].leveldetect0,
+		__raw_writel(bank->context.leveldetect0,
 				bank->base + OMAP24XX_GPIO_LEVELDETECT0);
-		__raw_writel(gpio_context[i].leveldetect1,
+		__raw_writel(bank->context.leveldetect1,
 				bank->base + OMAP24XX_GPIO_LEVELDETECT1);
-		__raw_writel(gpio_context[i].risingdetect,
+		__raw_writel(bank->context.risingdetect,
 				bank->base + OMAP24XX_GPIO_RISINGDETECT);
-		__raw_writel(gpio_context[i].fallingdetect,
+		__raw_writel(bank->context.fallingdetect,
 				bank->base + OMAP24XX_GPIO_FALLINGDETECT);
-		__raw_writel(gpio_context[i].dataout,
+		__raw_writel(bank->context.dataout,
 				bank->base + OMAP24XX_GPIO_DATAOUT);
 	}
 }
Signature · 1 line
1.6.0.4
#24 lore raw

PATCH 5/15 OMAP: GPIO: Make gpio_context part of gpio_bank structure

Quoted 9 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

gpio_context array, which is used to save gpio bank's context, is used only for OMAP3 architecture.

Move gpio_context as part of gpio_bank structure so that it can be specific to each gpio bank and can be used for any OMAP architecture

Quoted 5 lines

TODO: extend the gpio save/restore context function for OMAP4 architecture. This is done in one of the next patches in this series

Looks good.

Kevin

#25 lore raw

PATCH 5/15 OMAP: GPIO: Make gpio_context part of gpio_bank structure

In reply to Tarun Kanti DebBarma
Quoted 16 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM
To: linux-omap at vger.kernel.org
Cc: Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha
Subject: [PATCH 05/15] OMAP: GPIO: Make gpio_context part of gpio_bank structure

From: Charulatha V <[email protected]>

gpio_context array, which is used to save gpio bank's context, is used only for OMAP3 architecture.

Quoted 7 lines

Move gpio_context as part of gpio_bank structure so that it can be specific to each gpio bank and can be used for any OMAP architecture

TODO: extend the gpio save/restore context function for OMAP4 architecture. This is done in one of the next patches in this series

[sp] Should this TODO be part of commit?
BTW, this is the last patch in the series.

~sanjeev

#26 lore raw

PATCH 5/15 OMAP: GPIO: Make gpio_context part of gpio_bank structure

Quoted 20 lines · Sanjeev
Quoted 20 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM
To: linux-omap at vger.kernel.org
Cc: Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha
Subject: [PATCH 05/15] OMAP: GPIO: Make gpio_context part of gpio_bank structure

From: Charulatha V <[email protected]>

gpio_context array, which is used to save gpio bank's context, is used only for OMAP3 architecture.

Move gpio_context as part of gpio_bank structure so that it can be specific to each gpio bank and can be used for any OMAP architecture

Quoted 5 lines
Quoted 3 lines

TODO: extend the gpio save/restore context function for OMAP4 architecture. This is done in one of the next patches in this series

[sp] Should this TODO be part of commit?

Probably this could be moved into diff section.

<<<snip>>

#27 lore raw

PATCH 5/15 OMAP: GPIO: Make gpio_context part of gpio_bank structure

In reply to Tarun Kanti DebBarma
Quoted 30 lines

-----Original Message-----
From: Premi, Sanjeev
Sent: Thursday, May 26, 2011 3:29 PM
To: DebBarma, Tarun Kanti; linux-omap at vger.kernel.org
Cc: Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha
Subject: RE: [PATCH 05/15] OMAP: GPIO: Make gpio_context part of gpio_bank structure

Quoted 20 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM
To: linux-omap at vger.kernel.org
Cc: Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; Varadarajan, Charulatha
Subject: [PATCH 05/15] OMAP: GPIO: Make gpio_context part of gpio_bank structure

From: Charulatha V <[email protected]>

gpio_context array, which is used to save gpio bank's context, is used only for OMAP3 architecture.

Move gpio_context as part of gpio_bank structure so that it can be specific to each gpio bank and can be used for any OMAP architecture

Quoted 7 lines
Quoted 3 lines

TODO: extend the gpio save/restore context function for OMAP4 architecture. This is done in one of the next patches in this series

[sp] Should this TODO be part of commit?
BTW, this is the last patch in the series.

Sorry, mistake... This showed up last on my mailbox. ~sanjeev

Quoted 2 lines

~sanjeev

#28 lore raw

PATCH 6/15 OMAP4: GPIO: Save/restore context

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Modify the omap_gpio_save/restore_context to support OMAP4 architecture so that the OMAP GPIO driver need not be modified when OMAP4 off mode support is available.

---
 drivers/gpio/gpio_omap.c |  130 +++++++++++++++++++++++++++++++---------------
 1 files changed, 87 insertions(+), 43 deletions(-)
drivers/gpio/gpio_omap.c +87 -43
index 5673951..9d55b7d 100644
@@ -1476,9 +1476,6 @@ void omap2_gpio_resume_after_idle(void)
 
 }
 
-#endif
-
-#ifdef CONFIG_ARCH_OMAP3
 void omap_gpio_save_context(void)
 {
 	struct gpio_bank *bank;
@@ -1488,26 +1485,49 @@ void omap_gpio_save_context(void)
 		if (!bank->loses_context)
 			continue;
 
-		bank->context.irqenable1 =
-			__raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE1);
-		bank->context.irqenable2 =
-			__raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE2);
-		bank->context.wake_en =
-			__raw_readl(bank->base + OMAP24XX_GPIO_WAKE_EN);
-		bank->context.ctrl =
-			__raw_readl(bank->base + OMAP24XX_GPIO_CTRL);
-		bank->context.oe =
-			__raw_readl(bank->base + OMAP24XX_GPIO_OE);
-		bank->context.leveldetect0 =
-			__raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0);
-		bank->context.leveldetect1 =
-			__raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
-		bank->context.risingdetect =
-			__raw_readl(bank->base + OMAP24XX_GPIO_RISINGDETECT);
-		bank->context.fallingdetect =
-			__raw_readl(bank->base + OMAP24XX_GPIO_FALLINGDETECT);
-		bank->context.dataout =
-			__raw_readl(bank->base + OMAP24XX_GPIO_DATAOUT);
+		if (bank->method == METHOD_GPIO_24XX) {
+			bank->context.irqenable1 = __raw_readl(
+					bank->base + OMAP24XX_GPIO_IRQENABLE1);
+			bank->context.irqenable2 = __raw_readl(
+					bank->base + OMAP24XX_GPIO_IRQENABLE2);
+			bank->context.wake_en = __raw_readl(
+					bank->base + OMAP24XX_GPIO_WAKE_EN);
+			bank->context.ctrl = __raw_readl(
+					bank->base + OMAP24XX_GPIO_CTRL);
+			bank->context.oe = __raw_readl(
+					bank->base + OMAP24XX_GPIO_OE);
+			bank->context.leveldetect0 = __raw_readl(bank->base +
+					OMAP24XX_GPIO_LEVELDETECT0);
+			bank->context.leveldetect1 = __raw_readl(bank->base +
+					OMAP24XX_GPIO_LEVELDETECT1);
+			bank->context.risingdetect = __raw_readl(bank->base +
+					OMAP24XX_GPIO_RISINGDETECT);
+			bank->context.fallingdetect = __raw_readl(bank->base +
+					OMAP24XX_GPIO_FALLINGDETECT);
+			bank->context.dataout = __raw_readl(
+					bank->base + OMAP24XX_GPIO_DATAOUT);
+		} else if (bank->method == METHOD_GPIO_44XX) {
+			bank->context.irqenable1 = __raw_readl(
+					bank->base + OMAP4_GPIO_IRQSTATUSSET0);
+			bank->context.irqenable2 = __raw_readl(
+					bank->base + OMAP4_GPIO_IRQSTATUSSET1);
+			bank->context.wake_en = __raw_readl(
+					bank->base + OMAP4_GPIO_IRQWAKEN0);
+			bank->context.ctrl = __raw_readl(
+					bank->base + OMAP4_GPIO_CTRL);
+			bank->context.oe = __raw_readl(
+					bank->base + OMAP24XX_GPIO_OE);
+			bank->context.leveldetect0 = __raw_readl(bank->base +
+					OMAP4_GPIO_LEVELDETECT0);
+			bank->context.leveldetect1 = __raw_readl(bank->base +
+					OMAP4_GPIO_LEVELDETECT1);
+			bank->context.risingdetect = __raw_readl(bank->base +
+					OMAP4_GPIO_RISINGDETECT);
+			bank->context.fallingdetect = __raw_readl(bank->base +
+					OMAP4_GPIO_FALLINGDETECT);
+			bank->context.dataout = __raw_readl(
+					bank->base + OMAP4_GPIO_DATAOUT);
+		}
 	}
 }
 
@@ -1520,28 +1540,52 @@ void omap_gpio_restore_context(void)
 		if (!bank->loses_context)
 			continue;
 
-		__raw_writel(bank->context.irqenable1,
-				bank->base + OMAP24XX_GPIO_IRQENABLE1);
-		__raw_writel(bank->context.irqenable2,
-				bank->base + OMAP24XX_GPIO_IRQENABLE2);
-		__raw_writel(bank->context.wake_en,
-				bank->base + OMAP24XX_GPIO_WAKE_EN);
-		__raw_writel(bank->context.ctrl,
-				bank->base + OMAP24XX_GPIO_CTRL);
-		__raw_writel(bank->context.oe,
-				bank->base + OMAP24XX_GPIO_OE);
-		__raw_writel(bank->context.leveldetect0,
-				bank->base + OMAP24XX_GPIO_LEVELDETECT0);
-		__raw_writel(bank->context.leveldetect1,
-				bank->base + OMAP24XX_GPIO_LEVELDETECT1);
-		__raw_writel(bank->context.risingdetect,
-				bank->base + OMAP24XX_GPIO_RISINGDETECT);
-		__raw_writel(bank->context.fallingdetect,
-				bank->base + OMAP24XX_GPIO_FALLINGDETECT);
-		__raw_writel(bank->context.dataout,
-				bank->base + OMAP24XX_GPIO_DATAOUT);
+		if (bank->method == METHOD_GPIO_24XX) {
+			__raw_writel(bank->context.irqenable1, bank->base +
+						OMAP24XX_GPIO_IRQENABLE1);
+			__raw_writel(bank->context.irqenable2, bank->base +
+						OMAP24XX_GPIO_IRQENABLE2);
+			__raw_writel(bank->context.wake_en, bank->base +
+						OMAP24XX_GPIO_WAKE_EN);
+			__raw_writel(bank->context.ctrl, bank->base +
+						OMAP24XX_GPIO_CTRL);
+			__raw_writel(bank->context.oe, bank->base +
+						OMAP24XX_GPIO_OE);
+			__raw_writel(bank->context.leveldetect0, bank->base +
+						OMAP24XX_GPIO_LEVELDETECT0);
+			__raw_writel(bank->context.leveldetect1, bank->base +
+						OMAP24XX_GPIO_LEVELDETECT1);
+			__raw_writel(bank->context.risingdetect, bank->base +
+						OMAP24XX_GPIO_RISINGDETECT);
+			__raw_writel(bank->context.fallingdetect, bank->base +
+						OMAP24XX_GPIO_FALLINGDETECT);
+			__raw_writel(bank->context.dataout, bank->base +
+						OMAP24XX_GPIO_DATAOUT);
+		} else if (bank->method == METHOD_GPIO_44XX) {
+			__raw_writel(bank->context.irqenable1, bank->base +
+						OMAP4_GPIO_IRQSTATUSSET0);
+			__raw_writel(bank->context.irqenable2, bank->base +
+						OMAP4_GPIO_IRQSTATUSSET1);
+			__raw_writel(bank->context.wake_en, bank->base +
+						OMAP4_GPIO_IRQWAKEN0);
+			__raw_writel(bank->context.ctrl, bank->base +
+						OMAP4_GPIO_CTRL);
+			__raw_writel(bank->context.oe, bank->base +
+						OMAP24XX_GPIO_OE);
+			__raw_writel(bank->context.leveldetect0, bank->base +
+						OMAP4_GPIO_LEVELDETECT0);
+			__raw_writel(bank->context.leveldetect1, bank->base +
+						OMAP4_GPIO_LEVELDETECT1);
+			__raw_writel(bank->context.risingdetect, bank->base +
+						OMAP4_GPIO_RISINGDETECT);
+			__raw_writel(bank->context.fallingdetect, bank->base +
+						OMAP4_GPIO_FALLINGDETECT);
+			__raw_writel(bank->context.dataout, bank->base +
+						OMAP4_GPIO_DATAOUT);
+		}
 	}
 }
+
 #endif
 
 static struct platform_driver omap_gpio_driver = {
Signature · 1 line
1.6.0.4
#29 lore raw

PATCH 6/15 OMAP4: GPIO: Save/restore context

Quoted 7 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Modify the omap_gpio_save/restore_context to support OMAP4 architecture so that the OMAP GPIO driver need not be modified when OMAP4 off mode support is available.

I don't think this patch is needed.

PATCH 11/15 removes everything added in this patch when it moves to using the register offsets.

Kevin

#30 lore raw

PATCH 6/15 OMAP4: GPIO: Save/restore context

Kevin,

Thanks for the comments on this series.

Quoted 8 lines · Kevin Hilman
Quoted 6 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Modify the omap_gpio_save/restore_context to support OMAP4 architecture so that the OMAP GPIO driver need not be modified when OMAP4 off mode support is available.

Quoted 6 lines
Quoted 1 line

I don't think this patch is needed.

PATCH 11/15 removes everything added in this patch when it moves to using the register offsets.

Okay.

Quoted 3 lines

Kevin

#31 lore raw

PATCH 7/15 OMAP: GPIO: handle save/restore ctx in GPIO driver

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Modify omap_gpio_prepare_for_idle() & omap_gpio_resume_after_idle() functions to handle save context & restore context respectively in the OMAP GPIO driver itself instead of calling these functions from pm specific files. For this, in gpio_prepare_for_idle(), use omap_device_get_context_loss_count() and in gpio_resume_after_idle() call it again. If the count is different, do restore context.

context lost count is modified in omap_sram_idle() path when pwrdm_post_transition() is called. But pwrdm_post_transition() is called only after omap_gpio_resume_after_idle() is called. Hence correct this so that context lost count is modified before calling omap_gpio_resume_after_idle().

omap_gpio_prepare_for_idle() & omap_gpio_resume_after_idle() do nothing if none of the GPIOs in a bank is being used.

Also remove usage of cpu_is_* checks from the above mentioned functions and fix the multi-line comment style

---
 arch/arm/mach-omap2/pm34xx.c           |   22 +----
 arch/arm/plat-omap/include/plat/gpio.h |    2 -
 drivers/gpio/gpio_omap.c               |  138 +++++++++++++++++---------------
 3 files changed, 78 insertions(+), 84 deletions(-)
arch/arm/mach-omap2/pm34xx.c +5 -17
index 0c5e3a4..682d147 100644
@@ -91,16 +91,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
 static struct powerdomain *core_pwrdm, *per_pwrdm;
 static struct powerdomain *cam_pwrdm;
 
-static inline void omap3_per_save_context(void)
-{
-	omap_gpio_save_context();
-}
-
-static inline void omap3_per_restore_context(void)
-{
-	omap_gpio_restore_context();
-}
-
 static void omap3_enable_io_chain(void)
 {
 	int timeout = 0;
@@ -395,8 +385,10 @@ void omap_sram_idle(void)
 	if (!is_suspending())
 		if (per_next_state < PWRDM_POWER_ON ||
 		    core_next_state < PWRDM_POWER_ON)
-			if (!console_trylock())
+			if (!console_trylock()) {
+				pwrdm_post_transition();
 				goto console_still_active;
+			}
 
 	/* PER */
 	if (per_next_state < PWRDM_POWER_ON) {
@@ -404,8 +396,6 @@ void omap_sram_idle(void)
 		omap_uart_prepare_idle(2);
 		omap_uart_prepare_idle(3);
 		omap2_gpio_prepare_for_idle(per_going_off);
-		if (per_next_state == PWRDM_POWER_OFF)
-				omap3_per_save_context();
 	}
 
 	/* CORE */
@@ -467,12 +457,12 @@ void omap_sram_idle(void)
 	}
 	omap3_intc_resume_idle();
 
+	pwrdm_post_transition();
+
 	/* PER */
 	if (per_next_state < PWRDM_POWER_ON) {
 		per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
 		omap2_gpio_resume_after_idle();
-		if (per_prev_state == PWRDM_POWER_OFF)
-			omap3_per_restore_context();
 		omap_uart_resume_idle(2);
 		omap_uart_resume_idle(3);
 	}
@@ -490,8 +480,6 @@ console_still_active:
 		omap3_disable_io_chain();
 	}
 
-	pwrdm_post_transition();
-
 	clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
 }
 
arch/arm/plat-omap/include/plat/gpio.h +0 -2
index 64b1ee7..5718a45 100644
@@ -209,8 +209,6 @@ extern void omap2_gpio_prepare_for_idle(int off_mode);
 extern void omap2_gpio_resume_after_idle(void);
 extern void omap_set_gpio_debounce(int gpio, int enable);
 extern void omap_set_gpio_debounce_time(int gpio, int enable);
-extern void omap_gpio_save_context(void);
-extern void omap_gpio_restore_context(void);
 /*-------------------------------------------------------------------------*/
 
 /* Wrappers for "new style" GPIO calls, using the new infrastructure
drivers/gpio/gpio_omap.c +73 -65

244 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#32 lore raw

PATCH 7/15 OMAP: GPIO: handle save/restore ctx in GPIO driver

Quoted 9 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Modify omap_gpio_prepare_for_idle() & omap_gpio_resume_after_idle() functions to handle save context & restore context respectively in the OMAP GPIO driver itself instead of calling these functions from pm specific files. For this, in gpio_prepare_for_idle(), use omap_device_get_context_loss_count() and in gpio_resume_after_idle() call it again. If the count is different, do restore context.

Quoted 5 lines

context lost count is modified in omap_sram_idle() path when pwrdm_post_transition() is called. But pwrdm_post_transition() is called only after omap_gpio_resume_after_idle() is called. Hence correct this so that context lost count is modified before calling omap_gpio_resume_after_idle().

This change to modify where pwrdm_post_transition() is called should be separated out into a dedicated patch.

Quoted 35 lines

omap_gpio_prepare_for_idle() & omap_gpio_resume_after_idle() do nothing if none of the GPIOs in a bank is being used.

Also remove usage of cpu_is_* checks from the above mentioned functions and fix the multi-line comment style

---
 arch/arm/mach-omap2/pm34xx.c           |   22 +----
 arch/arm/plat-omap/include/plat/gpio.h |    2 -
 drivers/gpio/gpio_omap.c               |  138 +++++++++++++++++---------------
 3 files changed, 78 insertions(+), 84 deletions(-)
arch/arm/mach-omap2/pm34xx.c +0 -10
index 0c5e3a4..682d147 100644
@@ -91,16 +91,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
 static struct powerdomain *core_pwrdm, *per_pwrdm;
 static struct powerdomain *cam_pwrdm;
 
-static inline void omap3_per_save_context(void)
-{
-	omap_gpio_save_context();
-}
-
-static inline void omap3_per_restore_context(void)
-{
-	omap_gpio_restore_context();
-}
-
 static void omap3_enable_io_chain(void)
 {
 	int timeout = 0;

arch/arm/mach-omap2/pm34xx.c void omap_sram_idle(void) · line 391

Quoted 8 lines
arch/arm/mach-omap2/pm34xx.c +3 -1
@@ -395,8 +385,10 @@ void omap_sram_idle(void)
 	if (!is_suspending())
 		if (per_next_state < PWRDM_POWER_ON ||
 		    core_next_state < PWRDM_POWER_ON)
-			if (!console_trylock())
+			if (!console_trylock()) {
+				pwrdm_post_transition();
 				goto console_still_active;
+			}

Rather than having to add an extra post_transition call, I think i best to move the pre_transition call down to just before the following /* PER */ block.

Quoted 54 lines
arch/arm/mach-omap2/pm34xx.c +2 -6
 	/* PER */
 	if (per_next_state < PWRDM_POWER_ON) {
@@ -404,8 +396,6 @@ void omap_sram_idle(void)
 		omap_uart_prepare_idle(2);
 		omap_uart_prepare_idle(3);
 		omap2_gpio_prepare_for_idle(per_going_off);
-		if (per_next_state == PWRDM_POWER_OFF)
-				omap3_per_save_context();
 	}
 
 	/* CORE */
@@ -467,12 +457,12 @@ void omap_sram_idle(void)
 	}
 	omap3_intc_resume_idle();
 
+	pwrdm_post_transition();
+
 	/* PER */
 	if (per_next_state < PWRDM_POWER_ON) {
 		per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
 		omap2_gpio_resume_after_idle();
-		if (per_prev_state == PWRDM_POWER_OFF)
-			omap3_per_restore_context();
 		omap_uart_resume_idle(2);
 		omap_uart_resume_idle(3);
 	}
@@ -490,8 +480,6 @@ console_still_active:
 		omap3_disable_io_chain();
 	}
 
-	pwrdm_post_transition();
-
 	clkdm_allow_idle(mpu_pwrdm->pwrdm_clkdms[0]);
 }
 
arch/arm/plat-omap/include/plat/gpio.h +0 -2
index 64b1ee7..5718a45 100644
@@ -209,8 +209,6 @@ extern void omap2_gpio_prepare_for_idle(int off_mode);
 extern void omap2_gpio_resume_after_idle(void);
 extern void omap_set_gpio_debounce(int gpio, int enable);
 extern void omap_set_gpio_debounce_time(int gpio, int enable);
-extern void omap_gpio_save_context(void);
-extern void omap_gpio_restore_context(void);
 /*-------------------------------------------------------------------------*/
 
 /* Wrappers for "new style" GPIO calls, using the new infrastructure
drivers/gpio/gpio_omap.c +0 -0
index 9d55b7d..bc02ec5 100644

drivers/gpio/gpio_omap.c line 26

Quoted 5 lines
drivers/gpio/gpio_omap.c +2 -0
@@ -22,6 +22,8 @@
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
 
+#include <plat/omap_device.h>
+

Should not be needed. More on this below.

drivers/gpio/gpio_omap.c struct gpio_bank { · line 77

Quoted 8 lines
drivers/gpio/gpio_omap.c +1 -0
 #include <mach/hardware.h>
 #include <asm/irq.h>
 #include <mach/irqs.h>
@@ -72,6 +74,7 @@ struct gpio_bank {
 	bool loses_context;
 	int stride;
 	u32 width;
+	u32 ctx_lost_cnt_before;

Please call this ctx_loss_count.

Quoted 31 lines
drivers/gpio/gpio_omap.c +5 -1
 	u16 id;
 
 	void (*set_dataout)(struct gpio_bank *bank, int gpio, int enable);
@@ -1310,6 +1313,9 @@ static struct sys_device omap_gpio_device = {
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
+static void omap_gpio_save_context(struct gpio_bank *bank);
+static void omap_gpio_restore_context(struct gpio_bank *bank);
+
 static int workaround_enabled;
 
 void omap2_gpio_prepare_for_idle(int off_mode)
@@ -1318,6 +1324,7 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 	struct gpio_bank *bank;
 
 	list_for_each_entry(bank, &omap_gpio_list, node) {
+		struct platform_device *pdev;
 		u32 l1 = 0, l2 = 0;
 		int j;
 
@@ -1334,7 +1341,7 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 		 * non-wakeup GPIOs.  Otherwise spurious IRQs will be
 		 * generated.  See OMAP2420 Errata item 1.101. */
 		if (!(bank->enabled_non_wakeup_gpios))
-			continue;
+			goto save_gpio_ctx;
 
 		if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
 			bank->saved_datain = __raw_readl(bank->base +

drivers/gpio/gpio_omap.c void omap2_gpio_prepare_for_idle(int off_mode) · line 1386

Quoted 8 lines
drivers/gpio/gpio_omap.c +5 -0
@@ -1372,6 +1379,12 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 		}
 
 		c++;
+
+save_gpio_ctx:
+		pdev = to_platform_device(bank->dev);
+		bank->ctx_lost_cnt_before =
+				omap_device_get_context_loss_count(pdev);

Drivers should not be directly calling omap_device APIs. Instead, drivers should use a pdata function pointer to call device specific code for getting context loss. See OMAP HSMMC driver for an example on how this is done.

Quoted 16 lines
drivers/gpio/gpio_omap.c +3 -0
+		omap_gpio_save_context(bank);
 	}
 	if (!c) {
 		workaround_enabled = 0;
@@ -1385,6 +1398,8 @@ void omap2_gpio_resume_after_idle(void)
 	struct gpio_bank *bank;
 
 	list_for_each_entry(bank, &omap_gpio_list, node) {
+		u32 ctx_lost_cnt_after;
+		struct platform_device *pdev;
 		u32 l = 0, gen, gen0, gen1;
 		int j;
 
@@ -1394,11 +1409,17 @@ void omap2_gpio_resume_after_idle(void)
 		for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
 			clk_enable(bank->dbck);

drivers/gpio/gpio_omap.c void omap2_gpio_resume_after_idle(void) · line 1419

Quoted 10 lines
drivers/gpio/gpio_omap.c +6 -1
 
-		if (!workaround_enabled)
+		pdev = to_platform_device(bank->dev);
+		ctx_lost_cnt_after = omap_device_get_context_loss_count(pdev);
+
+		if (ctx_lost_cnt_after == bank->ctx_lost_cnt_before)
 			continue;
 
+		if (!workaround_enabled)
+			goto restore_gpio_ctx;

Now that these functions are all bank-specific, this 'workaround_enabled' flag should be made per-bank.

That being said, do we even need this flag? I think that the combination of enabled_non_wakeup_gpios and whether or not context has been lost reflects the same condition.

drivers/gpio/gpio_omap.c void omap2_gpio_resume_after_idle(void) · line 1498

Quoted 13 lines
drivers/gpio/gpio_omap.c +4 -1
 		if (!(bank->enabled_non_wakeup_gpios))
-			continue;
+			goto restore_gpio_ctx;
 
 		if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
 			__raw_writel(bank->saved_fallingdetect,
@@ -1472,117 +1493,104 @@ void omap2_gpio_resume_after_idle(void)
 						OMAP4_GPIO_LEVELDETECT1);
 			}
 		}
+
+restore_gpio_ctx:
+		omap_gpio_restore_context(bank);

After considering the placement of the restore context here, I don't think it's quite right. It is equivalent to current behavior, but I'm having a hard time understanding how current behavior is actually working.

Consider the sequence

- prepare for idle
- remove triggering
- save edge-detect registers, then modify them to "workaround" values
- save context (w/ "workaround" edge-detect register values
- WFI, off-mode hit
- wakeup, resume from idle
- write "saved" values to edge-detect registers
- restore context
- here the "workaround" values from the saved context are restored !!! so the "saved" values are now lost.

For this to be symmetric with the save, I think the restore context should come before handling the workaround/hack.

Kevin

#33 lore raw

PATCH 7/15 OMAP: GPIO: handle save/restore ctx in GPIO driver

Kevin Hilman <[email protected]> writes:

[...]

Quoted 11 lines
Quoted 11 lines
drivers/gpio/gpio_omap.c +4 -1
@@ -1394,11 +1409,17 @@ void omap2_gpio_resume_after_idle(void)
 		for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
 			clk_enable(bank->dbck);
 
-		if (!workaround_enabled)
+		pdev = to_platform_device(bank->dev);
+		ctx_lost_cnt_after = omap_device_get_context_loss_count(pdev);
+
+		if (ctx_lost_cnt_after == bank->ctx_lost_cnt_before)
 			continue;
 
Quoted 5 lines

Review void omap2_gpio_resume_after_idle(void) · line 1419

Quoted 2 lines
(quoted diff) +2 -0
+		if (!workaround_enabled)
+			goto restore_gpio_ctx;

Now that these functions are all bank-specific, this 'workaround_enabled' flag should be made per-bank.

Oops, ignore this comment... I see it's done in the next patch.

Kevin

#34 lore raw

PATCH 8/15 OMAP2+: GPIO: make workaround_enabled bank specific

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Make workaround_enabled flag bank-specific instead of using a single flag for all the banks together. This would be helpful while making use of runtime framework in OMAP GPIO driver which would make the driver handle each GPIO bank independently.

Also rename workaround_enabled flag to off_mode_wkup_wa_enabled

---
 drivers/gpio/gpio_omap.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)
drivers/gpio/gpio_omap.c +5 -10
index bc02ec5..fcc60be 100644
@@ -72,6 +72,7 @@ struct gpio_bank {
 	struct device *dev;
 	bool dbck_flag;
 	bool loses_context;
+	bool off_mode_wkup_wa_enabled;
 	int stride;
 	u32 width;
 	u32 ctx_lost_cnt_before;
@@ -1077,6 +1078,7 @@ static void __init omap_gpio_chip_init(struct gpio_bank *bank)
 	static int gpio;
 
 	bank->mod_usage = 0;
+	bank->off_mode_wkup_wa_enabled = false;
 	/*
 	 * REVISIT eventually switch from OMAP-specific gpio structs
 	 * over to the generic ones
@@ -1316,11 +1318,8 @@ static struct sys_device omap_gpio_device = {
 static void omap_gpio_save_context(struct gpio_bank *bank);
 static void omap_gpio_restore_context(struct gpio_bank *bank);
 
-static int workaround_enabled;
-
 void omap2_gpio_prepare_for_idle(int off_mode)
 {
-	int c = 0;
 	struct gpio_bank *bank;
 
 	list_for_each_entry(bank, &omap_gpio_list, node) {
@@ -1378,7 +1377,7 @@ void omap2_gpio_prepare_for_idle(int off_mode)
 			__raw_writel(l2, bank->base + OMAP4_GPIO_RISINGDETECT);
 		}
 
-		c++;
+		bank->off_mode_wkup_wa_enabled = true;
 
 save_gpio_ctx:
 		pdev = to_platform_device(bank->dev);
@@ -1386,11 +1385,6 @@ save_gpio_ctx:
 				omap_device_get_context_loss_count(pdev);
 		omap_gpio_save_context(bank);
 	}
-	if (!c) {
-		workaround_enabled = 0;
-		return;
-	}
-	workaround_enabled = 1;
 }
 
 void omap2_gpio_resume_after_idle(void)
@@ -1415,7 +1409,7 @@ void omap2_gpio_resume_after_idle(void)
 		if (ctx_lost_cnt_after == bank->ctx_lost_cnt_before)
 			continue;
 
-		if (!workaround_enabled)
+		if (!bank->off_mode_wkup_wa_enabled)
 			goto restore_gpio_ctx;
 
 		if (!(bank->enabled_non_wakeup_gpios))
@@ -1495,6 +1489,7 @@ void omap2_gpio_resume_after_idle(void)
 		}
 
 restore_gpio_ctx:
+		bank->off_mode_wkup_wa_enabled = false;
 		omap_gpio_restore_context(bank);
 	}
 
Signature · 1 line
1.6.0.4
#35 lore raw

PATCH 8/15 OMAP2+: GPIO: make workaround_enabled bank specific

Quoted 8 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Make workaround_enabled flag bank-specific instead of using a single flag for all the banks together. This would be helpful while making use of runtime framework in OMAP GPIO driver which would make the driver handle each GPIO bank independently.

Also rename workaround_enabled flag to off_mode_wkup_wa_enabled

Do we even need a dedicated flag for this?

I seems that the combination of enabled_non_wakeup_gpios and whether or not context has been lost could be used to check this condition.

Kevin

#36 lore raw

PATCH 8/15 OMAP2+: GPIO: make workaround_enabled bank specific

Quoted 9 lines · Kevin Hilman
Quoted 7 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Make workaround_enabled flag bank-specific instead of using a single flag for all the banks together. This would be helpful while making use of runtime framework in OMAP GPIO driver which would make the driver handle each GPIO bank independently.

Quoted 6 lines
Quoted 1 line

Also rename workaround_enabled flag to off_mode_wkup_wa_enabled

Do we even need a dedicated flag for this?

I seems that the combination of enabled_non_wakeup_gpios and whether or not context has been lost could be used to check this condition.

Okay, will check and do the needful.

Quoted 3 lines

Kevin

#37 lore raw

PATCH 9/15 OMAP: GPIO: cleanup suspend and resume functions

In reply to Tarun Kanti DebBarma

Since wake_status, wake_clear, wake_set is common for all banks on a given OMAP version it is enough to get their values once during probe(). Also, register offsets are already initialzed according to OMAP versions during device registration. We no longer need these explicit checks.

---
 arch/arm/mach-omap1/gpio15xx.c         |    6 ++
 arch/arm/mach-omap1/gpio16xx.c         |    6 ++
 arch/arm/mach-omap1/gpio7xx.c          |    6 ++
 arch/arm/mach-omap2/gpio.c             |    6 ++
 arch/arm/plat-omap/include/plat/gpio.h |    3 +
 drivers/gpio/gpio_omap.c               |  102 +++++++-------------------------
 6 files changed, 49 insertions(+), 80 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +6 -0
index f18a4a9..b0bd21e 100644
@@ -43,6 +43,9 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -85,6 +88,9 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 	.irqenable	= OMAP1510_GPIO_INT_MASK,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +6 -0
index d886b88..403437b 100644
@@ -46,6 +46,9 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -91,6 +94,9 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
 	.set_irqenable	= OMAP1610_GPIO_SET_IRQENABLE1,
 	.clr_irqenable	= OMAP1610_GPIO_CLEAR_IRQENABLE1,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= OMAP1610_GPIO_WAKEUPENABLE,
+	.wkupclear	= OMAP1610_GPIO_CLEAR_WAKEUPENA,
+	.wkupset	= OMAP1610_GPIO_SET_WAKEUPENA,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +6 -0
index c7684ce..d5a4aaf 100644
@@ -48,6 +48,9 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT / 2,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -90,6 +93,9 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 	.irqenable	= OMAP7XX_GPIO_INT_MASK,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +6 -0
index 0782e06..7e79999 100644
@@ -111,6 +111,9 @@ 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->wkupstatus = OMAP24XX_GPIO_WAKE_EN;
+		pdata->regs->wkupclear = OMAP24XX_GPIO_CLEARWKUENA;
+		pdata->regs->wkupset = OMAP24XX_GPIO_SETWKUENA;
 		break;
 	case 3:
 		pdata->bank_type = METHOD_GPIO_44XX;
@@ -128,6 +131,9 @@ 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->wkupstatus = OMAP4_GPIO_IRQWAKEN0;
+		pdata->regs->wkupclear = OMAP4_GPIO_IRQWAKEN0;
+		pdata->regs->wkupset = OMAP4_GPIO_IRQWAKEN0;
 		break;
 	default:
 		WARN(1, "Invalid gpio bank_type\n");
arch/arm/plat-omap/include/plat/gpio.h +3 -0
index 5718a45..2d1a5d6 100644
@@ -189,6 +189,9 @@ struct omap_gpio_reg_offs {
 	u16 debounce;
 	u16 debounce_en;
 	u16 ctrl;
+	u16 wkupstatus;
+	u16 wkupclear;
+	u16 wkupset;
 
 	bool irqenable_inv;
 };
drivers/gpio/gpio_omap.c +22 -80

145 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#38 lore raw

PATCH 9/15 OMAP: GPIO: cleanup suspend and resume functions

Quoted 21 lines · Tarun Kanti DebBarma

Since wake_status, wake_clear, wake_set is common for all banks on a given OMAP version it is enough to get their values once during probe(). Also, register offsets are already initialzed according to OMAP versions during device registration. We no longer need these explicit checks.

---
 arch/arm/mach-omap1/gpio15xx.c         |    6 ++
 arch/arm/mach-omap1/gpio16xx.c         |    6 ++
 arch/arm/mach-omap1/gpio7xx.c          |    6 ++
 arch/arm/mach-omap2/gpio.c             |    6 ++
 arch/arm/plat-omap/include/plat/gpio.h |    3 +
 drivers/gpio/gpio_omap.c               |  102 +++++++-------------------------
 6 files changed, 49 insertions(+), 80 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +0 -0
index f18a4a9..b0bd21e 100644

arch/arm/mach-omap1/gpio15xx.c static struct omap_gpio_reg_offs omap15xx_mpuio_regs = { · line 49

Quoted 7 lines
arch/arm/mach-omap1/gpio15xx.c +3 -0
@@ -43,6 +43,9 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };

Same comment as earlier about USHRT_MAX.

Just use zero to indicate no register present.

Quoted 88 lines
arch/arm/mach-omap1/gpio15xx.c +3 -0
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -85,6 +88,9 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 	.irqenable	= OMAP1510_GPIO_INT_MASK,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +6 -0
index d886b88..403437b 100644
@@ -46,6 +46,9 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -91,6 +94,9 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
 	.set_irqenable	= OMAP1610_GPIO_SET_IRQENABLE1,
 	.clr_irqenable	= OMAP1610_GPIO_CLEAR_IRQENABLE1,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= OMAP1610_GPIO_WAKEUPENABLE,
+	.wkupclear	= OMAP1610_GPIO_CLEAR_WAKEUPENA,
+	.wkupset	= OMAP1610_GPIO_SET_WAKEUPENA,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +6 -0
index c7684ce..d5a4aaf 100644
@@ -48,6 +48,9 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 	.irqenable	= OMAP_MPUIO_GPIO_MASKIT / 2,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -90,6 +93,9 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 	.irqenable	= OMAP7XX_GPIO_INT_MASK,
 	.irqenable_inv	= true,
 	.ctrl		= USHRT_MAX,
+	.wkupstatus	= USHRT_MAX,
+	.wkupclear	= USHRT_MAX,
+	.wkupset	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +6 -0
index 0782e06..7e79999 100644
@@ -111,6 +111,9 @@ 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->wkupstatus = OMAP24XX_GPIO_WAKE_EN;
+		pdata->regs->wkupclear = OMAP24XX_GPIO_CLEARWKUENA;
+		pdata->regs->wkupset = OMAP24XX_GPIO_SETWKUENA;
 		break;
 	case 3:
 		pdata->bank_type = METHOD_GPIO_44XX;
@@ -128,6 +131,9 @@ 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->wkupstatus = OMAP4_GPIO_IRQWAKEN0;
+		pdata->regs->wkupclear = OMAP4_GPIO_IRQWAKEN0;
+		pdata->regs->wkupset = OMAP4_GPIO_IRQWAKEN0;
 		break;
 	default:
 		WARN(1, "Invalid gpio bank_type\n");
arch/arm/plat-omap/include/plat/gpio.h +0 -0
index 5718a45..2d1a5d6 100644

arch/arm/plat-omap/include/plat/gpio.h struct omap_gpio_reg_offs { · line 194

Quoted 6 lines
arch/arm/plat-omap/include/plat/gpio.h +3 -0
@@ -189,6 +189,9 @@ struct omap_gpio_reg_offs {
 	u16 debounce;
 	u16 debounce_en;
 	u16 ctrl;
+	u16 wkupstatus;
+	u16 wkupclear;
+	u16 wkupset;

s/wkup/wkup_/

Quoted 28 lines
arch/arm/plat-omap/include/plat/gpio.h +0 -0
 	bool irqenable_inv;
 };
drivers/gpio/gpio_omap.c +3 -8
index fcc60be..c189416 100644
@@ -77,6 +77,9 @@ struct gpio_bank {
 	u32 width;
 	u32 ctx_lost_cnt_before;
 	u16 id;
+	void __iomem *wake_status;
+	void __iomem *wake_clear;
+	void __iomem *wake_set;
 
 	void (*set_dataout)(struct gpio_bank *bank, int gpio, int enable);
 
@@ -606,27 +609,11 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
 	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)

drivers/gpio/gpio_omap.c static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) · line 613

Quoted 10 lines
drivers/gpio/gpio_omap.c +2 -8
-	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->wkupclear != USHRT_MAX)

Here you check the 'regs' version...

drivers/gpio/gpio_omap.c static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) · line 616

Quoted 7 lines
drivers/gpio/gpio_omap.c +2 -4
 		/* Disable wake-up during idle for dynamic tick */
-		void __iomem *reg = bank->base + OMAP4_GPIO_IRQWAKEN0;
-		__raw_writel(1 << offset, reg);
-	}
-#endif
+		__raw_writel(1 << offset, bank->wake_clear);
+

...and here you write using the copy. Not good for readability. More on this below.

Quoted 5 lines
drivers/gpio/gpio_omap.c +0 -0
 	bank->mod_usage &= ~(1 << offset);
 
 	if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {
@@ -1189,6 +1176,15 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 		goto err_free;

drivers/gpio/gpio_omap.c static int __devinit omap_gpio_probe(struct platform_device *pdev) · line 1186

Quoted 10 lines
drivers/gpio/gpio_omap.c +8 -0
 	}
 
+	/*
+	 * Storing these addresses avoids redundant computation of these
+	 * values every time in suspend/resume functions and for all the
+	 * gpio banks.
+	 */
+	bank->wake_status = bank->base + bank->regs->wkupstatus;
+	bank->wake_clear = bank->base + bank->regs->wkupclear;
+	bank->wake_set = bank->base + bank->regs->wkupset;

Well, it's not really redundant since these are only used in the suspend and resume functions. I'd rather have an extra add in the suspend/resume functions than have 3 extra words in every struct gpio_bank.

Also, Using 'bank + reg offset' in the functions that use them is consistent with the pattern of all the other changes in the cleanup series, so lets not start something new.

drivers/gpio/gpio_omap.c err_exit: · line 1206

Quoted 9 lines
drivers/gpio/gpio_omap.c +1 -1
 	pm_runtime_enable(bank->dev);
 	pm_runtime_get_sync(bank->dev);
 
@@ -1207,7 +1203,7 @@ err_exit:
 }
 
 #if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS)
-static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg)
+static int omap_gpio_suspend(struct sys_device *dev, pm_message_t unused)

change not related to $SUBJECT patch

drivers/gpio/gpio_omap.c static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg) · line 1220

Quoted 10 lines
drivers/gpio/gpio_omap.c +0 -3
 {
 	struct gpio_bank *bank;
 
@@ -1215,41 +1211,12 @@ static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg)
 		return 0;
 
 	list_for_each_entry(bank, &omap_gpio_list, node) {
-		void __iomem *wake_status;
-		void __iomem *wake_clear;
-		void __iomem *wake_set;

IMO, these should stay here and should just be assigned 'bank->base + bank->regs->...'

Quoted 66 lines
drivers/gpio/gpio_omap.c +3 -51
 		unsigned long flags;
 
-		switch (bank->method) {
-#ifdef CONFIG_ARCH_OMAP16XX
-		case METHOD_GPIO_1610:
-			wake_status = bank->base + OMAP1610_GPIO_WAKEUPENABLE;
-			wake_clear = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
-			wake_set = bank->base + OMAP1610_GPIO_SET_WAKEUPENA;
-			break;
-#endif
-#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
-		case METHOD_GPIO_24XX:
-			wake_status = bank->base + OMAP24XX_GPIO_WAKE_EN;
-			wake_clear = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
-			wake_set = bank->base + OMAP24XX_GPIO_SETWKUENA;
-			break;
-#endif
-#ifdef CONFIG_ARCH_OMAP4
-		case METHOD_GPIO_44XX:
-			wake_status = bank->base + OMAP4_GPIO_IRQWAKEN0;
-			wake_clear = bank->base + OMAP4_GPIO_IRQWAKEN0;
-			wake_set = bank->base + OMAP4_GPIO_IRQWAKEN0;
-			break;
-#endif
-		default:
-			continue;
-		}
-
 		spin_lock_irqsave(&bank->lock, flags);
-		bank->saved_wakeup = __raw_readl(wake_status);
-		__raw_writel(0xffffffff, wake_clear);
-		__raw_writel(bank->suspend_wakeup, wake_set);
+		bank->saved_wakeup = __raw_readl(bank->wake_status);
+		__raw_writel(0xffffffff, bank->wake_clear);
+		__raw_writel(bank->suspend_wakeup, bank->wake_set);
 		spin_unlock_irqrestore(&bank->lock, flags);
 	}
 
@@ -1264,36 +1231,11 @@ static int omap_gpio_resume(struct sys_device *dev)
 		return 0;
 
 	list_for_each_entry(bank, &omap_gpio_list, node) {
-		void __iomem *wake_clear;
-		void __iomem *wake_set;
 		unsigned long flags;
 
-		switch (bank->method) {
-#ifdef CONFIG_ARCH_OMAP16XX
-		case METHOD_GPIO_1610:
-			wake_clear = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
-			wake_set = bank->base + OMAP1610_GPIO_SET_WAKEUPENA;
-			break;
-#endif
-#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
-		case METHOD_GPIO_24XX:
-			wake_clear = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
-			wake_set = bank->base + OMAP24XX_GPIO_SETWKUENA;
-			break;
-#endif
-#ifdef CONFIG_ARCH_OMAP4
-		case METHOD_GPIO_44XX:
-			wake_clear = bank->base + OMAP4_GPIO_IRQWAKEN0;
-			wake_set = bank->base + OMAP4_GPIO_IRQWAKEN0;
-			break;
-#endif
-		default:

drivers/gpio/gpio_omap.c static int omap_gpio_resume(struct sys_device *dev) · line 1240

Quoted 10 lines
drivers/gpio/gpio_omap.c +2 -5
-			continue;
-		}
-
 		spin_lock_irqsave(&bank->lock, flags);
-		__raw_writel(0xffffffff, wake_clear);
-		__raw_writel(bank->saved_wakeup, wake_set);
+		__raw_writel(0xffffffff, bank->wake_clear);
+		__raw_writel(bank->saved_wakeup, bank->wake_set);
 		spin_unlock_irqrestore(&bank->lock, flags);
 	}

In addition, the cpu_is_* checks in the suspend/resume functions could be replaced by checking for non-zero values in bank->regs->wkup*

Kevin

#39 lore raw

PATCH 9/15 OMAP: GPIO: cleanup suspend and resume functions

Kevin,

Quoted 123 lines · Kevin Hilman
Quoted 21 lines · Tarun Kanti DebBarma

Since wake_status, wake_clear, wake_set is common for all banks on a given OMAP version it is enough to get their values once during probe(). Also, register offsets are already initialzed according to OMAP versions during device registration. We no longer need these explicit checks.

---

?arch/arm/mach-omap1/gpio15xx.c ? ? ? ? | ? ?6 ++
?arch/arm/mach-omap1/gpio16xx.c ? ? ? ? | ? ?6 ++
?arch/arm/mach-omap1/gpio7xx.c ? ? ? ? ?| ? ?6 ++
?arch/arm/mach-omap2/gpio.c ? ? ? ? ? ? | ? ?6 ++
?arch/arm/plat-omap/include/plat/gpio.h | ? ?3 +
?drivers/gpio/gpio_omap.c ? ? ? ? ? ? ? | ?102 +++++++-------------------------

?6 files changed, 49 insertions(+), 80 deletions(-)

arch/arm/mach-omap1/gpio15xx.c +0 -0
index f18a4a9..b0bd21e 100644

arch/arm/mach-omap1/gpio15xx.c static struct omap_gpio_reg_offs omap15xx_mpuio_regs = { · line 49

Quoted 7 lines
arch/arm/mach-omap1/gpio15xx.c +3 -0
@@ -43,6 +43,9 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 ? ? ? .irqenable ? ? ?= OMAP_MPUIO_GPIO_MASKIT,
 ? ? ? .irqenable_inv ?= true,
 ? ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
+ ? ? .wkupstatus ? ? = USHRT_MAX,
+ ? ? .wkupclear ? ? ?= USHRT_MAX,
+ ? ? .wkupset ? ? ? ?= USHRT_MAX,
 ?};

Same comment as earlier about USHRT_MAX.

Just use zero to indicate no register present.

Quoted 88 lines
arch/arm/mach-omap1/gpio15xx.c +3 -0
 ?static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -85,6 +88,9 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 ? ? ? .irqenable ? ? ?= OMAP1510_GPIO_INT_MASK,
 ? ? ? .irqenable_inv ?= true,
 ? ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
+ ? ? .wkupstatus ? ? = USHRT_MAX,
+ ? ? .wkupclear ? ? ?= USHRT_MAX,
+ ? ? .wkupset ? ? ? ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +6 -0
index d886b88..403437b 100644
@@ -46,6 +46,9 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 ? ? ? .irqenable ? ? ?= OMAP_MPUIO_GPIO_MASKIT,
 ? ? ? .irqenable_inv ?= true,
 ? ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
+ ? ? .wkupstatus ? ? = USHRT_MAX,
+ ? ? .wkupclear ? ? ?= USHRT_MAX,
+ ? ? .wkupset ? ? ? ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -91,6 +94,9 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
 ? ? ? .set_irqenable ?= OMAP1610_GPIO_SET_IRQENABLE1,
 ? ? ? .clr_irqenable ?= OMAP1610_GPIO_CLEAR_IRQENABLE1,
 ? ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
+ ? ? .wkupstatus ? ? = OMAP1610_GPIO_WAKEUPENABLE,
+ ? ? .wkupclear ? ? ?= OMAP1610_GPIO_CLEAR_WAKEUPENA,
+ ? ? .wkupset ? ? ? ?= OMAP1610_GPIO_SET_WAKEUPENA,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +6 -0
index c7684ce..d5a4aaf 100644
@@ -48,6 +48,9 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 ? ? ? .irqenable ? ? ?= OMAP_MPUIO_GPIO_MASKIT / 2,
 ? ? ? .irqenable_inv ?= true,
 ? ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
+ ? ? .wkupstatus ? ? = USHRT_MAX,
+ ? ? .wkupclear ? ? ?= USHRT_MAX,
+ ? ? .wkupset ? ? ? ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -90,6 +93,9 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 ? ? ? .irqenable ? ? ?= OMAP7XX_GPIO_INT_MASK,
 ? ? ? .irqenable_inv ?= true,
 ? ? ? .ctrl ? ? ? ? ? = USHRT_MAX,
+ ? ? .wkupstatus ? ? = USHRT_MAX,
+ ? ? .wkupclear ? ? ?= USHRT_MAX,
+ ? ? .wkupset ? ? ? ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +3 -0
index 0782e06..7e79999 100644
@@ -111,6 +111,9 @@ 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->wkupstatus = OMAP24XX_GPIO_WAKE_EN;
+ ? ? ? ? ? ? pdata->regs->wkupclear = OMAP24XX_GPIO_CLEARWKUENA;
+ ? ? ? ? ? ? pdata->regs->wkupset = OMAP24XX_GPIO_SETWKUENA;
 ? ? ? ? ? ? ? break;

? ? ? case 3:
? ? ? ? ? ? ? pdata->bank_type = METHOD_GPIO_44XX;

arch/arm/mach-omap2/gpio.c +3 -0
@@ -128,6 +131,9 @@ 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->wkupstatus = OMAP4_GPIO_IRQWAKEN0;
+ ? ? ? ? ? ? pdata->regs->wkupclear = OMAP4_GPIO_IRQWAKEN0;
+ ? ? ? ? ? ? pdata->regs->wkupset = OMAP4_GPIO_IRQWAKEN0;
 ? ? ? ? ? ? ? break;

? ? ? default:
? ? ? ? ? ? ? WARN(1, "Invalid gpio bank_type\n");

arch/arm/plat-omap/include/plat/gpio.h +0 -0
index 5718a45..2d1a5d6 100644
@@ -189,6 +189,9 @@ struct omap_gpio_reg_offs {
Quoted 8 lines

arch/arm/plat-omap/include/plat/gpio.h struct omap_gpio_reg_offs { · line 194

Quoted 6 lines
arch/arm/plat-omap/include/plat/gpio.h +3 -0
 ? ? ? u16 debounce;
 ? ? ? u16 debounce_en;
 ? ? ? u16 ctrl;
+ ? ? u16 wkupstatus;
+ ? ? u16 wkupclear;
+ ? ? u16 wkupset;

s/wkup/wkup_/

Okay.

Quoted 42 lines
Quoted 29 lines
arch/arm/plat-omap/include/plat/gpio.h +0 -0
 ? ? ? bool irqenable_inv;
 ?};
drivers/gpio/gpio_omap.c +3 -8
index fcc60be..c189416 100644
@@ -77,6 +77,9 @@ struct gpio_bank {
 ? ? ? u32 width;
 ? ? ? u32 ctx_lost_cnt_before;
 ? ? ? u16 id;
+ ? ? void __iomem *wake_status;
+ ? ? void __iomem *wake_clear;
+ ? ? void __iomem *wake_set;
 
 ? ? ? void (*set_dataout)(struct gpio_bank *bank, int gpio, int enable);
 
@@ -606,27 +609,11 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
 ? ? ? 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)

drivers/gpio/gpio_omap.c static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) · line 613

Quoted 10 lines
drivers/gpio/gpio_omap.c +2 -8
- ? ? 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->wkupclear != USHRT_MAX)

Here you check the 'regs' version...

Quoted 10 lines

drivers/gpio/gpio_omap.c static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) · line 612

Quoted 7 lines

? ? ? ? ? ? ? /* Disable wake-up during idle for dynamic tick */
- ? ? ? ? ? ? void __iomem *reg = bank->base + OMAP4_GPIO_IRQWAKEN0;
- ? ? ? ? ? ? __raw_writel(1 << offset, reg);
- ? ? }

drivers/gpio/gpio_omap.c +2 -1
-#endif
+ ? ? ? ? ? ? __raw_writel(1 << offset, bank->wake_clear);
+

...and here you write using the copy. ?Not good for readability. ?More on this below.

Agreed. Will do the needful.

Quoted 21 lines
Quoted 6 lines

? ? ? bank->mod_usage &= ~(1 << offset);

? ? ? if ((bank->regs->ctrl != USHRT_MAX) && (!bank->mod_usage)) {

drivers/gpio/gpio_omap.c +0 -0
@@ -1189,6 +1176,15 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 ? ? ? ? ? ? ? goto err_free;

drivers/gpio/gpio_omap.c static int __devinit omap_gpio_probe(struct platform_device *pdev) · line 1186

Quoted 10 lines
drivers/gpio/gpio_omap.c +8 -0
 ? ? ? }
 
+ ? ? /*
+ ? ? ?* Storing these addresses avoids redundant computation of these
+ ? ? ?* values every time in suspend/resume functions and for all the
+ ? ? ?* gpio banks.
+ ? ? ?*/
+ ? ? bank->wake_status = bank->base + bank->regs->wkupstatus;
+ ? ? bank->wake_clear = bank->base + bank->regs->wkupclear;
+ ? ? bank->wake_set = bank->base + bank->regs->wkupset;

Well, it's not really redundant since these are only used in the suspend and resume functions. ?I'd rather have an extra add in the suspend/resume functions than have 3 extra words in every struct gpio_bank.

Quoted 3 lines

Also, Using 'bank + reg offset' in the functions that use them is consistent with the pattern of all the other changes in the cleanup series, so lets not start something new.

Agreed.

Quoted 19 lines

drivers/gpio/gpio_omap.c err_exit: · line 1206

Quoted 10 lines
drivers/gpio/gpio_omap.c +1 -1
 ? ? ? pm_runtime_enable(bank->dev);
 ? ? ? pm_runtime_get_sync(bank->dev);
 
@@ -1207,7 +1203,7 @@ err_exit:
 ?}
 
 ?#if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS)
-static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg)
+static int omap_gpio_suspend(struct sys_device *dev, pm_message_t unused)

change not related to $SUBJECT patch

Quoted 6 lines
drivers/gpio/gpio_omap.c +0 -0
 ?{
 ? ? ? struct gpio_bank *bank;
 
@@ -1215,41 +1211,12 @@ static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg)
 ? ? ? ? ? ? ? return 0;
 
Quoted 7 lines

drivers/gpio/gpio_omap.c static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg) · line 1220

Quoted 4 lines
drivers/gpio/gpio_omap.c +0 -3
 ? ? ? list_for_each_entry(bank, &omap_gpio_list, node) {
- ? ? ? ? ? ? void __iomem *wake_status;
- ? ? ? ? ? ? void __iomem *wake_clear;
- ? ? ? ? ? ? void __iomem *wake_set;

IMO, these should stay here and should just be assigned 'bank->base + bank->regs->...'

Okay.

Quoted 72 lines
Quoted 72 lines
drivers/gpio/gpio_omap.c +3 -55
 ? ? ? ? ? ? ? unsigned long flags;
 
- ? ? ? ? ? ? switch (bank->method) {
-#ifdef CONFIG_ARCH_OMAP16XX
- ? ? ? ? ? ? case METHOD_GPIO_1610:
- ? ? ? ? ? ? ? ? ? ? wake_status = bank->base + OMAP1610_GPIO_WAKEUPENABLE;
- ? ? ? ? ? ? ? ? ? ? wake_clear = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
- ? ? ? ? ? ? ? ? ? ? wake_set = bank->base + OMAP1610_GPIO_SET_WAKEUPENA;
- ? ? ? ? ? ? ? ? ? ? break;
-#endif
-#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
- ? ? ? ? ? ? case METHOD_GPIO_24XX:
- ? ? ? ? ? ? ? ? ? ? wake_status = bank->base + OMAP24XX_GPIO_WAKE_EN;
- ? ? ? ? ? ? ? ? ? ? wake_clear = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
- ? ? ? ? ? ? ? ? ? ? wake_set = bank->base + OMAP24XX_GPIO_SETWKUENA;
- ? ? ? ? ? ? ? ? ? ? break;
-#endif
-#ifdef CONFIG_ARCH_OMAP4
- ? ? ? ? ? ? case METHOD_GPIO_44XX:
- ? ? ? ? ? ? ? ? ? ? wake_status = bank->base + OMAP4_GPIO_IRQWAKEN0;
- ? ? ? ? ? ? ? ? ? ? wake_clear = bank->base + OMAP4_GPIO_IRQWAKEN0;
- ? ? ? ? ? ? ? ? ? ? wake_set = bank->base + OMAP4_GPIO_IRQWAKEN0;
- ? ? ? ? ? ? ? ? ? ? break;
-#endif
- ? ? ? ? ? ? default:
- ? ? ? ? ? ? ? ? ? ? continue;
- ? ? ? ? ? ? }
-
 ? ? ? ? ? ? ? spin_lock_irqsave(&bank->lock, flags);
- ? ? ? ? ? ? bank->saved_wakeup = __raw_readl(wake_status);
- ? ? ? ? ? ? __raw_writel(0xffffffff, wake_clear);
- ? ? ? ? ? ? __raw_writel(bank->suspend_wakeup, wake_set);
+ ? ? ? ? ? ? bank->saved_wakeup = __raw_readl(bank->wake_status);
+ ? ? ? ? ? ? __raw_writel(0xffffffff, bank->wake_clear);
+ ? ? ? ? ? ? __raw_writel(bank->suspend_wakeup, bank->wake_set);
 ? ? ? ? ? ? ? spin_unlock_irqrestore(&bank->lock, flags);
 ? ? ? }
 
@@ -1264,36 +1231,11 @@ static int omap_gpio_resume(struct sys_device *dev)
 ? ? ? ? ? ? ? return 0;
 
 ? ? ? list_for_each_entry(bank, &omap_gpio_list, node) {
- ? ? ? ? ? ? void __iomem *wake_clear;
- ? ? ? ? ? ? void __iomem *wake_set;
 ? ? ? ? ? ? ? unsigned long flags;
 
- ? ? ? ? ? ? switch (bank->method) {
-#ifdef CONFIG_ARCH_OMAP16XX
- ? ? ? ? ? ? case METHOD_GPIO_1610:
- ? ? ? ? ? ? ? ? ? ? wake_clear = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
- ? ? ? ? ? ? ? ? ? ? wake_set = bank->base + OMAP1610_GPIO_SET_WAKEUPENA;
- ? ? ? ? ? ? ? ? ? ? break;
-#endif
-#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
- ? ? ? ? ? ? case METHOD_GPIO_24XX:
- ? ? ? ? ? ? ? ? ? ? wake_clear = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
- ? ? ? ? ? ? ? ? ? ? wake_set = bank->base + OMAP24XX_GPIO_SETWKUENA;
- ? ? ? ? ? ? ? ? ? ? break;
-#endif
-#ifdef CONFIG_ARCH_OMAP4
- ? ? ? ? ? ? case METHOD_GPIO_44XX:
- ? ? ? ? ? ? ? ? ? ? wake_clear = bank->base + OMAP4_GPIO_IRQWAKEN0;
- ? ? ? ? ? ? ? ? ? ? wake_set = bank->base + OMAP4_GPIO_IRQWAKEN0;
- ? ? ? ? ? ? ? ? ? ? break;
-#endif
- ? ? ? ? ? ? default:
- ? ? ? ? ? ? ? ? ? ? continue;
- ? ? ? ? ? ? }
-
 ? ? ? ? ? ? ? spin_lock_irqsave(&bank->lock, flags);
- ? ? ? ? ? ? __raw_writel(0xffffffff, wake_clear);
Quoted 8 lines

drivers/gpio/gpio_omap.c static int omap_gpio_resume(struct sys_device *dev) · line 1240

Quoted 5 lines
drivers/gpio/gpio_omap.c +2 -1
- ? ? ? ? ? ? __raw_writel(bank->saved_wakeup, wake_set);
+ ? ? ? ? ? ? __raw_writel(0xffffffff, bank->wake_clear);
+ ? ? ? ? ? ? __raw_writel(bank->saved_wakeup, bank->wake_set);
 ? ? ? ? ? ? ? spin_unlock_irqrestore(&bank->lock, flags);
 ? ? ? }

In addition, the cpu_is_* checks in the suspend/resume functions could be replaced by checking for non-zero values in bank->regs->wkup*

This is taken care in a later patch. In our next series, we will take care about the patch order too with cleanup taken care in a separately and later any functionality change/fixes.

-V Charulatha

Quoted 3 lines

Kevin

#40 lore raw

PATCH 10/15 OMAP: GPIO: cleanup prepare/resume idle functions

In reply to Tarun Kanti DebBarma

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.

---
 arch/arm/mach-omap2/gpio.c             |    8 ++
 arch/arm/plat-omap/include/plat/gpio.h |    4 +
 drivers/gpio/gpio_omap.c               |  116 ++++++++++----------------------
 3 files changed, 48 insertions(+), 80 deletions(-)
arch/arm/mach-omap2/gpio.c +8 -0
index 7e79999..0f8782f 100644
@@ -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;
arch/arm/plat-omap/include/plat/gpio.h +4 -0
index 2d1a5d6..7712e97 100644
@@ -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;
drivers/gpio/gpio_omap.c +36 -80

163 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#42 lore raw

PATCH 11/15 OMAP: GPIO: Remove hardcoded offsets in ctxt save/restore

In reply to Tarun Kanti DebBarma

It is not required to use hard-coded offsets any more in context save and restore functions and instead use the generic offsets which have been correctly initialized during device registration.

---
 arch/arm/mach-omap2/gpio.c             |    2 +
 arch/arm/plat-omap/include/plat/gpio.h |    1 +
 drivers/gpio/gpio_omap.c               |  123 ++++++++++----------------------
 3 files changed, 40 insertions(+), 86 deletions(-)
arch/arm/mach-omap2/gpio.c +2 -0
index 0f8782f..5c888dd 100644
@@ -106,6 +106,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		pdata->regs->irqstatus = OMAP24XX_GPIO_IRQSTATUS1;
 		pdata->regs->irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2;
 		pdata->regs->irqenable = OMAP24XX_GPIO_IRQENABLE1;
+		pdata->regs->irqenable2 = OMAP24XX_GPIO_IRQENABLE2;
 		pdata->regs->set_irqenable = OMAP24XX_GPIO_SETIRQENABLE1;
 		pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1;
 		pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL;
@@ -130,6 +131,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		pdata->regs->irqstatus = OMAP4_GPIO_IRQSTATUS0;
 		pdata->regs->irqstatus2 = OMAP4_GPIO_IRQSTATUS1;
 		pdata->regs->irqenable = OMAP4_GPIO_IRQSTATUSSET0;
+		pdata->regs->irqenable2 = OMAP4_GPIO_IRQSTATUSSET1;
 		pdata->regs->set_irqenable = OMAP4_GPIO_IRQSTATUSSET0;
 		pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0;
 		pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME;
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index 7712e97..a341790 100644
@@ -184,6 +184,7 @@ struct omap_gpio_reg_offs {
 	u16 irqstatus;
 	u16 irqstatus2;
 	u16 irqenable;
+	u16 irqenable2;
 	u16 set_irqenable;
 	u16 clr_irqenable;
 	u16 debounce;
drivers/gpio/gpio_omap.c +37 -86

133 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#43 lore raw

PATCH 11/15 OMAP: GPIO: Remove hardcoded offsets in ctxt save/restore

Quoted 6 lines · Tarun Kanti DebBarma

It is not required to use hard-coded offsets any more in context save and restore functions and instead use the generic offsets which have been correctly initialized during device registration.

Looks good.

I suggest you move this and all the other patches that just change to using regsister offsets earlier in the series.

Kevin

#44 lore raw

PATCH 11/15 OMAP: GPIO: Remove hardcoded offsets in ctxt save/restore

Quoted 6 lines · Kevin Hilman
Quoted 4 lines · Tarun Kanti DebBarma

It is not required to use hard-coded offsets any more in context save and restore functions and instead use the generic offsets which have been correctly initialized during device registration.

Quoted 7 lines
Quoted 2 lines

Looks good.

I suggest you move this and all the other patches that just change to using regsister offsets earlier in the series.

okay.

Quoted 3 lines

Kevin

#45 lore raw

PATCH 11/15 OMAP: GPIO: Remove hardcoded offsets in ctxt save/restore

In reply to Tarun Kanti DebBarma

arch/arm/mach-omap2/gpio.c

Quoted 27 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM
To: linux-omap at vger.kernel.org
Cc: Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; DebBarma, Tarun Kanti; Varadarajan, Charulatha
Subject: [PATCH 11/15] OMAP: GPIO: Remove hardcoded offsets in ctxt save/restore

It is not required to use hard-coded offsets any more in context save and restore functions and instead use the generic offsets which have been correctly initialized during device registration.

---
 arch/arm/mach-omap2/gpio.c             |    2 +
 arch/arm/plat-omap/include/plat/gpio.h |    1 +
 drivers/gpio/gpio_omap.c               |  123 
++++++++++----------------------
 3 files changed, 40 insertions(+), 86 deletions(-)
arch/arm/mach-omap2/gpio.c +0 -0
index 0f8782f..5c888dd 100644

[snip]...[snip]

drivers/gpio/gpio_omap.c restore_gpio_ctx: · line 1397

Quoted 8 lines
drivers/gpio/gpio_omap.c +0 -0
index 28390a9..05c2857 100644
@@ -1395,96 +1395,47 @@ restore_gpio_ctx:
 
 void omap_gpio_save_context(struct gpio_bank *bank)
 {

[sp] The [PATCH 06/15] OMAP4: GPIO: Save/restore context
seems to be doing exactly opposite:
It introduces the checks for
[quote]
+ if (bank->method == METHOD_GPIO_24XX) {
...
...
+ } else if (bank->method == METHOD_GPIO_44XX) {
[/quote]

and this patch removes the same checks.

Am I missing something?

~sanjeev

Quoted 168 lines
drivers/gpio/gpio_omap.c +17 -67
-	if (bank->method == METHOD_GPIO_24XX) {
-		bank->context.irqenable1 = __raw_readl(
-					bank->base + 
 OMAP24XX_GPIO_IRQENABLE1);
-		bank->context.irqenable2 = __raw_readl(
-					bank->base + 
 OMAP24XX_GPIO_IRQENABLE2);
-		bank->context.wake_en = __raw_readl(
-					bank->base + 
 OMAP24XX_GPIO_WAKE_EN);
-		bank->context.ctrl = __raw_readl(
-					bank->base + 
 OMAP24XX_GPIO_CTRL);
-		bank->context.oe = __raw_readl(
-					bank->base + OMAP24XX_GPIO_OE);
-		bank->context.leveldetect0 = __raw_readl(bank->base +
-					OMAP24XX_GPIO_LEVELDETECT0);
-		bank->context.leveldetect1 = __raw_readl(bank->base +
-					OMAP24XX_GPIO_LEVELDETECT1);
-		bank->context.risingdetect = __raw_readl(bank->base +
-					OMAP24XX_GPIO_RISINGDETECT);
-		bank->context.fallingdetect = __raw_readl(bank->base +
-					OMAP24XX_GPIO_FALLINGDETECT);
-		bank->context.dataout = __raw_readl(
-					bank->base + 
 OMAP24XX_GPIO_DATAOUT);
-	} else if (bank->method == METHOD_GPIO_44XX) {
-		bank->context.irqenable1 = __raw_readl(
-					bank->base + 
 OMAP4_GPIO_IRQSTATUSSET0);
-		bank->context.irqenable2 = __raw_readl(
-					bank->base + 
 OMAP4_GPIO_IRQSTATUSSET1);
-		bank->context.wake_en = __raw_readl(
-					bank->base + 
 OMAP4_GPIO_IRQWAKEN0);
-		bank->context.ctrl = __raw_readl(
-					bank->base + OMAP4_GPIO_CTRL);
-		bank->context.oe = __raw_readl(
-					bank->base + OMAP24XX_GPIO_OE);
-		bank->context.leveldetect0 = __raw_readl(bank->base +
-					OMAP4_GPIO_LEVELDETECT0);
-		bank->context.leveldetect1 = __raw_readl(bank->base +
-					OMAP4_GPIO_LEVELDETECT1);
-		bank->context.risingdetect = __raw_readl(bank->base +
-					OMAP4_GPIO_RISINGDETECT);
-		bank->context.fallingdetect = __raw_readl(bank->base +
-					OMAP4_GPIO_FALLINGDETECT);
-		bank->context.dataout = __raw_readl(
-					bank->base + 
 OMAP4_GPIO_DATAOUT);
-	}
+	bank->context.irqenable1 =
+			__raw_readl(bank->base + bank->regs->irqenable);
+	bank->context.irqenable2 =
+			__raw_readl(bank->base + 
 bank->regs->irqenable2);
+	bank->context.wake_en =
+			__raw_readl(bank->base + 
 bank->regs->wkupstatus);
+	bank->context.ctrl = __raw_readl(bank->base + bank->regs->ctrl);
+	bank->context.oe = __raw_readl(bank->base + 
 bank->regs->direction);
+	bank->context.leveldetect0 =
+			__raw_readl(bank->base + 
 bank->regs->leveldetect0);
+	bank->context.leveldetect1 =
+			__raw_readl(bank->base + 
 bank->regs->leveldetect1);
+	bank->context.risingdetect =
+			__raw_readl(bank->base + 
 bank->regs->risingdetect);
+	bank->context.fallingdetect =
+			__raw_readl(bank->base + 
 bank->regs->fallingdetect);
+	bank->context.dataout = __raw_readl(bank->base + 
 bank->regs->dataout);
 }
 
 void omap_gpio_restore_context(struct gpio_bank *bank)
 {
-	if (bank->method == METHOD_GPIO_24XX) {
-		__raw_writel(bank->context.irqenable1, bank->base +
-						
 OMAP24XX_GPIO_IRQENABLE1);
-		__raw_writel(bank->context.irqenable2, bank->base +
-						
 OMAP24XX_GPIO_IRQENABLE2);
-		__raw_writel(bank->context.wake_en, bank->base +
-						OMAP24XX_GPIO_WAKE_EN);
-		__raw_writel(bank->context.ctrl, bank->base +
-						OMAP24XX_GPIO_CTRL);
-		__raw_writel(bank->context.oe, bank->base +
-						OMAP24XX_GPIO_OE);
-		__raw_writel(bank->context.leveldetect0, bank->base +
-						
 OMAP24XX_GPIO_LEVELDETECT0);
-		__raw_writel(bank->context.leveldetect1, bank->base +
-						
 OMAP24XX_GPIO_LEVELDETECT1);
-		__raw_writel(bank->context.risingdetect, bank->base +
-						
 OMAP24XX_GPIO_RISINGDETECT);
-		__raw_writel(bank->context.fallingdetect, bank->base +
-						
 OMAP24XX_GPIO_FALLINGDETECT);
-		__raw_writel(bank->context.dataout, bank->base +
-						OMAP24XX_GPIO_DATAOUT);
-	} else if (bank->method == METHOD_GPIO_44XX) {
-		__raw_writel(bank->context.irqenable1, bank->base +
-						

OMAP4_GPIO_IRQSTATUSSET0);

drivers/gpio/gpio_omap.c +0 -2
-		__raw_writel(bank->context.irqenable2, bank->base +
-						

OMAP4_GPIO_IRQSTATUSSET1);

drivers/gpio/gpio_omap.c +0 -8
-		__raw_writel(bank->context.wake_en, bank->base +
-						OMAP4_GPIO_IRQWAKEN0);
-		__raw_writel(bank->context.ctrl, bank->base +
-						OMAP4_GPIO_CTRL);
-		__raw_writel(bank->context.oe, bank->base +
-						OMAP24XX_GPIO_OE);
-		__raw_writel(bank->context.leveldetect0, bank->base +
-						

OMAP4_GPIO_LEVELDETECT0);

drivers/gpio/gpio_omap.c +0 -2
-		__raw_writel(bank->context.leveldetect1, bank->base +
-						

OMAP4_GPIO_LEVELDETECT1);

drivers/gpio/gpio_omap.c +0 -2
-		__raw_writel(bank->context.risingdetect, bank->base +
-						

OMAP4_GPIO_RISINGDETECT);

drivers/gpio/gpio_omap.c +0 -2
-		__raw_writel(bank->context.fallingdetect, bank->base +
-						

OMAP4_GPIO_FALLINGDETECT);

drivers/gpio/gpio_omap.c +20 -3
-		__raw_writel(bank->context.dataout, bank->base +
-						OMAP4_GPIO_DATAOUT);
-	}
+	__raw_writel(bank->context.irqenable1,
+				bank->base + bank->regs->irqenable);
+	__raw_writel(bank->context.irqenable2,
+				bank->base + bank->regs->irqenable2);
+	__raw_writel(bank->context.wake_en,
+				bank->base + bank->regs->wkupstatus);
+	__raw_writel(bank->context.ctrl,
+				bank->base + bank->regs->ctrl);
+	__raw_writel(bank->context.oe,
+				bank->base + bank->regs->direction);
+	__raw_writel(bank->context.leveldetect0,
+				bank->base + bank->regs->leveldetect0);
+	__raw_writel(bank->context.leveldetect1,
+				bank->base + bank->regs->leveldetect1);
+	__raw_writel(bank->context.risingdetect,
+				bank->base + bank->regs->risingdetect);
+	__raw_writel(bank->context.fallingdetect,
+				bank->base + bank->regs->fallingdetect);
+	__raw_writel(bank->context.dataout,
+				bank->base + bank->regs->dataout);
 }
 
 #endif
Signature · 7 lines
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe 
linux-omap" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#46 lore raw

PATCH 11/15 OMAP: GPIO: Remove hardcoded offsets in ctxt save/restore

Sanjeev,

Quoted 48 lines · Sanjeev

arch/arm/mach-omap2/gpio.c

Quoted 27 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of DebBarma, Tarun Kanti
Sent: Tuesday, May 24, 2011 7:55 PM
To: linux-omap at vger.kernel.org
Cc: Hilman, Kevin; Shilimkar, Santosh; tony at atomide.com; linux-arm-kernel at lists.infradead.org; DebBarma, Tarun Kanti; Varadarajan, Charulatha
Subject: [PATCH 11/15] OMAP: GPIO: Remove hardcoded offsets in ctxt save/restore

It is not required to use hard-coded offsets any more in context save and restore functions and instead use the generic offsets which have been correctly initialized during device registration.

---

?arch/arm/mach-omap2/gpio.c ? ? ? ? ? ? | ? ?2 +
?arch/arm/plat-omap/include/plat/gpio.h | ? ?1 +
?drivers/gpio/gpio_omap.c ? ? ? ? ? ? ? | ?123

++++++++++----------------------
?3 files changed, 40 insertions(+), 86 deletions(-)

arch/arm/mach-omap2/gpio.c +0 -0
index 0f8782f..5c888dd 100644

[snip]...[snip]

drivers/gpio/gpio_omap.c restore_gpio_ctx: · line 1397

Quoted 8 lines
drivers/gpio/gpio_omap.c +0 -0
index 28390a9..05c2857 100644
@@ -1395,96 +1395,47 @@ restore_gpio_ctx:
 
 ?void omap_gpio_save_context(struct gpio_bank *bank)
 ?{

[sp] The [PATCH 06/15] OMAP4: GPIO: Save/restore context ? ? seems to be doing exactly opposite:
? ? It introduces the checks for
[quote]
?+ ? ? ? ? ? ? ?if (bank->method == METHOD_GPIO_24XX) {
...
...
?+ ? ? ? ? ? ? ?} else if (bank->method == METHOD_GPIO_44XX) { [/quote]

Quoted 3 lines

and this patch removes the same checks.

Am I missing something?

Patch 6 introduces the save/restore context code for OMAP4 and this patch tries to replace all the macro usage with the reg offset values which is nothing but cleanup.

Based on your comments and Kevin's I understand that I should make cleanups first and then any fixes/functionality changes to avoid confusions. Will do that and send a revised series next week.

-V Charulatha

Quoted 172 lines

~sanjeev

Quoted 168 lines
drivers/gpio/gpio_omap.c +17 -67
- ? ? if (bank->method == METHOD_GPIO_24XX) {
- ? ? ? ? ? ? bank->context.irqenable1 = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP24XX_GPIO_IRQENABLE1);
- ? ? ? ? ? ? bank->context.irqenable2 = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP24XX_GPIO_IRQENABLE2);
- ? ? ? ? ? ? bank->context.wake_en = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP24XX_GPIO_WAKE_EN);
- ? ? ? ? ? ? bank->context.ctrl = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP24XX_GPIO_CTRL);
- ? ? ? ? ? ? bank->context.oe = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + OMAP24XX_GPIO_OE);
- ? ? ? ? ? ? bank->context.leveldetect0 = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_LEVELDETECT0);
- ? ? ? ? ? ? bank->context.leveldetect1 = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_LEVELDETECT1);
- ? ? ? ? ? ? bank->context.risingdetect = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_RISINGDETECT);
- ? ? ? ? ? ? bank->context.fallingdetect = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_FALLINGDETECT);
- ? ? ? ? ? ? bank->context.dataout = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP24XX_GPIO_DATAOUT);
- ? ? } else if (bank->method == METHOD_GPIO_44XX) {
- ? ? ? ? ? ? bank->context.irqenable1 = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP4_GPIO_IRQSTATUSSET0);
- ? ? ? ? ? ? bank->context.irqenable2 = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP4_GPIO_IRQSTATUSSET1);
- ? ? ? ? ? ? bank->context.wake_en = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP4_GPIO_IRQWAKEN0);
- ? ? ? ? ? ? bank->context.ctrl = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + OMAP4_GPIO_CTRL);
- ? ? ? ? ? ? bank->context.oe = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + OMAP24XX_GPIO_OE);
- ? ? ? ? ? ? bank->context.leveldetect0 = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_LEVELDETECT0);
- ? ? ? ? ? ? bank->context.leveldetect1 = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_LEVELDETECT1);
- ? ? ? ? ? ? bank->context.risingdetect = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_RISINGDETECT);
- ? ? ? ? ? ? bank->context.fallingdetect = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_FALLINGDETECT);
- ? ? ? ? ? ? bank->context.dataout = __raw_readl(
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base +
 OMAP4_GPIO_DATAOUT);
- ? ? }
+ ? ? bank->context.irqenable1 =
+ ? ? ? ? ? ? ? ? ? ? __raw_readl(bank->base + bank->regs->irqenable);
+ ? ? bank->context.irqenable2 =
+ ? ? ? ? ? ? ? ? ? ? __raw_readl(bank->base +
 bank->regs->irqenable2);
+ ? ? bank->context.wake_en =
+ ? ? ? ? ? ? ? ? ? ? __raw_readl(bank->base +
 bank->regs->wkupstatus);
+ ? ? bank->context.ctrl = __raw_readl(bank->base + bank->regs->ctrl);
+ ? ? bank->context.oe = __raw_readl(bank->base +
 bank->regs->direction);
+ ? ? bank->context.leveldetect0 =
+ ? ? ? ? ? ? ? ? ? ? __raw_readl(bank->base +
 bank->regs->leveldetect0);
+ ? ? bank->context.leveldetect1 =
+ ? ? ? ? ? ? ? ? ? ? __raw_readl(bank->base +
 bank->regs->leveldetect1);
+ ? ? bank->context.risingdetect =
+ ? ? ? ? ? ? ? ? ? ? __raw_readl(bank->base +
 bank->regs->risingdetect);
+ ? ? bank->context.fallingdetect =
+ ? ? ? ? ? ? ? ? ? ? __raw_readl(bank->base +
 bank->regs->fallingdetect);
+ ? ? bank->context.dataout = __raw_readl(bank->base +
 bank->regs->dataout);
 ?}
 
 ?void omap_gpio_restore_context(struct gpio_bank *bank)
 ?{
- ? ? if (bank->method == METHOD_GPIO_24XX) {
- ? ? ? ? ? ? __raw_writel(bank->context.irqenable1, bank->base +
-
 OMAP24XX_GPIO_IRQENABLE1);
- ? ? ? ? ? ? __raw_writel(bank->context.irqenable2, bank->base +
-
 OMAP24XX_GPIO_IRQENABLE2);
- ? ? ? ? ? ? __raw_writel(bank->context.wake_en, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_WAKE_EN);
- ? ? ? ? ? ? __raw_writel(bank->context.ctrl, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_CTRL);
- ? ? ? ? ? ? __raw_writel(bank->context.oe, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_OE);
- ? ? ? ? ? ? __raw_writel(bank->context.leveldetect0, bank->base +
-
 OMAP24XX_GPIO_LEVELDETECT0);
- ? ? ? ? ? ? __raw_writel(bank->context.leveldetect1, bank->base +
-
 OMAP24XX_GPIO_LEVELDETECT1);
- ? ? ? ? ? ? __raw_writel(bank->context.risingdetect, bank->base +
-
 OMAP24XX_GPIO_RISINGDETECT);
- ? ? ? ? ? ? __raw_writel(bank->context.fallingdetect, bank->base +
-
 OMAP24XX_GPIO_FALLINGDETECT);
- ? ? ? ? ? ? __raw_writel(bank->context.dataout, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_DATAOUT);
- ? ? } else if (bank->method == METHOD_GPIO_44XX) {
- ? ? ? ? ? ? __raw_writel(bank->context.irqenable1, bank->base +
-

OMAP4_GPIO_IRQSTATUSSET0);
- ? ? ? ? ? ? __raw_writel(bank->context.irqenable2, bank->base + -
OMAP4_GPIO_IRQSTATUSSET1);
- ? ? ? ? ? ? __raw_writel(bank->context.wake_en, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_IRQWAKEN0);
- ? ? ? ? ? ? __raw_writel(bank->context.ctrl, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_CTRL);
- ? ? ? ? ? ? __raw_writel(bank->context.oe, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_OE);
- ? ? ? ? ? ? __raw_writel(bank->context.leveldetect0, bank->base + -
OMAP4_GPIO_LEVELDETECT0);
- ? ? ? ? ? ? __raw_writel(bank->context.leveldetect1, bank->base + -
OMAP4_GPIO_LEVELDETECT1);
- ? ? ? ? ? ? __raw_writel(bank->context.risingdetect, bank->base + -
OMAP4_GPIO_RISINGDETECT);
- ? ? ? ? ? ? __raw_writel(bank->context.fallingdetect, bank->base + -
OMAP4_GPIO_FALLINGDETECT);
- ? ? ? ? ? ? __raw_writel(bank->context.dataout, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_DATAOUT);
- ? ? }
+ ? ? __raw_writel(bank->context.irqenable1,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->irqenable);
+ ? ? __raw_writel(bank->context.irqenable2,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->irqenable2);
+ ? ? __raw_writel(bank->context.wake_en,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->wkupstatus);
+ ? ? __raw_writel(bank->context.ctrl,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->ctrl);
+ ? ? __raw_writel(bank->context.oe,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->direction);
+ ? ? __raw_writel(bank->context.leveldetect0,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->leveldetect0);
+ ? ? __raw_writel(bank->context.leveldetect1,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->leveldetect1);
+ ? ? __raw_writel(bank->context.risingdetect,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->risingdetect);
+ ? ? __raw_writel(bank->context.fallingdetect,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->fallingdetect);
+ ? ? __raw_writel(bank->context.dataout,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->base + bank->regs->dataout); ?}

?#endif
--
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo at vger.kernel.org More majordomo info at ?http://vger.kernel.org/majordomo-info.html

#47 lore raw

PATCH 12/15 OMAP: GPIO: Fix: use wake set/clear regs

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

In set_24xx_gpio_triggering(), for OMAP4, GPIO wakeup request is set for all type of GPIO triggers whereas as per TRM the GPIO wakeup request can only be generated on edge transitions. Fix this.

In set_24xx_gpio_triggering(), OMAP4_GPIO_IRQWAKEN0 register is used for wakeup request and the GPIO set/clear wakeup registers are not used in OMAP4 but is handled without retaining it's old value. This would corrupt the contents of OMAP4_GPIO_IRQWAKEN0 register by writing the value of the last requested GPIO pin in a given bank. This can be avoided by making use of GPIO set/clear wakeup registers.

---
 arch/arm/mach-omap2/gpio.c |    4 ++--
 drivers/gpio/gpio_omap.c   |   32 ++++++++++----------------------
 2 files changed, 12 insertions(+), 24 deletions(-)
arch/arm/mach-omap2/gpio.c +2 -2
index 5c888dd..fbedbbb 100644
@@ -142,8 +142,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		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;
+		pdata->regs->wkupclear = OMAP4_GPIO_CLEARWKUENA;
+		pdata->regs->wkupset = OMAP4_GPIO_SETWKUENA;
 		break;
 	default:
 		WARN(1, "Invalid gpio bank_type\n");
drivers/gpio/gpio_omap.c +10 -22
index 05c2857..762d73c 100644
@@ -229,30 +229,18 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
 		MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
 			trigger & IRQ_TYPE_EDGE_FALLING);
 	}
+
 	if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
-		if (cpu_is_omap44xx()) {
-			if (trigger != 0)
-				__raw_writel(1 << gpio, bank->base+
-						OMAP4_GPIO_IRQWAKEN0);
-			else {
-				val = __raw_readl(bank->base +
-							OMAP4_GPIO_IRQWAKEN0);
-				__raw_writel(val & (~(1 << gpio)), bank->base +
-							 OMAP4_GPIO_IRQWAKEN0);
-			}
-		} else {
-			/*
-			 * GPIO wakeup request can only be generated on edge
-			 * transitions
-			 */
-			if (trigger & IRQ_TYPE_EDGE_BOTH)
-				__raw_writel(1 << gpio, bank->base
-					+ OMAP24XX_GPIO_SETWKUENA);
-			else
-				__raw_writel(1 << gpio, bank->base
-					+ OMAP24XX_GPIO_CLEARWKUENA);
-		}
+		/*
+		 * GPIO wakeup request can only be generated on edge
+		 * transitions
+		 */
+		if (trigger & IRQ_TYPE_EDGE_BOTH)
+			__raw_writel(1 << gpio, bank->wake_set);
+		else
+			__raw_writel(1 << gpio, bank->wake_clear);
 	}
+
 	/* This part needs to be executed always for OMAP34xx */
 	if (cpu_is_omap34xx() || (bank->non_wakeup_gpios & gpio_bit)) {
 		/*
Signature · 1 line
1.6.0.4
#48 lore raw

PATCH 12/15 OMAP: GPIO: Fix: use wake set/clear regs

Quoted 5 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

In set_24xx_gpio_triggering(), for OMAP4, GPIO wakeup request is set for all type of GPIO triggers whereas as per TRM the GPIO wakeup request can only be generated on edge transitions. Fix this.

OK. Please make a dedicated patch for this part.

Subject: GPIO: OMAP: IRQ triggering: use wake set/clear regs

Quoted 7 lines

In set_24xx_gpio_triggering(), OMAP4_GPIO_IRQWAKEN0 register is used for wakeup request and the GPIO set/clear wakeup registers are not used in OMAP4 but is handled without retaining it's old value. This would corrupt the contents of OMAP4_GPIO_IRQWAKEN0 register by writing the value of the last requested GPIO pin in a given bank. This can be avoided by making use of GPIO set/clear wakeup registers.

And this should be a separate patch too, or probably folded into PATCH 09/15 with an updated changelog of course.

Kevin

Quoted 66 lines
---
 arch/arm/mach-omap2/gpio.c |    4 ++--
 drivers/gpio/gpio_omap.c   |   32 ++++++++++----------------------
 2 files changed, 12 insertions(+), 24 deletions(-)
arch/arm/mach-omap2/gpio.c +2 -2
index 5c888dd..fbedbbb 100644
@@ -142,8 +142,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		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;
+		pdata->regs->wkupclear = OMAP4_GPIO_CLEARWKUENA;
+		pdata->regs->wkupset = OMAP4_GPIO_SETWKUENA;
 		break;
 	default:
 		WARN(1, "Invalid gpio bank_type\n");
drivers/gpio/gpio_omap.c +10 -22
index 05c2857..762d73c 100644
@@ -229,30 +229,18 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
 		MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
 			trigger & IRQ_TYPE_EDGE_FALLING);
 	}
+
 	if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
-		if (cpu_is_omap44xx()) {
-			if (trigger != 0)
-				__raw_writel(1 << gpio, bank->base+
-						OMAP4_GPIO_IRQWAKEN0);
-			else {
-				val = __raw_readl(bank->base +
-							OMAP4_GPIO_IRQWAKEN0);
-				__raw_writel(val & (~(1 << gpio)), bank->base +
-							 OMAP4_GPIO_IRQWAKEN0);
-			}
-		} else {
-			/*
-			 * GPIO wakeup request can only be generated on edge
-			 * transitions
-			 */
-			if (trigger & IRQ_TYPE_EDGE_BOTH)
-				__raw_writel(1 << gpio, bank->base
-					+ OMAP24XX_GPIO_SETWKUENA);
-			else
-				__raw_writel(1 << gpio, bank->base
-					+ OMAP24XX_GPIO_CLEARWKUENA);
-		}
+		/*
+		 * GPIO wakeup request can only be generated on edge
+		 * transitions
+		 */
+		if (trigger & IRQ_TYPE_EDGE_BOTH)
+			__raw_writel(1 << gpio, bank->wake_set);
+		else
+			__raw_writel(1 << gpio, bank->wake_clear);
 	}
+
 	/* This part needs to be executed always for OMAP34xx */
 	if (cpu_is_omap34xx() || (bank->non_wakeup_gpios & gpio_bit)) {
 		/*
#49 lore raw

PATCH 12/15 OMAP: GPIO: Fix: use wake set/clear regs

Quoted 9 lines · Kevin Hilman
Quoted 5 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

In set_24xx_gpio_triggering(), for OMAP4, GPIO wakeup request is set for all type of GPIO triggers whereas as per TRM the GPIO wakeup request can only be generated on edge transitions. Fix this.

OK. ?Please make a dedicated patch for this part.

Okay.

Quoted 2 lines

Subject: GPIO: OMAP: IRQ triggering: use wake set/clear regs

Okay.

Quoted 11 lines
Quoted 8 lines

In set_24xx_gpio_triggering(), OMAP4_GPIO_IRQWAKEN0 register is used for wakeup request and the GPIO set/clear wakeup registers are not used in OMAP4 but is handled without retaining it's old value. This would corrupt the contents of OMAP4_GPIO_IRQWAKEN0 register by writing the value of the last requested GPIO pin in a given bank. This can be avoided by making use of GPIO set/clear wakeup registers.

And this should be a separate patch too, or probably folded into PATCH 09/15 with an updated changelog of course.

Okay.

Quoted 70 lines

Kevin

Quoted 66 lines

---
?arch/arm/mach-omap2/gpio.c | ? ?4 ++-- ?drivers/gpio/gpio_omap.c ? | ? 32 ++++++++++---------------------- ?2 files changed, 12 insertions(+), 24 deletions(-)

arch/arm/mach-omap2/gpio.c +2 -2
index 5c888dd..fbedbbb 100644
@@ -142,8 +142,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 ? ? ? ? ? ? ? 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;
+ ? ? ? ? ? ? pdata->regs->wkupclear = OMAP4_GPIO_CLEARWKUENA;
+ ? ? ? ? ? ? pdata->regs->wkupset = OMAP4_GPIO_SETWKUENA;
 ? ? ? ? ? ? ? break;

? ? ? default:
? ? ? ? ? ? ? WARN(1, "Invalid gpio bank_type\n");

drivers/gpio/gpio_omap.c +10 -22
index 05c2857..762d73c 100644
@@ -229,30 +229,18 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
 ? ? ? ? ? ? ? MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
 ? ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_EDGE_FALLING);
 ? ? ? }
+
 ? ? ? if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
- ? ? ? ? ? ? if (cpu_is_omap44xx()) {
- ? ? ? ? ? ? ? ? ? ? if (trigger != 0)
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->base+
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_IRQWAKEN0);
- ? ? ? ? ? ? ? ? ? ? else {
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? val = __raw_readl(bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_IRQWAKEN0);
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? __raw_writel(val & (~(1 << gpio)), bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?OMAP4_GPIO_IRQWAKEN0);
- ? ? ? ? ? ? ? ? ? ? }
- ? ? ? ? ? ? } else {
- ? ? ? ? ? ? ? ? ? ? /*
- ? ? ? ? ? ? ? ? ? ? ?* GPIO wakeup request can only be generated on edge
- ? ? ? ? ? ? ? ? ? ? ?* transitions
- ? ? ? ? ? ? ? ? ? ? ?*/
- ? ? ? ? ? ? ? ? ? ? if (trigger & IRQ_TYPE_EDGE_BOTH)
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->base
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? + OMAP24XX_GPIO_SETWKUENA);
- ? ? ? ? ? ? ? ? ? ? else
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->base
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? + OMAP24XX_GPIO_CLEARWKUENA);
- ? ? ? ? ? ? }
+ ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ?* GPIO wakeup request can only be generated on edge
+ ? ? ? ? ? ? ?* transitions
+ ? ? ? ? ? ? ?*/
+ ? ? ? ? ? ? if (trigger & IRQ_TYPE_EDGE_BOTH)
+ ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->wake_set);
+ ? ? ? ? ? ? else
+ ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->wake_clear);
 ? ? ? }
+

? ? ? /* This part needs to be executed always for OMAP34xx */ ? ? ? if (cpu_is_omap34xx() || (bank->non_wakeup_gpios & gpio_bit)) { ? ? ? ? ? ? ? /*

#50 lore raw

PATCH 13/15 OMAP: GPIO: clean set_gpio_triggering function

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Getting rid of ifdefs within the function by adding register offset intctrl and associating OMAPXXXX_GPIO_INT_CONTROL in respective SoC specific files.

---
 arch/arm/mach-omap1/gpio15xx.c         |   14 ++++
 arch/arm/mach-omap1/gpio16xx.c         |   14 ++++
 arch/arm/mach-omap1/gpio7xx.c          |   14 ++++
 arch/arm/mach-omap2/gpio.c             |    4 +
 arch/arm/plat-omap/include/plat/gpio.h |    3 +
 drivers/gpio/gpio_omap.c               |  125 +++++++-------------------------
 6 files changed, 77 insertions(+), 97 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +14 -0
index b0bd21e..ceee046 100644
@@ -46,6 +46,13 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP_MPUIO_GPIO_INT_EDGE,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -91,6 +98,13 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP1510_GPIO_INT_CONTROL,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +14 -0
index 403437b..b2479c5 100644
@@ -49,6 +49,13 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP_MPUIO_GPIO_INT_EDGE,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -97,6 +104,13 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
 	.wkupstatus	= OMAP1610_GPIO_WAKEUPENABLE,
 	.wkupclear	= OMAP1610_GPIO_CLEAR_WAKEUPENA,
 	.wkupset	= OMAP1610_GPIO_SET_WAKEUPENA,
+	.irqctrl	= USHRT_MAX,
+	.edgectrl1	= OMAP1610_GPIO_EDGE_CTRL1,
+	.edgectrl2	= OMAP1610_GPIO_EDGE_CTRL2,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +14 -0
index d5a4aaf..ceac936 100644
@@ -51,6 +51,13 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP_MPUIO_GPIO_INT_EDGE / 2,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -96,6 +103,13 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP7XX_GPIO_INT_CONTROL,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +4 -0
index fbedbbb..eda1846 100644
@@ -92,6 +92,10 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		return -ENOMEM;
 	}
 
+	pdata->regs->irqctrl = USHRT_MAX;
+	pdata->regs->edgectrl1 = USHRT_MAX;
+	pdata->regs->edgectrl2 = USHRT_MAX;
+
 	switch (oh->class->rev) {
 	case 0:
 	case 1:
arch/arm/plat-omap/include/plat/gpio.h +3 -0
index a341790..f82881c 100644
@@ -197,6 +197,9 @@ struct omap_gpio_reg_offs {
 	u16 wkupstatus;
 	u16 wkupclear;
 	u16 wkupset;
+	u16 irqctrl;
+	u16 edgectrl1;
+	u16 edgectrl2;
 
 	bool irqenable_inv;
 };
drivers/gpio/gpio_omap.c +28 -97

199 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#51 lore raw

PATCH 13/15 OMAP: GPIO: clean set_gpio_triggering function

Quoted 22 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Getting rid of ifdefs within the function by adding register offset intctrl and associating OMAPXXXX_GPIO_INT_CONTROL in respective SoC specific files.

---
 arch/arm/mach-omap1/gpio15xx.c         |   14 ++++
 arch/arm/mach-omap1/gpio16xx.c         |   14 ++++
 arch/arm/mach-omap1/gpio7xx.c          |   14 ++++
 arch/arm/mach-omap2/gpio.c             |    4 +
 arch/arm/plat-omap/include/plat/gpio.h |    3 +
 drivers/gpio/gpio_omap.c               |  125 +++++++-------------------------
 6 files changed, 77 insertions(+), 97 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +0 -0
index b0bd21e..ceee046 100644
@@ -46,6 +46,13 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 	.wkupstatus	= USHRT_MAX,

arch/arm/mach-omap1/gpio15xx.c static struct omap_gpio_reg_offs omap15xx_mpuio_regs = { · line 56

Quoted 10 lines
arch/arm/mach-omap1/gpio15xx.c +7 -0
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP_MPUIO_GPIO_INT_EDGE,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };

As before, drop the USHRT_MAX and just use non-zer value to determine if register exists.

Quoted 157 lines
arch/arm/mach-omap1/gpio15xx.c +7 -0
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -91,6 +98,13 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP1510_GPIO_INT_CONTROL,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +14 -0
index 403437b..b2479c5 100644
@@ -49,6 +49,13 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP_MPUIO_GPIO_INT_EDGE,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -97,6 +104,13 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
 	.wkupstatus	= OMAP1610_GPIO_WAKEUPENABLE,
 	.wkupclear	= OMAP1610_GPIO_CLEAR_WAKEUPENA,
 	.wkupset	= OMAP1610_GPIO_SET_WAKEUPENA,
+	.irqctrl	= USHRT_MAX,
+	.edgectrl1	= OMAP1610_GPIO_EDGE_CTRL1,
+	.edgectrl2	= OMAP1610_GPIO_EDGE_CTRL2,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +14 -0
index d5a4aaf..ceac936 100644
@@ -51,6 +51,13 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP_MPUIO_GPIO_INT_EDGE / 2,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -96,6 +103,13 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 	.wkupstatus	= USHRT_MAX,
 	.wkupclear	= USHRT_MAX,
 	.wkupset	= USHRT_MAX,
+	.irqctrl	= OMAP7XX_GPIO_INT_CONTROL,
+	.edgectrl1	= USHRT_MAX,
+	.edgectrl2	= USHRT_MAX,
+	.leveldetect0	= USHRT_MAX,
+	.leveldetect1	= USHRT_MAX,
+	.risingdetect	= USHRT_MAX,
+	.fallingdetect	= USHRT_MAX,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +4 -0
index fbedbbb..eda1846 100644
@@ -92,6 +92,10 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		return -ENOMEM;
 	}
 
+	pdata->regs->irqctrl = USHRT_MAX;
+	pdata->regs->edgectrl1 = USHRT_MAX;
+	pdata->regs->edgectrl2 = USHRT_MAX;
+
 	switch (oh->class->rev) {
 	case 0:
 	case 1:
arch/arm/plat-omap/include/plat/gpio.h +3 -0
index a341790..f82881c 100644
@@ -197,6 +197,9 @@ struct omap_gpio_reg_offs {
 	u16 wkupstatus;
 	u16 wkupclear;
 	u16 wkupset;
+	u16 irqctrl;
+	u16 edgectrl1;
+	u16 edgectrl2;
 
 	bool irqenable_inv;
 };
drivers/gpio/gpio_omap.c +5 -19
index 762d73c..ebeb16e 100644
@@ -202,33 +202,20 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
 	__raw_writel(val, reg);
 }
 
-#ifdef CONFIG_ARCH_OMAP2PLUS
-static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
+static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
 						int trigger)
 {
 	void __iomem *base = bank->base;
 	u32 gpio_bit = 1 << gpio;
-	u32 val;
 
-	if (cpu_is_omap44xx()) {
-		MOD_REG_BIT(OMAP4_GPIO_LEVELDETECT0, gpio_bit,
+	MOD_REG_BIT(bank->regs->leveldetect0, gpio_bit,
 			trigger & IRQ_TYPE_LEVEL_LOW);
-		MOD_REG_BIT(OMAP4_GPIO_LEVELDETECT1, gpio_bit,
+	MOD_REG_BIT(bank->regs->leveldetect1, gpio_bit,
 			trigger & IRQ_TYPE_LEVEL_HIGH);
-		MOD_REG_BIT(OMAP4_GPIO_RISINGDETECT, gpio_bit,
+	MOD_REG_BIT(bank->regs->risingdetect, gpio_bit,
 			trigger & IRQ_TYPE_EDGE_RISING);
-		MOD_REG_BIT(OMAP4_GPIO_FALLINGDETECT, gpio_bit,
+	MOD_REG_BIT(bank->regs->fallingdetect, gpio_bit,
 			trigger & IRQ_TYPE_EDGE_FALLING);
-	} else {
-		MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT0, gpio_bit,
-			trigger & IRQ_TYPE_LEVEL_LOW);
-		MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT1, gpio_bit,
-			trigger & IRQ_TYPE_LEVEL_HIGH);
-		MOD_REG_BIT(OMAP24XX_GPIO_RISINGDETECT, gpio_bit,
-			trigger & IRQ_TYPE_EDGE_RISING);
-		MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
-			trigger & IRQ_TYPE_EDGE_FALLING);
-	}
 
 	if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
 		/*
@@ -259,36 +246,16 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
 		__raw_readl(bank->base + bank->regs->leveldetect0) |
 		__raw_readl(bank->base + bank->regs->leveldetect1);
 }
-#endif
 

drivers/gpio/gpio_omap.c static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio, · line 257

Quoted 10 lines
drivers/gpio/gpio_omap.c +1 -2
-#ifdef CONFIG_ARCH_OMAP1
 /*
  * This only applies to chips that can't do both rising and falling edge
  * detection at once.  For all other chips, this function is a noop.
  */
 static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio)
 {
-	void __iomem *reg = bank->base;
+	void __iomem *reg = bank->base + bank->regs->irqctrl;
 	u32 l = 0;

Need to check for valid regs->irqctrl here.

Quoted 139 lines
drivers/gpio/gpio_omap.c +20 -74
-	switch (bank->method) {
-	case METHOD_MPUIO:
-		reg += OMAP_MPUIO_GPIO_INT_EDGE / bank->stride;
-		break;
-#ifdef CONFIG_ARCH_OMAP15XX
-	case METHOD_GPIO_1510:
-		reg += OMAP1510_GPIO_INT_CONTROL;
-		break;
-#endif
-#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
-	case METHOD_GPIO_7XX:
-		reg += OMAP7XX_GPIO_INT_CONTROL;
-		break;
-#endif
-	default:
-		return;
-	}
-
 	l = __raw_readl(reg);
 	if ((l >> gpio) & 1)
 		l &= ~(1 << gpio);
@@ -297,31 +264,18 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio)
 
 	__raw_writel(l, reg);
 }
-#endif
 
 static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
 {
 	void __iomem *reg = bank->base;
 	u32 l = 0;
 
-	switch (bank->method) {
-#ifdef CONFIG_ARCH_OMAP1
-	case METHOD_MPUIO:
-		reg += OMAP_MPUIO_GPIO_INT_EDGE / bank->stride;
-		l = __raw_readl(reg);
-		if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
-			bank->toggle_mask |= 1 << gpio;
-		if (trigger & IRQ_TYPE_EDGE_RISING)
-			l |= 1 << gpio;
-		else if (trigger & IRQ_TYPE_EDGE_FALLING)
-			l &= ~(1 << gpio);
-		else
-			goto bad;
-		break;
-#endif
-#ifdef CONFIG_ARCH_OMAP15XX
-	case METHOD_GPIO_1510:
-		reg += OMAP1510_GPIO_INT_CONTROL;
+	if ((bank->regs->leveldetect0 != USHRT_MAX) &&
+			(bank->regs->wkupstatus != USHRT_MAX)) {
+		set_gpio_trigger(bank, gpio, trigger);
+	} else if (bank->regs->irqctrl != USHRT_MAX) {
+		reg += bank->regs->irqctrl;
+
 		l = __raw_readl(reg);
 		if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
 			bank->toggle_mask |= 1 << gpio;
@@ -330,15 +284,16 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
 		else if (trigger & IRQ_TYPE_EDGE_FALLING)
 			l &= ~(1 << gpio);
 		else
-			goto bad;
-		break;
-#endif
-#ifdef CONFIG_ARCH_OMAP16XX
-	case METHOD_GPIO_1610:
+			return -EINVAL;
+
+		__raw_writel(l, reg);
+
+	} else if (bank->regs->edgectrl1 != USHRT_MAX) {
 		if (gpio & 0x08)
-			reg += OMAP1610_GPIO_EDGE_CTRL2;
+			reg += bank->regs->edgectrl2;
 		else
-			reg += OMAP1610_GPIO_EDGE_CTRL1;
+			reg += bank->regs->edgectrl1;
+
 		gpio &= 0x07;
 		l = __raw_readl(reg);
 		l &= ~(3 << (gpio << 1));
@@ -346,40 +301,17 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
 			l |= 2 << (gpio << 1);
 		if (trigger & IRQ_TYPE_EDGE_FALLING)
 			l |= 1 << (gpio << 1);
+
 		if (trigger)
 			/* Enable wake-up during idle for dynamic tick */
-			__raw_writel(1 << gpio, bank->base + OMAP1610_GPIO_SET_WAKEUPENA);
-		else
-			__raw_writel(1 << gpio, bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA);
-		break;
-#endif
-#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
-	case METHOD_GPIO_7XX:
-		reg += OMAP7XX_GPIO_INT_CONTROL;
-		l = __raw_readl(reg);
-		if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
-			bank->toggle_mask |= 1 << gpio;
-		if (trigger & IRQ_TYPE_EDGE_RISING)
-			l |= 1 << gpio;
-		else if (trigger & IRQ_TYPE_EDGE_FALLING)
-			l &= ~(1 << gpio);
+			__raw_writel(1 << gpio, bank->wake_set);
 		else
-			goto bad;
-		break;
-#endif
-#ifdef CONFIG_ARCH_OMAP2PLUS
-	case METHOD_GPIO_24XX:
-	case METHOD_GPIO_44XX:
-		set_24xx_gpio_triggering(bank, gpio, trigger);
-		return 0;
-#endif
-	default:
-		goto bad;
+			__raw_writel(1 << gpio, bank->wake_clear);
+
+		__raw_writel(l, reg);
 	}
-	__raw_writel(l, reg);
+
 	return 0;
-bad:
-	return -EINVAL;
 }
 
 static int gpio_irq_type(struct irq_data *d, unsigned type)
@@ -678,7 +610,6 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
 			if (!(isr & 1))
 				continue;
 
-#ifdef CONFIG_ARCH_OMAP1
 			/*
 			 * Some chips can't respond to both rising and falling
 			 * at the same time.  If this irq was requested with

drivers/gpio/gpio_omap.c static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) · line 620

Quoted 5 lines
drivers/gpio/gpio_omap.c +1 -1
@@ -686,9 +617,9 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
 			 * to respond to the IRQ for the opposite direction.
 			 * This will be indicated in the bank toggle_mask.
 			 */
-			if (bank->toggle_mask & (1 << gpio_index))
+			if ((bank->regs->irqctrl != USHRT_MAX) &&

The valid register check belongs in function, not here.

drivers/gpio/gpio_omap.c static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) · line 691

Quoted 3 lines
drivers/gpio/gpio_omap.c +1 -1
+					(bank->toggle_mask & (1 << gpio_index)))
 				_toggle_gpio_edge_triggering(bank, gpio_index);
-#endif

This change isn't quite right, as we don't want (or need) do do this on OMAP2+. This really is an OMAP1-specific hack.

For the purposes of this patch, leave the OMAP1 #ifdef. Then, in a subsequent patch, add another per-bank flag (passed in from pdata) that indicates whether we want to use this hack, and enable it for OMAP1-based platforms.

Kevin

#52 lore raw

PATCH 13/15 OMAP: GPIO: clean set_gpio_triggering function

Kevin,

Quoted 195 lines · Kevin Hilman
Quoted 22 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Getting rid of ifdefs within the function by adding register offset intctrl and associating OMAPXXXX_GPIO_INT_CONTROL in respective SoC specific files.

---

?arch/arm/mach-omap1/gpio15xx.c ? ? ? ? | ? 14 ++++
?arch/arm/mach-omap1/gpio16xx.c ? ? ? ? | ? 14 ++++
?arch/arm/mach-omap1/gpio7xx.c ? ? ? ? ?| ? 14 ++++
?arch/arm/mach-omap2/gpio.c ? ? ? ? ? ? | ? ?4 +
?arch/arm/plat-omap/include/plat/gpio.h | ? ?3 +
?drivers/gpio/gpio_omap.c ? ? ? ? ? ? ? | ?125 +++++++-------------------------

?6 files changed, 77 insertions(+), 97 deletions(-)

arch/arm/mach-omap1/gpio15xx.c +0 -0
index b0bd21e..ceee046 100644
@@ -46,6 +46,13 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 ? ? ? .wkupstatus ? ? = USHRT_MAX,

arch/arm/mach-omap1/gpio15xx.c static struct omap_gpio_reg_offs omap15xx_mpuio_regs = { · line 56

Quoted 10 lines
arch/arm/mach-omap1/gpio15xx.c +7 -0
 ? ? ? .wkupclear ? ? ?= USHRT_MAX,
 ? ? ? .wkupset ? ? ? ?= USHRT_MAX,
+ ? ? .irqctrl ? ? ? ?= OMAP_MPUIO_GPIO_INT_EDGE,
+ ? ? .edgectrl1 ? ? ?= USHRT_MAX,
+ ? ? .edgectrl2 ? ? ?= USHRT_MAX,
+ ? ? .leveldetect0 ? = USHRT_MAX,
+ ? ? .leveldetect1 ? = USHRT_MAX,
+ ? ? .risingdetect ? = USHRT_MAX,
+ ? ? .fallingdetect ?= USHRT_MAX,
 ?};

As before, drop the USHRT_MAX and just use non-zer value to determine if register exists.

Quoted 157 lines
arch/arm/mach-omap1/gpio15xx.c +7 -0
 ?static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -91,6 +98,13 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 ? ? ? .wkupstatus ? ? = USHRT_MAX,
 ? ? ? .wkupclear ? ? ?= USHRT_MAX,
 ? ? ? .wkupset ? ? ? ?= USHRT_MAX,
+ ? ? .irqctrl ? ? ? ?= OMAP1510_GPIO_INT_CONTROL,
+ ? ? .edgectrl1 ? ? ?= USHRT_MAX,
+ ? ? .edgectrl2 ? ? ?= USHRT_MAX,
+ ? ? .leveldetect0 ? = USHRT_MAX,
+ ? ? .leveldetect1 ? = USHRT_MAX,
+ ? ? .risingdetect ? = USHRT_MAX,
+ ? ? .fallingdetect ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
arch/arm/mach-omap1/gpio16xx.c +14 -0
index 403437b..b2479c5 100644
@@ -49,6 +49,13 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 ? ? ? .wkupstatus ? ? = USHRT_MAX,
 ? ? ? .wkupclear ? ? ?= USHRT_MAX,
 ? ? ? .wkupset ? ? ? ?= USHRT_MAX,
+ ? ? .irqctrl ? ? ? ?= OMAP_MPUIO_GPIO_INT_EDGE,
+ ? ? .edgectrl1 ? ? ?= USHRT_MAX,
+ ? ? .edgectrl2 ? ? ?= USHRT_MAX,
+ ? ? .leveldetect0 ? = USHRT_MAX,
+ ? ? .leveldetect1 ? = USHRT_MAX,
+ ? ? .risingdetect ? = USHRT_MAX,
+ ? ? .fallingdetect ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -97,6 +104,13 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
 ? ? ? .wkupstatus ? ? = OMAP1610_GPIO_WAKEUPENABLE,
 ? ? ? .wkupclear ? ? ?= OMAP1610_GPIO_CLEAR_WAKEUPENA,
 ? ? ? .wkupset ? ? ? ?= OMAP1610_GPIO_SET_WAKEUPENA,
+ ? ? .irqctrl ? ? ? ?= USHRT_MAX,
+ ? ? .edgectrl1 ? ? ?= OMAP1610_GPIO_EDGE_CTRL1,
+ ? ? .edgectrl2 ? ? ?= OMAP1610_GPIO_EDGE_CTRL2,
+ ? ? .leveldetect0 ? = USHRT_MAX,
+ ? ? .leveldetect1 ? = USHRT_MAX,
+ ? ? .risingdetect ? = USHRT_MAX,
+ ? ? .fallingdetect ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
arch/arm/mach-omap1/gpio7xx.c +14 -0
index d5a4aaf..ceac936 100644
@@ -51,6 +51,13 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 ? ? ? .wkupstatus ? ? = USHRT_MAX,
 ? ? ? .wkupclear ? ? ?= USHRT_MAX,
 ? ? ? .wkupset ? ? ? ?= USHRT_MAX,
+ ? ? .irqctrl ? ? ? ?= OMAP_MPUIO_GPIO_INT_EDGE / 2,
+ ? ? .edgectrl1 ? ? ?= USHRT_MAX,
+ ? ? .edgectrl2 ? ? ?= USHRT_MAX,
+ ? ? .leveldetect0 ? = USHRT_MAX,
+ ? ? .leveldetect1 ? = USHRT_MAX,
+ ? ? .risingdetect ? = USHRT_MAX,
+ ? ? .fallingdetect ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -96,6 +103,13 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 ? ? ? .wkupstatus ? ? = USHRT_MAX,
 ? ? ? .wkupclear ? ? ?= USHRT_MAX,
 ? ? ? .wkupset ? ? ? ?= USHRT_MAX,
+ ? ? .irqctrl ? ? ? ?= OMAP7XX_GPIO_INT_CONTROL,
+ ? ? .edgectrl1 ? ? ?= USHRT_MAX,
+ ? ? .edgectrl2 ? ? ?= USHRT_MAX,
+ ? ? .leveldetect0 ? = USHRT_MAX,
+ ? ? .leveldetect1 ? = USHRT_MAX,
+ ? ? .risingdetect ? = USHRT_MAX,
+ ? ? .fallingdetect ?= USHRT_MAX,
 ?};
 
 ?static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
arch/arm/mach-omap2/gpio.c +4 -0
index fbedbbb..eda1846 100644
@@ -92,6 +92,10 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 ? ? ? ? ? ? ? return -ENOMEM;
 ? ? ? }
 
+ ? ? pdata->regs->irqctrl = USHRT_MAX;
+ ? ? pdata->regs->edgectrl1 = USHRT_MAX;
+ ? ? pdata->regs->edgectrl2 = USHRT_MAX;
+
 ? ? ? switch (oh->class->rev) {

? ? ? case 0:
? ? ? case 1:

arch/arm/plat-omap/include/plat/gpio.h +3 -0
index a341790..f82881c 100644
@@ -197,6 +197,9 @@ struct omap_gpio_reg_offs {
 ? ? ? u16 wkupstatus;
 ? ? ? u16 wkupclear;
 ? ? ? u16 wkupset;
+ ? ? u16 irqctrl;
+ ? ? u16 edgectrl1;
+ ? ? u16 edgectrl2;
 
 ? ? ? bool irqenable_inv;
 ?};
drivers/gpio/gpio_omap.c +5 -18
index 762d73c..ebeb16e 100644
@@ -202,33 +202,20 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
 ? ? ? __raw_writel(val, reg);
 ?}
 
-#ifdef CONFIG_ARCH_OMAP2PLUS
-static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
+static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int trigger)
 ?{
 ? ? ? void __iomem *base = bank->base;
 ? ? ? u32 gpio_bit = 1 << gpio;
- ? ? u32 val;
 
- ? ? if (cpu_is_omap44xx()) {
- ? ? ? ? ? ? MOD_REG_BIT(OMAP4_GPIO_LEVELDETECT0, gpio_bit,
+ ? ? MOD_REG_BIT(bank->regs->leveldetect0, gpio_bit,
 ? ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_LEVEL_LOW);
- ? ? ? ? ? ? MOD_REG_BIT(OMAP4_GPIO_LEVELDETECT1, gpio_bit,
+ ? ? MOD_REG_BIT(bank->regs->leveldetect1, gpio_bit,
 ? ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_LEVEL_HIGH);
- ? ? ? ? ? ? MOD_REG_BIT(OMAP4_GPIO_RISINGDETECT, gpio_bit,
+ ? ? MOD_REG_BIT(bank->regs->risingdetect, gpio_bit,
 ? ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_EDGE_RISING);
- ? ? ? ? ? ? MOD_REG_BIT(OMAP4_GPIO_FALLINGDETECT, gpio_bit,
+ ? ? MOD_REG_BIT(bank->regs->fallingdetect, gpio_bit,
 ? ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_EDGE_FALLING);
- ? ? } else {
- ? ? ? ? ? ? MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT0, gpio_bit,
- ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_LEVEL_LOW);
- ? ? ? ? ? ? MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT1, gpio_bit,
- ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_LEVEL_HIGH);
- ? ? ? ? ? ? MOD_REG_BIT(OMAP24XX_GPIO_RISINGDETECT, gpio_bit,
- ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_EDGE_RISING);
- ? ? ? ? ? ? MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
- ? ? ? ? ? ? ? ? ? ? trigger & IRQ_TYPE_EDGE_FALLING);
- ? ? }
 
 ? ? ? if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {

? ? ? ? ? ? ? /*

drivers/gpio/gpio_omap.c +0 -0
@@ -259,36 +246,16 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,

? ? ? ? ? ? ? __raw_readl(bank->base + bank->regs->leveldetect0) | ? ? ? ? ? ? ? __raw_readl(bank->base + bank->regs->leveldetect1); ?}
-#endif

Quoted 12 lines
Quoted 10 lines

-#ifdef CONFIG_ARCH_OMAP1
?/*
? * This only applies to chips that can't do both rising and falling edge ? * detection at once. ?For all other chips, this function is a noop. ? */
?static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) ?{
- ? ? void __iomem *reg = bank->base;
+ ? ? void __iomem *reg = bank->base + bank->regs->irqctrl;
? ? ? u32 l = 0;

Need to check for valid regs->irqctrl here.

Okay. I will move the check to this place.

Quoted 152 lines
Quoted 140 lines

- ? ? switch (bank->method) {
- ? ? case METHOD_MPUIO:
- ? ? ? ? ? ? reg += OMAP_MPUIO_GPIO_INT_EDGE / bank->stride;
- ? ? ? ? ? ? break;

drivers/gpio/gpio_omap.c +0 -14
-#ifdef CONFIG_ARCH_OMAP15XX
- ? ? case METHOD_GPIO_1510:
- ? ? ? ? ? ? reg += OMAP1510_GPIO_INT_CONTROL;
- ? ? ? ? ? ? break;
-#endif
-#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
- ? ? case METHOD_GPIO_7XX:
- ? ? ? ? ? ? reg += OMAP7XX_GPIO_INT_CONTROL;
- ? ? ? ? ? ? break;
-#endif
- ? ? default:
- ? ? ? ? ? ? return;
- ? ? }
-

? ? ? l = __raw_readl(reg);
? ? ? if ((l >> gpio) & 1)
? ? ? ? ? ? ? l &= ~(1 << gpio);

drivers/gpio/gpio_omap.c +6 -19
@@ -297,31 +264,18 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio)
 
 ? ? ? __raw_writel(l, reg);
 ?}
-#endif
 
 ?static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
 ?{
 ? ? ? void __iomem *reg = bank->base;
 ? ? ? u32 l = 0;
 
- ? ? switch (bank->method) {
-#ifdef CONFIG_ARCH_OMAP1
- ? ? case METHOD_MPUIO:
- ? ? ? ? ? ? reg += OMAP_MPUIO_GPIO_INT_EDGE / bank->stride;
- ? ? ? ? ? ? l = __raw_readl(reg);
- ? ? ? ? ? ? if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
- ? ? ? ? ? ? ? ? ? ? bank->toggle_mask |= 1 << gpio;
- ? ? ? ? ? ? if (trigger & IRQ_TYPE_EDGE_RISING)
- ? ? ? ? ? ? ? ? ? ? l |= 1 << gpio;
- ? ? ? ? ? ? else if (trigger & IRQ_TYPE_EDGE_FALLING)
- ? ? ? ? ? ? ? ? ? ? l &= ~(1 << gpio);
- ? ? ? ? ? ? else
- ? ? ? ? ? ? ? ? ? ? goto bad;
- ? ? ? ? ? ? break;
-#endif
-#ifdef CONFIG_ARCH_OMAP15XX
- ? ? case METHOD_GPIO_1510:
- ? ? ? ? ? ? reg += OMAP1510_GPIO_INT_CONTROL;
+ ? ? if ((bank->regs->leveldetect0 != USHRT_MAX) &&
+ ? ? ? ? ? ? ? ? ? ? (bank->regs->wkupstatus != USHRT_MAX)) {
+ ? ? ? ? ? ? set_gpio_trigger(bank, gpio, trigger);
+ ? ? } else if (bank->regs->irqctrl != USHRT_MAX) {
+ ? ? ? ? ? ? reg += bank->regs->irqctrl;
+
 ? ? ? ? ? ? ? l = __raw_readl(reg);
 ? ? ? ? ? ? ? if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
 ? ? ? ? ? ? ? ? ? ? ? bank->toggle_mask |= 1 << gpio;
@@ -330,15 +284,16 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
 ? ? ? ? ? ? ? else if (trigger & IRQ_TYPE_EDGE_FALLING)
 ? ? ? ? ? ? ? ? ? ? ? l &= ~(1 << gpio);

? ? ? ? ? ? ? else
- ? ? ? ? ? ? ? ? ? ? goto bad;
- ? ? ? ? ? ? break;

drivers/gpio/gpio_omap.c +5 -3
-#endif
-#ifdef CONFIG_ARCH_OMAP16XX
- ? ? case METHOD_GPIO_1610:
+ ? ? ? ? ? ? ? ? ? ? return -EINVAL;
+
+ ? ? ? ? ? ? __raw_writel(l, reg);
+
+ ? ? } else if (bank->regs->edgectrl1 != USHRT_MAX) {

? ? ? ? ? ? ? if (gpio & 0x08)
- ? ? ? ? ? ? ? ? ? ? reg += OMAP1610_GPIO_EDGE_CTRL2;
+ ? ? ? ? ? ? ? ? ? ? reg += bank->regs->edgectrl2; ? ? ? ? ? ? ? else
- ? ? ? ? ? ? ? ? ? ? reg += OMAP1610_GPIO_EDGE_CTRL1;
+ ? ? ? ? ? ? ? ? ? ? reg += bank->regs->edgectrl1; +
? ? ? ? ? ? ? gpio &= 0x07;
? ? ? ? ? ? ? l = __raw_readl(reg);
? ? ? ? ? ? ? l &= ~(3 << (gpio << 1));

drivers/gpio/gpio_omap.c +1 -0
@@ -346,40 +301,17 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
 ? ? ? ? ? ? ? ? ? ? ? l |= 2 << (gpio << 1);
 ? ? ? ? ? ? ? if (trigger & IRQ_TYPE_EDGE_FALLING)
 ? ? ? ? ? ? ? ? ? ? ? l |= 1 << (gpio << 1);
+
 ? ? ? ? ? ? ? if (trigger)

? ? ? ? ? ? ? ? ? ? ? /* Enable wake-up during idle for dynamic tick */
- ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->base + OMAP1610_GPIO_SET_WAKEUPENA);
- ? ? ? ? ? ? else
- ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA);
- ? ? ? ? ? ? break;

drivers/gpio/gpio_omap.c +1 -11
-#endif
-#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
- ? ? case METHOD_GPIO_7XX:
- ? ? ? ? ? ? reg += OMAP7XX_GPIO_INT_CONTROL;
- ? ? ? ? ? ? l = __raw_readl(reg);
- ? ? ? ? ? ? if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
- ? ? ? ? ? ? ? ? ? ? bank->toggle_mask |= 1 << gpio;
- ? ? ? ? ? ? if (trigger & IRQ_TYPE_EDGE_RISING)
- ? ? ? ? ? ? ? ? ? ? l |= 1 << gpio;
- ? ? ? ? ? ? else if (trigger & IRQ_TYPE_EDGE_FALLING)
- ? ? ? ? ? ? ? ? ? ? l &= ~(1 << gpio);
+ ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->wake_set);

? ? ? ? ? ? ? else
- ? ? ? ? ? ? ? ? ? ? goto bad;
- ? ? ? ? ? ? break;

drivers/gpio/gpio_omap.c +3 -9
-#endif
-#ifdef CONFIG_ARCH_OMAP2PLUS
- ? ? case METHOD_GPIO_24XX:
- ? ? case METHOD_GPIO_44XX:
- ? ? ? ? ? ? set_24xx_gpio_triggering(bank, gpio, trigger);
- ? ? ? ? ? ? return 0;
-#endif
- ? ? default:
- ? ? ? ? ? ? goto bad;
+ ? ? ? ? ? ? ? ? ? ? __raw_writel(1 << gpio, bank->wake_clear);
+
+ ? ? ? ? ? ? __raw_writel(l, reg);

? ? ? }
- ? ? __raw_writel(l, reg);
+
? ? ? return 0;
-bad:
- ? ? return -EINVAL;
?}

?static int gpio_irq_type(struct irq_data *d, unsigned type)

drivers/gpio/gpio_omap.c +0 -1
@@ -678,7 +610,6 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
 ? ? ? ? ? ? ? ? ? ? ? if (!(isr & 1))
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? continue;
 
-#ifdef CONFIG_ARCH_OMAP1

? ? ? ? ? ? ? ? ? ? ? /*
? ? ? ? ? ? ? ? ? ? ? ?* Some chips can't respond to both rising and falling ? ? ? ? ? ? ? ? ? ? ? ?* at the same time. ?If this irq was requested with

drivers/gpio/gpio_omap.c +0 -0
@@ -686,9 +617,9 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
Quoted 5 lines

? ? ? ? ? ? ? ? ? ? ? ?* to respond to the IRQ for the opposite direction. ? ? ? ? ? ? ? ? ? ? ? ?* This will be indicated in the bank toggle_mask. ? ? ? ? ? ? ? ? ? ? ? ?*/
- ? ? ? ? ? ? ? ? ? ? if (bank->toggle_mask & (1 << gpio_index))
+ ? ? ? ? ? ? ? ? ? ? if ((bank->regs->irqctrl != USHRT_MAX) &&

The valid register check belongs in function, not here.

Quoted 3 lines

+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (bank->toggle_mask & (1 << gpio_index))) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? _toggle_gpio_edge_triggering(bank, gpio_index); -#endif

Quoted 7 lines

This change isn't quite right, as we don't want (or need) do do this on OMAP2+. ?This really is an OMAP1-specific hack.

For the purposes of this patch, leave the OMAP1 #ifdef. ?Then, in a subsequent patch, add another per-bank flag (passed in from pdata) that indicates whether we want to use this hack, and enable it for OMAP1-based platforms.

Agreed.

-V Charulatha

Quoted 3 lines

Kevin

#53 lore raw

PATCH 14/15 OMAP: GPIO: Use memset for omap_gpio_reg_offs

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Use memset to fill omap_gpio_reg_offs structure with 0xFFFF instead of filling each and every undefined register offset separately with USHRT_MAX in a given OMAP SoC. This would ease while adding new register offsets in the future SoCs.

---
 arch/arm/mach-omap1/gpio15xx.c |   63 ++++++++++++---------------------
 arch/arm/mach-omap1/gpio16xx.c |   74 +++++++++++++++++-----------------------
 arch/arm/mach-omap1/gpio7xx.c  |   62 ++++++++++++---------------------
 arch/arm/mach-omap2/gpio.c     |    5 +--
 4 files changed, 78 insertions(+), 126 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +23 -40
index ceee046..7f90bcf 100644
@@ -34,26 +34,7 @@ static struct __initdata resource omap15xx_mpu_gpio_resources[] = {
 	},
 };
 
-static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
-	.revision       = USHRT_MAX,
-	.direction	= OMAP_MPUIO_IO_CNTL,
-	.datain		= OMAP_MPUIO_INPUT_LATCH,
-	.dataout	= OMAP_MPUIO_OUTPUT,
-	.irqstatus	= OMAP_MPUIO_GPIO_INT,
-	.irqenable	= OMAP_MPUIO_GPIO_MASKIT,
-	.irqenable_inv	= true,
-	.ctrl		= USHRT_MAX,
-	.wkupstatus	= USHRT_MAX,
-	.wkupclear	= USHRT_MAX,
-	.wkupset	= USHRT_MAX,
-	.irqctrl	= OMAP_MPUIO_GPIO_INT_EDGE,
-	.edgectrl1	= USHRT_MAX,
-	.edgectrl2	= USHRT_MAX,
-	.leveldetect0	= USHRT_MAX,
-	.leveldetect1	= USHRT_MAX,
-	.risingdetect	= USHRT_MAX,
-	.fallingdetect	= USHRT_MAX,
-};
+static struct omap_gpio_reg_offs omap15xx_mpuio_regs;
 
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
 	.virtual_irq_start	= IH_MPUIO_BASE,
@@ -86,26 +67,7 @@ static struct __initdata resource omap15xx_gpio_resources[] = {
 	},
 };
 
-static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
-	.revision	= USHRT_MAX,
-	.direction	= OMAP1510_GPIO_DIR_CONTROL,
-	.datain		= OMAP1510_GPIO_DATA_INPUT,
-	.dataout	= OMAP1510_GPIO_DATA_OUTPUT,
-	.irqstatus	= OMAP1510_GPIO_INT_STATUS,
-	.irqenable	= OMAP1510_GPIO_INT_MASK,
-	.irqenable_inv	= true,
-	.ctrl		= USHRT_MAX,
-	.wkupstatus	= USHRT_MAX,
-	.wkupclear	= USHRT_MAX,
-	.wkupset	= USHRT_MAX,
-	.irqctrl	= OMAP1510_GPIO_INT_CONTROL,
-	.edgectrl1	= USHRT_MAX,
-	.edgectrl2	= USHRT_MAX,
-	.leveldetect0	= USHRT_MAX,
-	.leveldetect1	= USHRT_MAX,
-	.risingdetect	= USHRT_MAX,
-	.fallingdetect	= USHRT_MAX,
-};
+static struct omap_gpio_reg_offs omap15xx_gpio_regs;
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
 	.virtual_irq_start	= IH_GPIO_BASE,
@@ -134,7 +96,28 @@ static int __init omap15xx_gpio_init(void)
 	if (!cpu_is_omap15xx())
 		return -EINVAL;
 
+	memset(&omap15xx_mpuio_regs, USHRT_MAX, sizeof(omap15xx_mpuio_regs));
+
+	omap15xx_mpuio_regs.direction = OMAP_MPUIO_IO_CNTL;
+	omap15xx_mpuio_regs.datain = OMAP_MPUIO_INPUT_LATCH;
+	omap15xx_mpuio_regs.dataout = OMAP_MPUIO_OUTPUT;
+	omap15xx_mpuio_regs.irqstatus = OMAP_MPUIO_GPIO_INT;
+	omap15xx_mpuio_regs.irqenable = OMAP_MPUIO_GPIO_MASKIT;
+	omap15xx_mpuio_regs.irqenable_inv = true;
+	omap15xx_mpuio_regs.irqctrl = OMAP_MPUIO_GPIO_INT_EDGE;
+
 	platform_device_register(&omap15xx_mpu_gpio);
+
+	memset(&omap15xx_gpio_regs, USHRT_MAX, sizeof(omap15xx_gpio_regs));
+
+	omap15xx_gpio_regs.direction = OMAP1510_GPIO_DIR_CONTROL;
+	omap15xx_gpio_regs.datain = OMAP1510_GPIO_DATA_INPUT;
+	omap15xx_gpio_regs.dataout = OMAP1510_GPIO_DATA_OUTPUT;
+	omap15xx_gpio_regs.irqstatus = OMAP1510_GPIO_INT_STATUS;
+	omap15xx_gpio_regs.irqenable = OMAP1510_GPIO_INT_MASK;
+	omap15xx_gpio_regs.irqenable_inv = true;
+	omap15xx_gpio_regs.irqctrl = OMAP1510_GPIO_INT_CONTROL;
+
 	platform_device_register(&omap15xx_gpio);
 
 	return 0;
arch/arm/mach-omap1/gpio16xx.c +31 -43

92 lines not on this page · raw message

arch/arm/mach-omap1/gpio7xx.c +22 -40

80 lines not on this page · raw message

arch/arm/mach-omap2/gpio.c +2 -3
index eda1846..dce56d9 100644
@@ -92,9 +92,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 		return -ENOMEM;
 	}
 
-	pdata->regs->irqctrl = USHRT_MAX;
-	pdata->regs->edgectrl1 = USHRT_MAX;
-	pdata->regs->edgectrl2 = USHRT_MAX;
+	memset(pdata->regs, USHRT_MAX, sizeof(struct omap_gpio_reg_offs));
+	pdata->regs->irqenable_inv = false;
 
 	switch (oh->class->rev) {
 	case 0:
Signature · 1 line
1.6.0.4
#54 lore raw

PATCH 14/15 OMAP: GPIO: Use memset for omap_gpio_reg_offs

Quoted 9 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

Use memset to fill omap_gpio_reg_offs structure with 0xFFFF instead of filling each and every undefined register offset separately with USHRT_MAX in a given OMAP SoC. This would ease while adding new register offsets in the future SoCs.

This can be dropped in favor of using zero to indicate a non-existant register offset. Only the revision register needs a special case of using USHRT_MAX since zero can be a valid offset for the revision register.

Kevin

#55 lore raw

PATCH 15/15 OMAP: GPIO: clean omap_gpio_mod_init function

In reply to Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

With register offsets now defined for respective OMAP versions we can get rid of cpu_class_* checks. In addition, organized common initialization for the different OMAP silicon versions.

---
 arch/arm/mach-omap1/gpio16xx.c         |    1 +
 arch/arm/plat-omap/include/plat/gpio.h |    1 +
 drivers/gpio/gpio_omap.c               |   74 +++++++++++++-------------------
 3 files changed, 32 insertions(+), 44 deletions(-)
arch/arm/mach-omap1/gpio16xx.c +1 -0
index 24f6cfa..e9f8abd 100644
@@ -227,6 +227,7 @@ static int __init omap16xx_gpio_init(void)
 	omap16xx_gpio_regs.wkupset = OMAP1610_GPIO_SET_WAKEUPENA;
 	omap16xx_gpio_regs.edgectrl1 = OMAP1610_GPIO_EDGE_CTRL1;
 	omap16xx_gpio_regs.edgectrl2 = OMAP1610_GPIO_EDGE_CTRL2;
+	omap16xx_gpio_regs.sysconfig = OMAP1610_GPIO_SYSCONFIG;
 
 	for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
 		platform_device_register(omap16xx_gpio_dev[i]);
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index f82881c..ac45191 100644
@@ -176,6 +176,7 @@ struct omap_gpio_dev_attr {
 
 struct omap_gpio_reg_offs {
 	u16 revision;
+	u16 sysconfig;
 	u16 direction;
 	u16 datain;
 	u16 dataout;
drivers/gpio/gpio_omap.c +30 -44

95 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#56 lore raw

PATCH 15/15 OMAP: GPIO: clean omap_gpio_mod_init function

Quoted 8 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

With register offsets now defined for respective OMAP versions we can get rid of cpu_class_* checks. In addition, organized common initialization for the different OMAP silicon versions.

The sysconfig stuff in this patch should be removed. In fact, now that hwmod is used to manage all the GPIO IP blocks, the driver should not be touching sysconfig at all.

The hwmod defaults should be enough, and for enabling wake-ups, the device-specific code should be calling omap_hwmod_enable_wakeup() (which will also enable smart-idle if the IP supports it.)

Quoted 60 lines
---
 arch/arm/mach-omap1/gpio16xx.c         |    1 +
 arch/arm/plat-omap/include/plat/gpio.h |    1 +
 drivers/gpio/gpio_omap.c               |   74 +++++++++++++-------------------
 3 files changed, 32 insertions(+), 44 deletions(-)
arch/arm/mach-omap1/gpio16xx.c +1 -0
index 24f6cfa..e9f8abd 100644
@@ -227,6 +227,7 @@ static int __init omap16xx_gpio_init(void)
 	omap16xx_gpio_regs.wkupset = OMAP1610_GPIO_SET_WAKEUPENA;
 	omap16xx_gpio_regs.edgectrl1 = OMAP1610_GPIO_EDGE_CTRL1;
 	omap16xx_gpio_regs.edgectrl2 = OMAP1610_GPIO_EDGE_CTRL2;
+	omap16xx_gpio_regs.sysconfig = OMAP1610_GPIO_SYSCONFIG;
 
 	for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
 		platform_device_register(omap16xx_gpio_dev[i]);
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index f82881c..ac45191 100644
@@ -176,6 +176,7 @@ struct omap_gpio_dev_attr {
 
 struct omap_gpio_reg_offs {
 	u16 revision;
+	u16 sysconfig;
 	u16 direction;
 	u16 datain;
 	u16 dataout;
drivers/gpio/gpio_omap.c +2 -14
index ebeb16e..3649c74 100644
@@ -885,65 +885,51 @@ static void __init omap_gpio_show_rev(struct gpio_bank *bank)
 	called = true;
 }
 
-/* This lock class tells lockdep that GPIO irqs are in a different
+/*
+ * This lock class tells lockdep that GPIO irqs are in a different
  * category than their parents, so it won't report false recursion.
  */
 static struct lock_class_key gpio_lock_class;
 
-/* TODO: Cleanup cpu_is_* checks */
 static void omap_gpio_mod_init(struct gpio_bank *bank)
 {
-	if (cpu_class_is_omap2()) {
-		if (cpu_is_omap44xx()) {
-			__raw_writel(0xffffffff, bank->base +
-					OMAP4_GPIO_IRQSTATUSCLR0);
-			__raw_writel(0x00000000, bank->base +
-					 OMAP4_GPIO_DEBOUNCENABLE);
-			/* Initialize interface clk ungated, module enabled */
-			__raw_writel(0, bank->base + OMAP4_GPIO_CTRL);
-		} else if (cpu_is_omap34xx()) {
-			__raw_writel(0x00000000, bank->base +
-					OMAP24XX_GPIO_IRQENABLE1);
-			__raw_writel(0xffffffff, bank->base +

drivers/gpio/gpio_omap.c static void __init omap_gpio_show_rev(struct gpio_bank *bank) · line 902

Quoted 10 lines
drivers/gpio/gpio_omap.c +6 -3
-					OMAP24XX_GPIO_IRQSTATUS1);
-			__raw_writel(0x00000000, bank->base +
-					OMAP24XX_GPIO_DEBOUNCE_EN);
+	if (bank->width == 32) {
+		u32 l = 0;
+
+		if (bank->regs->irqenable_inv)
+			l = ~l;
 
+		__raw_writel(l, bank->base + bank->regs->irqstatus);

The ->irqenable_inv flag doesn't affect ->irqstatus.

drivers/gpio/gpio_omap.c static void __init omap_gpio_show_rev(struct gpio_bank *bank) · line 906

Quoted 4 lines
drivers/gpio/gpio_omap.c +4 -0
+		__raw_writel(l, bank->base + bank->regs->irqenable);
+
+		if (bank->regs->debounce_en != USHRT_MAX)
+			__raw_writel(l, bank->base + bank->regs->debounce_en);

If ->irqenable_inv = true, debounce was just enabled for all GPIOs in the bank.

drivers/gpio/gpio_omap.c static void __init omap_gpio_show_rev(struct gpio_bank *bank) · line 910

Quoted 9 lines
drivers/gpio/gpio_omap.c +2 -6
+		if (bank->regs->ctrl != USHRT_MAX)
 			/* Initialize interface clk ungated, module enabled */
-			__raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
-		}
-	} else if (cpu_class_is_omap1()) {
-		if (bank_is_mpuio(bank)) {
-			__raw_writew(0xffff, bank->base +
-				OMAP_MPUIO_GPIO_MASKIT / bank->stride);
+			 __raw_writel(l, bank->base + bank->regs->ctrl);

If ->irqenable_env = true, all the clocks were just gated.

Similar problems below.

Kevin

Quoted 46 lines
drivers/gpio/gpio_omap.c +15 -21
+
+	} else if (bank->width == 16) {
+		u16 l = 0;
+
+		if (bank_is_mpuio(bank))
 			mpuio_init(bank);
-		}
-		if (cpu_is_omap15xx() && bank->method == METHOD_GPIO_1510) {
-			__raw_writew(0xffff, bank->base
-						+ OMAP1510_GPIO_INT_MASK);
-			__raw_writew(0x0000, bank->base
-						+ OMAP1510_GPIO_INT_STATUS);
-		}
-		if (cpu_is_omap16xx() && bank->method == METHOD_GPIO_1610) {
-			__raw_writew(0x0000, bank->base
-						+ OMAP1610_GPIO_IRQENABLE1);
-			__raw_writew(0xffff, bank->base
-						+ OMAP1610_GPIO_IRQSTATUS1);
-			__raw_writew(0x0014, bank->base
-						+ OMAP1610_GPIO_SYSCONFIG);
 
+		if (bank->regs->irqenable_inv)
+			l = ~l;
+
+		__raw_writew(l, bank->base + bank->regs->irqstatus);
+		__raw_writew(l, bank->base + bank->regs->irqenable);
+
+		if (bank->regs->sysconfig != USHRT_MAX) {
+			/* set wakeup-enable and smart-idle */
+			__raw_writew(0x14, bank->base + bank->regs->sysconfig);
 			/*
 			 * Enable system clock for GPIO module.
 			 * The CAM_CLK_CTRL *is* really the right place.
 			 */
 			omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04,
-						ULPD_CAM_CLK_CTRL);
-		}
-		if (cpu_is_omap7xx() && bank->method == METHOD_GPIO_7XX) {
-			__raw_writel(0xffffffff, bank->base
-						+ OMAP7XX_GPIO_INT_MASK);
-			__raw_writel(0x00000000, bank->base
-						+ OMAP7XX_GPIO_INT_STATUS);
+					ULPD_CAM_CLK_CTRL);
 		}
 	}
 }
#57 lore raw

PATCH 15/15 OMAP: GPIO: clean omap_gpio_mod_init function

Kevin,

Quoted 8 lines · Kevin Hilman
Quoted 6 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

With register offsets now defined for respective OMAP versions we can get rid of cpu_class_* checks. In addition, organized common initialization for the different OMAP silicon versions.

Quoted 6 lines
Quoted 2 lines

The sysconfig stuff in this patch should be removed. ?In fact, now that hwmod is used to manage all the GPIO IP blocks, the driver should not be touching sysconfig at all.

The sysconfig stuff in this patch is for OMAP16XX.

Quoted 97 lines

The hwmod defaults should be enough, and for enabling wake-ups, the device-specific code should be calling omap_hwmod_enable_wakeup() (which will also enable smart-idle if the IP supports it.)

Quoted 69 lines

---

?arch/arm/mach-omap1/gpio16xx.c ? ? ? ? | ? ?1 +
?arch/arm/plat-omap/include/plat/gpio.h | ? ?1 +
?drivers/gpio/gpio_omap.c ? ? ? ? ? ? ? | ? 74 +++++++++++++-------------------

?3 files changed, 32 insertions(+), 44 deletions(-)

arch/arm/mach-omap1/gpio16xx.c +1 -0
index 24f6cfa..e9f8abd 100644
@@ -227,6 +227,7 @@ static int __init omap16xx_gpio_init(void)
 ? ? ? omap16xx_gpio_regs.wkupset = OMAP1610_GPIO_SET_WAKEUPENA;
 ? ? ? omap16xx_gpio_regs.edgectrl1 = OMAP1610_GPIO_EDGE_CTRL1;
 ? ? ? omap16xx_gpio_regs.edgectrl2 = OMAP1610_GPIO_EDGE_CTRL2;
+ ? ? omap16xx_gpio_regs.sysconfig = OMAP1610_GPIO_SYSCONFIG;
 
 ? ? ? for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
 ? ? ? ? ? ? ? platform_device_register(omap16xx_gpio_dev[i]);
arch/arm/plat-omap/include/plat/gpio.h +1 -0
index f82881c..ac45191 100644
@@ -176,6 +176,7 @@ struct omap_gpio_dev_attr {
 
 ?struct omap_gpio_reg_offs {
 ? ? ? u16 revision;
+ ? ? u16 sysconfig;
 ? ? ? u16 direction;
 ? ? ? u16 datain;
 ? ? ? u16 dataout;
drivers/gpio/gpio_omap.c +2 -1
index ebeb16e..3649c74 100644
@@ -885,65 +885,51 @@ static void __init omap_gpio_show_rev(struct gpio_bank *bank)
 ? ? ? called = true;
 ?}
 
-/* This lock class tells lockdep that GPIO irqs are in a different
+/*
+ * This lock class tells lockdep that GPIO irqs are in a different

? * category than their parents, so it won't report false recursion. ? */
?static struct lock_class_key gpio_lock_class;

-/* TODO: Cleanup cpu_is_* checks */
?static void omap_gpio_mod_init(struct gpio_bank *bank)
?{
- ? ? if (cpu_class_is_omap2()) {
- ? ? ? ? ? ? if (cpu_is_omap44xx()) {
- ? ? ? ? ? ? ? ? ? ? __raw_writel(0xffffffff, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP4_GPIO_IRQSTATUSCLR0);
- ? ? ? ? ? ? ? ? ? ? __raw_writel(0x00000000, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?OMAP4_GPIO_DEBOUNCENABLE);
- ? ? ? ? ? ? ? ? ? ? /* Initialize interface clk ungated, module enabled */
- ? ? ? ? ? ? ? ? ? ? __raw_writel(0, bank->base + OMAP4_GPIO_CTRL);
- ? ? ? ? ? ? } else if (cpu_is_omap34xx()) {
- ? ? ? ? ? ? ? ? ? ? __raw_writel(0x00000000, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_IRQENABLE1);
- ? ? ? ? ? ? ? ? ? ? __raw_writel(0xffffffff, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_IRQSTATUS1);
- ? ? ? ? ? ? ? ? ? ? __raw_writel(0x00000000, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP24XX_GPIO_DEBOUNCE_EN);
+ ? ? if (bank->width == 32) {
+ ? ? ? ? ? ? u32 l = 0;
+
+ ? ? ? ? ? ? if (bank->regs->irqenable_inv)
+ ? ? ? ? ? ? ? ? ? ? l = ~l;

Quoted 1 line

+ ? ? ? ? ? ? __raw_writel(l, bank->base + bank->regs->irqstatus);

The ->irqenable_inv flag doesn't affect ->irqstatus.

Quoted 4 lines

+ ? ? ? ? ? ? __raw_writel(l, bank->base + bank->regs->irqenable); +
+ ? ? ? ? ? ? if (bank->regs->debounce_en != USHRT_MAX)
+ ? ? ? ? ? ? ? ? ? ? __raw_writel(l, bank->base + bank->regs->debounce_en);

If ->irqenable_inv = true, debounce was just enabled for all GPIOs in the bank.

Quoted 9 lines

+ ? ? ? ? ? ? if (bank->regs->ctrl != USHRT_MAX)
? ? ? ? ? ? ? ? ? ? ? /* Initialize interface clk ungated, module enabled */
- ? ? ? ? ? ? ? ? ? ? __raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
- ? ? ? ? ? ? }
- ? ? } else if (cpu_class_is_omap1()) {
- ? ? ? ? ? ? if (bank_is_mpuio(bank)) {
- ? ? ? ? ? ? ? ? ? ? __raw_writew(0xffff, bank->base +
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? OMAP_MPUIO_GPIO_MASKIT / bank->stride);
+ ? ? ? ? ? ? ? ? ? ? ?__raw_writel(l, bank->base + bank->regs->ctrl);

Quoted 1 line

If ->irqenable_env = true, all the clocks were just gated.

Okay. Will do the needful.

Quoted 4 lines

Similar problems below.

Kevin

#58 lore raw

PATCH 15/15 OMAP: GPIO: clean omap_gpio_mod_init function

Quoted 11 lines · Charulatha

Kevin,

Quoted 8 lines · Kevin Hilman
Quoted 6 lines · Tarun Kanti DebBarma

From: Charulatha V <[email protected]>

With register offsets now defined for respective OMAP versions we can get rid of cpu_class_* checks. In addition, organized common initialization for the different OMAP silicon versions.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

The sysconfig stuff in this patch should be removed. ?In fact, now that hwmod is used to manage all the GPIO IP blocks, the driver should not be touching sysconfig at all.

The sysconfig stuff in this patch is for OMAP16XX.

Ah, OK. Sorry I missed that.

Kevin