Skip to contentSkip to conversation

gpio/omap: fix incorrect initialization of omap_gpio_mod_init

PATCH Superseded Tarun Kanti DebBarma 5 participants 8 messages Apr 30, 2012 – May 11, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpio/omap: fix incorrect initialization of omap_gpio_mod_init

Initialization of irqenable, irqstatus registers is the common operation done in this function for all OMAP platforms, viz. OMAP1, OMAP2+. The latter _gpio_rmw()'s which supposedly got introduced wrongly to take care of OMAP2+ platforms were overwriting initially programmed OMAP1 value breaking functionality on OMAP1. Somehow incorrect assumption was made that each _gpio_rmw()'s were mutually exclusive. On close observation it is found that the first _gpio_rmw() which is supposedly done to take care of OMAP1 platform is generic enough and takes care of OMAP2+ platform as well. Therefore remove the latter _gpio_rmw() to irqenable as they are redundant now.

Writing to ctrl and debounce_en registers for OMAP2+ platforms are modified to match the original(pre-cleanup) code where the registers are initialized with 0. In the cleanup series since we are using _gpio_rmw(reg, 0, 1), instead of __raw_writel(), we are just reading and writing the same values to ctrl and debounce_en. This is not an issue for debounce_en register because it has 0x0 as the default value. But in the case of ctrl register the default value is 0x2 (GATINGRATIO
= 0x1) so that we end up writing 0x2 instead of intended 0 value.
Therefore changing back to __raw_writel() as this is sufficient for this case besides simpler to understand.

Also, change irqstatus initalization logic that avoids comparison with bool, besides making it fit in a single line.

Cc stable at vger.kernel.org
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Grant Likely <[email protected]>

---
v2:
Avoid irqstatus initialization sequence change.
Use __raw_writel() to update debounce_en and ctrl registers. Update changelog to elaborate how redundant _gpio_rmw() got added.

 drivers/gpio/gpio-omap.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/gpio/gpio-omap.c +3 -6
index 59a4af1..9b71f04 100644
@@ -957,18 +957,15 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
 	}
 
 	_gpio_rmw(base, bank->regs->irqenable, l, bank->regs->irqenable_inv);
-	_gpio_rmw(base, bank->regs->irqstatus, l,
-					bank->regs->irqenable_inv == false);
-	_gpio_rmw(base, bank->regs->irqenable, l, bank->regs->debounce_en != 0);
-	_gpio_rmw(base, bank->regs->irqenable, l, bank->regs->ctrl != 0);
+	_gpio_rmw(base, bank->regs->irqstatus, l, !bank->regs->irqenable_inv);
 	if (bank->regs->debounce_en)
-		_gpio_rmw(base, bank->regs->debounce_en, 0, 1);
+		__raw_writel(0, base + bank->regs->debounce_en);
 
 	/* Save OE default value (0xffffffff) in the context */
 	bank->context.oe = __raw_readl(bank->base + bank->regs->direction);
 	 /* Initialize interface clk ungated, module enabled */
 	if (bank->regs->ctrl)
-		_gpio_rmw(base, bank->regs->ctrl, 0, 1);
+		__raw_writel(0, base + bank->regs->ctrl);
 }
 
 static __devinit void
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v2 1/1 gpio/omap: fix incorrect initialization of omap_gpio_mod_init

I've noticed that current mainline enables _all_ possible GPIO interrupts, this patch fixes that problem.
Also Grant doesn't seem to be on CC so might not be able to pick this up.

Quoted 75 lines · Tarun Kanti DebBarma

Initialization of irqenable, irqstatus registers is the common operation done in this function for all OMAP platforms, viz. OMAP1, OMAP2+. The latter _gpio_rmw()'s which supposedly got introduced wrongly to take care of OMAP2+ platforms were overwriting initially programmed OMAP1 value breaking functionality on OMAP1. Somehow incorrect assumption was made that each _gpio_rmw()'s were mutually exclusive. On close observation it is found that the first _gpio_rmw() which is supposedly done to take care of OMAP1 platform is generic enough and takes care of OMAP2+ platform as well. Therefore remove the latter _gpio_rmw() to irqenable as they are redundant now.

Writing to ctrl and debounce_en registers for OMAP2+ platforms are modified to match the original(pre-cleanup) code where the registers are initialized with 0. In the cleanup series since we are using _gpio_rmw(reg, 0, 1), instead of __raw_writel(), we are just reading and writing the same values to ctrl and debounce_en. This is not an issue for debounce_en register because it has 0x0 as the default value. But in the case of ctrl register the default value is 0x2 (GATINGRATIO ?= 0x1) so that we end up writing 0x2 instead of intended 0 value. Therefore changing back to __raw_writel() as this is sufficient for this case besides simpler to understand.

Also, change irqstatus initalization logic that avoids comparison with bool, besides making it fit in a single line.

Cc stable at vger.kernel.org
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Grant Likely <[email protected]>

---
v2:
Avoid irqstatus initialization sequence change.
Use __raw_writel() to update debounce_en and ctrl registers. Update changelog to elaborate how redundant _gpio_rmw() got added.

?drivers/gpio/gpio-omap.c | ? ?9 +++------
?1 files changed, 3 insertions(+), 6 deletions(-)

drivers/gpio/gpio-omap.c +2 -5
index 59a4af1..9b71f04 100644
@@ -957,18 +957,15 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
 ? ? ? ?}
 
 ? ? ? ?_gpio_rmw(base, bank->regs->irqenable, l, bank->regs->irqenable_inv);
- ? ? ? _gpio_rmw(base, bank->regs->irqstatus, l,
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->regs->irqenable_inv == false);
- ? ? ? _gpio_rmw(base, bank->regs->irqenable, l, bank->regs->debounce_en != 0);
- ? ? ? _gpio_rmw(base, bank->regs->irqenable, l, bank->regs->ctrl != 0);
+ ? ? ? _gpio_rmw(base, bank->regs->irqstatus, l, !bank->regs->irqenable_inv);
 ? ? ? ?if (bank->regs->debounce_en)
- ? ? ? ? ? ? ? _gpio_rmw(base, bank->regs->debounce_en, 0, 1);
+ ? ? ? ? ? ? ? __raw_writel(0, base + bank->regs->debounce_en);
 

? ? ? ?/* Save OE default value (0xffffffff) in the context */ ? ? ? ?bank->context.oe = __raw_readl(bank->base + bank->regs->direction); ? ? ? ? /* Initialize interface clk ungated, module enabled */ ? ? ? ?if (bank->regs->ctrl)
- ? ? ? ? ? ? ? _gpio_rmw(base, bank->regs->ctrl, 0, 1);
+ ? ? ? ? ? ? ? __raw_writel(0, base + bank->regs->ctrl);
?}

?static __devinit void
--
1.7.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

Signature · 1 line
Gra?vydas
#2 lore raw

PATCH v2 1/1 gpio/omap: fix incorrect initialization of omap_gpio_mod_init

Hi,

Quoted 2 lines · Grazvydas Ignotas

I've noticed that current mainline enables _all_ possible GPIO interrupts, this patch fixes that problem.

OK, thanks.

Quoted 1 line

Also Grant doesn't seem to be on CC so might not be able to pick this up.

I have added Cc: in the patch and was expecting that would take care. Looks like that has not happened. Anyways, I have explicitly added in the email. --
Tarun

Quoted 83 lines
Quoted 67 lines · Tarun Kanti DebBarma

Initialization of irqenable, irqstatus registers is the common operation done in this function for all OMAP platforms, viz. OMAP1, OMAP2+. The latter _gpio_rmw()'s which supposedly got introduced wrongly to take care of OMAP2+ platforms were overwriting initially programmed OMAP1 value breaking functionality on OMAP1. Somehow incorrect assumption was made that each _gpio_rmw()'s were mutually exclusive. On close observation it is found that the first _gpio_rmw() which is supposedly done to take care of OMAP1 platform is generic enough and takes care of OMAP2+ platform as well. Therefore remove the latter _gpio_rmw() to irqenable as they are redundant now.

Writing to ctrl and debounce_en registers for OMAP2+ platforms are modified to match the original(pre-cleanup) code where the registers are initialized with 0. In the cleanup series since we are using _gpio_rmw(reg, 0, 1), instead of __raw_writel(), we are just reading and writing the same values to ctrl and debounce_en. This is not an issue for debounce_en register because it has 0x0 as the default value. But in the case of ctrl register the default value is 0x2 (GATINGRATIO ?= 0x1) so that we end up writing 0x2 instead of intended 0 value. Therefore changing back to __raw_writel() as this is sufficient for this case besides simpler to understand.

Also, change irqstatus initalization logic that avoids comparison with bool, besides making it fit in a single line.

Cc stable at vger.kernel.org
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Grant Likely <[email protected]>

---
v2:
Avoid irqstatus initialization sequence change.
Use __raw_writel() to update debounce_en and ctrl registers. Update changelog to elaborate how redundant _gpio_rmw() got added.

?drivers/gpio/gpio-omap.c | ? ?9 +++------
?1 files changed, 3 insertions(+), 6 deletions(-)

drivers/gpio/gpio-omap.c +2 -5
index 59a4af1..9b71f04 100644
@@ -957,18 +957,15 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
 ? ? ? ?}
 
 ? ? ? ?_gpio_rmw(base, bank->regs->irqenable, l, bank->regs->irqenable_inv);
- ? ? ? _gpio_rmw(base, bank->regs->irqstatus, l,
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bank->regs->irqenable_inv == false);
- ? ? ? _gpio_rmw(base, bank->regs->irqenable, l, bank->regs->debounce_en != 0);
- ? ? ? _gpio_rmw(base, bank->regs->irqenable, l, bank->regs->ctrl != 0);
+ ? ? ? _gpio_rmw(base, bank->regs->irqstatus, l, !bank->regs->irqenable_inv);
 ? ? ? ?if (bank->regs->debounce_en)
- ? ? ? ? ? ? ? _gpio_rmw(base, bank->regs->debounce_en, 0, 1);
+ ? ? ? ? ? ? ? __raw_writel(0, base + bank->regs->debounce_en);
 

? ? ? ?/* Save OE default value (0xffffffff) in the context */ ? ? ? ?bank->context.oe = __raw_readl(bank->base + bank->regs->direction); ? ? ? ? /* Initialize interface clk ungated, module enabled */ ? ? ? ?if (bank->regs->ctrl)
- ? ? ? ? ? ? ? _gpio_rmw(base, bank->regs->ctrl, 0, 1);
+ ? ? ? ? ? ? ? __raw_writel(0, base + bank->regs->ctrl);
?}

Quoted 8 lines

?static __devinit void
--
1.7.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

--
Gra?vydas

#3 lore raw

PATCH v2 1/1 gpio/omap: fix incorrect initialization of omap_gpio_mod_init

Quoted 8 lines · Tarun Kanti
Quoted 7 lines · Grazvydas Ignotas
Quoted 5 lines · Tarun Kanti DebBarma

Initialization of irqenable, irqstatus registers is the common operation done in this function for all OMAP platforms, viz. OMAP1, OMAP2+. The latter _gpio_rmw()'s which supposedly got introduced wrongly to take care of OMAP2+ platforms were overwriting initially programmed OMAP1 value breaking functionality on OMAP1.

Hi,
I can confirm that my other issues with GPIO on Amstrad Delta were not related, and this patch is still required for GPIO interrupts hardware being correctly initialized on OMAP1 in 3.4-rc6. You can add my

if you wish.

Thanks,
Janusz

#4 lore raw

PATCH v2 1/1 gpio/omap: fix incorrect initialization of omap_gpio_mod_init

Hi,

Quoted 10 lines · Janusz Krzysztofik
Quoted 8 lines · Tarun Kanti
Quoted 7 lines · Grazvydas Ignotas
Quoted 5 lines · Tarun Kanti DebBarma

Initialization of irqenable, irqstatus registers is the common operation done in this function for all OMAP platforms, viz. OMAP1, OMAP2+. The latter _gpio_rmw()'s which supposedly got introduced wrongly to take care of OMAP2+ platforms were overwriting initially programmed OMAP1 value breaking functionality on OMAP1.

Quoted 8 lines

Hi,
I can confirm that my other issues with GPIO on Amstrad Delta were not related, and this patch is still required for GPIO interrupts hardware being correctly initialized on OMAP1 in 3.4-rc6. You can add my

if you wish.

Thank you for confirming!!
--
Tarun

Quoted 3 lines

Thanks,
Janusz

#5 lore raw

PATCH v2 1/1 gpio/omap: fix incorrect initialization of omap_gpio_mod_init

Grant,

Quoted 19 lines · Tarun Kanti

Hi,

Quoted 15 lines · Janusz Krzysztofik
Quoted 8 lines · Tarun Kanti
Quoted 7 lines · Grazvydas Ignotas
Quoted 5 lines · Tarun Kanti DebBarma

Initialization of irqenable, irqstatus registers is the common operation done in this function for all OMAP platforms, viz. OMAP1, OMAP2+. The latter _gpio_rmw()'s which supposedly got introduced wrongly to take care of OMAP2+ platforms were overwriting initially programmed OMAP1 value breaking functionality on OMAP1.

Hi,
I can confirm that my other issues with GPIO on Amstrad Delta were not related, and this patch is still required for GPIO interrupts hardware being correctly initialized on OMAP1 in 3.4-rc6. You can add my

Quoted 4 lines
Quoted 3 lines

if you wish.

Thank you for confirming!!

We'd like to get this one in for v3.4-rc. Can you queue it?

I added the tested-by from Janusz and my signoff, and pull request is below.

Thanks,

Kevin

The following changes since commit d48b97b403d23f6df0b990cee652bdf9a52337a3:

Linux 3.4-rc6 (2012-05-06 15:07:32 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git for_3.5/fixes/gpio

for you to fetch changes up to 6edd94db250038c8fdf176f23ca4017d2f312509:

gpio/omap: fix incorrect initialization of omap_gpio_mod_init (2012-05-10 07:16:15 -0700)

----------------------------------------------------------------
Tarun Kanti DebBarma (1):
gpio/omap: fix incorrect initialization of omap_gpio_mod_init

 drivers/gpio/gpio-omap.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
#6 lore raw

PATCH v2 1/1 gpio/omap: fix incorrect initialization of omap_gpio_mod_init

Quoted 25 lines · Kevin Hilman

Grant,

Quoted 21 lines · Tarun Kanti

Hi,

Quoted 17 lines · Janusz Krzysztofik
Quoted 8 lines · Tarun Kanti
Quoted 7 lines · Grazvydas Ignotas
Quoted 5 lines · Tarun Kanti DebBarma

Initialization of irqenable, irqstatus registers is the common operation done in this function for all OMAP platforms, viz. OMAP1, OMAP2+. The latter _gpio_rmw()'s which supposedly got introduced wrongly to take care of OMAP2+ platforms were overwriting initially programmed OMAP1 value breaking functionality on OMAP1.

Hi,
I can confirm that my other issues with GPIO on Amstrad Delta were not related, and this patch is still required for GPIO interrupts hardware being correctly initialized on OMAP1 in 3.4-rc6. You can add my

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

if you wish.

Thank you for confirming!!

We'd like to get this one in for v3.4-rc. Can you queue it?

I added the tested-by from Janusz and my signoff, and pull request is below.

Pulled, thanks. I'll send a pull req out to Linus today.

g.

#7 lore raw

PATCH v2 1/1 gpio/omap: fix incorrect initialization of omap_gpio_mod_init

In reply to DebBarma, Tarun Kanti
Quoted 10 lines · Tarun Kanti

Hi,

Quoted 2 lines · Grazvydas Ignotas

I've noticed that current mainline enables _all_ possible GPIO interrupts, this patch fixes that problem.

OK, thanks.

Quoted 1 line

Also Grant doesn't seem to be on CC so might not be able to pick this up.

I have added Cc: in the patch and was expecting that would take care. Looks like that has not happened. Anyways, I have explicitly added in the email.

I'm particularly bursty when it comes to patch review and applying. Sometimes it takes me a while to find time for maintainership work.

g.