mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] MMC/SD improvements
@ 2013-01-20  9:58 Sascha Hauer
  2013-01-20  9:58 ` [PATCH 1/5] mci: return 0 for probe parameter even when already initialized Sascha Hauer
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-01-20  9:58 UTC (permalink / raw)
  To: barebox

- make sure the mci*.probe parameter is always present and so that scripts
  can rely on it.
- let setting of the parameter be succesful when there is a card detected,
  even when it was present before
- Add proper card present callback for host drivers so that we can give
  a meaningful message in the framework.

Sascha

----------------------------------------------------------------
Sascha Hauer (5):
      mci: return 0 for probe parameter even when already initialized
      mci: Always add probe parameter for cards
      mci: Add card_present callback
      mci i.MX esdhc: implement card_present callback
      mci atmel: implement card_present callback

 drivers/mci/atmel_mci.c |   21 +++++++++++++++------
 drivers/mci/imx-esdhc.c |   14 +++-----------
 drivers/mci/mci-core.c  |   33 +++++++++++----------------------
 include/mci.h           |    2 ++
 4 files changed, 31 insertions(+), 39 deletions(-)

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

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

* [PATCH 1/5] mci: return 0 for probe parameter even when already initialized
  2013-01-20  9:58 [PATCH] MMC/SD improvements Sascha Hauer
@ 2013-01-20  9:58 ` Sascha Hauer
  2013-01-20  9:58 ` [PATCH 2/5] mci: Always add probe parameter for cards Sascha Hauer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-01-20  9:58 UTC (permalink / raw)
  To: barebox

This makes the behaviour more friendly to scripts which can now
set the probe parameter without checking if it has been done before.
Having a succesful result now means that there is a card.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 559f8ab..711f74b 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1448,7 +1448,7 @@ static int mci_set_probe(struct device_d *mci_dev, struct param_d *param,
 
 	rc = mci_check_if_already_initialized(mci);
 	if (rc != 0)
-		return rc;
+		return 0;
 
 	probe = simple_strtoul(val, NULL, 0);
 	if (probe != 0) {
-- 
1.7.10.4


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

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

* [PATCH 2/5] mci: Always add probe parameter for cards
  2013-01-20  9:58 [PATCH] MMC/SD improvements Sascha Hauer
  2013-01-20  9:58 ` [PATCH 1/5] mci: return 0 for probe parameter even when already initialized Sascha Hauer
@ 2013-01-20  9:58 ` Sascha Hauer
  2013-01-20  9:58 ` [PATCH 3/5] mci: Add card_present callback Sascha Hauer
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-01-20  9:58 UTC (permalink / raw)
  To: barebox

Always add the 'probe' parameter to cards so that scripts can
rely on the parameter to be present.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c |   26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 711f74b..7d43fe3 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1499,34 +1499,18 @@ static int mci_probe(struct device_d *mci_dev)
 
 	dev_info(mci->host->hw_dev, "registered as %s\n", dev_name(mci_dev));
 
-#ifdef CONFIG_MCI_STARTUP
-	/* if enabled, probe the attached card immediately */
-	rc = mci_card_probe(mci);
-	if (rc) {
-		/*
-		 * If it fails, add the 'probe' parameter to give the user
-		 * a chance to insert a card and try again. Note: This may fail
-		 * systems that rely on the MCI card for startup (for the
-		 * persistant environment for example)
-		 */
-		rc = add_mci_parameter(mci_dev);
-		if (rc != 0) {
-			dev_dbg(mci->mci_dev, "Failed to add 'probe' parameter to the MCI device\n");
-			goto on_error;
-		}
-	}
-#endif
-
-#ifndef CONFIG_MCI_STARTUP
-	/* add params on demand */
 	rc = add_mci_parameter(mci_dev);
 	if (rc != 0) {
 		dev_dbg(mci->mci_dev, "Failed to add 'probe' parameter to the MCI device\n");
 		goto on_error;
 	}
+
+#ifdef CONFIG_MCI_STARTUP
+	/* if enabled, probe the attached card immediately */
+	mci_card_probe(mci);
 #endif
 
-	return rc;
+	return 0;
 
 on_error:
 	free(mci);
-- 
1.7.10.4


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

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

* [PATCH 3/5] mci: Add card_present callback
  2013-01-20  9:58 [PATCH] MMC/SD improvements Sascha Hauer
  2013-01-20  9:58 ` [PATCH 1/5] mci: return 0 for probe parameter even when already initialized Sascha Hauer
  2013-01-20  9:58 ` [PATCH 2/5] mci: Always add probe parameter for cards Sascha Hauer
@ 2013-01-20  9:58 ` Sascha Hauer
  2013-01-20  9:58 ` [PATCH 4/5] mci i.MX esdhc: implement " Sascha Hauer
  2013-01-20  9:58 ` [PATCH 5/5] mci atmel: " Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-01-20  9:58 UTC (permalink / raw)
  To: barebox

Currently there is no common way for the mci host driver to tell
that there is no card present. This adds a card_present callback
which is used by the framework to tell whether it's present or not.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c |    5 +++++
 include/mci.h          |    2 ++
 2 files changed, 7 insertions(+)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 7d43fe3..fd052f1 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1352,6 +1352,11 @@ static int mci_card_probe(struct mci *mci)
 	struct mci_host *host = mci->host;
 	int rc, disknum;
 
+	if (host->card_present && !host->card_present(host)) {
+		dev_err(mci->mci_dev, "no card inserted\n");
+		return -ENODEV;
+	}
+
 	/* start with a host interface reset */
 	rc = (host->init)(host, mci->mci_dev);
 	if (rc) {
diff --git a/include/mci.h b/include/mci.h
index 0041e27..c0d179b 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -300,6 +300,8 @@ struct mci_host {
 	void (*set_ios)(struct mci_host*, struct mci_ios *);
 	/** handle a command */
 	int (*send_cmd)(struct mci_host*, struct mci_cmd*, struct mci_data*);
+	/** check if a card is inserted */
+	int (*card_present)(struct mci_host *);
 };
 
 /** MMC/SD and interface instance information */
-- 
1.7.10.4


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

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

* [PATCH 4/5] mci i.MX esdhc: implement card_present callback
  2013-01-20  9:58 [PATCH] MMC/SD improvements Sascha Hauer
                   ` (2 preceding siblings ...)
  2013-01-20  9:58 ` [PATCH 3/5] mci: Add card_present callback Sascha Hauer
@ 2013-01-20  9:58 ` Sascha Hauer
  2013-01-20  9:58 ` [PATCH 5/5] mci atmel: " Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-01-20  9:58 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/imx-esdhc.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index dfeb509..aad1b86 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -421,8 +421,9 @@ static void esdhc_set_ios(struct mci_host *mci, struct mci_ios *ios)
 
 }
 
-static int esdhc_card_detect(struct fsl_esdhc_host *host)
+static int esdhc_card_present(struct mci_host *mci)
 {
+	struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
 	struct fsl_esdhc __iomem *regs = host->regs;
 	struct esdhc_platform_data *pdata = host->dev->platform_data;
 	int ret;
@@ -453,16 +454,6 @@ static int esdhc_init(struct mci_host *mci, struct device_d *dev)
 	int timeout = 1000;
 	int ret = 0;
 
-	ret = esdhc_card_detect(host);
-
-	if (ret == 0)
-		return -ENODEV;
-
-	if (ret < 0)
-		return ret;
-
-	ret = 0;
-
 	/* Enable cache snooping */
 	if (host && !host->no_snoop)
 		esdhc_write32(&regs->scr, 0x00000040);
@@ -561,6 +552,7 @@ static int fsl_esdhc_probe(struct device_d *dev)
 	host->mci.send_cmd = esdhc_send_cmd;
 	host->mci.set_ios = esdhc_set_ios;
 	host->mci.init = esdhc_init;
+	host->mci.card_present = esdhc_card_present;
 	host->mci.hw_dev = dev;
 
 	rate = clk_get_rate(host->clk);
-- 
1.7.10.4


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

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

* [PATCH 5/5] mci atmel: implement card_present callback
  2013-01-20  9:58 [PATCH] MMC/SD improvements Sascha Hauer
                   ` (3 preceding siblings ...)
  2013-01-20  9:58 ` [PATCH 4/5] mci i.MX esdhc: implement " Sascha Hauer
@ 2013-01-20  9:58 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-01-20  9:58 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/atmel_mci.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c
index 4065355..222cd4a 100644
--- a/drivers/mci/atmel_mci.c
+++ b/drivers/mci/atmel_mci.c
@@ -331,18 +331,26 @@ static int atmel_start_cmd(struct atmel_mci_host *host, struct mci_cmd *cmd,
 	return 0;
 }
 
-/** init the host interface */
-static int mci_reset(struct mci_host *mci, struct device_d *mci_dev)
+
+static int mci_card_present(struct mci_host *mci)
 {
-	int ret;
 	struct atmel_mci_host *host = to_mci_host(mci);
 	struct atmel_mci_platform_data *pd = host->hw_dev->platform_data;
+	int ret;
+
+	/* No gpio, assume card is present */
+	if (!gpio_is_valid(pd->detect_pin))
+		return 1;
 
 	ret = gpio_get_value(pd->detect_pin);
-	dev_dbg(host->hw_dev, "card %sdetected\n", ret != 0 ? "not " : "");
 
-	if (pd->detect_pin && ret == 1)
-		return -ENODEV;
+	return ret == 0 ? 1 : 0;
+}
+
+/** init the host interface */
+static int mci_reset(struct mci_host *mci, struct device_d *mci_dev)
+{
+	struct atmel_mci_host *host = to_mci_host(mci);
 
 	clk_enable(host->clk);
 	atmel_mci_reset(host);
@@ -454,6 +462,7 @@ static int mci_probe(struct device_d *hw_dev)
 	host->mci.send_cmd = mci_request;
 	host->mci.set_ios = mci_set_ios;
 	host->mci.init = mci_reset;
+	host->mci.card_present = mci_card_present;
 	host->mci.hw_dev = hw_dev;
 
 	host->mci.host_caps = pd->host_caps;
-- 
1.7.10.4


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

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

end of thread, other threads:[~2013-01-20  9:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-20  9:58 [PATCH] MMC/SD improvements Sascha Hauer
2013-01-20  9:58 ` [PATCH 1/5] mci: return 0 for probe parameter even when already initialized Sascha Hauer
2013-01-20  9:58 ` [PATCH 2/5] mci: Always add probe parameter for cards Sascha Hauer
2013-01-20  9:58 ` [PATCH 3/5] mci: Add card_present callback Sascha Hauer
2013-01-20  9:58 ` [PATCH 4/5] mci i.MX esdhc: implement " Sascha Hauer
2013-01-20  9:58 ` [PATCH 5/5] mci atmel: " Sascha Hauer

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