[U-Boot] [PATCH 3/8] nomadik_gpio: get base address from platform code

Rabin Vincent
2010-03-18T05:02:22Z

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@unipv.it>
Acked-by: Michael Brandt <michael.brandt@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
---
board/st/nhk8815/nhk8815.c | 7 +++++++
drivers/gpio/nomadik_gpio.c | 9 +--------
include/nomadik_gpio.h | 2 ++
3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/board/st/nhk8815/nhk8815.c b/board/st/nhk8815/nhk8815.c
index 4f5f94f..79c91a7 100644
--- a/board/st/nhk8815/nhk8815.c
+++ b/board/st/nhk8815/nhk8815.c
@@ -32,6 +32,13 @@

DECLARE_GLOBAL_DATA_PTR;

+unsigned long nmk_gpio_base[] = {
+ NOMADIK_GPIO0_BASE,
+ NOMADIK_GPIO1_BASE,
+ NOMADIK_GPIO2_BASE,
+ NOMADIK_GPIO3_BASE
+};
+
#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 e8a7bca..deb2beb 100644
--- a/drivers/gpio/nomadik_gpio.c
+++ b/drivers/gpio/nomadik_gpio.c
@@ -24,13 +24,6 @@
#include <asm/io.h>
#include <nomadik_gpio.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,7 +38,7 @@ enum gpio_registers {

static inline unsigned long gpio_to_base(int gpio)
{
- return gpio_base[gpio / 32];
+ return nmk_gpio_base[gpio / 32];
}

static inline u32 gpio_to_bit(int gpio)
diff --git a/include/nomadik_gpio.h b/include/nomadik_gpio.h
index 1d3c9ce..2822db4 100644
--- a/include/nomadik_gpio.h
+++ b/include/nomadik_gpio.h
@@ -34,6 +34,8 @@ enum nmk_af { /* alternate function settings */
GPIO_ALT_C
};

+extern unsigned long nmk_gpio_base[];
+
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