[coreboot-gerrit] Patch set updated for coreboot: ac95437 ARMv7: De-uboot-ify Exynos5250 GPIO code

Gabe Black (gabeblack@chromium.org) gerrit at coreboot.org
Wed Jul 10 04:01:31 CEST 2013


Gabe Black (gabeblack at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3643

-gerrit

commit ac95437b40ba6a9f8cdfd59a356e0b7ac10798bd
Author: Stefan Reinauer <reinauer at chromium.org>
Date:   Wed May 15 14:54:07 2013 -0700

    ARMv7: De-uboot-ify Exynos5250 GPIO code
    
    The Exynos GPIO code has three different APIs that, unfortunately,
    were widely used throughout the code base. This patch is cleaning
    up the mess.
    
    Change-Id: I09ccc7819fb892dbace9693c786dacc62f3f8eac
    Signed-off-by: Stefan Reinauer <reinauer at google.com>
    Signed-off-by: Gabe Black <gabeblack at chromium.org>
---
 src/cpu/samsung/exynos5250/cpu.h      |   6 --
 src/cpu/samsung/exynos5250/gpio.c     | 161 ++++++----------------------------
 src/cpu/samsung/exynos5250/gpio.h     | 111 +----------------------
 src/cpu/samsung/exynos5250/pinmux.c   | 116 ++++++++++++------------
 src/mainboard/google/snow/chromeos.c  |  22 +----
 src/mainboard/google/snow/mainboard.c |  12 +--
 src/mainboard/google/snow/romstage.c  |  33 +++----
 7 files changed, 110 insertions(+), 351 deletions(-)

diff --git a/src/cpu/samsung/exynos5250/cpu.h b/src/cpu/samsung/exynos5250/cpu.h
index 46c46bd..63f17e2 100644
--- a/src/cpu/samsung/exynos5250/cpu.h
+++ b/src/cpu/samsung/exynos5250/cpu.h
@@ -99,12 +99,6 @@
 #define samsung_get_base_dsim() ((struct exynos5_dsim *)EXYNOS5_MIPI_DSI1_BASE)
 #define samsung_get_base_disp_ctrl() ((struct exynos5_disp_ctrl *)EXYNOS5_DISP1_CTRL_BASE)
 #define samsung_get_base_fimd() ((struct exynos5_fimd *)EXYNOS5_FIMD_BASE)
-#define samsung_get_base_gpio_part1() ((struct exynos5_gpio_part1 *)EXYNOS5_GPIO_PART1_BASE)
-#define samsung_get_base_gpio_part2() ((struct exynos5_gpio_part2 *)EXYNOS5_GPIO_PART2_BASE)
-#define samsung_get_base_gpio_part3() ((struct exynos5_gpio_part3 *)EXYNOS5_GPIO_PART3_BASE)
-#define samsung_get_base_gpio_part4() ((struct exynos5_gpio_part4 *)EXYNOS5_GPIO_PART4_BASE)
-#define samsung_get_base_gpio_part5() ((struct exynos5_gpio_part5 *)EXYNOS5_GPIO_PART5_BASE)
-#define samsung_get_base_gpio_part6() ((struct exynos5_gpio_part6 *)EXYNOS5_GPIO_PART6_BASE)
 #define samsung_get_base_pro_id() ((struct exynos5_pro_id *)EXYNOS5_PRO_ID)
 
 #define samsung_get_base_mmc() ((struct exynos5_mmc *)EXYNOS5_MMC_BASE)
diff --git a/src/cpu/samsung/exynos5250/gpio.c b/src/cpu/samsung/exynos5250/gpio.c
index 223f6a1..b8ebb0a 100644
--- a/src/cpu/samsung/exynos5250/gpio.c
+++ b/src/cpu/samsung/exynos5250/gpio.c
@@ -55,7 +55,7 @@ static const struct gpio_info gpio_data[EXYNOS_GPIO_NUM_PARTS] = {
 /* This macro gets gpio pin offset from 0..7 */
 #define GPIO_BIT(x)     ((x) & 0x7)
 
-static struct s5p_gpio_bank *gpio_get_bank(unsigned int gpio)
+static struct gpio_bank *gpio_get_bank(unsigned int gpio)
 {
 	const struct gpio_info *data;
 	unsigned int upto;
@@ -64,9 +64,9 @@ static struct s5p_gpio_bank *gpio_get_bank(unsigned int gpio)
 	for (i = upto = 0, data = gpio_data; i < EXYNOS_GPIO_NUM_PARTS;
 			i++, upto = data->max_gpio, data++) {
 		if (gpio < data->max_gpio) {
-			struct s5p_gpio_bank *bank;
+			struct gpio_bank *bank;
 
-			bank = (struct s5p_gpio_bank *)data->reg_addr;
+			bank = (struct gpio_bank *)data->reg_addr;
 			bank += (gpio - upto) / GPIO_PER_BANK;
 			return bank;
 		}
@@ -76,118 +76,11 @@ static struct s5p_gpio_bank *gpio_get_bank(unsigned int gpio)
 	return NULL;
 }
 
-/* TODO: Deprecation this interface in favour of asm-generic/gpio.h */
-void s5p_gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg)
-{
-	unsigned int value;
-
-	value = readl(&bank->con);
-	value &= ~CON_MASK(gpio);
-	value |= CON_SFR(gpio, cfg);
-	writel(value, &bank->con);
-}
-
-void s5p_gpio_direction_output(struct s5p_gpio_bank *bank, int gpio, int en)
-{
-	unsigned int value;
-
-	s5p_gpio_cfg_pin(bank, gpio, EXYNOS_GPIO_OUTPUT);
-
-	value = readl(&bank->dat);
-	value &= ~DAT_MASK(gpio);
-	if (en)
-		value |= DAT_SET(gpio);
-	writel(value, &bank->dat);
-}
-
-void s5p_gpio_direction_input(struct s5p_gpio_bank *bank, int gpio)
-{
-	s5p_gpio_cfg_pin(bank, gpio, EXYNOS_GPIO_INPUT);
-}
-
-void s5p_gpio_set_value(struct s5p_gpio_bank *bank, int gpio, int en)
-{
-	unsigned int value;
-
-	value = readl(&bank->dat);
-	value &= ~DAT_MASK(gpio);
-	if (en)
-		value |= DAT_SET(gpio);
-	writel(value, &bank->dat);
-}
-
-unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio)
-{
-	unsigned int value;
-
-	value = readl(&bank->dat);
-	return !!(value & DAT_MASK(gpio));
-}
-
-void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode)
-{
-	unsigned int value;
-
-	value = readl(&bank->pull);
-	value &= ~PULL_MASK(gpio);
-
-	switch (mode) {
-	case EXYNOS_GPIO_PULL_DOWN:
-	case EXYNOS_GPIO_PULL_UP:
-		value |= PULL_MODE(gpio, mode);
-		break;
-	default:
-		break;
-	}
-
-	writel(value, &bank->pull);
-}
-
-void s5p_gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode)
-{
-	unsigned int value;
-
-	value = readl(&bank->drv);
-	value &= ~DRV_MASK(gpio);
-
-	switch (mode) {
-	case EXYNOS_GPIO_DRV_1X:
-	case EXYNOS_GPIO_DRV_2X:
-	case EXYNOS_GPIO_DRV_3X:
-	case EXYNOS_GPIO_DRV_4X:
-		value |= DRV_SET(gpio, mode);
-		break;
-	default:
-		return;
-	}
-
-	writel(value, &bank->drv);
-}
-
-void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode)
-{
-	unsigned int value;
-
-	value = readl(&bank->drv);
-	value &= ~RATE_MASK(gpio);
-
-	switch (mode) {
-	case EXYNOS_GPIO_DRV_FAST:
-	case EXYNOS_GPIO_DRV_SLOW:
-		value |= RATE_SET(gpio);
-		break;
-	default:
-		return;
-	}
-
-	writel(value, &bank->drv);
-}
-
 /* Common GPIO API - only available on Exynos5 */
 void gpio_cfg_pin(int gpio, int cfg)
 {
 	unsigned int value;
-	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
+	struct gpio_bank *bank = gpio_get_bank(gpio);
 
 	value = readl(&bank->con);
 	value &= ~CON_MASK(GPIO_BIT(gpio));
@@ -197,7 +90,7 @@ void gpio_cfg_pin(int gpio, int cfg)
 
 static int gpio_get_cfg(int gpio)
 {
-	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
+	struct gpio_bank *bank = gpio_get_bank(gpio);
 	int shift = GPIO_BIT(gpio) << 2;
 
 	return (readl(&bank->con) & CON_MASK(GPIO_BIT(gpio))) >> shift;
@@ -206,14 +99,14 @@ static int gpio_get_cfg(int gpio)
 void gpio_set_pull(int gpio, int mode)
 {
 	unsigned int value;
-	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
+	struct gpio_bank *bank = gpio_get_bank(gpio);
 
 	value = readl(&bank->pull);
 	value &= ~PULL_MASK(GPIO_BIT(gpio));
 
 	switch (mode) {
-	case EXYNOS_GPIO_PULL_DOWN:
-	case EXYNOS_GPIO_PULL_UP:
+	case GPIO_PULL_DOWN:
+	case GPIO_PULL_UP:
 		value |= PULL_MODE(GPIO_BIT(gpio), mode);
 		break;
 	default:
@@ -226,16 +119,16 @@ void gpio_set_pull(int gpio, int mode)
 void gpio_set_drv(int gpio, int mode)
 {
 	unsigned int value;
-	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
+	struct gpio_bank *bank = gpio_get_bank(gpio);
 
 	value = readl(&bank->drv);
 	value &= ~DRV_MASK(GPIO_BIT(gpio));
 
 	switch (mode) {
-	case EXYNOS_GPIO_DRV_1X:
-	case EXYNOS_GPIO_DRV_2X:
-	case EXYNOS_GPIO_DRV_3X:
-	case EXYNOS_GPIO_DRV_4X:
+	case GPIO_DRV_1X:
+	case GPIO_DRV_2X:
+	case GPIO_DRV_3X:
+	case GPIO_DRV_4X:
 		value |= DRV_SET(GPIO_BIT(gpio), mode);
 		break;
 	default:
@@ -248,14 +141,14 @@ void gpio_set_drv(int gpio, int mode)
 void gpio_set_rate(int gpio, int mode)
 {
 	unsigned int value;
-	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
+	struct gpio_bank *bank = gpio_get_bank(gpio);
 
 	value = readl(&bank->drv);
 	value &= ~RATE_MASK(GPIO_BIT(gpio));
 
 	switch (mode) {
-	case EXYNOS_GPIO_DRV_FAST:
-	case EXYNOS_GPIO_DRV_SLOW:
+	case GPIO_DRV_FAST:
+	case GPIO_DRV_SLOW:
 		value |= RATE_SET(GPIO_BIT(gpio));
 		break;
 	default:
@@ -267,7 +160,7 @@ void gpio_set_rate(int gpio, int mode)
 
 int gpio_direction_input(unsigned gpio)
 {
-	gpio_cfg_pin(gpio, EXYNOS_GPIO_INPUT);
+	gpio_cfg_pin(gpio, GPIO_INPUT);
 
 	return 0;
 }
@@ -275,9 +168,9 @@ int gpio_direction_input(unsigned gpio)
 int gpio_direction_output(unsigned gpio, int value)
 {
 	unsigned int val;
-	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
+	struct gpio_bank *bank = gpio_get_bank(gpio);
 
-	gpio_cfg_pin(gpio, EXYNOS_GPIO_OUTPUT);
+	gpio_cfg_pin(gpio, GPIO_OUTPUT);
 
 	val = readl(&bank->dat);
 	val &= ~DAT_MASK(GPIO_BIT(gpio));
@@ -291,7 +184,7 @@ int gpio_direction_output(unsigned gpio, int value)
 int gpio_get_value(unsigned gpio)
 {
 	unsigned int value;
-	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
+	struct gpio_bank *bank = gpio_get_bank(gpio);
 
 	value = readl(&bank->dat);
 	return !!(value & DAT_MASK(GPIO_BIT(gpio)));
@@ -300,7 +193,7 @@ int gpio_get_value(unsigned gpio)
 int gpio_set_value(unsigned gpio, int value)
 {
 	unsigned int val;
-	struct s5p_gpio_bank *bank = gpio_get_bank(gpio);
+	struct gpio_bank *bank = gpio_get_bank(gpio);
 
 	val = readl(&bank->dat);
 	val &= ~DAT_MASK(GPIO_BIT(gpio));
@@ -333,10 +226,10 @@ int gpio_read_mvl3(unsigned gpio)
 		return -1;
 
 	gpio_direction_input(gpio);
-	gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+	gpio_set_pull(gpio, GPIO_PULL_UP);
 	udelay(GPIO_DELAY_US);
 	high = gpio_get_value(gpio);
-	gpio_set_pull(gpio, EXYNOS_GPIO_PULL_DOWN);
+	gpio_set_pull(gpio, GPIO_PULL_DOWN);
 	udelay(GPIO_DELAY_US);
 	low = gpio_get_value(gpio);
 
@@ -355,7 +248,7 @@ int gpio_read_mvl3(unsigned gpio)
 	 * above test.
 	 */
 	if (value == LOGIC_1)
-		gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+		gpio_set_pull(gpio, GPIO_PULL_UP);
 
 	return value;
 }
@@ -372,14 +265,14 @@ void gpio_info(void)
 		int cfg = gpio_get_cfg(gpio);
 
 		printk(BIOS_INFO, "GPIO_%-3d: ", gpio);
-		if (cfg == EXYNOS_GPIO_INPUT)
+		if (cfg == GPIO_INPUT)
 			printk(BIOS_INFO, "input");
-		else if (cfg == EXYNOS_GPIO_OUTPUT)
+		else if (cfg == GPIO_OUTPUT)
 			printk(BIOS_INFO, "output");
 		else
 			printk(BIOS_INFO, "func %d", cfg);
 
-		if (cfg == EXYNOS_GPIO_INPUT || cfg == EXYNOS_GPIO_OUTPUT)
+		if (cfg == GPIO_INPUT || cfg == GPIO_OUTPUT)
 			printk(BIOS_INFO, ", value = %d", gpio_get_value(gpio));
 		printk(BIOS_INFO, "\n");
 	}
diff --git a/src/cpu/samsung/exynos5250/gpio.h b/src/cpu/samsung/exynos5250/gpio.h
index e70c653..0b97526 100644
--- a/src/cpu/samsung/exynos5250/gpio.h
+++ b/src/cpu/samsung/exynos5250/gpio.h
@@ -20,7 +20,7 @@
 #ifndef CPU_SAMSUNG_EXYNOS5250_GPIO_H
 #define CPU_SAMSUNG_EXYNOS5250_GPIO_H
 
-struct s5p_gpio_bank {
+struct gpio_bank {
 	unsigned int	con;
 	unsigned int	dat;
 	unsigned int	pull;
@@ -30,16 +30,6 @@ struct s5p_gpio_bank {
 	unsigned char	res1[8];
 };
 
-/* functions */
-void s5p_gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg);
-void s5p_gpio_direction_output(struct s5p_gpio_bank *bank, int gpio, int en);
-void s5p_gpio_direction_input(struct s5p_gpio_bank *bank, int gpio);
-void s5p_gpio_set_value(struct s5p_gpio_bank *bank, int gpio, int en);
-unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio);
-void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode);
-void s5p_gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode);
-void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
-
 /* GPIO pins per bank  */
 #define GPIO_PER_BANK 8
 
@@ -52,7 +42,7 @@ void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
 /* Pull mode */
 #define GPIO_PULL_NONE	0x0
 #define GPIO_PULL_DOWN	0x1
-#define GPIO_PULL_UP	0x2
+#define GPIO_PULL_UP	0x3
 
 /* Drive Strength level */
 #define GPIO_DRV_1X	0x0
@@ -62,28 +52,6 @@ void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
 #define GPIO_DRV_FAST	0x0
 #define GPIO_DRV_SLOW	0x1
 
-/* GPIO pins per bank  */
-#define GPIO_PER_BANK 8
-
-/* Pin configurations */
-#define EXYNOS_GPIO_INPUT	0x0
-#define EXYNOS_GPIO_OUTPUT	0x1
-#define EXYNOS_GPIO_IRQ	0xf
-#define EXYNOS_GPIO_FUNC(x)	(x)
-
-/* Pull mode */
-#define EXYNOS_GPIO_PULL_NONE	0x0
-#define EXYNOS_GPIO_PULL_DOWN	0x1
-#define EXYNOS_GPIO_PULL_UP	0x3
-
-/* Drive Strength level */
-#define EXYNOS_GPIO_DRV_1X	0x0
-#define EXYNOS_GPIO_DRV_3X	0x1
-#define EXYNOS_GPIO_DRV_2X	0x2
-#define EXYNOS_GPIO_DRV_4X	0x3
-#define EXYNOS_GPIO_DRV_FAST	0x0
-#define EXYNOS_GPIO_DRV_SLOW	0x1
-
 #define EXYNOS5_GPIO_BASE0	0x11400000
 #define EXYNOS5_GPIO_BASE1	0x13400000
 #define EXYNOS5_GPIO_BASE2	0x10d10000
@@ -151,63 +119,6 @@ enum exynos5_gpio_port {
 	EXYNOS5_GPZ = EXYNOS5_GPIO_BASE3 + 0x0000,
 };
 
-struct exynos5_gpio_part1 {
-	struct s5p_gpio_bank a0;
-	struct s5p_gpio_bank a1;
-	struct s5p_gpio_bank a2;
-	struct s5p_gpio_bank b0;
-	struct s5p_gpio_bank b1;
-	struct s5p_gpio_bank b2;
-	struct s5p_gpio_bank b3;
-	struct s5p_gpio_bank c0;
-	struct s5p_gpio_bank c1;
-	struct s5p_gpio_bank c2;
-	struct s5p_gpio_bank c3;
-	struct s5p_gpio_bank d0;
-	struct s5p_gpio_bank d1;
-	struct s5p_gpio_bank y0;
-	struct s5p_gpio_bank y1;
-	struct s5p_gpio_bank y2;
-	struct s5p_gpio_bank y3;
-	struct s5p_gpio_bank y4;
-	struct s5p_gpio_bank y5;
-	struct s5p_gpio_bank y6;
-};
-
-struct exynos5_gpio_part2 {
-	struct s5p_gpio_bank x0;
-	struct s5p_gpio_bank x1;
-	struct s5p_gpio_bank x2;
-	struct s5p_gpio_bank x3;
-};
-
-struct exynos5_gpio_part3 {
-	struct s5p_gpio_bank e0;
-	struct s5p_gpio_bank e1;
-	struct s5p_gpio_bank f0;
-	struct s5p_gpio_bank f1;
-	struct s5p_gpio_bank g0;
-	struct s5p_gpio_bank g1;
-	struct s5p_gpio_bank g2;
-	struct s5p_gpio_bank h0;
-	struct s5p_gpio_bank h1;
-};
-
-struct exynos5_gpio_part4 {
-	struct s5p_gpio_bank v0;
-	struct s5p_gpio_bank v1;
-	struct s5p_gpio_bank v2;
-	struct s5p_gpio_bank v3;
-};
-
-struct exynos5_gpio_part5 {
-	struct s5p_gpio_bank v4;
-};
-
-struct exynos5_gpio_part6 {
-	struct s5p_gpio_bank z;
-};
-
 enum {
 	/* GPIO banks are split into this many parts */
 	EXYNOS_GPIO_NUM_PARTS		= 6
@@ -545,8 +456,6 @@ enum exynos5_gpio_pin {
 	GPIO_MAX_PORT
 };
 
-#define gpio_status		gpio_info
-
 /**
  * Set GPIO pin configuration.
  *
@@ -588,8 +497,8 @@ void gpio_set_rate(int gpio, int mode);
  */
 int gpio_read_mvl3(unsigned gpio);
 
+void gpio_info(void);
 
-///////////////////////////////
 /*
  * Generic GPIO API for U-Boot
  *
@@ -644,18 +553,6 @@ int gpio_get_value(unsigned gpio);
  */
 int gpio_set_value(unsigned gpio, int value);
 
-
-///////////////////////////////
-
-
-void gpio_info(void);
-
-enum gpio_types {
-	GPIO_IN,
-	GPIO_OUT,
-	GPIO_ALT,		/* catch-all for alternate functions */
-};
-
 /*
  * Many-value logic (3 states). This can be used for inputs whereby presence
  * of external pull-up or pull-down resistors can be added to overcome internal
@@ -678,4 +575,4 @@ enum mvl3 {
 	LOGIC_Z,		/* high impedence / tri-stated / floating */
 };
 
-#endif	/* EXYNOS5250_GPIO_H_ */
+#endif	/* CPU_SAMSUNG_EXYNOS5250_GPIO_H */
diff --git a/src/cpu/samsung/exynos5250/pinmux.c b/src/cpu/samsung/exynos5250/pinmux.c
index 747ecab..6991dfc 100644
--- a/src/cpu/samsung/exynos5250/pinmux.c
+++ b/src/cpu/samsung/exynos5250/pinmux.c
@@ -48,17 +48,17 @@ int exynos_pinmux_config(enum periph_id peripheral, int flags)
 			break;
 		}
 		for (i = start; i < start + count; i++) {
-			gpio_set_pull(i, EXYNOS_GPIO_PULL_NONE);
-			gpio_cfg_pin(i, EXYNOS_GPIO_FUNC(0x2));
+			gpio_set_pull(i, GPIO_PULL_NONE);
+			gpio_cfg_pin(i, GPIO_FUNC(0x2));
 		}
 		break;
 	case PERIPH_ID_SDMMC0:
 	case PERIPH_ID_SDMMC1:
 	case PERIPH_ID_SDMMC2:
 	case PERIPH_ID_SDMMC3:
-		pin = EXYNOS_GPIO_FUNC(0x2);
-		pin_ext = EXYNOS_GPIO_FUNC(0x2);
-		drv = EXYNOS_GPIO_DRV_4X;
+		pin = GPIO_FUNC(0x2);
+		pin_ext = GPIO_FUNC(0x2);
+		drv = GPIO_DRV_4X;
 		switch (peripheral) {
 		default:
 		case PERIPH_ID_SDMMC0:
@@ -96,18 +96,18 @@ int exynos_pinmux_config(enum periph_id peripheral, int flags)
 			for (i = 0; i <= 3; i++) {
 				gpio_cfg_pin(start_ext + i, pin_ext);
 				gpio_set_pull(start_ext + i,
-					      EXYNOS_GPIO_PULL_UP);
+					      GPIO_PULL_UP);
 				gpio_set_drv(start_ext + i, drv);
 			}
 		}
 		for (i = 0; i < 2; i++) {
 			gpio_cfg_pin(start + i, pin);
-			gpio_set_pull(start + i, EXYNOS_GPIO_PULL_NONE);
+			gpio_set_pull(start + i, GPIO_PULL_NONE);
 			gpio_set_drv(start + i, drv);
 		}
 		for (i = 2; i <= 6; i++) {
 			gpio_cfg_pin(start + i, pin);
-			gpio_set_pull(start + i, EXYNOS_GPIO_PULL_UP);
+			gpio_set_pull(start + i, GPIO_PULL_UP);
 			gpio_set_drv(start + i, drv);
 		}
 		break;
@@ -128,12 +128,12 @@ int exynos_pinmux_config(enum periph_id peripheral, int flags)
 		 * GPY1[3]	EBI_DATA_RDn(2)
 		 */
 		gpio_cfg_pin(GPIO_Y00 + (flags & PINMUX_FLAG_BANK),
-				EXYNOS_GPIO_FUNC(2));
-		gpio_cfg_pin(GPIO_Y04, EXYNOS_GPIO_FUNC(2));
-		gpio_cfg_pin(GPIO_Y05, EXYNOS_GPIO_FUNC(2));
+				GPIO_FUNC(2));
+		gpio_cfg_pin(GPIO_Y04, GPIO_FUNC(2));
+		gpio_cfg_pin(GPIO_Y05, GPIO_FUNC(2));
 
 		for (i = 2; i < 4; i++)
-			gpio_cfg_pin(GPIO_Y10 + i, EXYNOS_GPIO_FUNC(2));
+			gpio_cfg_pin(GPIO_Y10 + i, GPIO_FUNC(2));
 
 		/*
 		 * EBI: 8 Addrss Lines
@@ -168,16 +168,16 @@ int exynos_pinmux_config(enum periph_id peripheral, int flags)
 		 * GPY6[7]	EBI_DATA[15](2)
 		 */
 		for (i = 0; i < 8; i++) {
-			gpio_cfg_pin(GPIO_Y30 + i, EXYNOS_GPIO_FUNC(2));
-			gpio_set_pull(GPIO_Y30 + i, EXYNOS_GPIO_PULL_UP);
+			gpio_cfg_pin(GPIO_Y30 + i, GPIO_FUNC(2));
+			gpio_set_pull(GPIO_Y30 + i, GPIO_PULL_UP);
 
-			gpio_cfg_pin(GPIO_Y50 + i, EXYNOS_GPIO_FUNC(2));
-			gpio_set_pull(GPIO_Y50 + i, EXYNOS_GPIO_PULL_UP);
+			gpio_cfg_pin(GPIO_Y50 + i, GPIO_FUNC(2));
+			gpio_set_pull(GPIO_Y50 + i, GPIO_PULL_UP);
 
 			if (flags & PINMUX_FLAG_16BIT) {
-				gpio_cfg_pin(GPIO_Y60 + i, EXYNOS_GPIO_FUNC(2));
+				gpio_cfg_pin(GPIO_Y60 + i, GPIO_FUNC(2));
 				gpio_set_pull(GPIO_Y60 + i,
-					      EXYNOS_GPIO_PULL_UP);
+					      GPIO_PULL_UP);
 			}
 		}
 		break;
@@ -208,86 +208,86 @@ int exynos_pinmux_config(enum periph_id peripheral, int flags)
 		}
 
 		for (i = 0; i < 4; i++)
-			gpio_cfg_pin(start + i, EXYNOS_GPIO_FUNC(cfg));
+			gpio_cfg_pin(start + i, GPIO_FUNC(cfg));
 		break;
 	}
 	case PERIPH_ID_SPI4:
 		for (i = 0; i < 2; i++)
-			gpio_cfg_pin(GPIO_F02 + i, EXYNOS_GPIO_FUNC(0x4));
+			gpio_cfg_pin(GPIO_F02 + i, GPIO_FUNC(0x4));
 		for (i = 2; i < 4; i++)
-			gpio_cfg_pin(GPIO_E02 + i, EXYNOS_GPIO_FUNC(0x4));
+			gpio_cfg_pin(GPIO_E02 + i, GPIO_FUNC(0x4));
 		break;
 	case PERIPH_ID_BACKLIGHT:
-		gpio_cfg_pin(GPIO_B20, EXYNOS_GPIO_OUTPUT);
+		gpio_cfg_pin(GPIO_B20, GPIO_OUTPUT);
 		gpio_set_value(GPIO_B20, 1);
 		break;
 	case PERIPH_ID_LCD:
-		gpio_cfg_pin(GPIO_Y25, EXYNOS_GPIO_OUTPUT);
+		gpio_cfg_pin(GPIO_Y25, GPIO_OUTPUT);
 		gpio_set_value(GPIO_Y25, 1);
-		gpio_cfg_pin(GPIO_X15, EXYNOS_GPIO_OUTPUT);
+		gpio_cfg_pin(GPIO_X15, GPIO_OUTPUT);
 		gpio_set_value(GPIO_X15, 1);
-		gpio_cfg_pin(GPIO_X30, EXYNOS_GPIO_OUTPUT);
+		gpio_cfg_pin(GPIO_X30, GPIO_OUTPUT);
 		gpio_set_value(GPIO_X30, 1);
 		break;
 	case PERIPH_ID_I2C0:
-		gpio_cfg_pin(GPIO_B30, EXYNOS_GPIO_FUNC(0x2));
-		gpio_cfg_pin(GPIO_B31, EXYNOS_GPIO_FUNC(0x2));
-		gpio_set_pull(GPIO_B30, EXYNOS_GPIO_PULL_NONE);
-		gpio_set_pull(GPIO_B31, EXYNOS_GPIO_PULL_NONE);
+		gpio_cfg_pin(GPIO_B30, GPIO_FUNC(0x2));
+		gpio_cfg_pin(GPIO_B31, GPIO_FUNC(0x2));
+		gpio_set_pull(GPIO_B30, GPIO_PULL_NONE);
+		gpio_set_pull(GPIO_B31, GPIO_PULL_NONE);
 		break;
 	case PERIPH_ID_I2C1:
-		gpio_cfg_pin(GPIO_B32, EXYNOS_GPIO_FUNC(0x2));
-		gpio_cfg_pin(GPIO_B33, EXYNOS_GPIO_FUNC(0x2));
-		gpio_set_pull(GPIO_B32, EXYNOS_GPIO_PULL_NONE);
-		gpio_set_pull(GPIO_B33, EXYNOS_GPIO_PULL_NONE);
+		gpio_cfg_pin(GPIO_B32, GPIO_FUNC(0x2));
+		gpio_cfg_pin(GPIO_B33, GPIO_FUNC(0x2));
+		gpio_set_pull(GPIO_B32, GPIO_PULL_NONE);
+		gpio_set_pull(GPIO_B33, GPIO_PULL_NONE);
 		break;
 	case PERIPH_ID_I2C2:
-		gpio_cfg_pin(GPIO_A06, EXYNOS_GPIO_FUNC(0x3));
-		gpio_cfg_pin(GPIO_A07, EXYNOS_GPIO_FUNC(0x3));
-		gpio_set_pull(GPIO_A06, EXYNOS_GPIO_PULL_NONE);
-		gpio_set_pull(GPIO_A07, EXYNOS_GPIO_PULL_NONE);
+		gpio_cfg_pin(GPIO_A06, GPIO_FUNC(0x3));
+		gpio_cfg_pin(GPIO_A07, GPIO_FUNC(0x3));
+		gpio_set_pull(GPIO_A06, GPIO_PULL_NONE);
+		gpio_set_pull(GPIO_A07, GPIO_PULL_NONE);
 		break;
 	case PERIPH_ID_I2C3:
-		gpio_cfg_pin(GPIO_A12, EXYNOS_GPIO_FUNC(0x3));
-		gpio_cfg_pin(GPIO_A13, EXYNOS_GPIO_FUNC(0x3));
-		gpio_set_pull(GPIO_A12, EXYNOS_GPIO_PULL_NONE);
-		gpio_set_pull(GPIO_A13, EXYNOS_GPIO_PULL_NONE);
+		gpio_cfg_pin(GPIO_A12, GPIO_FUNC(0x3));
+		gpio_cfg_pin(GPIO_A13, GPIO_FUNC(0x3));
+		gpio_set_pull(GPIO_A12, GPIO_PULL_NONE);
+		gpio_set_pull(GPIO_A13, GPIO_PULL_NONE);
 		break;
 	case PERIPH_ID_I2C4:
-		gpio_cfg_pin(GPIO_A20, EXYNOS_GPIO_FUNC(0x3));
-		gpio_cfg_pin(GPIO_A21, EXYNOS_GPIO_FUNC(0x3));
-		gpio_set_pull(GPIO_A20, EXYNOS_GPIO_PULL_NONE);
-		gpio_set_pull(GPIO_A21, EXYNOS_GPIO_PULL_NONE);
+		gpio_cfg_pin(GPIO_A20, GPIO_FUNC(0x3));
+		gpio_cfg_pin(GPIO_A21, GPIO_FUNC(0x3));
+		gpio_set_pull(GPIO_A20, GPIO_PULL_NONE);
+		gpio_set_pull(GPIO_A21, GPIO_PULL_NONE);
 		break;
 	case PERIPH_ID_I2C5:
-		gpio_cfg_pin(GPIO_A22, EXYNOS_GPIO_FUNC(0x3));
-		gpio_cfg_pin(GPIO_A23, EXYNOS_GPIO_FUNC(0x3));
-		gpio_set_pull(GPIO_A22, EXYNOS_GPIO_PULL_NONE);
-		gpio_set_pull(GPIO_A23, EXYNOS_GPIO_PULL_NONE);
+		gpio_cfg_pin(GPIO_A22, GPIO_FUNC(0x3));
+		gpio_cfg_pin(GPIO_A23, GPIO_FUNC(0x3));
+		gpio_set_pull(GPIO_A22, GPIO_PULL_NONE);
+		gpio_set_pull(GPIO_A23, GPIO_PULL_NONE);
 		break;
 	case PERIPH_ID_I2C6:
-		gpio_cfg_pin(GPIO_B13, EXYNOS_GPIO_FUNC(0x4));
-		gpio_cfg_pin(GPIO_B14, EXYNOS_GPIO_FUNC(0x4));
+		gpio_cfg_pin(GPIO_B13, GPIO_FUNC(0x4));
+		gpio_cfg_pin(GPIO_B14, GPIO_FUNC(0x4));
 		break;
 	case PERIPH_ID_I2C7:
-		gpio_cfg_pin(GPIO_B22, EXYNOS_GPIO_FUNC(0x3));
-		gpio_cfg_pin(GPIO_B23, EXYNOS_GPIO_FUNC(0x3));
-		gpio_set_pull(GPIO_B22, EXYNOS_GPIO_PULL_NONE);
-		gpio_set_pull(GPIO_B23, EXYNOS_GPIO_PULL_NONE);
+		gpio_cfg_pin(GPIO_B22, GPIO_FUNC(0x3));
+		gpio_cfg_pin(GPIO_B23, GPIO_FUNC(0x3));
+		gpio_set_pull(GPIO_B22, GPIO_PULL_NONE);
+		gpio_set_pull(GPIO_B23, GPIO_PULL_NONE);
 		break;
 	case PERIPH_ID_DPHPD:
 		/* Set Hotplug detect for DP */
-		gpio_cfg_pin(GPIO_X07, EXYNOS_GPIO_FUNC(0x3));
+		gpio_cfg_pin(GPIO_X07, GPIO_FUNC(0x3));
 
 		/*
 		 * Hotplug detect should have an external pullup; disable the
 		 * internal pulldown so they don't fight.
 		 */
-		gpio_set_pull(GPIO_X07, EXYNOS_GPIO_PULL_NONE);
+		gpio_set_pull(GPIO_X07, GPIO_PULL_NONE);
 		break;
 	case PERIPH_ID_I2S1:
 		for (i = 0; i < 5; i++)
-			gpio_cfg_pin(GPIO_B00 + i, EXYNOS_GPIO_FUNC(0x02));
+			gpio_cfg_pin(GPIO_B00 + i, GPIO_FUNC(0x02));
 		break;
 	default:
 		printk(BIOS_DEBUG, "%s: invalid peripheral %d", __func__, peripheral);
diff --git a/src/mainboard/google/snow/chromeos.c b/src/mainboard/google/snow/chromeos.c
index 404ed4a..2b830a1 100644
--- a/src/mainboard/google/snow/chromeos.c
+++ b/src/mainboard/google/snow/chromeos.c
@@ -23,7 +23,6 @@
 #include <ec/google/chromeec/ec_commands.h>
 #include <string.h>
 #include <vendorcode/google/chromeos/chromeos.h>
-
 #include <cpu/samsung/exynos5250/cpu.h>
 #include <cpu/samsung/exynos5250/gpio.h>
 
@@ -32,18 +31,6 @@ enum {
 	ACTIVE_HIGH = 1
 };
 
-enum {
-	WP_GPIO = 6,
-	RECMODE_GPIO = 0,
-	LID_GPIO = 5,
-	POWER_GPIO = 3
-};
-
-static struct exynos5_gpio_part1 *gpio_pt1 =
-	(struct exynos5_gpio_part1 *)EXYNOS5_GPIO_PART1_BASE;
-static struct exynos5_gpio_part2 *gpio_pt2 =
-	(struct exynos5_gpio_part2 *)EXYNOS5_GPIO_PART2_BASE;
-
 void fill_lb_gpios(struct lb_gpios *gpios)
 {
 	int count = 0;
@@ -51,7 +38,7 @@ void fill_lb_gpios(struct lb_gpios *gpios)
 	/* Write Protect: active low */
 	gpios->gpios[count].port = EXYNOS5_GPD1;
 	gpios->gpios[count].polarity = ACTIVE_LOW;
-	gpios->gpios[count].value = s5p_gpio_get_value(&gpio_pt1->d1, WP_GPIO);
+	gpios->gpios[count].value = gpio_get_value(GPIO_D16); // WP_GPIO
 	strncpy((char *)gpios->gpios[count].name, "write protect",
 		GPIO_MAX_NAME_LENGTH);
 	count++;
@@ -67,7 +54,7 @@ void fill_lb_gpios(struct lb_gpios *gpios)
 	/* Lid: active high */
 	gpios->gpios[count].port = EXYNOS5_GPX3;
 	gpios->gpios[count].polarity = ACTIVE_HIGH;
-	gpios->gpios[count].value = s5p_gpio_get_value(&gpio_pt2->x3, LID_GPIO);
+	gpios->gpios[count].value = gpio_get_value(GPIO_X35); // LID_GPIO
 	strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH);
 	count++;
 
@@ -75,7 +62,7 @@ void fill_lb_gpios(struct lb_gpios *gpios)
 	gpios->gpios[count].port = EXYNOS5_GPX1;
 	gpios->gpios[count].polarity = ACTIVE_LOW;
 	gpios->gpios[count].value =
-		s5p_gpio_get_value(&gpio_pt2->x1, POWER_GPIO);
+		gpio_get_value(GPIO_X13); // POWER_GPIO
 	strncpy((char *)gpios->gpios[count].name, "power",
 		GPIO_MAX_NAME_LENGTH);
 	count++;
@@ -92,7 +79,6 @@ void fill_lb_gpios(struct lb_gpios *gpios)
 	gpios->count = count;
 
 	printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size);
-
 }
 
 int get_developer_mode_switch(void)
@@ -105,7 +91,7 @@ int get_recovery_mode_switch(void)
 	uint32_t ec_events;
 
 	/* The GPIO is active low. */
-	if (!s5p_gpio_get_value(&gpio_pt1->y1, RECMODE_GPIO))
+	if (!gpio_get_value(GPIO_Y10)) // RECMODE_GPIO
 		return 1;
 
 	ec_events = google_chromeec_get_events_b();
diff --git a/src/mainboard/google/snow/mainboard.c b/src/mainboard/google/snow/mainboard.c
index a62f62c..250b71f 100644
--- a/src/mainboard/google/snow/mainboard.c
+++ b/src/mainboard/google/snow/mainboard.c
@@ -59,12 +59,12 @@ static void exynos_dp_bridge_setup(void)
 	exynos_pinmux_config(PERIPH_ID_DPHPD, 0);
 
 	gpio_set_value(dp_pd_l, 1);
-	gpio_cfg_pin(dp_pd_l, EXYNOS_GPIO_OUTPUT);
-	gpio_set_pull(dp_pd_l, EXYNOS_GPIO_PULL_NONE);
+	gpio_cfg_pin(dp_pd_l, GPIO_OUTPUT);
+	gpio_set_pull(dp_pd_l, GPIO_PULL_NONE);
 
 	gpio_set_value(dp_rst_l, 0);
-	gpio_cfg_pin(dp_rst_l, EXYNOS_GPIO_OUTPUT);
-	gpio_set_pull(dp_rst_l, EXYNOS_GPIO_PULL_NONE);
+	gpio_cfg_pin(dp_rst_l, GPIO_OUTPUT);
+	gpio_set_pull(dp_rst_l, GPIO_PULL_NONE);
 	udelay(10);
 	gpio_set_value(dp_rst_l, 1);
 }
@@ -122,7 +122,7 @@ static void backlight_pwm(void)
 
 static void backlight_en(void)
 {
-	/* * Configure GPIO for LCD_BL_EN */
+	/* Configure GPIO for LCD_BL_EN */
 	gpio_direction_output(GPIO_X30, 1);
 }
 
@@ -227,6 +227,8 @@ static void mainboard_init(device_t dev)
 
 	if (dp_tries > MAX_DP_TRIES)
 		printk(BIOS_ERR, "%s: Failed to set up displayport\n", __func__);
+
+	gpio_info();
 }
 
 static void mainboard_enable(device_t dev)
diff --git a/src/mainboard/google/snow/romstage.c b/src/mainboard/google/snow/romstage.c
index 0e25def..a7d6bb0 100644
--- a/src/mainboard/google/snow/romstage.c
+++ b/src/mainboard/google/snow/romstage.c
@@ -98,8 +98,8 @@ static void setup_storage(void)
 	if (gpio_direction_output(MMC0_GPIO_PIN, 1)) {
 		printk(BIOS_CRIT, "%s: Unable to power on MMC0.\n", __func__);
 	}
-	gpio_set_pull(MMC0_GPIO_PIN, EXYNOS_GPIO_PULL_NONE);
-	gpio_set_drv(MMC0_GPIO_PIN, EXYNOS_GPIO_DRV_4X);
+	gpio_set_pull(MMC0_GPIO_PIN, GPIO_PULL_NONE);
+	gpio_set_drv(MMC0_GPIO_PIN, GPIO_DRV_4X);
 	exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
 
 	/* MMC2: Removable, 4 bit mode, no GPIO. */
@@ -114,30 +114,17 @@ static void setup_graphics(void)
 
 static void setup_gpio(void)
 {
-	struct exynos5_gpio_part1 *gpio_pt1;
-	struct exynos5_gpio_part2 *gpio_pt2;
+	gpio_direction_input(GPIO_D16); // WP_GPIO
+	gpio_set_pull(GPIO_D16, GPIO_PULL_NONE);
 
-	enum {
-		WP_GPIO = 6,
-		RECMODE_GPIO = 0,
-		LID_GPIO = 5,
-		POWER_GPIO = 3
-	};
+	gpio_direction_input(GPIO_Y10); // RECMODE_GPIO
+	gpio_set_pull(GPIO_Y10, GPIO_PULL_NONE);
 
-	gpio_pt1 = (struct exynos5_gpio_part1 *)EXYNOS5_GPIO_PART1_BASE;
-	gpio_pt2 = (struct exynos5_gpio_part2 *)EXYNOS5_GPIO_PART2_BASE;
+	gpio_direction_input(GPIO_X35); // LID_GPIO
+	gpio_set_pull(GPIO_X35, GPIO_PULL_NONE);
 
-	s5p_gpio_direction_input(&gpio_pt1->d1, WP_GPIO);
-	s5p_gpio_set_pull(&gpio_pt1->d1, WP_GPIO, EXYNOS_GPIO_PULL_NONE);
-
-	s5p_gpio_direction_input(&gpio_pt1->y1, RECMODE_GPIO);
-	s5p_gpio_set_pull(&gpio_pt1->y1, RECMODE_GPIO, EXYNOS_GPIO_PULL_NONE);
-
-	s5p_gpio_direction_input(&gpio_pt2->x3, LID_GPIO);
-	s5p_gpio_set_pull(&gpio_pt2->x3, LID_GPIO, EXYNOS_GPIO_PULL_NONE);
-
-	s5p_gpio_direction_input(&gpio_pt2->x1, POWER_GPIO);
-	s5p_gpio_set_pull(&gpio_pt2->x1, POWER_GPIO, EXYNOS_GPIO_PULL_NONE);
+	gpio_direction_input(GPIO_X13); // POWER_GPIO
+	gpio_set_pull(GPIO_X13, GPIO_PULL_NONE);
 }
 
 static void setup_memory(struct mem_timings *mem, int is_resume)



More information about the coreboot-gerrit mailing list