From: Ricky WU <ricky_wu@realtek.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>
Subject: RE: [PATCH] mmc: rtsx: usb add 74 clocks in poweron flow
Date: Thu, 10 Apr 2025 06:36:56 +0000 [thread overview]
Message-ID: <1fde0217fa544560888c3e6f4f5963f9@realtek.com> (raw)
In-Reply-To: <CAPDyKFpn5xB50eTomNM=4LbFDX4r154iY2Qk8GBiYb+vor0kbA@mail.gmail.com>
> >
> > SD spec definition:
> > "Host provides at least 74 Clocks before issuing first command"
> > After 1ms for the voltage stable then start issuing the Clock signals
> >
> > add if statement to issue/stop the clock signal to card:
> > The power state from POWER_OFF to POWER_UP issue the signal to card,
> > POWER_UP to POWER_ON stop the signal
> >
> > add 100ms delay in power_on to make sure the power cycle complete
>
> Why 100ms? That sounds a lot to me?
>
Hi Ulf,
This 100ms delay is to ensure the voltage is below 0.5V before power on during a power cycle,
The delays in the mmc core is not sufficient for the rtsx usb device.
Because during the card recognition process, the card power will be toggled once in 1ms.
If the card power is not fully discharged within that 1ms before being turned on again,
It may affect the card recognition
> Is this fixing a real problem or is just trying to better follow the spec?
>
We found some cards not be recognized if not issue this 74 clocks
> >
> > Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> > ---
> > drivers/mmc/host/rtsx_usb_sdmmc.c | 28
> +++++++++++++++++++++++++---
> > 1 file changed, 25 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c
> > b/drivers/mmc/host/rtsx_usb_sdmmc.c
> > index d229c2b83ea9..e5820b2bb380 100644
> > --- a/drivers/mmc/host/rtsx_usb_sdmmc.c
> > +++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
> > @@ -48,7 +48,7 @@ struct rtsx_usb_sdmmc {
> > bool ddr_mode;
> >
> > unsigned char power_mode;
> > -
> > + unsigned char prev_power_mode;
> > #ifdef RTSX_USB_USE_LEDS_CLASS
> > struct led_classdev led;
> > char led_name[32];
> > @@ -952,6 +952,8 @@ static int sd_power_on(struct rtsx_usb_sdmmc
> *host)
> > struct rtsx_ucr *ucr = host->ucr;
> > int err;
> >
> > + msleep(100);
> > +
> > dev_dbg(sdmmc_dev(host), "%s\n", __func__);
> > rtsx_usb_init_cmd(ucr);
> > rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_SELECT, 0x07,
> > SD_MOD_SEL); @@ -1014,6 +1016,16 @@ static int
> sd_set_power_mode(struct rtsx_usb_sdmmc *host,
> > unsigned char power_mode) {
> > int err;
> > + int power_mode_temp;
> > + struct rtsx_ucr *ucr = host->ucr;
> > +
> > + power_mode_temp = power_mode;
> > +
> > + if ((power_mode == MMC_POWER_ON) && (host->power_mode
> == MMC_POWER_ON) &&
> > + (host->prev_power_mode ==
> MMC_POWER_UP)) {
> > + host->prev_power_mode = MMC_POWER_ON;
> > + rtsx_usb_write_register(ucr, SD_BUS_STAT,
> SD_CLK_TOGGLE_EN, 0x00);
> > + }
> >
> > if (power_mode != MMC_POWER_OFF)
> > power_mode = MMC_POWER_ON; @@ -1029,9
> +1041,18 @@
> > static int sd_set_power_mode(struct rtsx_usb_sdmmc *host,
> > err = sd_power_on(host);
> > }
> >
> > - if (!err)
> > - host->power_mode = power_mode;
> > + if (!err) {
> > + if ((power_mode_temp == MMC_POWER_UP) &&
> (host->power_mode == MMC_POWER_OFF)) {
> > + host->prev_power_mode = MMC_POWER_UP;
> > + rtsx_usb_write_register(ucr, SD_BUS_STAT,
> SD_CLK_TOGGLE_EN,
> > + SD_CLK_TOGGLE_EN);
> > + }
> > +
> > + if ((power_mode_temp == MMC_POWER_OFF) &&
> (host->power_mode == MMC_POWER_ON))
> > + host->prev_power_mode = MMC_POWER_OFF;
> >
> > + host->power_mode = power_mode;
> > + }
> > return err;
> > }
> >
> > @@ -1316,6 +1337,7 @@ static void rtsx_usb_init_host(struct
> rtsx_usb_sdmmc *host)
> > mmc->max_req_size = 524288;
> >
> > host->power_mode = MMC_POWER_OFF;
> > + host->prev_power_mode = MMC_POWER_OFF;
> > }
> >
> > static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev)
> > --
> > 2.25.1
> >
>
> Kind regards
> Uffe
next prev parent reply other threads:[~2025-04-10 6:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 2:51 [PATCH] mmc: rtsx: usb add 74 clocks in poweron flow Ricky Wu
2025-04-09 13:04 ` Ulf Hansson
2025-04-10 6:36 ` Ricky WU [this message]
2025-04-10 13:44 ` Ulf Hansson
2025-04-11 6:08 ` Ricky WU
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=1fde0217fa544560888c3e6f4f5963f9@realtek.com \
--to=ricky_wu@realtek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=viro@zeniv.linux.org.uk \
/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