mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] mci_spi: add sanity check
Date: Tue, 13 Nov 2012 21:07:20 +0100	[thread overview]
Message-ID: <1352837241-16777-3-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1352837241-16777-1-git-send-email-plagnioj@jcrosoft.com>

as in linux

SD/MMC support only mode 0 or 3 (if 0 not supported by the spi master)
so if the mode is not 3 force 0

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/mci/mci_spi.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
index cb5e0bb..08939be 100644
--- a/drivers/mci/mci_spi.c
+++ b/drivers/mci/mci_spi.c
@@ -366,6 +366,7 @@ static int spi_mci_probe(struct device_d *dev)
 	struct spi_device	*spi = (struct spi_device *)dev->type_data;
 	struct mmc_spi_host	*host;
 	void			*ones;
+	int			status;
 
 	host = xzalloc(sizeof(*host));
 	host->mci.send_cmd = mmc_spi_request;
@@ -373,6 +374,16 @@ static int spi_mci_probe(struct device_d *dev)
 	host->mci.init = mmc_spi_init;
 	host->mci.hw_dev = dev;
 
+	/* MMC and SD specs only seem to care that sampling is on the
+	 * rising edge ... meaning SPI modes 0 or 3.  So either SPI mode
+	 * should be legit.  We'll use mode 0 since the steady state is 0,
+	 * which is appropriate for hotplugging, unless the platform data
+	 * specify mode 3 (if hardware is not compatible to mode 0).
+	 */
+	if (spi->mode != SPI_MODE_3)
+		spi->mode = SPI_MODE_0;
+	spi->bits_per_word = 8;
+
 	host->dev = dev;
 	host->spi = spi;
 	dev->priv = host;
-- 
1.7.10.4


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

  parent reply	other threads:[~2012-11-13 20:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13 20:02 [PATCH 0/4] mci-spi fix Jean-Christophe PLAGNIOL-VILLARD
2012-11-13 20:07 ` [PATCH 1/4] mci_spi: always compute command crc byte Jean-Christophe PLAGNIOL-VILLARD
2012-11-13 20:07   ` [PATCH 2/4] mci-core: spi fix op cond support Jean-Christophe PLAGNIOL-VILLARD
2012-11-13 20:07   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-11-13 20:07   ` [PATCH 4/4] mci_spi: add clock frequency change support Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1352837241-16777-3-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox