summaryrefslogtreecommitdiffstats
path: root/drivers/mci/mci_spi.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-11-13 21:07:20 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-14 21:09:41 +0100
commit0738b3c6fe2425e03f3c858b3809dd584b826c8f (patch)
treefb94dca096d1a1a224c3f10750eb2db61dac05e7 /drivers/mci/mci_spi.c
parentbcdafc8f3c405fa74aeb71b8db38dbf8664ecd46 (diff)
downloadbarebox-0738b3c6fe2425e03f3c858b3809dd584b826c8f.tar.gz
barebox-0738b3c6fe2425e03f3c858b3809dd584b826c8f.tar.xz
mci_spi: add sanity check
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/mci_spi.c')
-rw-r--r--drivers/mci/mci_spi.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
index cb5e0bb981..08939bea58 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;