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

Rabin Vincent rabin.vincent at stericsson.com
Thu Apr 8 15:43:14 CEST 2010


Change the Nomadik GPIO driver to get the base addresses from platform
specific code, since it will be used on multiple platforms with
different base addresses.

Acked-by: Alessandro Rubini <rubini at unipv.it>
Acked-by: Michael Brandt <michael.brandt at stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent at 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);
-- 
1.7.0



More information about the U-Boot mailing list