qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Alistair Francis <alistair@alistair23.me>,
	Thomas Huth <thuth@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>
Subject: Re: [Qemu-devel] [RFC PATCH v2 7/7] hw/sd/ssi-sd: Force cards connected in SPI mode to use Spec v1.10
Date: Fri, 8 Jun 2018 13:13:31 +0100	[thread overview]
Message-ID: <CAFEAcA_9e6_=2doj0_uJCDEWiho0WqnAU6SXhdh--Yeb7m++nw@mail.gmail.com> (raw)
In-Reply-To: <20180607180641.874-8-f4bug@amsat.org>

On 7 June 2018 at 19:06, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> 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:

You say here that SPI mode doesn't support extensions added
"after spec v3"...

>   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.

...but here quote the spec which says that commands defined after
version 2.00 are not supported in SPI mode...

and then the patch itself enforces spec 1.10, rather than 2.
So I'm confused.

> 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 = mmcsd_sendcmd(slot, &g_cmd8, 0x1aa);
>     if (result == 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_spi.c?mmcsd_spi.c-1645#mmcsd_spi.c-1645

This seems reasonable guest behaviour, and it's what the spec says
to do. Why do we need to enforce 1.10 to get things to work?

thanks
-- PMM

  reply	other threads:[~2018-06-08 12:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 18:06 [Qemu-devel] [PATCH v2 0/7] sdcard: cleanup the SD_SPEC version Philippe Mathieu-Daudé
2018-06-07 18:06 ` [Qemu-devel] [PATCH v2 1/7] sdcard: Update the Configuration Register (SCR) to Spec Version 1.10 Philippe Mathieu-Daudé
2018-06-07 18:06 ` [Qemu-devel] [PATCH v2 2/7] sdcard: Allow commands valid in SPI mode Philippe Mathieu-Daudé
2018-06-07 18:06 ` [Qemu-devel] [PATCH v2 3/7] sdcard: Add a 'spec_version' property, default to Spec v2.00 Philippe Mathieu-Daudé
2018-06-07 18:06 ` [Qemu-devel] [PATCH v2 4/7] sdcard: Disable SEND_IF_COND (CMD8) for Spec v1 Philippe Mathieu-Daudé
2018-06-07 18:06 ` [Qemu-devel] [PATCH v2 5/7] sdcard: Reflect when the Spec v3 is supported in the Config Register (SCR) Philippe Mathieu-Daudé
2018-06-07 18:06 ` [Qemu-devel] [PATCH v2 6/7] sdcard: Disable CMD19/CMD23 for Spec v2 Philippe Mathieu-Daudé
2018-06-07 18:06 ` [Qemu-devel] [RFC PATCH v2 7/7] hw/sd/ssi-sd: Force cards connected in SPI mode to use Spec v1.10 Philippe Mathieu-Daudé
2018-06-08 12:13   ` Peter Maydell [this message]
2018-06-07 18:09 ` [Qemu-devel] [PATCH v2 0/7] sdcard: cleanup the SD_SPEC version Philippe Mathieu-Daudé
2018-06-08 12:14 ` Peter Maydell
2018-06-08 14:43   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA_9e6_=2doj0_uJCDEWiho0WqnAU6SXhdh--Yeb7m++nw@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=alistair@alistair23.me \
    --cc=crosthwaite.peter@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).