diff mbox series

[U-Boot] dm: mmc: sandbox: Update SD card emulation

Message ID 1513248434-20409-1-git-send-email-jjhiblot@ti.com
State Accepted
Commit 49f89252ed4abf7f3899731f914f6b67462ea690
Delegated to: Jaehoon Chung
Headers show
Series [U-Boot] dm: mmc: sandbox: Update SD card emulation | expand

Commit Message

Jean-Jacques Hiblot Dec. 14, 2017, 10:47 a.m. UTC
The SDcard initialization procedure does a few more things than it did earlier:
* switch the bus width even for 1-bit bus width
* check that speed has been properly set (in resp[4] of SD_CMD_SWITCH_FUNC)

Update the SD simulator to handle those requests gracefully.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

This patch makes 'make tests' work again with the HS200/UHS support.
The new SD initialization procedures checks the content of resp[4] because
it indicates the speed of the card.
This patch also fixes a crash occurring during bus width selection (NULL
pointer).

Jean-Jacques

drivers/mmc/sandbox_mmc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jaehoon Chung Dec. 15, 2017, 7:45 a.m. UTC | #1
On 12/14/2017 07:47 PM, Jean-Jacques Hiblot wrote:
> The SDcard initialization procedure does a few more things than it did earlier:
> * switch the bus width even for 1-bit bus width
> * check that speed has been properly set (in resp[4] of SD_CMD_SWITCH_FUNC)
> 
> Update the SD simulator to handle those requests gracefully.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

> ---
> 
> This patch makes 'make tests' work again with the HS200/UHS support.
> The new SD initialization procedures checks the content of resp[4] because
> it indicates the speed of the card.
> This patch also fixes a crash occurring during bus width selection (NULL
> pointer).
> 
> Jean-Jacques
> 
> drivers/mmc/sandbox_mmc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c
> index fdb29a5..8a5d256 100644
> --- a/drivers/mmc/sandbox_mmc.c
> +++ b/drivers/mmc/sandbox_mmc.c
> @@ -48,9 +48,12 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
>  		cmd->response[1] = 10 << 16;	/* 1 << block_len */
>  		break;
>  	case SD_CMD_SWITCH_FUNC: {
> +		if (!data)
> +			break;
>  		u32 *resp = (u32 *)data->dest;
> -
>  		resp[7] = cpu_to_be32(SD_HIGHSPEED_BUSY);
> +		if ((cmd->cmdarg & 0xF) == UHS_SDR12_BUS_SPEED)
> +			resp[4] = (cmd->cmdarg & 0xF) << 24;
>  		break;
>  	}
>  	case MMC_CMD_READ_SINGLE_BLOCK:
>
Tom Rini Dec. 18, 2017, 11:37 p.m. UTC | #2
On Thu, Dec 14, 2017 at 11:47:14AM +0100, Jean-Jacques Hiblot wrote:

> The SDcard initialization procedure does a few more things than it did earlier:
> * switch the bus width even for 1-bit bus width
> * check that speed has been properly set (in resp[4] of SD_CMD_SWITCH_FUNC)
> 
> Update the SD simulator to handle those requests gracefully.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

Applied to u-boot/next, thanks!
diff mbox series

Patch

diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c
index fdb29a5..8a5d256 100644
--- a/drivers/mmc/sandbox_mmc.c
+++ b/drivers/mmc/sandbox_mmc.c
@@ -48,9 +48,12 @@  static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
 		cmd->response[1] = 10 << 16;	/* 1 << block_len */
 		break;
 	case SD_CMD_SWITCH_FUNC: {
+		if (!data)
+			break;
 		u32 *resp = (u32 *)data->dest;
-
 		resp[7] = cpu_to_be32(SD_HIGHSPEED_BUSY);
+		if ((cmd->cmdarg & 0xF) == UHS_SDR12_BUS_SPEED)
+			resp[4] = (cmd->cmdarg & 0xF) << 24;
 		break;
 	}
 	case MMC_CMD_READ_SINGLE_BLOCK: