summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2014-09-26 17:48:28 -0700
committerPatrick Georgi <pgeorgi@google.com>2015-03-27 08:06:51 +0100
commite35e2e7867607520fa242d4f7d1b0b0e96fa959a (patch)
tree11e221de7415c8f5146335b70a3c221e6526f8e1
parent5c8b034f21ddc0c8c362814f832be16b752f106a (diff)
downloadcoreboot-e35e2e7867607520fa242d4f7d1b0b0e96fa959a.tar.xz
rk3288: Add GPIO() macro
The static gpio_t initializers are stylish, but they are still a little too annoying to write and read in day-to-day use. Let's wrap that in a macro to make it a little easier to handle. BUG=None TEST=None Change-Id: If41b2b3fd3c3f94797d314ba5f3ffcb2a250a005 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 102a5c0a800f43d688d11d1d7bbc51e360341517 Original-Change-Id: I385ae5182776c8cbb20bbf3c79b986628040f1cf Original-Signed-off-by: Julius Werner <jwerner@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/220250 Original-Reviewed-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: http://review.coreboot.org/9052 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rw-r--r--src/mainboard/google/veyron_pinky/chromeos.c8
-rw-r--r--src/mainboard/google/veyron_pinky/mainboard.c20
-rw-r--r--src/mainboard/google/veyron_pinky/reset.c2
-rw-r--r--src/mainboard/google/veyron_pinky/sdram_configs.c8
-rw-r--r--src/soc/rockchip/rk3288/gpio.h2
5 files changed, 21 insertions, 19 deletions
diff --git a/src/mainboard/google/veyron_pinky/chromeos.c b/src/mainboard/google/veyron_pinky/chromeos.c
index 4e1e50cc47..50dc4947dc 100644
--- a/src/mainboard/google/veyron_pinky/chromeos.c
+++ b/src/mainboard/google/veyron_pinky/chromeos.c
@@ -25,10 +25,10 @@
#include <vendorcode/google/chromeos/chromeos.h>
#include <soc/rockchip/rk3288/gpio.h>
-#define GPIO_WP (gpio_t){.port = 7, .bank = GPIO_A, .idx = 6}
-#define GPIO_LID (gpio_t){.port = 7, .bank = GPIO_B, .idx = 5}
-#define GPIO_POWER (gpio_t){.port = 0, .bank = GPIO_A, .idx = 5}
-#define GPIO_RECOVERY (gpio_t){.port = 0, .bank = GPIO_B, .idx = 1}
+#define GPIO_WP GPIO(7, A, 6)
+#define GPIO_LID GPIO(7, B, 5)
+#define GPIO_POWER GPIO(0, A, 5)
+#define GPIO_RECOVERY GPIO(0, B, 1)
void setup_chromeos_gpios(void)
{
diff --git a/src/mainboard/google/veyron_pinky/mainboard.c b/src/mainboard/google/veyron_pinky/mainboard.c
index d3537bf093..4d647d3e09 100644
--- a/src/mainboard/google/veyron_pinky/mainboard.c
+++ b/src/mainboard/google/veyron_pinky/mainboard.c
@@ -39,16 +39,16 @@
static void setup_gpio(void)
{
/*SOC and TPM reset GPIO, active high.*/
- gpio_output((gpio_t){.port = 0, .bank = GPIO_B, .idx = 2}, 0);
+ gpio_output(GPIO(0, B, 2), 0);
/* Configure GPIO for lcd_bl_en */
- gpio_output((gpio_t){.port = 7, .bank = GPIO_A, .idx = 2}, 1);
+ gpio_output(GPIO(7, A, 2), 1);
/*Configure backlight PWM 100% brightness*/
- gpio_output((gpio_t){.port = 7, .bank = GPIO_A, .idx = 0}, 0);
+ gpio_output(GPIO(7, A, 0), 0);
/* Configure GPIO for lcd_en */
- gpio_output((gpio_t){.port = 7, .bank = GPIO_B, .idx = 7}, 1);
+ gpio_output(GPIO(7, B, 7), 1);
}
static void setup_iomux(void)
@@ -76,22 +76,22 @@ static void setup_iomux(void)
static void setup_usb_poweron(void)
{
/* Configure GPIO for usb1_pwr_en */
- gpio_output((gpio_t){.port = 0, .bank = GPIO_B, .idx = 3}, 1);
+ gpio_output(GPIO(0, B, 3), 1);
/* Configure GPIO for usb2_pwr_en */
- gpio_output((gpio_t){.port = 0, .bank = GPIO_B, .idx = 4}, 1);
+ gpio_output(GPIO(0, B, 4), 1);
/* Configure GPIO for 5v_drv */
- gpio_output((gpio_t){.port = 7, .bank = GPIO_B, .idx = 3}, 1);
+ gpio_output(GPIO(7, B, 3), 1);
}
static void configure_sdmmc(void)
{
/* Configure GPIO for sd_en */
- gpio_output((gpio_t){.port = 7, .bank = GPIO_C, .idx = 5}, 1);
+ gpio_output(GPIO(7, C, 5), 1);
/* Configure GPIO for sd_detec */
- gpio_input_pullup((gpio_t){.port = 7, .bank = GPIO_A, .idx = 5});
+ gpio_input_pullup(GPIO(7, A, 5));
/*use sdmmc0 io, disable JTAG function*/
writel(RK_CLRBITS(1 << 12), &rk3288_grf->soc_con0);
@@ -100,7 +100,7 @@ static void configure_sdmmc(void)
static void configure_emmc(void)
{
/* Configure GPIO for emmc_pwrctrl */
- gpio_output((gpio_t){.port = 7, .bank = GPIO_B, .idx = 4}, 1);
+ gpio_output(GPIO(7, B, 4), 1);
}
static void configure_i2s(void)
diff --git a/src/mainboard/google/veyron_pinky/reset.c b/src/mainboard/google/veyron_pinky/reset.c
index fa90f549bd..d769665a9e 100644
--- a/src/mainboard/google/veyron_pinky/reset.c
+++ b/src/mainboard/google/veyron_pinky/reset.c
@@ -23,6 +23,6 @@
void hard_reset(void)
{
- gpio_output((gpio_t){.port = 0, .bank = GPIO_B, .idx = 2}, 1);
+ gpio_output(GPIO(0, B, 2), 1);
while (1);
}
diff --git a/src/mainboard/google/veyron_pinky/sdram_configs.c b/src/mainboard/google/veyron_pinky/sdram_configs.c
index b3600fbfff..21a483ce73 100644
--- a/src/mainboard/google/veyron_pinky/sdram_configs.c
+++ b/src/mainboard/google/veyron_pinky/sdram_configs.c
@@ -42,10 +42,10 @@ static struct rk3288_sdram_params sdram_configs[] = {
#include "sdram_inf/sdram-unused.inc" /* ram_code = 1111 */
};
-#define GPIO_RAMCODE0 (gpio_t){.port = 8, .bank = GPIO_A, .idx = 0}
-#define GPIO_RAMCODE1 (gpio_t){.port = 8, .bank = GPIO_A, .idx = 1}
-#define GPIO_RAMCODE2 (gpio_t){.port = 8, .bank = GPIO_A, .idx = 2}
-#define GPIO_RAMCODE3 (gpio_t){.port = 8, .bank = GPIO_A, .idx = 3}
+#define GPIO_RAMCODE0 GPIO(8, A, 0)
+#define GPIO_RAMCODE1 GPIO(8, A, 1)
+#define GPIO_RAMCODE2 GPIO(8, A, 2)
+#define GPIO_RAMCODE3 GPIO(8, A, 3)
u32 sdram_get_ram_code(void)
{
diff --git a/src/soc/rockchip/rk3288/gpio.h b/src/soc/rockchip/rk3288/gpio.h
index 6cac6cbdec..7049ddffe2 100644
--- a/src/soc/rockchip/rk3288/gpio.h
+++ b/src/soc/rockchip/rk3288/gpio.h
@@ -23,6 +23,8 @@
#include "addressmap.h"
#include "grf.h"
+#define GPIO(p, b, i) ((gpio_t){.port = p, .bank = GPIO_##b, .idx = i})
+
struct rk3288_gpio_regs {
u32 swporta_dr;
u32 swporta_ddr;