[U-Boot] [PATCH v6 10/12] exynos: Make sure that GPIOs are requested

Simon Glass sjg at chromium.org
Mon Aug 11 17:24:01 CEST 2014


With driver model GPIOs must be requested before use. Make sure this is
done correctly.

(Note that the soft SPI part of universal is omitted, since this driver
is about to be replaced with a driver-model-aware version)

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v6: None
Changes in v5:
- Add additional gpio_request() calls for other samsung boards
- Use a mask instead of division in gpio_request() naming call

Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/exynos/pinmux.c       |  3 +++
 board/samsung/arndale/arndale.c          |  2 ++
 board/samsung/common/misc.c              |  2 ++
 board/samsung/goni/goni.c                |  2 ++
 board/samsung/smdk5250/exynos5-dt.c      |  7 +++++++
 board/samsung/smdk5420/smdk5420.c        |  4 ++++
 board/samsung/trats/trats.c              | 15 ++++++++++++---
 board/samsung/trats2/trats2.c            | 26 +++++++++++++++++++++-----
 board/samsung/universal_c210/universal.c |  3 +++
 drivers/mmc/s5p_sdhci.c                  |  7 ++++++-
 10 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c b/arch/arm/cpu/armv7/exynos/pinmux.c
index 8cc4e9c..fb1375d 100644
--- a/arch/arm/cpu/armv7/exynos/pinmux.c
+++ b/arch/arm/cpu/armv7/exynos/pinmux.c
@@ -172,6 +172,9 @@ static int exynos5420_mmc_config(int peripheral, int flags)
 		 * this same assumption.
 		 */
 		if ((peripheral == PERIPH_ID_SDMMC0) && (i == (start + 2))) {
+#ifndef CONFIG_SPL_BUILD
+			gpio_request(i, "sdmmc0_vdden");
+#endif
 			gpio_set_value(i, 1);
 			gpio_cfg_pin(i, S5P_GPIO_OUTPUT);
 		} else {
diff --git a/board/samsung/arndale/arndale.c b/board/samsung/arndale/arndale.c
index c0f00cf..9ce2fca 100644
--- a/board/samsung/arndale/arndale.c
+++ b/board/samsung/arndale/arndale.c
@@ -19,6 +19,8 @@ int board_usb_init(int index, enum usb_init_type init)
 	/* Configure gpios for usb 3503 hub:
 	 * disconnect, toggle reset and connect
 	 */
+	gpio_request(EXYNOS5_GPIO_D17, "usb_connect");
+	gpio_request(EXYNOS5_GPIO_X35, "usb_reset");
 	gpio_direction_output(EXYNOS5_GPIO_D17, 0);
 	gpio_direction_output(EXYNOS5_GPIO_X35, 0);
 
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index a79119a..d274eb6 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -362,6 +362,8 @@ void check_boot_mode(void)
 void keys_init(void)
 {
 	/* Set direction to input */
+	gpio_request(KEY_VOL_UP_GPIO, "volume-up");
+	gpio_request(KEY_VOL_DOWN_GPIO, "volume-down");
 	gpio_direction_input(KEY_VOL_UP_GPIO);
 	gpio_direction_input(KEY_VOL_DOWN_GPIO);
 }
diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
index 01be714..22f4995 100644
--- a/board/samsung/goni/goni.c
+++ b/board/samsung/goni/goni.c
@@ -80,6 +80,7 @@ int board_mmc_init(bd_t *bis)
 	int i, ret, ret_sd = 0;
 
 	/* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
+	gpio_request(S5PC110_GPIO_J27, "massmemory_en");
 	gpio_direction_output(S5PC110_GPIO_J27, 1);
 
 	/*
@@ -108,6 +109,7 @@ int board_mmc_init(bd_t *bis)
 	 * SD card (T_FLASH) detect and init
 	 * T_FLASH_DETECT: EINT28: GPH3[4] input mode
 	 */
+	gpio_request(S5PC110_GPIO_H34, "t_flash_detect");
 	gpio_cfg_pin(S5PC110_GPIO_H34, S5P_GPIO_INPUT);
 	gpio_set_pull(S5PC110_GPIO_H34, S5P_GPIO_PULL_UP);
 
diff --git a/board/samsung/smdk5250/exynos5-dt.c b/board/samsung/smdk5250/exynos5-dt.c
index d6ce133..53ff706 100644
--- a/board/samsung/smdk5250/exynos5-dt.c
+++ b/board/samsung/smdk5250/exynos5-dt.c
@@ -29,6 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static void board_enable_audio_codec(void)
 {
 	/* Enable MAX98095 Codec */
+	gpio_request(EXYNOS5_GPIO_X17, "max98095_enable");
 	gpio_direction_output(EXYNOS5_GPIO_X17, 1);
 	gpio_set_pull(EXYNOS5_GPIO_X17, S5P_GPIO_PULL_NONE);
 }
@@ -199,16 +200,19 @@ static int board_dp_bridge_setup(void)
 	/* Setup the GPIOs */
 
 	/* PD is ACTIVE_LOW, and initially de-asserted */
+	gpio_request(EXYNOS5_GPIO_Y25, "dp_bridge_pd");
 	gpio_set_pull(EXYNOS5_GPIO_Y25, S5P_GPIO_PULL_NONE);
 	gpio_direction_output(EXYNOS5_GPIO_Y25, 1);
 
 	/* Reset is ACTIVE_LOW */
+	gpio_request(EXYNOS5_GPIO_X15, "dp_bridge_reset");
 	gpio_set_pull(EXYNOS5_GPIO_X15, S5P_GPIO_PULL_NONE);
 	gpio_direction_output(EXYNOS5_GPIO_X15, 0);
 
 	udelay(10);
 	gpio_set_value(EXYNOS5_GPIO_X15, 1);
 
+	gpio_request(EXYNOS5_GPIO_X07, "dp_bridge_hpd");
 	gpio_direction_input(EXYNOS5_GPIO_X07);
 
 	/*
@@ -236,10 +240,12 @@ static int board_dp_bridge_setup(void)
 void exynos_cfg_lcd_gpio(void)
 {
 	/* For Backlight */
+	gpio_request(EXYNOS5_GPIO_B20, "lcd_backlight");
 	gpio_cfg_pin(EXYNOS5_GPIO_B20, S5P_GPIO_OUTPUT);
 	gpio_set_value(EXYNOS5_GPIO_B20, 1);
 
 	/* LCD power on */
+	gpio_request(EXYNOS5_GPIO_X15, "lcd_power");
 	gpio_cfg_pin(EXYNOS5_GPIO_X15, S5P_GPIO_OUTPUT);
 	gpio_set_value(EXYNOS5_GPIO_X15, 1);
 
@@ -276,6 +282,7 @@ void exynos_backlight_on(unsigned int on)
 	mdelay(10);
 
 	/* board_dp_backlight_en */
+	gpio_request(EXYNOS5_GPIO_X30, "board_dp_backlight_en");
 	gpio_direction_output(EXYNOS5_GPIO_X30, 1);
 #endif
 }
diff --git a/board/samsung/smdk5420/smdk5420.c b/board/samsung/smdk5420/smdk5420.c
index 47998ab..a691222 100644
--- a/board/samsung/smdk5420/smdk5420.c
+++ b/board/samsung/smdk5420/smdk5420.c
@@ -74,9 +74,12 @@ void exynos_lcd_power_on(void)
 	mdelay(5);
 
 	/* TODO(ajaykumar.rs at samsung.com): Use device tree */
+	gpio_request(EXYNOS5420_GPIO_X35, "edp_slp#");
 	gpio_direction_output(EXYNOS5420_GPIO_X35, 1);	/* EDP_SLP# */
 	mdelay(10);
+	gpio_request(EXYNOS5420_GPIO_Y77, "edp_rst#");
 	gpio_direction_output(EXYNOS5420_GPIO_Y77, 1);	/* EDP_RST# */
+	gpio_request(EXYNOS5420_GPIO_X26, "edp_hpd");
 	gpio_direction_input(EXYNOS5420_GPIO_X26);	/* EDP_HPD */
 	gpio_set_pull(EXYNOS5420_GPIO_X26, S5P_GPIO_PULL_NONE);
 
@@ -88,6 +91,7 @@ void exynos_lcd_power_on(void)
 void exynos_backlight_on(unsigned int onoff)
 {
 	/* For PWM */
+	gpio_request(EXYNOS5420_GPIO_B20, "backlight_on");
 	gpio_cfg_pin(EXYNOS5420_GPIO_B20, S5P_GPIO_FUNC(0x1));
 	gpio_set_value(EXYNOS5420_GPIO_B20, 1);
 
diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
index 9e76b5d..e163e45 100644
--- a/board/samsung/trats/trats.c
+++ b/board/samsung/trats/trats.c
@@ -63,6 +63,8 @@ void i2c_init_board(void)
 	}
 
 	/* I2C_8 -> FG */
+	gpio_request(EXYNOS4_GPIO_Y40, "i2c_clk");
+	gpio_request(EXYNOS4_GPIO_Y41, "i2c_data");
 	gpio_direction_output(EXYNOS4_GPIO_Y40, 1);
 	gpio_direction_output(EXYNOS4_GPIO_Y41, 1);
 }
@@ -346,12 +348,17 @@ int exynos_power_init(void)
 static unsigned int get_hw_revision(void)
 {
 	int hwrev = 0;
+	char str[10];
 	int i;
 
 	/* hw_rev[3:0] == GPE1[3:0] */
-	for (i = EXYNOS4_GPIO_E10; i < EXYNOS4_GPIO_E14; i++) {
-		gpio_cfg_pin(i, S5P_GPIO_INPUT);
-		gpio_set_pull(i, S5P_GPIO_PULL_NONE);
+	for (i = 0; i < 4; i++) {
+		int pin = i + EXYNOS4_GPIO_E10;
+
+		sprintf(str, "hw_rev%d", i);
+		gpio_request(pin, str);
+		gpio_cfg_pin(pin, S5P_GPIO_INPUT);
+		gpio_set_pull(pin, S5P_GPIO_PULL_NONE);
 	}
 
 	udelay(1);
@@ -517,6 +524,7 @@ static void board_power_init(void)
 static void exynos_uart_init(void)
 {
 	/* UART_SEL GPY4[7] (part2) at EXYNOS4 */
+	gpio_request(EXYNOS4_GPIO_Y47, "uart_sel");
 	gpio_set_pull(EXYNOS4_GPIO_Y47, S5P_GPIO_PULL_UP);
 	gpio_direction_output(EXYNOS4_GPIO_Y47, 1);
 }
@@ -534,6 +542,7 @@ int exynos_early_init_f(void)
 
 void exynos_reset_lcd(void)
 {
+	gpio_request(EXYNOS4_GPIO_Y45, "lcd_reset");
 	gpio_direction_output(EXYNOS4_GPIO_Y45, 1);
 	udelay(10000);
 	gpio_direction_output(EXYNOS4_GPIO_Y45, 0);
diff --git a/board/samsung/trats2/trats2.c b/board/samsung/trats2/trats2.c
index 2924ee6..a737749 100644
--- a/board/samsung/trats2/trats2.c
+++ b/board/samsung/trats2/trats2.c
@@ -33,6 +33,7 @@ static inline u32 get_model_rev(void);
 static void check_hw_revision(void)
 {
 	int modelrev = 0;
+	char str[12];
 	int i;
 
 	/*
@@ -41,13 +42,22 @@ static void check_hw_revision(void)
 	 * TRM say that it may cause unexcepted state and leakage current.
 	 * and pull-none is only for output function.
 	 */
-	for (i = EXYNOS4X12_GPIO_M10; i < EXYNOS4X12_GPIO_M12; i++)
-		gpio_cfg_pin(i, S5P_GPIO_INPUT);
+	for (i = 0; i < 2; i++) {
+		int pin = i + EXYNOS4X12_GPIO_M10;
+
+		sprintf(str, "model_rev%d", i);
+		gpio_request(pin, str);
+		gpio_cfg_pin(pin, S5P_GPIO_INPUT);
+	}
 
 	/* GPM1[5:2]: HW_REV[3:0] */
-	for (i = EXYNOS4X12_GPIO_M12; i < EXYNOS4X12_GPIO_M16; i++) {
-		gpio_cfg_pin(i, S5P_GPIO_INPUT);
-		gpio_set_pull(i, S5P_GPIO_PULL_NONE);
+	for (i = 0; i < 4; i++) {
+		int pin = i + EXYNOS4X12_GPIO_M12;
+
+		sprintf(str, "hw_rev%d", i);
+		gpio_request(pin, str);
+		gpio_cfg_pin(pin, S5P_GPIO_INPUT);
+		gpio_set_pull(pin, S5P_GPIO_PULL_NONE);
 	}
 
 	/* GPM1[1:0]: MODEL_REV[1:0] */
@@ -103,10 +113,14 @@ static void board_init_i2c(void)
 	}
 
 	/* I2C_8 */
+	gpio_request(EXYNOS4X12_GPIO_F14, "i2c8_clk");
+	gpio_request(EXYNOS4X12_GPIO_F15, "i2c8_data");
 	gpio_direction_output(EXYNOS4X12_GPIO_F14, 1);
 	gpio_direction_output(EXYNOS4X12_GPIO_F15, 1);
 
 	/* I2C_9 */
+	gpio_request(EXYNOS4X12_GPIO_M21, "i2c9_clk");
+	gpio_request(EXYNOS4X12_GPIO_M20, "i2c9_data");
 	gpio_direction_output(EXYNOS4X12_GPIO_M21, 1);
 	gpio_direction_output(EXYNOS4X12_GPIO_M20, 1);
 }
@@ -388,6 +402,7 @@ void exynos_lcd_power_on(void)
 	struct pmic *p = pmic_get("MAX77686_PMIC");
 
 	/* LCD_2.2V_EN: GPC0[1] */
+	gpio_request(EXYNOS4X12_GPIO_C01, "lcd_2v2_en");
 	gpio_set_pull(EXYNOS4X12_GPIO_C01, S5P_GPIO_PULL_UP);
 	gpio_direction_output(EXYNOS4X12_GPIO_C01, 1);
 
@@ -400,6 +415,7 @@ void exynos_lcd_power_on(void)
 void exynos_reset_lcd(void)
 {
 	/* reset lcd */
+	gpio_request(EXYNOS4X12_GPIO_F21, "lcd_reset");
 	gpio_direction_output(EXYNOS4X12_GPIO_F21, 0);
 	udelay(10);
 	gpio_set_value(EXYNOS4X12_GPIO_F21, 1);
diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
index f9d3325..c04f48c 100644
--- a/board/samsung/universal_c210/universal.c
+++ b/board/samsung/universal_c210/universal.c
@@ -330,6 +330,7 @@ void exynos_cfg_lcd_gpio(void)
 	}
 
 	/* gpio pad configuration for LCD reset. */
+	gpio_request(EXYNOS4_GPIO_Y45, "lcd_reset");
 	gpio_cfg_pin(EXYNOS4_GPIO_Y45, S5P_GPIO_OUTPUT);
 
 	spi_init();
@@ -386,6 +387,7 @@ int exynos_init(void)
 		 * you should set it HIGH since it removes the inverter
 		 */
 		/* MASSMEMORY_EN: XMDMDATA_6: GPE3[6] */
+		gpio_request(EXYNOS4_GPIO_E36, "ldo_en");
 		gpio_direction_output(EXYNOS4_GPIO_E36, 0);
 		break;
 	default:
@@ -394,6 +396,7 @@ int exynos_init(void)
 		 * But set it as HIGH to ensure
 		 */
 		/* MASSMEMORY_EN: XMDMADDR_3: GPE1[3] */
+		gpio_request(EXYNOS4_GPIO_E13, "massmemory_en");
 		gpio_direction_output(EXYNOS4_GPIO_E13, 1);
 		break;
 	}
diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
index 637dd97..0dea45d 100644
--- a/drivers/mmc/s5p_sdhci.c
+++ b/drivers/mmc/s5p_sdhci.c
@@ -102,6 +102,7 @@ struct sdhci_host sdhci_host[SDHCI_MAX_HOSTS];
 
 static int do_sdhci_init(struct sdhci_host *host)
 {
+	char str[20];
 	int dev_id, flag;
 	int err = 0;
 
@@ -109,6 +110,8 @@ static int do_sdhci_init(struct sdhci_host *host)
 	dev_id = host->index + PERIPH_ID_SDMMC0;
 
 	if (fdt_gpio_isvalid(&host->pwr_gpio)) {
+		sprintf(str, "sdhci%d_power", host->index & 0xf);
+		gpio_request(host->pwr_gpio.gpio, str);
 		gpio_direction_output(host->pwr_gpio.gpio, 1);
 		err = exynos_pinmux_config(dev_id, flag);
 		if (err) {
@@ -118,7 +121,9 @@ static int do_sdhci_init(struct sdhci_host *host)
 	}
 
 	if (fdt_gpio_isvalid(&host->cd_gpio)) {
-		gpio_direction_output(host->cd_gpio.gpio, 0xf);
+		sprintf(str, "sdhci%d_cd", host->index & 0xf);
+		gpio_request(host->cd_gpio.gpio, str);
+		gpio_direction_output(host->cd_gpio.gpio, 1);
 		if (gpio_get_value(host->cd_gpio.gpio))
 			return -ENODEV;
 
-- 
2.0.0.526.g5318336



More information about the U-Boot mailing list