[PATCH] hw/sd: ssi-sd: Fix SEND_IF_COND (CMD8) response

Bin Meng posted 1 patch 4 years, 9 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1611636214-52427-1-git-send-email-bmeng.cn@gmail.com
Maintainers: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
hw/sd/ssi-sd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] hw/sd: ssi-sd: Fix SEND_IF_COND (CMD8) response
Posted by Bin Meng 4 years, 9 months ago
From: Bin Meng <bin.meng@windriver.com>

The SEND_IF_COND command (CMD8) response is of format R7, but
current code returns R1 for CMD8. Fix it.

Fixes: 775616c3ae8c ("Partial SD card SPI mode support")
Signed-off-by: Bin Meng <bin.meng@windriver.com>

---
When testing with VxWorks driver, this additional issue was exposed.
It looks like VxWorks has stricter parsing on command responses while
U-Boot/Linux drivers are all happy with exising QEMU CMD8 response.

Based on http://patchwork.ozlabs.org/project/qemu-devel/list/?series=226136

 hw/sd/ssi-sd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index 2d08ce4..71911ae 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -178,9 +178,9 @@ static uint32_t ssi_sd_transfer(SSIPeripheral *dev, uint32_t val)
                 s->arglen = 1;
                 s->response[0] = 4;
                 DPRINTF("SD command failed\n");
-            } else if (s->cmd == 58) {
-                /* CMD58 returns R3 response (OCR)  */
-                DPRINTF("Returned OCR\n");
+            } else if (s->cmd == 8 || s->cmd == 58) {
+                /* CMD8/CMD58 returns R3/R7 response */
+                DPRINTF("Returned R3/R7\n");
                 s->arglen = 5;
                 s->response[0] = 1;
                 memcpy(&s->response[1], longresp, 4);
-- 
2.7.4


Re: [PATCH] hw/sd: ssi-sd: Fix SEND_IF_COND (CMD8) response
Posted by Philippe Mathieu-Daudé 4 years, 9 months ago
On 1/26/21 5:43 AM, Bin Meng wrote:
> From: Bin Meng <bin.meng@windriver.com>
> 
> The SEND_IF_COND command (CMD8) response is of format R7, but
> current code returns R1 for CMD8. Fix it.
> 
> Fixes: 775616c3ae8c ("Partial SD card SPI mode support")
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> 
> ---
> When testing with VxWorks driver, this additional issue was exposed.
> It looks like VxWorks has stricter parsing on command responses while
> U-Boot/Linux drivers are all happy with exising QEMU CMD8 response.
> 
> Based on http://patchwork.ozlabs.org/project/qemu-devel/list/?series=226136
> 
>  hw/sd/ssi-sd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>