All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] mmc: Handle switch error status bit in MMC card status
@ 2014-04-03  9:34 Andrew Gabbasov
  2014-05-23  8:34 ` Pantelis Antoniou
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Gabbasov @ 2014-04-03  9:34 UTC (permalink / raw)
  To: u-boot

MMC switch command for unsupported feature (e.g. bus width) sets a switch
error bit in card status. This bit should be checked, and, if it's set,
no access with new controller settings should be performed.

Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
---
 drivers/mmc/mmc.c |    4 +++-
 include/mmc.h     |    2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 16051e5..a850085 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -150,6 +150,8 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 #endif
 		return TIMEOUT;
 	}
+	if (cmd.response[0] & MMC_STATUS_SWITCH_ERROR)
+		return SWITCH_ERR;
 
 	return 0;
 }
@@ -501,7 +503,7 @@ static int mmc_change_freq(struct mmc *mmc)
 	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1);
 
 	if (err)
-		return err;
+		return err == SWITCH_ERR ? 0 : err;
 
 	/* Now check to see that it worked */
 	err = mmc_send_ext_csd(mmc, ext_csd);
diff --git a/include/mmc.h b/include/mmc.h
index c0a1d9e..213c112 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -53,6 +53,7 @@
 #define COMM_ERR		-18 /* Communications Error */
 #define TIMEOUT			-19
 #define IN_PROGRESS		-20 /* operation is in progress */
+#define SWITCH_ERR		-21 /* Card reports failure to switch mode */
 
 #define MMC_CMD_GO_IDLE_STATE		0
 #define MMC_CMD_SEND_OP_COND		1
@@ -108,6 +109,7 @@
 #define SECURE_ERASE		0x80000000
 
 #define MMC_STATUS_MASK		(~0x0206BF7F)
+#define MMC_STATUS_SWITCH_ERROR	(1 << 7)
 #define MMC_STATUS_RDY_FOR_DATA (1 << 8)
 #define MMC_STATUS_CURR_STATE	(0xf << 9)
 #define MMC_STATUS_ERROR	(1 << 19)
-- 
1.7.10.4

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

* [U-Boot] [PATCH v2] mmc: Handle switch error status bit in MMC card status
  2014-04-03  9:34 [U-Boot] [PATCH v2] mmc: Handle switch error status bit in MMC card status Andrew Gabbasov
@ 2014-05-23  8:34 ` Pantelis Antoniou
  0 siblings, 0 replies; 2+ messages in thread
From: Pantelis Antoniou @ 2014-05-23  8:34 UTC (permalink / raw)
  To: u-boot

Hi Andrew,

On Apr 3, 2014, at 12:34 PM, Andrew Gabbasov wrote:

> MMC switch command for unsupported feature (e.g. bus width) sets a switch
> error bit in card status. This bit should be checked, and, if it's set,
> no access with new controller settings should be performed.
> 
> Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
> ---
> drivers/mmc/mmc.c |    4 +++-
> include/mmc.h     |    2 ++
> 2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 16051e5..a850085 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -150,6 +150,8 @@ int mmc_send_status(struct mmc *mmc, int timeout)
> #endif
> 		return TIMEOUT;
> 	}
> +	if (cmd.response[0] & MMC_STATUS_SWITCH_ERROR)
> +		return SWITCH_ERR;
> 
> 	return 0;
> }
> @@ -501,7 +503,7 @@ static int mmc_change_freq(struct mmc *mmc)
> 	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1);
> 
> 	if (err)
> -		return err;
> +		return err == SWITCH_ERR ? 0 : err;
> 
> 	/* Now check to see that it worked */
> 	err = mmc_send_ext_csd(mmc, ext_csd);
> diff --git a/include/mmc.h b/include/mmc.h
> index c0a1d9e..213c112 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -53,6 +53,7 @@
> #define COMM_ERR		-18 /* Communications Error */
> #define TIMEOUT			-19
> #define IN_PROGRESS		-20 /* operation is in progress */
> +#define SWITCH_ERR		-21 /* Card reports failure to switch mode */
> 
> #define MMC_CMD_GO_IDLE_STATE		0
> #define MMC_CMD_SEND_OP_COND		1
> @@ -108,6 +109,7 @@
> #define SECURE_ERASE		0x80000000
> 
> #define MMC_STATUS_MASK		(~0x0206BF7F)
> +#define MMC_STATUS_SWITCH_ERROR	(1 << 7)
> #define MMC_STATUS_RDY_FOR_DATA (1 << 8)
> #define MMC_STATUS_CURR_STATE	(0xf << 9)
> #define MMC_STATUS_ERROR	(1 << 19)
> -- 
> 1.7.10.4
> 

Applied,

Thanks 

--Pantelis

Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>

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

end of thread, other threads:[~2014-05-23  8:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-03  9:34 [U-Boot] [PATCH v2] mmc: Handle switch error status bit in MMC card status Andrew Gabbasov
2014-05-23  8:34 ` Pantelis Antoniou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.