From nobody Wed Apr 16 17:29:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519314093679886.8732030315529; Thu, 22 Feb 2018 07:41:33 -0800 (PST) Received: from localhost ([::1]:39067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoszx-0003rt-OA for importer@patchew.org; Thu, 22 Feb 2018 10:41:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eosir-00056Y-IN for qemu-devel@nongnu.org; Thu, 22 Feb 2018 10:23:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eosiq-0001x0-J9 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 10:23:49 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:46618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eosiq-0001vB-B0 for qemu-devel@nongnu.org; Thu, 22 Feb 2018 10:23:48 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eosip-00026v-6L for qemu-devel@nongnu.org; Thu, 22 Feb 2018 15:23:47 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 22 Feb 2018 15:23:03 +0000 Message-Id: <20180222152307.7499-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180222152307.7499-1-peter.maydell@linaro.org> References: <20180222152307.7499-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 28/32] sdcard: handles more commands in SPI mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-id: 20180215221325.7611-13-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/sd/sd.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 34080f0e4c..ff7ace3491 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1386,9 +1386,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, =20 /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ - if (sd->rca !=3D rca) - return sd_r0; - + if (!sd->spi) { + if (sd->rca !=3D rca) { + return sd_r0; + } + } sd->expecting_acmd =3D true; sd->card_status |=3D APP_CMD; return sd_r1; @@ -1408,6 +1410,18 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, } break; =20 + case 58: /* CMD58: READ_OCR (SPI) */ + if (!sd->spi) { + goto bad_cmd; + } + return sd_r3; + + case 59: /* CMD59: CRC_ON_OFF (SPI) */ + if (!sd->spi) { + goto bad_cmd; + } + goto unimplemented_spi_cmd; + default: bad_cmd: qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); @@ -1431,6 +1445,9 @@ static sd_rsp_type_t sd_app_command(SDState *sd, sd->card_status |=3D APP_CMD; switch (req.cmd) { case 6: /* ACMD6: SET_BUS_WIDTH */ + if (sd->spi) { + goto unimplemented_spi_cmd; + } switch (sd->state) { case sd_transfer_state: sd->sd_status[0] &=3D 0x3f; @@ -1565,6 +1582,12 @@ static sd_rsp_type_t sd_app_command(SDState *sd, default: /* Fall back to standard commands. */ return sd_normal_command(sd, req); + + unimplemented_spi_cmd: + /* Commands that are recognised but not yet implemented in SPI mod= e. */ + qemu_log_mask(LOG_UNIMP, "SD: CMD%i not implemented in SPI mode\n", + req.cmd); + return sd_illegal; } =20 qemu_log_mask(LOG_GUEST_ERROR, "SD: ACMD%i in a wrong state\n", req.cm= d); --=20 2.16.1