Patchwork [U-Boot,PATCHv2,07/13] nomadik-gpio: get base address from platform code

login
register
mail settings
Submitter Rabin Vincent
Date April 8, 2010, 1:43 p.m.
Message ID <1270734200-17762-8-git-send-email-rabin.vincent@stericsson.com>
Download mbox | patch
Permalink /patch/71743/
State Not Applicable
Delegated to: Albert ARIBAUD
Headers show

Comments

Rabin Vincent - April 8, 2010, 1:43 p.m.
Change the Nomadik GPIO driver to get the base addresses from platform
specific code, since it will be used on multiple platforms with

Patch

different base addresses.

Acked-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Michael Brandt <michael.brandt@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
---
 board/st/nhk8815/nhk8815.c  |    9 +++++++++
 drivers/gpio/nomadik_gpio.c |   11 ++---------
 include/configs/nhk8815.h   |    1 +
 include/nomadik.h           |    2 ++
 4 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/board/st/nhk8815/nhk8815.c b/board/st/nhk8815/nhk8815.c
index fc5d3b8..08fb332 100644
--- a/board/st/nhk8815/nhk8815.c
+++ b/board/st/nhk8815/nhk8815.c
@@ -32,6 +32,15 @@ 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_NOMADIK_GPIO
+unsigned long nmk_gpio_base[CONFIG_NOMADIK_GPIO_NUM_BANKS] = {
+	NOMADIK_GPIO0_BASE,
+	NOMADIK_GPIO1_BASE,
+	NOMADIK_GPIO2_BASE,
+	NOMADIK_GPIO3_BASE
+};
+#endif
+
 #ifdef CONFIG_SHOW_BOOT_PROGRESS
 void show_boot_progress(int progress)
 {
diff --git a/drivers/gpio/nomadik_gpio.c b/drivers/gpio/nomadik_gpio.c
index d084235..721c167 100644
--- a/drivers/gpio/nomadik_gpio.c
+++ b/drivers/gpio/nomadik_gpio.c
@@ -24,13 +24,6 @@ 
 #include <asm/io.h>
 #include <nomadik.h>
 
-static unsigned long gpio_base[4] = {
-	NOMADIK_GPIO0_BASE,
-	NOMADIK_GPIO1_BASE,
-	NOMADIK_GPIO2_BASE,
-	NOMADIK_GPIO3_BASE
-};
-
 enum gpio_registers {
 	GPIO_DAT =	0x00,		/* data register */
 	GPIO_DATS =	0x04,		/* data set */
@@ -45,12 +38,12 @@  enum gpio_registers {
 
 static inline unsigned long gpio_to_base(int gpio)
 {
-	if ((gpio / 32) >= ARRAY_SIZE(gpio_base)) {
+	if ((gpio / 32) >= ARRAY_SIZE(nmk_gpio_base)) {
 		printf("nomadik-gpio: invalid gpio %d\n", gpio);
 		return 0;
 	}
 
-	return gpio_base[gpio / 32];
+	return nmk_gpio_base[gpio / 32];
 }
 
 static inline u32 gpio_to_bit(int gpio)
diff --git a/include/configs/nhk8815.h b/include/configs/nhk8815.h
index f882715..c7700b3 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -101,6 +101,7 @@ 
 
 /* GPIO */
 #define CONFIG_NOMADIK_GPIO
+#define CONFIG_NOMADIK_GPIO_NUM_BANKS	4
 
 /* serial port (PL011) configuration */
 #define CONFIG_PL011_SERIAL
diff --git a/include/nomadik.h b/include/nomadik.h
index 1d3c9ce..72f7e88 100644
--- a/include/nomadik.h
+++ b/include/nomadik.h
@@ -34,6 +34,8 @@  enum nmk_af { /* alternate function settings */
 	GPIO_ALT_C
 };
 
+extern unsigned long nmk_gpio_base[CONFIG_NOMADIK_GPIO_NUM_BANKS];
+
 extern void nmk_gpio_af(int gpio, int alternate_function);
 extern void nmk_gpio_dir(int gpio, int dir);
 extern void nmk_gpio_set(int gpio, int val);