From nobody Wed May 8 22:35:54 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528395039481615.8170543542598; Thu, 7 Jun 2018 11:10:39 -0700 (PDT) Received: from localhost ([::1]:59619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzMs-0004eg-O4 for importer@patchew.org; Thu, 07 Jun 2018 14:10:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzJG-0001wf-J0 for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:06:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQzJF-0004Lg-JV for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:06:54 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:38215) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQzJF-0004LS-Ek; Thu, 07 Jun 2018 14:06:53 -0400 Received: by mail-qk0-x241.google.com with SMTP id y4-v6so7133975qka.5; Thu, 07 Jun 2018 11:06:53 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id s15-v6sm26838414qtc.81.2018.06.07.11.06.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 11:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sz85XgAFXalMbW12R7xOcPRe5Swn41N+qiy1nU84b1o=; b=CR3RYjUJBE7LjNkeuZcyRhjrjmblt2+BH8PP/fs5bQ70JusyN+FyxE3xjqD1HomsQl Sj8fML5FICwM5MC9CytD6JFhm1KHCsCSSR0emt05PVu/8LqDyZzv4uD/bc81+IxyHYnO yV61zsWv3rbgVFHK65blB+HpM5l5fS6DXef+0d14cH71m1btHjJJajASlOB5G/VnMtgH TNyIrcM6IXf7zpzVTuBIXjLB8yuWkAs1FwQ6nO6IenO71v+ITd1/OlYc6D1mrAD+09sA t3n1lNrJlQ74cm1J0gjPuj8SqT/lPT5RjuhfsNd/3GQfIjwUliSV3FIojkMK0S0amfqO 6i4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Sz85XgAFXalMbW12R7xOcPRe5Swn41N+qiy1nU84b1o=; b=fXYrg0dxjgzKSAJYIChQXu8EyM+hp9iKfRfKCJHwrPEOOKQrx0edzr1oNLZMDswaAZ hfYNFXBPWVPi2iHO6YNB34P5SDW4q2aGu8HxMNj8GNc1cltBsVAgoWMCYlaorxB6WGDg s9Ky/C0quruAylsDzHCTF60O3vCNhWdzSyI2PkZfE6hiYh9RXLsPjtvtvw/xXVOCki/P +BWugLgK9JBJtnkk/8iR+lHeZhbzsSC6Pc44AdrJ1yyr/Mz97WPangMU1xXNQTOKup0N 2h7kvWQ9UtYWj0wLmHnhND6yptGztMVxeW1KyOCYWpOlxuhnioog2bwadh8/g+QIQL02 w1DA== X-Gm-Message-State: APt69E0yTcI5Avxhql+fZtSyLLWcnL2yAoKIErYGGTzjlW5ttYvIOnDv R8iqPfCV7zAaAQeWhWHglRQ= X-Google-Smtp-Source: ADUXVKIHH1k7lR/0UgN0V+kIGGOtkMZA4fWBLWIT6u0cOgTSsklwyw0epoXzdDdpHwmjxBdYrtlvxA== X-Received: by 2002:a37:7985:: with SMTP id u127-v6mr2601706qkc.272.1528394812934; Thu, 07 Jun 2018 11:06:52 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell Date: Thu, 7 Jun 2018 15:06:35 -0300 Message-Id: <20180607180641.874-2-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607180641.874-1-f4bug@amsat.org> References: <20180607180641.874-1-f4bug@amsat.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: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH v2 1/7] sdcard: Update the Configuration Register (SCR) to Spec Version 1.10 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: , Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 The initial implementation is based on the Specs v1.10 (see a1bb27b1e98). However the SCR is anouncing the card being v1.01. The new chapters added in version 1.10 are: 4.3.10 Switch function command Switch function command (CMD6) 1 is used to switch or expand memory card functions. [...] This is a new feature, introduced in SD physical Layer Specification Version 1.10. Therefore, cards that are compatible with earlier versions of the spec do not support it. The host shall check the "SD_SPEC" field in the SCR register to recognize what version of the spec the card complies with before using CMD6. It is mandatory for SD memory card of Ver1.10 to support CMD6. 4.3.11 High-Speed mode (25MB/sec interface speed) Though the Rev 1.01 SD memory card supports up to 12.5MB/sec interface speed, the speed of 25MB/sec is necessary to support increasing performance needs of the host and because of memory size which continues to grow. To achieve 25MB/sec interface speed, clock rate is increased to 50MHz and CLK/CMD/DAT signal timing and circuit conditions are reconsidered and changed from Physical Layer Specification Version 1.01. 4.3.12 Command system (This chapter is newly added in version 1.10) SD commands CMD34-37, CMD50, CMD57 are reserved for SD command system expansion via the switch command. [These commands] will be considered as illegal commands (as defined in revision 1.01 of the SD physical layer specification). The SWITCH_FUNCTION is implemented since the first commit, a1bb27b1e98. The 25MB/sec High-Speed mode was already updated in d7ecb867529. The current implementation does not implements CMD34-37, CMD50 and CMD57, thus these commands already return ILLEGAL. With this patch, the SCR register now matches the description of the header: * SD Memory Card emulation as defined in the "SD Memory Card Physical * layer specification, Version 1.10." Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7af19fa06c..e1218d1fb6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -310,8 +310,8 @@ static void sd_ocr_powerup(void *opaque) =20 static void sd_set_scr(SDState *sd) { - sd->scr[0] =3D (0 << 4) /* SCR version 1.0 */ - | 0; /* Spec Versions 1.0 and 1.01 */ + sd->scr[0] =3D (0 << 4) /* SCR structure version 1.0 */ + | 1; /* Spec Version 1.10 */ sd->scr[1] =3D (2 << 4) /* SDSC Card (Security Version 1.01) */ | 0b0101; /* 1-bit or 4-bit width bus modes */ sd->scr[2] =3D 0x00; /* Extended Security is not supported. */ --=20 2.17.1 From nobody Wed May 8 22:35:54 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528395149818470.8731538965901; Thu, 7 Jun 2018 11:12:29 -0700 (PDT) Received: from localhost ([::1]:59629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzOf-0005va-3y for importer@patchew.org; Thu, 07 Jun 2018 14:12:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzJJ-0001y6-CW for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQzJI-0004Nl-EC for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:06:57 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:43061) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQzJI-0004NU-9n; Thu, 07 Jun 2018 14:06:56 -0400 Received: by mail-qk0-x241.google.com with SMTP id g126-v6so7136930qke.10; Thu, 07 Jun 2018 11:06:56 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id s15-v6sm26838414qtc.81.2018.06.07.11.06.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 11:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j57TbYKsq9sZhOTQUMQ9/c4IJj1kN/Gj8wYczr2Piso=; b=dQ9WTUkyk6lq6WCB9sU7COPMInqRFrmXl/Ys5hdxkmfTEhS1dm0ZID1pVY2BDxXdSz r9uRd/A4GzYp7H8YQRASI0T07UdmNIDAC6VcwAKJVIB1wZ/lq4A1yIkF9pyyuokIVLBk wtZCmQNXjnblsRJpcBgNiAinEi9fUDEulf70pjOFoI79xU5z7+8sZJwMbmwvqltRl3A8 s43ydtjr9gPFQzXyGQVpZ26sdy1+Vlxhq1iahCJQjm5XWEcJH9HHfPET0yMBQpRO3SV6 o6lRLAwEHmC/At4gLlKCnFwdO1l7YWbx1i2sGUoJbVbz3/Rlrt3atf90zTXu13vUMN7a x/PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=j57TbYKsq9sZhOTQUMQ9/c4IJj1kN/Gj8wYczr2Piso=; b=dIhuM74N1uAAtYgRwiz3KcVkDe/N3xJzQyH5foHLt0KHOvJhZv7BvNhbfrFUG12PWa T6Fuhb3oqWWjJN/2AD7ZVWr0RX+aqLuitIiIgO7k8Vae2uUmB5hnSDqswU7fLJroooJB fKnyMGl8alc5MUTORvD7XWWYCmj8Cy332WDlXqucvtdncS9wSqqY0SqjKAOIUed+AEdd LYAwFe6HEsrSC+PEdKQhQTNqG1D+P0pHsxdBbO7wRzr/FCqRNbAGWV5eTWrUB5+tqMhg qmuiybAlnegbq0lNku83gv+W29MgtRN1Js+a267bhEFEuO8wOv1gx4BP2kyjJGWrv73y XB6A== X-Gm-Message-State: APt69E2m5lxFmSLwqtCCZPrd7BIjkqbGCgzQkUusMQtCQUv7wbYCfrZH r2/fN7uq0ZKfBz03GZiDfag= X-Google-Smtp-Source: ADUXVKLzQTTk/1x3Hl4bvk2XU3nCO3CBDuARNJZel4dhPdOnIrjvJvVhsSXDQR+2ua/G07yzzCNE5Q== X-Received: by 2002:a37:6216:: with SMTP id w22-v6mr2506419qkb.312.1528394815880; Thu, 07 Jun 2018 11:06:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell Date: Thu, 7 Jun 2018 15:06:36 -0300 Message-Id: <20180607180641.874-3-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607180641.874-1-f4bug@amsat.org> References: <20180607180641.874-1-f4bug@amsat.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: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH v2 2/7] sdcard: Allow commands valid 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: , Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From the "Physical Layer Simplified Specification Version 1.10" Chapter 7.3 "SPI Mode Transaction Packets" Table 57: "Commands and arguments" Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Alistair Francis --- hw/sd/sd.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e1218d1fb6..80e70dd93e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -960,8 +960,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDR= equest req) return sd_illegal; =20 case 6: /* CMD6: SWITCH_FUNCTION */ - if (sd->spi) - goto bad_cmd; switch (sd->mode) { case sd_data_transfer_mode: sd_function_switch(sd, req.arg); @@ -1190,9 +1188,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) =20 /* Block write commands (Class 4) */ case 24: /* CMD24: WRITE_SINGLE_BLOCK */ - if (sd->spi) { - goto unimplemented_spi_cmd; - } switch (sd->state) { case sd_transfer_state: /* Writing in SPI mode not implemented. */ @@ -1217,9 +1212,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ - if (sd->spi) { - goto unimplemented_spi_cmd; - } switch (sd->state) { case sd_transfer_state: /* Writing in SPI mode not implemented. */ @@ -1259,9 +1251,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 27: /* CMD27: PROGRAM_CSD */ - if (sd->spi) { - goto unimplemented_spi_cmd; - } switch (sd->state) { case sd_transfer_state: sd->state =3D sd_receivingdata_state; @@ -1371,9 +1360,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) =20 /* Lock card commands (Class 7) */ case 42: /* CMD42: LOCK_UNLOCK */ - if (sd->spi) { - goto unimplemented_spi_cmd; - } switch (sd->state) { case sd_transfer_state: sd->state =3D sd_receivingdata_state; --=20 2.17.1 From nobody Wed May 8 22:35:54 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528394929882993.1864596549891; Thu, 7 Jun 2018 11:08:49 -0700 (PDT) Received: from localhost ([::1]:59604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzL6-00035s-Ug for importer@patchew.org; Thu, 07 Jun 2018 14:08:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzJO-00023g-Nh for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQzJL-0004Q5-Hr for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:02 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:38896) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQzJL-0004Pg-DB; Thu, 07 Jun 2018 14:06:59 -0400 Received: by mail-qt0-x242.google.com with SMTP id x34-v6so10792330qtk.5; Thu, 07 Jun 2018 11:06:59 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id s15-v6sm26838414qtc.81.2018.06.07.11.06.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 11:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aR0TzY61TBen/2Yts4FTsgJ7yooXG4cIjBrvhGHVywY=; b=qT8IJyGAXz9+TOQuEXjuRs0dcBpzef1Cf4l2fCM70an2NS1Q2LD4fUuub/NnlV1+Go G5Q/FVpZAm57PzcOb5jcHnxSKB0+baxIk2ylh1HQ9VzwKjkyNrD3vIwgzSOoKgnHw4c1 Uvt3cAPiBQf5Pd/5uZi8MaodQaej/37BT/HM9Ykmem6leL8wsCj4ivXi/oxcym/R+LaB lo6ndbYVusEjny2yUGb+GTXFxzpCUQbmFL17gqnDOHA9MTEj3i9ptzzS0IFfG1BTQ7U0 ioLOlj8L6S++I7vF8O3dgHSPg+FXZQeH1Q2//BvkYa/uU2dW4nyt42WLv5hwOWR+M9aM J3DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=aR0TzY61TBen/2Yts4FTsgJ7yooXG4cIjBrvhGHVywY=; b=mpseXGQWXcPnHsiYLgkPUMDfc5pwf6DK//rBpPxJPGGNu4bx4zUjAvWVikjO791XbK Uannkz3/jvgF/bACxcNBRWU1SXjPnvdTPAEYVvztOoFr41M1fpR0vNgFxt/r9WgQchXw bOl3zlIv68tsYJkEnCU6pFQBBdQIOAi5RXwQOrRMVeif8pdOwSnByHOjUAGRI4NimAqf fqOy2cp4liXFkShWlnbqT8e3llW3xkSGN4+Jm4xaaXi4PBXOUH901fC0pzR5LvxVA/97 73r1Wq1UZzvmxNR1qhrT9A48wN40mLKmpMQxfpJJ6gRXUsOn3MasG7adPMDBnCamUGyu TONA== X-Gm-Message-State: APt69E3PLyDzHsYzhnJ/BguVDxnUh6CNr6AQl0MTwgE8MU2NL7BzR/hL S9huOb6XO+x8addNwSuWFYc= X-Google-Smtp-Source: ADUXVKIMsTl4lpCsdwmsvNTxou6V87NPvYUCUmWkNE++4elWvBkgTrg7iakKkl391lO242HXExJzXw== X-Received: by 2002:ac8:2a46:: with SMTP id l6-v6mr2923606qtl.118.1528394818885; Thu, 07 Jun 2018 11:06:58 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell Date: Thu, 7 Jun 2018 15:06:37 -0300 Message-Id: <20180607180641.874-4-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607180641.874-1-f4bug@amsat.org> References: <20180607180641.874-1-f4bug@amsat.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: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v2 3/7] sdcard: Add a 'spec_version' property, default to Spec v2.00 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: , Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 As of this commit, the Spec v1 is not working, and all controllers expect the cards to be conformant to Spec v2. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- include/hw/sd/sd.h | 5 +++++ hw/sd/sd.c | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 9bdb3c9285..7c6ad3c8f1 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -54,6 +54,11 @@ #define APP_CMD (1 << 5) #define AKE_SEQ_ERROR (1 << 3) =20 +enum SDPhySpecificationVersion { + SD_PHY_SPECv1_10_VERS =3D 1, + SD_PHY_SPECv2_00_VERS =3D 2, +}; + typedef enum { SD_VOLTAGE_0_4V =3D 400, /* currently not supported */ SD_VOLTAGE_1_8V =3D 1800, diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 80e70dd93e..1ae085de69 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1,9 +1,10 @@ /* * SD Memory Card emulation as defined in the "SD Memory Card Physical - * layer specification, Version 1.10." + * layer specification, Version 2.00." * * Copyright (c) 2006 Andrzej Zaborowski * Copyright (c) 2007 CodeSourcery + * Copyright (c) 2018 Philippe Mathieu-Daud=C3=A9 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -91,6 +92,7 @@ struct SDState { uint8_t sd_status[64]; =20 /* Configurable properties */ + uint8_t spec_version; BlockBackend *blk; bool spi; =20 @@ -310,8 +312,12 @@ static void sd_ocr_powerup(void *opaque) =20 static void sd_set_scr(SDState *sd) { - sd->scr[0] =3D (0 << 4) /* SCR structure version 1.0 */ - | 1; /* Spec Version 1.10 */ + sd->scr[0] =3D 0 << 4; /* SCR structure version 1.0 */ + if (sd->spec_version =3D=3D SD_PHY_SPECv1_10_VERS) { + sd->scr[0] |=3D 1; /* Spec Version 1.10 */ + } else { + sd->scr[0] |=3D 2; /* Spec Version 2.00 */ + } sd->scr[1] =3D (2 << 4) /* SDSC Card (Security Version 1.01) */ | 0b0101; /* 1-bit or 4-bit width bus modes */ sd->scr[2] =3D 0x00; /* Extended Security is not supported. */ @@ -2058,6 +2064,15 @@ static void sd_realize(DeviceState *dev, Error **err= p) =20 sd->proto_name =3D sd->spi ? "SPI" : "SD"; =20 + switch (sd->spec_version) { + case SD_PHY_SPECv1_10_VERS + ... SD_PHY_SPECv2_00_VERS: + break; + default: + error_setg(errp, "Invalid SD card Spec version: %u", sd->spec_vers= ion); + return; + } + if (sd->blk && blk_is_read_only(sd->blk)) { error_setg(errp, "Cannot use read-only drive as SD card"); return; @@ -2074,6 +2089,8 @@ static void sd_realize(DeviceState *dev, Error **errp) } =20 static Property sd_properties[] =3D { + DEFINE_PROP_UINT8("spec_version", SDState, + spec_version, SD_PHY_SPECv2_00_VERS), DEFINE_PROP_DRIVE("drive", SDState, blk), /* We do not model the chip select pin, so allow the board to select * whether card should be in SSI or MMC/SD mode. It is also up to the --=20 2.17.1 From nobody Wed May 8 22:35:54 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528395248877359.63831100303014; Thu, 7 Jun 2018 11:14:08 -0700 (PDT) Received: from localhost ([::1]:59634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzQ6-0006wg-Mm for importer@patchew.org; Thu, 07 Jun 2018 14:13:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzJP-00025T-PW for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQzJO-0004Sx-TO for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:03 -0400 Received: from mail-qt0-x22b.google.com ([2607:f8b0:400d:c0d::22b]:37498) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQzJO-0004SX-P5; Thu, 07 Jun 2018 14:07:02 -0400 Received: by mail-qt0-x22b.google.com with SMTP id q13-v6so10799766qtp.4; Thu, 07 Jun 2018 11:07:02 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id s15-v6sm26838414qtc.81.2018.06.07.11.06.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 11:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uuolPF/qep1do+QHIzhyDQZJtmzmVRMDR5bXzePYNiw=; b=lMlkTjjjIlmuyuW/Mhkkk7d/md6dgOYNWayG0NGUH6T/EEcZ/m/9sQWqmJA30s1feb duIteO9cykOGjGt07OwkMjlWo8s163itOmiJ5+JxL4MUpAIFx3aXNHOEzBd04jFZsu4H ujMmzm7Jfj5gtply54vOhL+Hd8cGyRvQwZUCayLhG5X6tcCdrrvRlRjlcMIybIoXC17N bVon3n6SFiPuLgnV1CGiGQ71s6T0F1OtkTbX6ThVzXq++D30DT+TTpRpDveNH5TIGd5K jzJndl6NeSB3DYqGu9cyKStRtjZNWUJ7M2xKnsHV9WAiVFvM1WVGBGc31o83NceWegfZ T3GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=uuolPF/qep1do+QHIzhyDQZJtmzmVRMDR5bXzePYNiw=; b=oApoCU8XnZD9/IDtbMhHkda7T5t9tOlnDGLf54EO0Lz0/tzKRuJfrFfVyH40iOe9OZ FAT8mWjhgZxIRg4hz/NPsgpw4zY4gApWS/Guilc8dN85MIeomftzSGr2ep32h9R63au3 L09otgxYhWhwoz+H7ZKHsW0osTVGBUAHdj0b9Vz1PRmLqHI/tQ0PKpkTyWLVZbpbXhnU 35j5TdQGHZTlejb7ZAaQuBxRwh38uY5RZ5OFZ4ZBtZsoQF5WBK42ICq2Xar9J8M1ojhV ov0y7KqHbBJK0IilkigK1Iiwmhm6WbEWw735ubDrt8lq6oeG10Zb/W8SN3N7K502KCHv dzkw== X-Gm-Message-State: APt69E1ufQVVfSCeNAiqyiJ4JSYzdVBWl6FARzXQvY6xURtFvSETRplo y/NVCVqo9L2pNu7BwMxZZZk= X-Google-Smtp-Source: ADUXVKIYN+N6DrXKxbr+vSqiFz/UVvDZ2K35RQRE/KE90PC6kEFplzgDeGUdkaPGnfyzEN3G7fD3hQ== X-Received: by 2002:ac8:23d4:: with SMTP id r20-v6mr2773538qtr.17.1528394822312; Thu, 07 Jun 2018 11:07:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell Date: Thu, 7 Jun 2018 15:06:38 -0300 Message-Id: <20180607180641.874-5-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607180641.874-1-f4bug@amsat.org> References: <20180607180641.874-1-f4bug@amsat.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: 2607:f8b0:400d:c0d::22b Subject: [Qemu-devel] [PATCH v2 4/7] sdcard: Disable SEND_IF_COND (CMD8) for Spec v1 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: , Cc: Peter Crosthwaite , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-arm@nongnu.org, Paul Brook , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 CMD8 is "Reserved" in Spec v1.10. Spec v2.00 introduces the SEND_IF_COND command: 6.4.1 Power Up CMD8 is newly added in the Physical Layer Specification Version 2.00 to support multiple voltage ranges and used to check whether the card supports supplied voltage. The version 2.00 or later host shall issue CMD8 and verify voltage before card initialization. The host that does not support CMD8 shall supply high voltage range. Message-Id: 201204252110.20873.paul@codesourcery.com Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1ae085de69..3ec0f71f24 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1018,7 +1018,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 8: /* CMD8: SEND_IF_COND */ - /* Physical Layer Specification Version 2.00 command */ + if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { + break; + } if (sd->state !=3D sd_idle_state) { break; } --=20 2.17.1 From nobody Wed May 8 22:35:54 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528394943891283.1700223014856; Thu, 7 Jun 2018 11:09:03 -0700 (PDT) Received: from localhost ([::1]:59605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzLL-0003E3-5T for importer@patchew.org; Thu, 07 Jun 2018 14:09:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzJS-00028a-QP for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQzJR-0004Uh-LR for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:06 -0400 Received: from mail-qt0-x22d.google.com ([2607:f8b0:400d:c0d::22d]:38214) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQzJR-0004U9-Fi; Thu, 07 Jun 2018 14:07:05 -0400 Received: by mail-qt0-x22d.google.com with SMTP id x34-v6so10792717qtk.5; Thu, 07 Jun 2018 11:07:05 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id s15-v6sm26838414qtc.81.2018.06.07.11.07.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 11:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p98FJDHXqtQFnoFIsChTFplRsIwsE6rDW5LxAt+70bk=; b=eHKgHOD1sFeaYlAO6ipnc86EjwDppKU1SaHdnK0PnxrhXneCQ+nls4p0gVvC1k+JKD H0fpSAl/EyujPkkm6rmdfZlmPj7PzEUMdNgy58w85NB/Cv71TsVCwxWYz9KmOhs6GKTa qpQaw3BLdeLvFLBrEcFvFSUjkfGAzuoEgGywKGE/0m0adBIocBprm9gCcLFlICIQldYz bDNWlBdXefBYqXFv4PTFtvgpPyGRStm6s5G7Tao7owIztSLCQ/XkI91ydD5fPupjGNQp jVCqH+YqUWP3wwGeGeckWwSkFVwCzqtGzCK5pqr0xr3kHEOE813nGRbjrL9IJtIWlpp1 Blpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=p98FJDHXqtQFnoFIsChTFplRsIwsE6rDW5LxAt+70bk=; b=tdVM+8/mfluir7lhqbVXqAPWxWrEkz9LynAk4zKbBygK++DFAQBxFLsAg9SFProD6e FkvEJmxRKQHgbeQGYr5yuPaF6+kS7L9bhm4/8AmZGnNiBWW/zZHW3DBzfZIORvmqceLP xcnFUxsqJwJyUIyd+i7la22lQjoK4EdlY5PFUqLF1N78FXEG3dHUcyNXHhHbWhILdQoC YRabtoOBYq2l/QM/jy01UbvoEZ9gzx9U2MFry83x12jHT+Dn894xZ5PEwDM5TOYOiF2E BMXE6kwSB44UY1+oj59veY+EBomb26OGFXb1aJkb2U4TO6OXJWEUi5cSv3LvVTJiGQcX 7gVg== X-Gm-Message-State: APt69E2LLNKKfKqGMmHj7AEvxY+CR/RpY/DdYwth5A03h1UC4xX/bXNf 5dzxe6bT9Q7xYi1TJCMvu9g= X-Google-Smtp-Source: ADUXVKIA0O+dEOhsO7kAueLvu4YwiS4QiTNHWkU6KPK6cB3LdVnAGdkGCOb3MfnSiz1xMRkU7iIeHw== X-Received: by 2002:ac8:358a:: with SMTP id k10-v6mr2752341qtb.248.1528394825013; Thu, 07 Jun 2018 11:07:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell Date: Thu, 7 Jun 2018 15:06:39 -0300 Message-Id: <20180607180641.874-6-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607180641.874-1-f4bug@amsat.org> References: <20180607180641.874-1-f4bug@amsat.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: 2607:f8b0:400d:c0d::22d Subject: [Qemu-devel] [PATCH v2 5/7] sdcard: Reflect when the Spec v3 is supported in the Config Register (SCR) 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: , Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- include/hw/sd/sd.h | 1 + hw/sd/sd.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 7c6ad3c8f1..b865aafc33 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -57,6 +57,7 @@ enum SDPhySpecificationVersion { SD_PHY_SPECv1_10_VERS =3D 1, SD_PHY_SPECv2_00_VERS =3D 2, + SD_PHY_SPECv3_01_VERS =3D 3, }; =20 typedef enum { diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 3ec0f71f24..4e49a3827a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -316,11 +316,14 @@ static void sd_set_scr(SDState *sd) if (sd->spec_version =3D=3D SD_PHY_SPECv1_10_VERS) { sd->scr[0] |=3D 1; /* Spec Version 1.10 */ } else { - sd->scr[0] |=3D 2; /* Spec Version 2.00 */ + sd->scr[0] |=3D 2; /* Spec Version 2.00 or Version 3.0X */ } sd->scr[1] =3D (2 << 4) /* SDSC Card (Security Version 1.01) */ | 0b0101; /* 1-bit or 4-bit width bus modes */ sd->scr[2] =3D 0x00; /* Extended Security is not supported. */ + if (sd->spec_version >=3D SD_PHY_SPECv3_01_VERS) { + sd->scr[2] |=3D 1 << 7; /* Spec Version 3.0X */ + } sd->scr[3] =3D 0x00; /* reserved for manufacturer usage */ sd->scr[4] =3D 0x00; @@ -2068,7 +2071,7 @@ static void sd_realize(DeviceState *dev, Error **errp) =20 switch (sd->spec_version) { case SD_PHY_SPECv1_10_VERS - ... SD_PHY_SPECv2_00_VERS: + ... SD_PHY_SPECv3_01_VERS: break; default: error_setg(errp, "Invalid SD card Spec version: %u", sd->spec_vers= ion); --=20 2.17.1 From nobody Wed May 8 22:35:54 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528395065880459.3761478698368; Thu, 7 Jun 2018 11:11:05 -0700 (PDT) Received: from localhost ([::1]:59620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzNJ-0004xE-06 for importer@patchew.org; Thu, 07 Jun 2018 14:11:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzJX-0002DJ-Fs for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQzJU-0004W9-8s for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:11 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:35001) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQzJU-0004Vs-4W; Thu, 07 Jun 2018 14:07:08 -0400 Received: by mail-qt0-x243.google.com with SMTP id s9-v6so10799337qtg.2; Thu, 07 Jun 2018 11:07:08 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id s15-v6sm26838414qtc.81.2018.06.07.11.07.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 11:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jac/D2I0BeGJ5N/WGcM7hCJ30SgLrQ/6pcubjDWhWFw=; b=bHnXy4XQKFtpADUOkL7Q01IVLizwHQPoOQSXoWRLigQh9i0pqFzjXTi+A8wFFHklNc jU+0iKMP2c6K7IisyldG5EH5IhE5o1wWDk9JBBBlWMwK4PrKn1nN+tBO9aizolum7RMv gbQQK7Pb/itMN6wQd2A3cNv78USrRPjqqLPhj2VR30lJ2S+HTpoHx8OO/SXASOayrt8n b0kUVh9vTvjoU61X0PpNVz8qImfNT/1KsQFMMlhaB2hXqOJKSerx9TCK6fm7zRuwiVS7 6dzQCwDL4rEl43mxgzu2/nAJicbuak1G48c9W7EjVjvsJhyFIdxAX7RW/lxOjtPxruTo q7PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jac/D2I0BeGJ5N/WGcM7hCJ30SgLrQ/6pcubjDWhWFw=; b=b1SwuNyY1IGQcg6WVHD/ztC3UGU6N2AmOBaG5z1Lo11ia9Gwgai7veVCBmrUPmrc+q qAhi9Vod1LzbOAI/2tk0UvbbnrtiX5VeMVmfsTRn+bj+Mc/XpSM/KuxOwijUPLahFd/+ eh34mPd2jUmG4kj4Qz06wk03bYAK+xBNhW7FrFaucYOhbOyILyFeOIecn5OPSEF1wvKh LeRx4Set2EUBOepsJJiyuO5u7PNTm74jXgFV1YJYr3n6AAag5vvuFLbyMBj+r2D0ifOt pepCVEK5vsSTsNUJVS1nfYGoLAQ3gG+nJOeRLTQLQQ65b2ZjSiGMZE1iKsZ7fEpojOaS PFzQ== X-Gm-Message-State: APt69E0MZ8bsWh4gQo/fVxBeunENgoCQccBIMIRAKMBwfA/xezQBRnbl zQcYYhymYNcaTCnOihZs+RC/F9/+ X-Google-Smtp-Source: ADUXVKJEBOe1zhNPTu8AqsZG2FvTVbIrA1phAP/MP7FAOS3gS4N3XEp7kJFh3xyXUMKiFRF+FOP3JQ== X-Received: by 2002:a0c:b116:: with SMTP id q22-v6mr2702808qvc.19.1528394827733; Thu, 07 Jun 2018 11:07:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell Date: Thu, 7 Jun 2018 15:06:40 -0300 Message-Id: <20180607180641.874-7-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607180641.874-1-f4bug@amsat.org> References: <20180607180641.874-1-f4bug@amsat.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: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH v2 6/7] sdcard: Disable CMD19/CMD23 for Spec v2 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: , Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 These commands got introduced by Spec v3 (see 0c3fb03f7ec and 4481bbc79d2). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4e49a3827a..540bccb8d1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1179,6 +1179,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ + if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { + break; + } if (sd->state =3D=3D sd_transfer_state) { sd->state =3D sd_sendingdata_state; sd->data_offset =3D 0; @@ -1187,6 +1190,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 23: /* CMD23: SET_BLOCK_COUNT */ + if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { + break; + } switch (sd->state) { case sd_transfer_state: sd->multi_blk_cnt =3D req.arg; --=20 2.17.1 From nobody Wed May 8 22:35:54 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528395324410918.4897658679608; Thu, 7 Jun 2018 11:15:24 -0700 (PDT) Received: from localhost ([::1]:59645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzRT-0007vQ-KI for importer@patchew.org; Thu, 07 Jun 2018 14:15:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQzJY-0002Ec-VG for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQzJX-0004Xo-Jh for qemu-devel@nongnu.org; Thu, 07 Jun 2018 14:07:12 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:36742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQzJX-0004XT-Ed; Thu, 07 Jun 2018 14:07:11 -0400 Received: by mail-qt0-x241.google.com with SMTP id o9-v6so10787092qtp.3; Thu, 07 Jun 2018 11:07:11 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id s15-v6sm26838414qtc.81.2018.06.07.11.07.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 11:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lOoU4srSGzyMHA96IQ33DE0CD0Wkm6Mltfv0GmandPk=; b=FIyyMatuf2qOGsxs5zqZ3ottgobg6rBBYMJRBONnJB+hp5BAcIJdXNSsNw3n9EZ4YA Vn64+Sv+0oZR7ccyQrqquJ6yBln6BkowYG1iV95HmZAX9tegzlTvMCxCFixwjag5Mp6j yg+BZjGJ2YnIgVQ3C89bRKD9ocAI9mPHhRuhXvLn1P7HWkaALYvKHGiO6OVHapII8Xb9 2ZJKVcGdeZBycV3l4pELyItEmJDz97+DZFFjQt2MmtXAXxP42QboHAD0bbs1DPeu3GyR X8Ay3oJWMXpT9b2PDz07n/ptjGK2wSHfarWd6+Gbq+N9MepgK1Oc5FLauxiBc9ttkgvz qTPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=lOoU4srSGzyMHA96IQ33DE0CD0Wkm6Mltfv0GmandPk=; b=iFna54Rl5MF9KhBuSnvNFwi/goiSALLjSif1nZuTIJtJGobsgRQnIFPdH10DB4r0q1 qHDP/hkKO7hxS5An/VFNSeYefKJHkAu4Ee5B4huKnn0AIoSYH85QMgbWTMMOLX82sBPs 9jbD6eQYREl/VeaqjChI0+6py8PO4POIZdMvsCjW+pGwndzUucfvYQnCpyc6zyR+Myt7 WcgFlhb62x5bsgsA8oxLtfS+8vC4I441PT1LHuE0GIDY4Z7uXnL+0ulQjWUnMbgsLBx8 EruSesGqSBhANbx2oMAM9d5doJeaAWhUDr8zPNSjBUa+HdMANHMvKe3z6EhCbaK85Ox5 +Kcg== X-Gm-Message-State: APt69E1dVgvadwXoCrCt3GNpW6OTdlQYz0MVGzfS3G/uemY8p/KbWu3W XNvWGSuk66dYw6TyGyFiIN4= X-Google-Smtp-Source: ADUXVKLPXXmh5Yuu1PUs0ZKyUWN7p3I2j5KJLP7hj+TUXwRhXsJyUQFDZN7Z570qm8/GqARTERIijA== X-Received: by 2002:ac8:3347:: with SMTP id u7-v6mr2783799qta.195.1528394830916; Thu, 07 Jun 2018 11:07:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell , Thomas Huth Date: Thu, 7 Jun 2018 15:06:41 -0300 Message-Id: <20180607180641.874-8-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607180641.874-1-f4bug@amsat.org> References: <20180607180641.874-1-f4bug@amsat.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: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [RFC PATCH v2 7/7] hw/sd/ssi-sd: Force cards connected in SPI mode to use Spec v1.10 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: , Cc: Paolo Bonzini , Peter Crosthwaite , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Due to physical restriction in SPI mode the maximum transfer speed is limited. All the extensions added after Spec v3 are simply not supported in SPI mode: 7.1 Introduction The SPI mode consists of a secondary communication protocol that is offered by Flash-based SD Memory Cards. This mode is a subset of the SD Memory Card protocol, designed to communicate with a SPI channel, commonly found in Motorola's (and lately a few other vendors') microcontrollers. The interface is selected during the first reset command after power up (CMD0) and cannot be changed once the part is powered on. The SPI standard defines the physical link only, and not the complete data transfer protocol. The SD Memory Card SPI implementation uses a subset of the SD Memory Card protocol and command set. The advantage of the SPI mode is the capability of using an off-the-shelf host, hence reducing the design-in effort to minimum. The disadvantage is the loss of performance of the SPI mode versus SD mode (e.g. Single data line and hardware CS signal per card). The commands and functions in SD mode defined after the Version 2.00 are not supported in SPI mode. The card may respond to the commands and functions even if the card is in SPI mode but host should not use them in SPI mode. Some firmwares use the CMD8 in SPI mode to poll which Spec version the SD card supports. 7.2.1 Mode Selection and Initialization (SPI mode) The SD Card is powered up in the SD mode. It will enter SPI mode if the CS signal is asserted (negative) during the reception of the reset command (CMD0). If the card recognizes that the SD mode is required it will not respond to the command and remain in the SD mode. If SPI mode is required, the card will switch to SPI and respond with the SPI mode R1 response. The only way to return to the SD mode is by entering the power cycle. In SPI mode, the SD Card protocol state machine in SD mode is not observed. All the SD Card commands supported in SPI mode are always available. [...] If the card indicates an illegal command, the card is legacy and does not support CMD8. If the card supports CMD8 and can operate on the supplied voltage, the response echoes back the supply voltage and the check pattern that were set in the command argument. The NuttX RTOS use it too: /* Check for SDHC Version 2.x. CMD 8 is reserved on SD version 1.0 and * MMC. */ finfo("Send CMD8\n"); result =3D mmcsd_sendcmd(slot, &g_cmd8, 0x1aa); if (result =3D=3D MMCSD_SPIR1_IDLESTATE) ... /* Check for SDC version 1.x or MMC */ else ... See https://bitbucket.org/nuttx/nuttx/src/nuttx-7.25/drivers/mmcsd/mmcsd_sp= i.c?mmcsd_spi.c-1645#mmcsd_spi.c-1645 The Stellaris LM3S6965EVB board is the only model using SD cards in SPI mode. The firmware found to work with the board expect the card to be following Spec v1 to work, and is the only one stressing the v1 code path of the SD card model. Thus it seems clever to restrict SPI connected cards to use Spec v1. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- This change would be better in the lm3s6965evb_init() rathar than here in ssi-sd. As suggested by Peter and Thomas here: http://lists.nongnu.org/archive/html/qemu-devel/2018-05/msg06616.html We can use -device sd-card,spec_version=3D1 to avoid this change. $ arm-softmmu/qemu-system-arm \ -M lm3s6965evb -nodefaults \ -serial stdio \ -kernel sd_card.bin \ -drive file=3Dsdcard.img,id=3Dmycard,if=3Dnone \ -device sd-card,spi=3Dtrue,spec_version=3D1,drive=3Dmycard=20 qemu-system-arm: warning: nic stellaris_enet.0 has no peer SD Card Example Program Type 'help' for help. /> ls Open listing ----A 2012/04/25 17:44 12 README.TXT 1 File(s), 12 bytes total 0 Dir(s), 61182K bytes free /> cat README.TXT Hello World />=20 Even if there are still 2 cards... (qemu) info qtree bus: main-system-bus type System dev: pl022, id "" gpio-out "sysbus-irq" 1 mmio 0000000040008000/0000000000001000 bus: ssi type SSI dev: ssd0323, id "" gpio-in "" 1 gpio-in "ssi-gpio-cs" 1 dev: ssi-sd, id "" gpio-in "ssi-gpio-cs" 1 bus: sd-bus type sd-bus dev: sd-card, id "" spec_version =3D 1 (0x1) drive =3D "mycard" spi =3D true dev: sd-card, id "" spec_version =3D 2 (0x2) drive =3D "" spi =3D true hw/sd/ssi-sd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c index 96542ecd62..82470a12e2 100644 --- a/hw/sd/ssi-sd.c +++ b/hw/sd/ssi-sd.c @@ -252,6 +252,8 @@ static void ssi_sd_realize(SSISlave *d, Error **errp) /* FIXME use a qdev drive property instead of drive_get_next() */ dinfo =3D drive_get_next(IF_SD); carddev =3D qdev_create(&s->sdbus.qbus, TYPE_SD_CARD); + object_property_set_uint(OBJECT(carddev), + SD_PHY_SPECv1_10_VERS, "spec_version", &err); if (dinfo) { qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), = &err); } --=20 2.17.1