linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lars@metafoo.de (Lars-Peter Clausen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: s3c24xx: Set ARCH_NR_GPIOS according to the selected SoC types.
Date: Tue, 21 Sep 2010 00:00:52 +0200	[thread overview]
Message-ID: <1285020052-20020-2-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1285020052-20020-1-git-send-email-lars@metafoo.de>

Currently the code in gpiolib.c tries to register GPIO BANKA to BANKM.
ARCH_NR_GPIOS on the other hand is set only to 256, which would be the
equivalent of BANKA to BANKH. Thus the registration of all other banks will fail.

This patch fixes this by setting S3C_GPIO_END according to the selected SoC
types. S3C_GPIO_END is set to the maximum of the number of GPIOs over all
selected SoC types. Thus it is ensured that memory is not wasted if support for
SoCs with higher GPIO numbers is not built-in.
When registering the banks it is made sure that banks which are outside of that
range are not even tried to be registered. Otherwise there would a problem with
configs where CONFIG_S3C24XX_GPIO_EXTRA is set to a non zero value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 arch/arm/mach-s3c2410/include/mach/gpio.h |   25 ++++++++++++-------------
 arch/arm/plat-s3c24xx/gpiolib.c           |    2 ++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-s3c2410/include/mach/gpio.h b/arch/arm/mach-s3c2410/include/mach/gpio.h
index b649bf2..80dfe25 100644
--- a/arch/arm/mach-s3c2410/include/mach/gpio.h
+++ b/arch/arm/mach-s3c2410/include/mach/gpio.h
@@ -16,22 +16,21 @@
 #define gpio_cansleep	__gpio_cansleep
 #define gpio_to_irq	__gpio_to_irq
 
-/* some boards require extra gpio capacity to support external
- * devices that need GPIO.
- */
+#include <mach/gpio-fns.h>
+#include <mach/gpio-nrs.h>
 
-#ifdef CONFIG_CPU_S3C244X
-#define ARCH_NR_GPIOS	(32 * 9 + CONFIG_S3C24XX_GPIO_EXTRA)
+#if defined(CPU_S3C2416) || defined(CPU_S3C2443)
+#define S3C_GPIO_END	S3C2410_GPM(S3C2410_GPIO_M_NR)
+#elif defined(CONFIG_CPU_S3C244X)
+#define S3C_GPIO_END	S3C2410_GPJ(S3C2410_GPIO_J_NR)
 #else
-#define ARCH_NR_GPIOS	(256 + CONFIG_S3C24XX_GPIO_EXTRA)
+#define S3C_GPIO_END	S3C2410_GPH(S3C2410_GPIO_H_NR)
 #endif
 
+/* some boards require extra gpio capacity to support external
+ * devices that need GPIO.
+ */
+#define ARCH_NR_GPIOS (S3C_GPIO_END + CONFIG_S3C24XX_GPIO_EXTRA)
+
 #include <asm-generic/gpio.h>
-#include <mach/gpio-nrs.h>
-#include <mach/gpio-fns.h>
 
-#ifdef CONFIG_CPU_S3C24XX
-#define S3C_GPIO_END	(S3C2410_GPIO_BANKJ + 32)
-#else
-#define S3C_GPIO_END	(S3C2410_GPIO_BANKH + 32)
-#endif
diff --git a/arch/arm/plat-s3c24xx/gpiolib.c b/arch/arm/plat-s3c24xx/gpiolib.c
index 4c0896f..65b6126 100644
--- a/arch/arm/plat-s3c24xx/gpiolib.c
+++ b/arch/arm/plat-s3c24xx/gpiolib.c
@@ -221,6 +221,8 @@ static __init int s3c24xx_gpiolib_init(void)
 	int gpn;
 
 	for (gpn = 0; gpn < ARRAY_SIZE(s3c24xx_gpios); gpn++, chip++) {
+		if (chip->chip.base >= S3C_GPIO_END)
+			break;
 		if (!chip->config)
 			chip->config = &s3c24xx_gpiocfg_default;
 
-- 
1.5.6.5

  reply	other threads:[~2010-09-20 22:00 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-20 22:00 [PATCH] ARM: s3c2442: Setup gpio {set,get}_pull callbacks Lars-Peter Clausen
2010-09-20 22:00 ` Lars-Peter Clausen [this message]
2010-09-20 23:41 ` Ben Dooks
2010-09-21  5:28   ` Abdoulaye Walsimou GAYE
2010-11-06  7:54 ` [PATCH v2] " Vasily Khoruzhick
2010-11-06 16:09   ` Abdoulaye Walsimou GAYE
2010-11-08  9:08     ` Vasily Khoruzhick
2010-11-08 20:26   ` [PATCH v3] " Vasily Khoruzhick
2010-11-08 21:41     ` Abdoulaye Walsimou GAYE
2010-11-29  9:56     ` Vasily Khoruzhick
2010-11-29 10:15       ` Kukjin Kim
2010-11-29 10:26         ` [PATCH RESEND " Vasily Khoruzhick
2010-11-30  6:18           ` [PATCH RESEND v3] ARM: s3c2442: Setup gpio {set, get}_pull callbacks Kukjin Kim
2010-11-30 11:53             ` Lars-Peter Clausen
2010-11-30 12:01               ` Vasily Khoruzhick
2010-11-30 13:12                 ` Lars-Peter Clausen
2010-11-30 14:33                   ` Vasily Khoruzhick
2010-11-30 14:53                     ` Lars-Peter Clausen
2010-11-30 15:01                       ` Vasily Khoruzhick
2010-11-30 19:46                         ` [PATCH v4] ARM: s3c244x: Fix mess with gpio {set,get}_pull callbacks Vasily Khoruzhick
2010-11-30 19:59                           ` [PATCH v4] ARM: s3c244x: Fix mess with gpio {set, get}_pull callbacks Lars-Peter Clausen
2010-11-30 20:05                             ` Vasily Khoruzhick
2010-11-30 20:12                             ` [PATCH v5] ARM: s3c244x: Fix mess with gpio {set,get}_pull callbacks Vasily Khoruzhick
2010-12-01  0:22                               ` [PATCH v5] ARM: s3c244x: Fix mess with gpio {set, get}_pull callbacks Ben Dooks
2010-12-03  9:40                                 ` Kukjin Kim
2010-12-01  7:26                               ` [PATCH v5] ARM: s3c244x: Fix mess with gpio {set,get}_pull callbacks Kukjin Kim
2010-12-01 10:17                                 ` [PATCH v5] ARM: s3c244x: Fix mess with gpio {set, get}_pull callbacks Vasily Khoruzhick
2010-12-01 12:05                                   ` [PATCH v5] ARM: s3c244x: Fix mess with gpio {set,get}_pull callbacks Kukjin Kim
2010-12-01 12:16                                     ` [PATCH v5] ARM: s3c244x: Fix mess with gpio {set, get}_pull callbacks Vasily Khoruzhick
2010-12-01  5:28                             ` [PATCH v4] ARM: s3c244x: Fix mess with gpio {set,get}_pull callbacks Kukjin Kim
2010-12-01  6:19                               ` [PATCH v4] ARM: s3c244x: Fix mess with gpio {set, get}_pull callbacks Vasily Khoruzhick
2010-12-01  6:29                               ` [PATCH v6] ARM: s3c244x: Fix mess with gpio {set,get}_pull callbacks Vasily Khoruzhick
2010-12-01  5:19               ` [PATCH RESEND v3] ARM: s3c2442: Setup gpio {set, get}_pull callbacks Kukjin Kim
2010-11-29 10:28         ` [PATCH v3] ARM: s3c2442: Setup gpio {set,get}_pull callbacks Vasily Khoruzhick

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1285020052-20020-2-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).