Thread (6 messages) 6 messages, 6 authors, 2009-12-23
STALE6028d

[PATCH] pxa: fix gpio_to_irq() for GPIOs on expander chips

From: pHilipp Zabel <hidden>
Date: 2009-12-14 09:49:27

On Wed, Nov 25, 2009 at 12:36 PM, Dmitry Artamonow [off-list ref] wrote:
Commit 9db95cb6c430b added support for gpios on PXA93x/950 and
increased PXA_GPIO_IRQ_NUM from 128 to 192, but missed to update
NR_BUILTIN_GPIO. This led to broken gpio_to_irq() for off-chip GPIOs.
Adjust NR_BUILTIN_GPIO accordingly, and also increase ARCH_NR_GPIOS,
as there exist platforms (hx4700) with more than 64 off-chip GPIOs,
so default value 256 is not enough.

Signed-off-by: Dmitry Artamonow <redacted>
Hi, are there any opinions on this one?

Personally, I'd prefer not to increase PXA_GPIO_IRQ_NUM to 196 unless
PXA9xx support is enabled. But as it is now, we either need to
increase NR_BUILTIN_GPIO and ARCH_NR_GPIOS too (moving hx4700's 70
ASIC3 GPIOs to 196..265), or add support for the gpiolib to_irq method
to the PXA gpio_to_irq macro (which Eric didn't like, see the thread
at http://www.spinics.net/lists/arm-kernel/msg53803.html) in order to
keep the ASIC3 GPIOs in the 128...197 range.

regards
Philipp
quoted hunk ↗ jump to hunk
---
?arch/arm/mach-pxa/include/mach/gpio.h | ? ?4 +++-
?1 files changed, 3 insertions(+), 1 deletions(-)

This is a fix for 2.6.32 regression.
Found this while testing 2.6.32-rc8 on hx4700. Here's errors in log
on unpatched kernel (all related to gpios on ASIC3 chip):
[ ? 37.369051] gpio-vbus gpio-vbus: can't request irq 286, err: -22
[ ? 37.398158] gpio-vbus: probe of gpio-vbus failed with error -22
...
[ ? 37.683452] gpio-keys: Unable to claim irq 278; error -22
[ ? 37.700759] gpio-keys: probe of gpio-keys failed with error -22
...
[ ? 38.025748] pda-power pda-power: request ac irq failed
[ ? 38.044569] pda-power: probe of pda-power failed with error -22

And after increasing NR_BUILTIN_GPIO to 192, I got this:
[ ?207.323467] gpiochip_add: gpios 256..263 (htc-egpio) not registered

With both NR_BUILTIN_GPIO and ARCH_NR_GPIOS increased there's no more
gpio-related errors.

I'm a bit unsure if this patch don't have any side effects on other PXA
platforms, and I even don't understand how exactly NR_BUILTIN_GPIO
and PXA_GPIO_IRQ_NUM affect gpios on expanders, so please check thoroughly!
diff --git a/arch/arm/mach-pxa/include/mach/gpio.h b/arch/arm/mach-pxa/include/mach/gpio.h
index b024a8b..bf53894 100644
--- a/arch/arm/mach-pxa/include/mach/gpio.h
+++ b/arch/arm/mach-pxa/include/mach/gpio.h
@@ -24,6 +24,8 @@
?#ifndef __ASM_ARCH_PXA_GPIO_H
?#define __ASM_ARCH_PXA_GPIO_H

+#define ARCH_NR_GPIOS ?320
+
?#include <mach/irqs.h>
?#include <mach/hardware.h>
?#include <asm-generic/gpio.h>
@@ -99,7 +101,7 @@
?#define GAFR(x) ? ? ? ? ? ? ? ?GPIO_REG(0x54 + (((x) & 0x70) >> 2))


-#define NR_BUILTIN_GPIO 128
+#define NR_BUILTIN_GPIO 192

?#define gpio_to_bank(gpio) ? ? ((gpio) >> 5)
?#define gpio_to_irq(gpio) ? ? ?IRQ_GPIO(gpio)
--
1.6.3.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help