rpi3: gpio: Simplify GPIO setup

There is really no reason to use and pass around a struct when its only
member is the (fixed) base address.

Remove the struct and just use the base address on its own inside the
GPIO driver. Then set the base address automatically.

This simplifies GPIO setup for users, which now don't need to deal with
zeroing a struct and setting the base address anymore.

Change-Id: I3060f7859e3f8ef9a24cc8fb38307b5da943f127
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
diff --git a/drivers/rpi3/gpio/rpi3_gpio.c b/drivers/rpi3/gpio/rpi3_gpio.c
index b39808f..f938f56 100644
--- a/drivers/rpi3/gpio/rpi3_gpio.c
+++ b/drivers/rpi3/gpio/rpi3_gpio.c
@@ -11,7 +11,7 @@
 #include <drivers/delay_timer.h>
 #include <drivers/rpi3/gpio/rpi3_gpio.h>
 
-static struct rpi3_gpio_params rpi3_gpio_params;
+static uintptr_t reg_base;
 
 static int rpi3_gpio_get_direction(int gpio);
 static void rpi3_gpio_set_direction(int gpio, int direction);
@@ -43,7 +43,6 @@
 int rpi3_gpio_get_select(int gpio)
 {
 	int ret;
-	uintptr_t reg_base = rpi3_gpio_params.reg_base;
 	int regN = gpio / 10;
 	int shift = 3 * (gpio % 10);
 	uintptr_t reg_sel = reg_base + RPI3_GPIO_GPFSEL(regN);
@@ -69,7 +68,6 @@
  */
 void rpi3_gpio_set_select(int gpio, int fsel)
 {
-	uintptr_t reg_base = rpi3_gpio_params.reg_base;
 	int regN = gpio / 10;
 	int shift = 3 * (gpio % 10);
 	uintptr_t reg_sel = reg_base + RPI3_GPIO_GPFSEL(regN);
@@ -106,7 +104,6 @@
 
 static int rpi3_gpio_get_value(int gpio)
 {
-	uintptr_t reg_base = rpi3_gpio_params.reg_base;
 	int regN = gpio / 32;
 	int shift = gpio % 32;
 	uintptr_t reg_lev = reg_base + RPI3_GPIO_GPLEV(regN);
@@ -119,7 +116,6 @@
 
 static void rpi3_gpio_set_value(int gpio, int value)
 {
-	uintptr_t reg_base = rpi3_gpio_params.reg_base;
 	int regN = gpio / 32;
 	int shift = gpio % 32;
 	uintptr_t reg_set = reg_base + RPI3_GPIO_GPSET(regN);
@@ -137,7 +133,6 @@
 
 static void rpi3_gpio_set_pull(int gpio, int pull)
 {
-	uintptr_t reg_base = rpi3_gpio_params.reg_base;
 	int regN = gpio / 32;
 	int shift = gpio % 32;
 	uintptr_t reg_pud = reg_base + RPI3_GPIO_GPPUD;
@@ -161,9 +156,8 @@
 	mmio_write_32(reg_pud, 0x0);
 }
 
-void rpi3_gpio_init(struct rpi3_gpio_params *params)
+void rpi3_gpio_init(void)
 {
-	assert(params != 0);
-	memcpy(&rpi3_gpio_params, params, sizeof(struct rpi3_gpio_params));
+	reg_base = RPI3_GPIO_BASE;
 	gpio_init(&rpi3_gpio_ops);
 }
diff --git a/include/drivers/rpi3/gpio/rpi3_gpio.h b/include/drivers/rpi3/gpio/rpi3_gpio.h
index 159a2e0..7bb3ee2 100644
--- a/include/drivers/rpi3/gpio/rpi3_gpio.h
+++ b/include/drivers/rpi3/gpio/rpi3_gpio.h
@@ -11,11 +11,7 @@
 #include <stdint.h>
 #include <drivers/gpio.h>
 
-struct rpi3_gpio_params {
-	uintptr_t       reg_base;
-};
-
-void rpi3_gpio_init(struct rpi3_gpio_params *params);
+void rpi3_gpio_init(void);
 int rpi3_gpio_get_select(int gpio);
 void rpi3_gpio_set_select(int gpio, int fsel);
 
diff --git a/plat/rpi/rpi3/rpi3_bl2_setup.c b/plat/rpi/rpi3/rpi3_bl2_setup.c
index 44827c6..d64235a 100644
--- a/plat/rpi/rpi3/rpi3_bl2_setup.c
+++ b/plat/rpi/rpi3/rpi3_bl2_setup.c
@@ -24,17 +24,6 @@
 /* Data structure which holds the extents of the trusted SRAM for BL2 */
 static meminfo_t bl2_tzram_layout __aligned(CACHE_WRITEBACK_GRANULE);
 
-/* rpi3 GPIO setup function. */
-static void rpi3_gpio_setup(void)
-{
-	struct rpi3_gpio_params params;
-
-	memset(&params, 0, sizeof(struct rpi3_gpio_params));
-	params.reg_base = RPI3_GPIO_BASE;
-
-	rpi3_gpio_init(&params);
-}
-
 /* Data structure which holds the MMC info */
 static struct mmc_device_info mmc_info;
 
@@ -68,7 +57,7 @@
 	generic_delay_timer_init();
 
 	/* Setup GPIO driver */
-	rpi3_gpio_setup();
+	rpi3_gpio_init();
 
 	/* Setup the BL2 memory layout */
 	bl2_tzram_layout = *mem_layout;