mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mmc: allow skipping SD card initialization
@ 2017-09-20 15:50 Philipp Zabel
  2017-09-26  6:53 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Philipp Zabel @ 2017-09-20 15:50 UTC (permalink / raw)
  To: barebox

This patch allows to skip SD card initialization for eMMCs by setting
the "no-sd" property in the host controller device tree node. Avoiding
two SD command timeouts speeds up detection time by well over 200 ms.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/mci/mci-core.c | 12 ++++++++----
 include/mci.h          |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 07911d43d..208b7666d 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1682,10 +1682,13 @@ static int mci_card_probe(struct mci *mci)
 	}
 
 	/* Check if this card can handle the "SD Card Physical Layer Specification 2.0" */
-	rc = sd_send_if_cond(mci);
-	rc = sd_send_op_cond(mci);
-	if (rc && rc == -ETIMEDOUT) {
-		/* If the command timed out, we check for an MMC card */
+	if (!host->no_sd) {
+		rc = sd_send_if_cond(mci);
+		rc = sd_send_op_cond(mci);
+	}
+	if (host->no_sd || rc == -ETIMEDOUT) {
+		/* If SD card initialization was skipped or if it timed out,
+		 * we check for an MMC card */
 		dev_dbg(&mci->dev, "Card seems to be a MultiMediaCard\n");
 		rc = mmc_send_op_cond(mci);
 	}
@@ -1904,6 +1907,7 @@ void mci_of_parse_node(struct mci_host *host,
 	}
 
 	host->non_removable = of_property_read_bool(np, "non-removable");
+	host->no_sd = of_property_read_bool(np, "no-sd");
 }
 
 void mci_of_parse(struct mci_host *host)
diff --git a/include/mci.h b/include/mci.h
index d3115e8cc..1f6533391 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -403,6 +403,7 @@ struct mci_host {
 	unsigned dsr_val;	/**< optional dsr value */
 	int use_dsr;		/**< optional dsr usage flag */
 	bool non_removable;	/**< device is non removable */
+	bool no_sd;		/**< do not send SD commands during initialization */
 	struct regulator *supply;
 
 	/** init the host interface */
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: allow skipping SD card initialization
  2017-09-20 15:50 [PATCH] mmc: allow skipping SD card initialization Philipp Zabel
@ 2017-09-26  6:53 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2017-09-26  6:53 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: barebox

On Wed, Sep 20, 2017 at 05:50:44PM +0200, Philipp Zabel wrote:
> This patch allows to skip SD card initialization for eMMCs by setting
> the "no-sd" property in the host controller device tree node. Avoiding
> two SD command timeouts speeds up detection time by well over 200 ms.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/mci/mci-core.c | 12 ++++++++----
>  include/mci.h          |  1 +
>  2 files changed, 9 insertions(+), 4 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 07911d43d..208b7666d 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -1682,10 +1682,13 @@ static int mci_card_probe(struct mci *mci)
>  	}
>  
>  	/* Check if this card can handle the "SD Card Physical Layer Specification 2.0" */
> -	rc = sd_send_if_cond(mci);
> -	rc = sd_send_op_cond(mci);
> -	if (rc && rc == -ETIMEDOUT) {
> -		/* If the command timed out, we check for an MMC card */
> +	if (!host->no_sd) {
> +		rc = sd_send_if_cond(mci);
> +		rc = sd_send_op_cond(mci);
> +	}
> +	if (host->no_sd || rc == -ETIMEDOUT) {
> +		/* If SD card initialization was skipped or if it timed out,
> +		 * we check for an MMC card */
>  		dev_dbg(&mci->dev, "Card seems to be a MultiMediaCard\n");
>  		rc = mmc_send_op_cond(mci);
>  	}
> @@ -1904,6 +1907,7 @@ void mci_of_parse_node(struct mci_host *host,
>  	}
>  
>  	host->non_removable = of_property_read_bool(np, "non-removable");
> +	host->no_sd = of_property_read_bool(np, "no-sd");
>  }
>  
>  void mci_of_parse(struct mci_host *host)
> diff --git a/include/mci.h b/include/mci.h
> index d3115e8cc..1f6533391 100644
> --- a/include/mci.h
> +++ b/include/mci.h
> @@ -403,6 +403,7 @@ struct mci_host {
>  	unsigned dsr_val;	/**< optional dsr value */
>  	int use_dsr;		/**< optional dsr usage flag */
>  	bool non_removable;	/**< device is non removable */
> +	bool no_sd;		/**< do not send SD commands during initialization */
>  	struct regulator *supply;
>  
>  	/** init the host interface */
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-26  6:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-20 15:50 [PATCH] mmc: allow skipping SD card initialization Philipp Zabel
2017-09-26  6:53 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox