mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mci_spi: always compute command crc byte
@ 2012-11-12 21:16 Franck Jullien
  2012-11-14  8:25 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Franck Jullien @ 2012-11-12 21:16 UTC (permalink / raw)
  To: barebox

The spec says: "the CMD8 CRC verification is always enabled.
The Host shall set correct CRC in the argument ofCMD8. If
CRC error is detected, card returns CRC error in R1 response
regardless of command index."

Make it simple, and compute crc on every commands.

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
---
 drivers/mci/Kconfig   |    2 +-
 drivers/mci/mci_spi.c |   12 ------------
 2 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index b1a678e..5c0ca4d 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -88,6 +88,7 @@ config MCI_ATMEL
 
 config MCI_SPI
 	bool "MMC/SD over SPI"
+	select CRC7
 	depends on SPI
 	help
 	  Some systems access MMC/SD/SDIO cards using a SPI controller
@@ -98,7 +99,6 @@ config MCI_SPI
 
 config MMC_SPI_CRC_ON
 	bool "Enable CRC protection for transfers"
-	select CRC7
 	select CRC16
 	depends on MCI_SPI
 	help
diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
index 5894104..cb5e0bb 100644
--- a/drivers/mci/mci_spi.c
+++ b/drivers/mci/mci_spi.c
@@ -121,14 +121,6 @@ mmc_spi_writebytes(struct mmc_spi_host *host, unsigned len, void *data)
 	return status;
 }
 
-/*
- * Note that while the CRC, in general, is ignored in SPI mode, the very first
- * command must be followed by a valid CRC, since the card is not yet in SPI mode.
- * The CRC byte for a CMD0 command with a zero argument is a constant 0x4A. For
- * simplicity, this CRC byte is always sent with every command.
- */
-#define MMC_SPI_CMD0_CRC	((0x4a << 1) | 0x1)
-
 static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
 {
 	uint8_t r1;
@@ -141,11 +133,7 @@ static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
 	command[3] = cmd->cmdarg >> 16;
 	command[4] = cmd->cmdarg >> 8;
 	command[5] = cmd->cmdarg;
-#ifdef CONFIG_MMC_SPI_CRC_ON
 	command[6] = (crc7(0, &command[1], 5) << 1) | 0x01;
-#else
-	command[6] = MMC_SPI_CMD0_CRC;
-#endif
 
 	mmc_spi_writebytes(host, 7, command);
 
-- 
1.7.1


_______________________________________________
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] mci_spi: always compute command crc byte
  2012-11-12 21:16 [PATCH] mci_spi: always compute command crc byte Franck Jullien
@ 2012-11-14  8:25 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2012-11-14  8:25 UTC (permalink / raw)
  To: Franck Jullien; +Cc: barebox

On Mon, Nov 12, 2012 at 10:16:31PM +0100, Franck Jullien wrote:
> The spec says: "the CMD8 CRC verification is always enabled.
> The Host shall set correct CRC in the argument ofCMD8. If
> CRC error is detected, card returns CRC error in R1 response
> regardless of command index."
> 
> Make it simple, and compute crc on every commands.
> 
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>

Applied, thanks

Sascha

> ---
>  drivers/mci/Kconfig   |    2 +-
>  drivers/mci/mci_spi.c |   12 ------------
>  2 files changed, 1 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
> index b1a678e..5c0ca4d 100644
> --- a/drivers/mci/Kconfig
> +++ b/drivers/mci/Kconfig
> @@ -88,6 +88,7 @@ config MCI_ATMEL
>  
>  config MCI_SPI
>  	bool "MMC/SD over SPI"
> +	select CRC7
>  	depends on SPI
>  	help
>  	  Some systems access MMC/SD/SDIO cards using a SPI controller
> @@ -98,7 +99,6 @@ config MCI_SPI
>  
>  config MMC_SPI_CRC_ON
>  	bool "Enable CRC protection for transfers"
> -	select CRC7
>  	select CRC16
>  	depends on MCI_SPI
>  	help
> diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
> index 5894104..cb5e0bb 100644
> --- a/drivers/mci/mci_spi.c
> +++ b/drivers/mci/mci_spi.c
> @@ -121,14 +121,6 @@ mmc_spi_writebytes(struct mmc_spi_host *host, unsigned len, void *data)
>  	return status;
>  }
>  
> -/*
> - * Note that while the CRC, in general, is ignored in SPI mode, the very first
> - * command must be followed by a valid CRC, since the card is not yet in SPI mode.
> - * The CRC byte for a CMD0 command with a zero argument is a constant 0x4A. For
> - * simplicity, this CRC byte is always sent with every command.
> - */
> -#define MMC_SPI_CMD0_CRC	((0x4a << 1) | 0x1)
> -
>  static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
>  {
>  	uint8_t r1;
> @@ -141,11 +133,7 @@ static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
>  	command[3] = cmd->cmdarg >> 16;
>  	command[4] = cmd->cmdarg >> 8;
>  	command[5] = cmd->cmdarg;
> -#ifdef CONFIG_MMC_SPI_CRC_ON
>  	command[6] = (crc7(0, &command[1], 5) << 1) | 0x01;
> -#else
> -	command[6] = MMC_SPI_CMD0_CRC;
> -#endif
>  
>  	mmc_spi_writebytes(host, 7, command);
>  
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> 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:[~2012-11-14  8:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-12 21:16 [PATCH] mci_spi: always compute command crc byte Franck Jullien
2012-11-14  8:25 ` Sascha Hauer

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