All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gary Thomas <samoht.yrag@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 2/3][v4] mmc: SEND_OP_COND considers card capabilities (voltage)
Date: Thu, 28 Jul 2011 13:25:48 -0600	[thread overview]
Message-ID: <4E31B7BC.1030907@gmail.com> (raw)
In-Reply-To: <BANLkTinavVJSUvsbFmeZENuCut6cL5=MDA@mail.gmail.com>

On 2011-04-13 05:24, Andy Fleming wrote:
> On Fri, Mar 11, 2011 at 6:01 AM, Raffaele Recalcati
> <lamiaposta71@gmail.com>  wrote:
>> From: Raffaele Recalcati<raffaele.recalcati@bticino.it>
>>
>> The first SEND_OP_COND (CMD1) command added is used to ask card capabilities.
>> After it an AND operation is done between card capabilities and host
>> capabilities (at the moment only for the voltage field).
>> Finally the correct value is sent to the MMC, waiting that the card
>> exits from busy state.
>>
>> Signed-off-by: Raffaele Recalcati<raffaele.recalcati@bticino.it>
>> ---
>>   drivers/mmc/mmc.c |   19 +++++++++++++++++--
>>   include/mmc.h     |    2 ++
>>   2 files changed, 19 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index fc1792a..5bea476 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -351,17 +351,32 @@ sd_send_op_cond(struct mmc *mmc)
>>
>>   int mmc_send_op_cond(struct mmc *mmc)
>>   {
>> -       int timeout = 1000;
>> +       int timeout = 10000;
>>         struct mmc_cmd cmd;
>>         int err;
>>
>>         /* Some cards seem to need this */
>>         mmc_go_idle(mmc);
>>
>> +       /* Asking to the card its capabilities */
>> +       cmd.cmdidx = MMC_CMD_SEND_OP_COND;
>> +       cmd.resp_type = MMC_RSP_R3;
>> +       cmd.cmdarg = 0;
>> +       cmd.flags = 0;
>> +
>> +       err = mmc_send_cmd(mmc,&cmd, NULL);
>> +
>> +       if (err)
>> +               return err;
>> +
>> +       udelay(1000);
>> +
>>         do {
>>                 cmd.cmdidx = MMC_CMD_SEND_OP_COND;
>>                 cmd.resp_type = MMC_RSP_R3;
>> -               cmd.cmdarg = OCR_HCS | mmc->voltages;
>> +               cmd.cmdarg = ((mmc->voltages&
>> +                             (cmd.response[0]&  OCR_VOLTAGE_MASK)) |
>> +                             (cmd.response[0]&  OCR_ACCESS_MODE));
>
>
> My concern here is that OCR_HCS has been dropped. I thought it was
> necessary to query the HCS abilities.
>
> I'm guessing I'm missing something, or that it's not needed, so I will
> apply this patch, and we'll see if anyone has issues.

I just tried this on my eMMC chip (THGBM1G5D2EBAI7) and without the OCR_HCS bit set, the
device gets totally hosed.  Only a power cycle will fix it.

Adding it back like this fixes the problem:
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 21aedba..76117da 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -446,7 +446,7 @@ int mmc_send_op_cond(struct mmc *mmc)
                 cmd.cmdidx = MMC_CMD_SEND_OP_COND;
                 cmd.resp_type = MMC_RSP_R3;
                 cmd.cmdarg = (mmc_host_is_spi(mmc) ? 0 :
-                               (mmc->voltages &
+                               OCR_HCS | (mmc->voltages &
                                 (cmd.response[0] & OCR_VOLTAGE_MASK)) |
                                 (cmd.response[0] & OCR_ACCESS_MODE));
                 cmd.flags = 0;

  parent reply	other threads:[~2011-07-28 19:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11 12:01 [U-Boot] [RFC 0/3][v4] mmc inizialization steps enhanced Raffaele Recalcati
2011-03-11 12:01 ` [U-Boot] [RFC 1/3][v4] mmc: checking status after commands with R1b response Raffaele Recalcati
2011-03-11 12:18   ` Lei Wen
2011-08-06 12:07     ` Marek Vasut
2011-08-06 12:18       ` Lei Wen
2011-03-11 12:01 ` [U-Boot] [RFC 2/3][v4] mmc: SEND_OP_COND considers card capabilities (voltage) Raffaele Recalcati
2011-03-11 12:18   ` Lei Wen
2011-04-13 11:24   ` Andy Fleming
2011-04-14  7:48     ` Raffaele Recalcati
2011-07-28 19:25     ` Gary Thomas [this message]
2011-08-17  2:51       ` Andy Fleming
2011-03-11 12:01 ` [U-Boot] [RFC 3/3][v4] mmc: trace added Raffaele Recalcati

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=4E31B7BC.1030907@gmail.com \
    --to=samoht.yrag@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.