diff mbox

[U-Boot,2/2] s5p sdhci: call pinmux for card's gpio pins before use them

Message ID 1446043310-21519-2-git-send-email-p.marczak@samsung.com
State Accepted
Delegated to: Minkyu Kang
Headers show

Commit Message

Przemyslaw Marczak Oct. 28, 2015, 2:41 p.m. UTC
The SD card detection depends on checking one pin state.
But the pin was configured after card was detected, which is wrong.

This commit fixes this, by moving call to pinmux before use the pin.

Tested-on: Odroid U3 and Odroid X2.

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Guillaume GARDET <guillaume.gardet@free.fr>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>
Cc: Simon Glass <sjg@chromium.org>
---
 drivers/mmc/s5p_sdhci.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Jaehoon Chung Oct. 29, 2015, 7:29 a.m. UTC | #1
Hi,

Looks good to me.

Acked-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

On 10/28/2015 11:41 PM, Przemyslaw Marczak wrote:
> The SD card detection depends on checking one pin state.
> But the pin was configured after card was detected, which is wrong.
> 
> This commit fixes this, by moving call to pinmux before use the pin.
> 
> Tested-on: Odroid U3 and Odroid X2.
> 
> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> Cc: Guillaume GARDET <guillaume.gardet@free.fr>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Minkyu Kang <mk7.kang@samsung.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  drivers/mmc/s5p_sdhci.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
> index 15ecfee..44353c7 100644
> --- a/drivers/mmc/s5p_sdhci.c
> +++ b/drivers/mmc/s5p_sdhci.c
> @@ -106,6 +106,12 @@ static int do_sdhci_init(struct sdhci_host *host)
>  	flag = host->bus_width == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE;
>  	dev_id = host->index + PERIPH_ID_SDMMC0;
>  
> +	ret = exynos_pinmux_config(dev_id, flag);
> +	if (ret) {
> +		printf("external SD not configured\n");
> +		return ret;
> +	}
> +
>  	if (dm_gpio_is_valid(&host->pwr_gpio)) {
>  		dm_gpio_set_value(&host->pwr_gpio, 1);
>  		ret = exynos_pinmux_config(dev_id, flag);
> @@ -121,12 +127,6 @@ static int do_sdhci_init(struct sdhci_host *host)
>  			debug("no SD card detected (%d)\n", ret);
>  			return -ENODEV;
>  		}
> -
> -		ret = exynos_pinmux_config(dev_id, flag);
> -		if (ret) {
> -			printf("external SD not configured\n");
> -			return ret;
> -		}
>  	}
>  
>  	return s5p_sdhci_core_init(host);
> @@ -193,7 +193,7 @@ static int process_nodes(const void *blob, int node_list[], int count)
>  		}
>  
>  		ret = do_sdhci_init(host);
> -		if (ret) {
> +		if (ret && ret != -ENODEV) {
>  			printf("%s: failed to initialize dev %d (%d)\n", __func__, i, ret);
>  			failed++;
>  		}
>
Ɓukasz Majewski Oct. 29, 2015, 5:13 p.m. UTC | #2
Hi Przemyslaw,

> The SD card detection depends on checking one pin state.
> But the pin was configured after card was detected, which is wrong.
> 
> This commit fixes this, by moving call to pinmux before use the pin.
> 
> Tested-on: Odroid U3 and Odroid X2.
> 
> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> Cc: Guillaume GARDET <guillaume.gardet@free.fr>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Minkyu Kang <mk7.kang@samsung.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  drivers/mmc/s5p_sdhci.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
> index 15ecfee..44353c7 100644
> --- a/drivers/mmc/s5p_sdhci.c
> +++ b/drivers/mmc/s5p_sdhci.c
> @@ -106,6 +106,12 @@ static int do_sdhci_init(struct sdhci_host *host)
>  	flag = host->bus_width == 8 ? PINMUX_FLAG_8BIT_MODE :
> PINMUX_FLAG_NONE; dev_id = host->index + PERIPH_ID_SDMMC0;
>  
> +	ret = exynos_pinmux_config(dev_id, flag);
> +	if (ret) {
> +		printf("external SD not configured\n");
> +		return ret;
> +	}
> +
>  	if (dm_gpio_is_valid(&host->pwr_gpio)) {
>  		dm_gpio_set_value(&host->pwr_gpio, 1);
>  		ret = exynos_pinmux_config(dev_id, flag);
> @@ -121,12 +127,6 @@ static int do_sdhci_init(struct sdhci_host *host)
>  			debug("no SD card detected (%d)\n", ret);
>  			return -ENODEV;
>  		}
> -
> -		ret = exynos_pinmux_config(dev_id, flag);
> -		if (ret) {
> -			printf("external SD not configured\n");
> -			return ret;
> -		}
>  	}
>  
>  	return s5p_sdhci_core_init(host);
> @@ -193,7 +193,7 @@ static int process_nodes(const void *blob, int
> node_list[], int count) }
>  
>  		ret = do_sdhci_init(host);
> -		if (ret) {
> +		if (ret && ret != -ENODEV) {
>  			printf("%s: failed to initialize dev %d
> (%d)\n", __func__, i, ret); failed++;
>  		}


Tested-by: Lukasz Majewski <l.majewski@samsung.com>

Test HW: Exynos 4210 - Trats board.
Minkyu Kang Nov. 2, 2015, 5:37 a.m. UTC | #3
On 28/10/15 23:41, Przemyslaw Marczak wrote:
> The SD card detection depends on checking one pin state.
> But the pin was configured after card was detected, which is wrong.
> 
> This commit fixes this, by moving call to pinmux before use the pin.
> 
> Tested-on: Odroid U3 and Odroid X2.
> 
> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> Cc: Guillaume GARDET <guillaume.gardet@free.fr>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Minkyu Kang <mk7.kang@samsung.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  drivers/mmc/s5p_sdhci.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 

applied to u-boot-samsung.

Thanks,
Minkyu Kang.
diff mbox

Patch

diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
index 15ecfee..44353c7 100644
--- a/drivers/mmc/s5p_sdhci.c
+++ b/drivers/mmc/s5p_sdhci.c
@@ -106,6 +106,12 @@  static int do_sdhci_init(struct sdhci_host *host)
 	flag = host->bus_width == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE;
 	dev_id = host->index + PERIPH_ID_SDMMC0;
 
+	ret = exynos_pinmux_config(dev_id, flag);
+	if (ret) {
+		printf("external SD not configured\n");
+		return ret;
+	}
+
 	if (dm_gpio_is_valid(&host->pwr_gpio)) {
 		dm_gpio_set_value(&host->pwr_gpio, 1);
 		ret = exynos_pinmux_config(dev_id, flag);
@@ -121,12 +127,6 @@  static int do_sdhci_init(struct sdhci_host *host)
 			debug("no SD card detected (%d)\n", ret);
 			return -ENODEV;
 		}
-
-		ret = exynos_pinmux_config(dev_id, flag);
-		if (ret) {
-			printf("external SD not configured\n");
-			return ret;
-		}
 	}
 
 	return s5p_sdhci_core_init(host);
@@ -193,7 +193,7 @@  static int process_nodes(const void *blob, int node_list[], int count)
 		}
 
 		ret = do_sdhci_init(host);
-		if (ret) {
+		if (ret && ret != -ENODEV) {
 			printf("%s: failed to initialize dev %d (%d)\n", __func__, i, ret);
 			failed++;
 		}