Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Ricky WU <ricky_wu@realtek.com>
To: Avri Altman <avri.altman@wdc.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>
Subject: RE: [PATCH v2 01/10] mmc: sd: SDUC Support Recognition
Date: Fri, 9 Aug 2024 09:53:57 +0000	[thread overview]
Message-ID: <9353f3aec3e846dd9075ada858d44fd4@realtek.com> (raw)
In-Reply-To: <20240807060309.2403023-2-avri.altman@wdc.com>

> 
> ACMD21 was extended to support the host-card handshake during initialization.

Is ACMD41?

> The card expects that the HCS & HO2T bits to be set in the command
> argument, and sets the applicable bits in the R3 returned response.  On the
> contrary, if a SDUC card is inserted to a non-supporting host, it will never
> respond to this ACMD21 until eventually, the host will timed out and give up.
> 
> Signed-off-by: Avri Altman <avri.altman@wdc.com>
> ---
>  drivers/mmc/core/sd_ops.c | 19 +++++++++++++++----
> include/linux/mmc/host.h  |  6 ++++++
>  include/linux/mmc/sd.h    |  1 +
>  3 files changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index
> 8b9b34286ef3..7f6963dac873 100644
> --- a/drivers/mmc/core/sd_ops.c
> +++ b/drivers/mmc/core/sd_ops.c
> @@ -168,12 +168,16 @@ int mmc_send_app_op_cond(struct mmc_host *host,
> u32 ocr, u32 *rocr)
>                 .cmd = &cmd
>         };
>         int err;
> +       u32 sduc_arg = SD_OCR_CCS | SD_OCR_2T;
> 
>         cmd.opcode = SD_APP_OP_COND;
> +       cmd.arg = ocr;
> +
>         if (mmc_host_is_spi(host))
> -               cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */
> +               cmd.arg &= (1 << 30); /* SPI only defines one bit */
>         else
> -               cmd.arg = ocr;
> +               cmd.arg |= sduc_arg;
> +
>         cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
> 
>         err = __mmc_poll_for_busy(host, SD_APP_OP_COND_PERIOD_US,
> @@ -182,8 +186,15 @@ int mmc_send_app_op_cond(struct mmc_host *host,
> u32 ocr, u32 *rocr)
>         if (err)
>                 return err;
> 
> -       if (rocr && !mmc_host_is_spi(host))
> -               *rocr = cmd.resp[0];
> +       if (!mmc_host_is_spi(host)) {
> +               if (rocr)
> +                       *rocr = cmd.resp[0];
> +
> +               if ((cmd.resp[0] & sduc_arg) == sduc_arg)
> +                       host->caps2 |= MMC_CAP2_SD_SDUC;
> +               else
> +                       host->caps2 &= ~MMC_CAP2_SD_SDUC;

I think host->caps2 is for host to claim caps, here can just call mmc_card_set_ult_capacity? 
Don't need to wait csd, because SDXC and SDHC need to identify by capacity, but SDUC can be identified here
And all your mmc_card_is_sduc() I think change to mmc_card_ult_capacity() to know the card type

> +       }
> 
>         return 0;
>  }
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index
> 88c6a76042ee..a9c36a3e1a10 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -427,6 +427,7 @@ struct mmc_host {
>  #define MMC_CAP2_CRYPTO                0
>  #endif
>  #define MMC_CAP2_ALT_GPT_TEGRA (1 << 28)       /* Host with eMMC
> that has GPT entry at a non-standard location */
> +#define MMC_CAP2_SD_SDUC       (1 << 29)       /* SD over 2TB */
> 
>         int                     fixed_drv_type; /* fixed driver type for
> non-removable media */
> 
> @@ -638,6 +639,11 @@ static inline int mmc_card_uhs(struct mmc_card
> *card)
>                 card->host->ios.timing <= MMC_TIMING_UHS_DDR50;  }
> 
> +static inline int mmc_card_is_sduc(struct mmc_host *host) {
> +       return host->caps2 & MMC_CAP2_SD_SDUC; }
> +
>  void mmc_retune_timer_stop(struct mmc_host *host);
> 
>  static inline void mmc_retune_needed(struct mmc_host *host) diff --git
> a/include/linux/mmc/sd.h b/include/linux/mmc/sd.h index
> 6727576a8755..865cc0ca8543 100644
> --- a/include/linux/mmc/sd.h
> +++ b/include/linux/mmc/sd.h
> @@ -36,6 +36,7 @@
>  /* OCR bit definitions */
>  #define SD_OCR_S18R            (1 << 24)    /* 1.8V switching request
> */
>  #define SD_ROCR_S18A           SD_OCR_S18R  /* 1.8V switching
> accepted by card */
> +#define SD_OCR_2T              (1 << 27)    /* HO2T/CO2T - SDUC
> support */
>  #define SD_OCR_XPC             (1 << 28)    /* SDXC power control */
>  #define SD_OCR_CCS             (1 << 30)    /* Card Capacity Status */
> 
> --
> 2.25.1


  reply	other threads:[~2024-08-09  9:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  6:02 [PATCH v2 00/10] Add SDUC Support Avri Altman
2024-08-07  6:03 ` [PATCH v2 01/10] mmc: sd: SDUC Support Recognition Avri Altman
2024-08-09  9:53   ` Ricky WU [this message]
2024-08-10  7:58     ` Avri Altman
2024-08-13  5:42       ` Avri Altman
2024-08-07  6:03 ` [PATCH v2 02/10] mmc: sd: Add SD CSD version 3.0 Avri Altman
2024-08-07  6:03 ` [PATCH v2 03/10] mmc: sd: Add Extension memory addressing Avri Altman
2024-08-09  9:54   ` Ricky WU
2024-08-10  8:11     ` Avri Altman
2024-08-07  6:03 ` [PATCH v2 04/10] mmc: core: Add open-ended Ext " Avri Altman
2024-08-07  6:03 ` [PATCH v2 05/10] mmc: host: Always use manual-cmd23 in SDUC Avri Altman
2024-08-07  6:03 ` [PATCH v2 06/10] mmc: core: Add close-ended Ext memory addressing Avri Altman
2024-08-07  6:03 ` [PATCH v2 07/10] mmc: host: " Avri Altman
2024-08-07  6:03 ` [PATCH v2 08/10] mmc: core: Allow mmc erase to carry large addresses Avri Altman
2024-08-07 20:15   ` kernel test robot
2024-08-07 21:07   ` kernel test robot
2024-08-07  6:03 ` [PATCH v2 09/10] mmc: core: Add Ext memory addressing for erase Avri Altman
2024-08-07  6:03 ` [PATCH v2 10/10] mmc: core: Adjust ACMD22 to SDUC Avri Altman
2024-08-09  6:54 ` [PATCH v2 00/10] Add SDUC Support Ricky WU
2024-08-09  7:37   ` Avri Altman

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=9353f3aec3e846dd9075ada858d44fd4@realtek.com \
    --to=ricky_wu@realtek.com \
    --cc=avri.altman@wdc.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /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