Skip to contentSkip to conversation

gpio: omap_gpio: Fix valid gpio range for AM33XX

PATCH New Axel Lin 1 participant 2 messages Jun 21, 2013

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH v3 1/2 gpio: omap_gpio: Fix valid gpio range for AM33XX

AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.

---
v2: define OMAP_MAX_GPIO and use it.
v3: no change, just for adding patch 2/2.

 drivers/gpio/omap_gpio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpio/omap_gpio.c +7 -1
index a30d7f0..6fa57c9 100644
@@ -40,6 +40,12 @@
 #include <asm/io.h>
 #include <asm/errno.h>
 
+#if defined(CONFIG_AM33XX)
+#define OMAP_MAX_GPIO		128
+#else
+#define OMAP_MAX_GPIO		192
+#endif
+
 #define OMAP_GPIO_DIR_OUT	0
 #define OMAP_GPIO_DIR_IN	1
 
@@ -55,7 +61,7 @@ static inline int get_gpio_index(int gpio)
 
 int gpio_is_valid(int gpio)
 {
-	return (gpio >= 0) && (gpio < 192);
+	return (gpio >= 0) && (gpio < OMAP_MAX_GPIO);
 }
 
 static int check_gpio(int gpio)
Signature · 1 line
1.8.1.2
author
#1 lore raw

PATCH v3 2/2 gpio: omap_gpio: Fix valid GPIO range for OMAP5

OMAP54XX and DRA7XX SoCs have 8 banks per 32 GPIOs, that is, 256 in total. The DRA7xx config defines CONFIG_DRA7XX, but also includes omap5_common.h, where CONFIG_OMAP54XX is defined (due to sharing of many internal IPs with the OMAP5, including GPIO).

---
v3: just a new patch adding to this patch serial.

Hi Lubomir,
I'd appreciate if you can test this patch serial ( mainly for OMAP5 ).

Thanks,
Axel

 arch/arm/cpu/armv7/omap5/hwinit.c      | 4 +++-
 arch/arm/include/asm/arch-omap5/gpio.h | 2 ++
 drivers/gpio/omap_gpio.c               | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/omap5/hwinit.c +3 -1
index daf124e..11ba36b 100644
@@ -43,13 +43,15 @@ DECLARE_GLOBAL_DATA_PTR;
 
 u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV;
 
-static struct gpio_bank gpio_bank_54xx[6] = {
+static struct gpio_bank gpio_bank_54xx[8] = {
 	{ (void *)OMAP54XX_GPIO1_BASE, METHOD_GPIO_24XX },
 	{ (void *)OMAP54XX_GPIO2_BASE, METHOD_GPIO_24XX },
 	{ (void *)OMAP54XX_GPIO3_BASE, METHOD_GPIO_24XX },
 	{ (void *)OMAP54XX_GPIO4_BASE, METHOD_GPIO_24XX },
 	{ (void *)OMAP54XX_GPIO5_BASE, METHOD_GPIO_24XX },
 	{ (void *)OMAP54XX_GPIO6_BASE, METHOD_GPIO_24XX },
+	{ (void *)OMAP54XX_GPIO7_BASE, METHOD_GPIO_24XX },
+	{ (void *)OMAP54XX_GPIO8_BASE, METHOD_GPIO_24XX },
 };
 
 const struct gpio_bank *const omap_gpio_bank = gpio_bank_54xx;
arch/arm/include/asm/arch-omap5/gpio.h +2 -0
index c14dff0..f507a35 100644
@@ -46,5 +46,7 @@
 #define OMAP54XX_GPIO4_BASE		0x48059000
 #define OMAP54XX_GPIO5_BASE		0x4805B000
 #define OMAP54XX_GPIO6_BASE		0x4805D000
+#define OMAP54XX_GPIO7_BASE		0x48051000
+#define OMAP54XX_GPIO8_BASE		0x48053000
 
 #endif /* _GPIO_OMAP5_H */
drivers/gpio/omap_gpio.c +2 -0
index 6fa57c9..0092c13 100644
@@ -42,6 +42,8 @@
 
 #if defined(CONFIG_AM33XX)
 #define OMAP_MAX_GPIO		128
+#elif defined(CONFIG_OMAP54XX)
+#define OMAP_MAX_GPIO		256
 #else
 #define OMAP_MAX_GPIO		192
 #endif
Signature · 1 line
1.8.1.2