All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: rtsx: add 74 Clocks in power on flow
@ 2022-02-22  7:27 Ricky WU
  2022-02-22  7:42 ` gregkh
  2022-02-28 16:12 ` Ulf Hansson
  0 siblings, 2 replies; 19+ messages in thread
From: Ricky WU @ 2022-02-22  7:27 UTC (permalink / raw)
  To: ulf.hansson, Ricky WU, gregkh, kai.heng.feng, tommyhebb,
	linux-mmc, linux-kernel

After 1ms stabilizing the voltage time
add "Host provides at least 74 Clocks
before issuing first command" that is
spec definition

Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 2a3f14afe9f8..e016d720e453 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -940,10 +940,17 @@ static int sd_power_on(struct realtek_pci_sdmmc *host)
 	if (err < 0)
 		return err;
 
+	mdelay(1);
+
 	err = rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN);
 	if (err < 0)
 		return err;
 
+	/* send init 74 clocks */
+	rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN);
+	mdelay(5);
+	rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0);
+
 	if (PCI_PID(pcr) == PID_5261) {
 		/*
 		 * If test mode is set switch to SD Express mandatorily,
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-02-22  7:27 [PATCH] mmc: rtsx: add 74 Clocks in power on flow Ricky WU
@ 2022-02-22  7:42 ` gregkh
  2022-02-22  8:48   ` Ricky WU
  2022-02-28 16:12 ` Ulf Hansson
  1 sibling, 1 reply; 19+ messages in thread
From: gregkh @ 2022-02-22  7:42 UTC (permalink / raw)
  To: Ricky WU; +Cc: ulf.hansson, kai.heng.feng, tommyhebb, linux-mmc, linux-kernel

On Tue, Feb 22, 2022 at 07:27:52AM +0000, Ricky WU wrote:
> After 1ms stabilizing the voltage time
> add "Host provides at least 74 Clocks
> before issuing first command" that is
> spec definition

You do have 72 columns to use here, no need to wrap this so tightly.

> 
> Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> ---
>  drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
> index 2a3f14afe9f8..e016d720e453 100644
> --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> @@ -940,10 +940,17 @@ static int sd_power_on(struct realtek_pci_sdmmc *host)
>  	if (err < 0)
>  		return err;
>  
> +	mdelay(1);

What is this delay for?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-02-22  7:42 ` gregkh
@ 2022-02-22  8:48   ` Ricky WU
  2022-02-22  8:59     ` gregkh
  0 siblings, 1 reply; 19+ messages in thread
From: Ricky WU @ 2022-02-22  8:48 UTC (permalink / raw)
  To: gregkh; +Cc: ulf.hansson, kai.heng.feng, tommyhebb, linux-mmc, linux-kernel

> -----Original Message-----
> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> Sent: Tuesday, February 22, 2022 3:42 PM
> To: Ricky WU <ricky_wu@realtek.com>
> Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> 
> On Tue, Feb 22, 2022 at 07:27:52AM +0000, Ricky WU wrote:
> > After 1ms stabilizing the voltage time add "Host provides at least 74
> > Clocks before issuing first command" that is spec definition
> 
> You do have 72 columns to use here, no need to wrap this so tightly.
>

Ok...
so I need to have next patch to fix this format?

> >
> > Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> > ---
> >  drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > index 2a3f14afe9f8..e016d720e453 100644
> > --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > @@ -940,10 +940,17 @@ static int sd_power_on(struct realtek_pci_sdmmc
> *host)
> >  	if (err < 0)
> >  		return err;
> >
> > +	mdelay(1);
> 
> What is this delay for?
>

Spec definition, need to wait 1ms for voltage stable
and below mdelay(5) is our device send 74 Clocks time
 
> thanks,
> 
> greg k-h
> ------Please consider the environment before printing this e-mail.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-02-22  8:48   ` Ricky WU
@ 2022-02-22  8:59     ` gregkh
  2022-02-22 12:31       ` Ricky WU
  0 siblings, 1 reply; 19+ messages in thread
From: gregkh @ 2022-02-22  8:59 UTC (permalink / raw)
  To: Ricky WU; +Cc: ulf.hansson, kai.heng.feng, tommyhebb, linux-mmc, linux-kernel

On Tue, Feb 22, 2022 at 08:48:30AM +0000, Ricky WU wrote:
> > -----Original Message-----
> > From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> > Sent: Tuesday, February 22, 2022 3:42 PM
> > To: Ricky WU <ricky_wu@realtek.com>
> > Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> > tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> > linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> > 
> > On Tue, Feb 22, 2022 at 07:27:52AM +0000, Ricky WU wrote:
> > > After 1ms stabilizing the voltage time add "Host provides at least 74
> > > Clocks before issuing first command" that is spec definition
> > 
> > You do have 72 columns to use here, no need to wrap this so tightly.
> >
> 
> Ok...
> so I need to have next patch to fix this format?

Please do, because:

> 
> > >
> > > Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> > > ---
> > >  drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > index 2a3f14afe9f8..e016d720e453 100644
> > > --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > @@ -940,10 +940,17 @@ static int sd_power_on(struct realtek_pci_sdmmc
> > *host)
> > >  	if (err < 0)
> > >  		return err;
> > >
> > > +	mdelay(1);
> > 
> > What is this delay for?
> >
> 
> Spec definition, need to wait 1ms for voltage stable
> and below mdelay(5) is our device send 74 Clocks time

Clock cycles and mdelay() are not going to always stay the same, right?

I really have no idea what "74 clocks time" means, is this some specific
timing value for this hardware?  What is the units?  This needs to be
documented better in both the changelog and in the code.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-02-22  8:59     ` gregkh
@ 2022-02-22 12:31       ` Ricky WU
  2022-02-22 14:18         ` gregkh
  0 siblings, 1 reply; 19+ messages in thread
From: Ricky WU @ 2022-02-22 12:31 UTC (permalink / raw)
  To: gregkh; +Cc: ulf.hansson, kai.heng.feng, tommyhebb, linux-mmc, linux-kernel

> -----Original Message-----
> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> Sent: Tuesday, February 22, 2022 4:59 PM
> To: Ricky WU <ricky_wu@realtek.com>
> Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> 
> On Tue, Feb 22, 2022 at 08:48:30AM +0000, Ricky WU wrote:
> > > -----Original Message-----
> > > From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> > > Sent: Tuesday, February 22, 2022 3:42 PM
> > > To: Ricky WU <ricky_wu@realtek.com>
> > > Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> > > tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> > > linux-kernel@vger.kernel.org
> > > Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> > >
> > > On Tue, Feb 22, 2022 at 07:27:52AM +0000, Ricky WU wrote:
> > > > After 1ms stabilizing the voltage time add "Host provides at least
> > > > 74 Clocks before issuing first command" that is spec definition
> > >
> > > You do have 72 columns to use here, no need to wrap this so tightly.
> > >
> >
> > Ok...
> > so I need to have next patch to fix this format?
> 
> Please do, because:
> 
> >
> > > >
> > > > Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> > > > ---
> > > >  drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
> > > >  1 file changed, 7 insertions(+)
> > > >
> > > > diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > index 2a3f14afe9f8..e016d720e453 100644
> > > > --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > @@ -940,10 +940,17 @@ static int sd_power_on(struct
> > > > realtek_pci_sdmmc
> > > *host)
> > > >  	if (err < 0)
> > > >  		return err;
> > > >
> > > > +	mdelay(1);
> > >
> > > What is this delay for?
> > >
> >
> > Spec definition, need to wait 1ms for voltage stable and below
> > mdelay(5) is our device send 74 Clocks time
> 
> Clock cycles and mdelay() are not going to always stay the same, right?
> 
> I really have no idea what "74 clocks time" means, is this some specific timing
> value for this hardware?  What is the units?  This needs to be documented
> better in both the changelog and in the code.
> 
> thanks,
> 

Please ref: https://www.sdcard.org/downloads/pls/ Version8
And see the 6.4.1.2 Power Up Time of Host Figure 6-5: Power Up Diagram of Host
mdelay(1) corresponds to Stable supply voltage
mdelay(5) corresponds to Host provides at least 74 Clocks before issuing first command
our device need 5ms to issue 74 Clocks


> greg k-h
> ------Please consider the environment before printing this e-mail.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-02-22 12:31       ` Ricky WU
@ 2022-02-22 14:18         ` gregkh
  2022-02-24  5:49           ` Ricky WU
  0 siblings, 1 reply; 19+ messages in thread
From: gregkh @ 2022-02-22 14:18 UTC (permalink / raw)
  To: Ricky WU; +Cc: ulf.hansson, kai.heng.feng, tommyhebb, linux-mmc, linux-kernel

On Tue, Feb 22, 2022 at 12:31:10PM +0000, Ricky WU wrote:
> > -----Original Message-----
> > From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> > Sent: Tuesday, February 22, 2022 4:59 PM
> > To: Ricky WU <ricky_wu@realtek.com>
> > Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> > tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> > linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> > 
> > On Tue, Feb 22, 2022 at 08:48:30AM +0000, Ricky WU wrote:
> > > > -----Original Message-----
> > > > From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> > > > Sent: Tuesday, February 22, 2022 3:42 PM
> > > > To: Ricky WU <ricky_wu@realtek.com>
> > > > Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> > > > tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> > > > linux-kernel@vger.kernel.org
> > > > Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> > > >
> > > > On Tue, Feb 22, 2022 at 07:27:52AM +0000, Ricky WU wrote:
> > > > > After 1ms stabilizing the voltage time add "Host provides at least
> > > > > 74 Clocks before issuing first command" that is spec definition
> > > >
> > > > You do have 72 columns to use here, no need to wrap this so tightly.
> > > >
> > >
> > > Ok...
> > > so I need to have next patch to fix this format?
> > 
> > Please do, because:
> > 
> > >
> > > > >
> > > > > Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> > > > > ---
> > > > >  drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
> > > > >  1 file changed, 7 insertions(+)
> > > > >
> > > > > diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > > b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > > index 2a3f14afe9f8..e016d720e453 100644
> > > > > --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > > +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > > @@ -940,10 +940,17 @@ static int sd_power_on(struct
> > > > > realtek_pci_sdmmc
> > > > *host)
> > > > >  	if (err < 0)
> > > > >  		return err;
> > > > >
> > > > > +	mdelay(1);
> > > >
> > > > What is this delay for?
> > > >
> > >
> > > Spec definition, need to wait 1ms for voltage stable and below
> > > mdelay(5) is our device send 74 Clocks time
> > 
> > Clock cycles and mdelay() are not going to always stay the same, right?
> > 
> > I really have no idea what "74 clocks time" means, is this some specific timing
> > value for this hardware?  What is the units?  This needs to be documented
> > better in both the changelog and in the code.
> > 
> > thanks,
> > 
> 
> Please ref: https://www.sdcard.org/downloads/pls/ Version8

I can not download those specifications according to the license that
they ask me to abide by.

> And see the 6.4.1.2 Power Up Time of Host Figure 6-5: Power Up Diagram of Host
> mdelay(1) corresponds to Stable supply voltage
> mdelay(5) corresponds to Host provides at least 74 Clocks before issuing first command
> our device need 5ms to issue 74 Clocks

What is a "clock"?  The kernel works with time units, how does "5" equal
to 74?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-02-22 14:18         ` gregkh
@ 2022-02-24  5:49           ` Ricky WU
  0 siblings, 0 replies; 19+ messages in thread
From: Ricky WU @ 2022-02-24  5:49 UTC (permalink / raw)
  To: gregkh; +Cc: ulf.hansson, kai.heng.feng, tommyhebb, linux-mmc, linux-kernel

> -----Original Message-----
> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> Sent: Tuesday, February 22, 2022 10:18 PM
> To: Ricky WU <ricky_wu@realtek.com>
> Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> 
> On Tue, Feb 22, 2022 at 12:31:10PM +0000, Ricky WU wrote:
> > > -----Original Message-----
> > > From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> > > Sent: Tuesday, February 22, 2022 4:59 PM
> > > To: Ricky WU <ricky_wu@realtek.com>
> > > Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> > > tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> > > linux-kernel@vger.kernel.org
> > > Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> > >
> > > On Tue, Feb 22, 2022 at 08:48:30AM +0000, Ricky WU wrote:
> > > > > -----Original Message-----
> > > > > From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> > > > > Sent: Tuesday, February 22, 2022 3:42 PM
> > > > > To: Ricky WU <ricky_wu@realtek.com>
> > > > > Cc: ulf.hansson@linaro.org; kai.heng.feng@canonical.com;
> > > > > tommyhebb@gmail.com; linux-mmc@vger.kernel.org;
> > > > > linux-kernel@vger.kernel.org
> > > > > Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
> > > > >
> > > > > On Tue, Feb 22, 2022 at 07:27:52AM +0000, Ricky WU wrote:
> > > > > > After 1ms stabilizing the voltage time add "Host provides at
> > > > > > least
> > > > > > 74 Clocks before issuing first command" that is spec
> > > > > > definition
> > > > >
> > > > > You do have 72 columns to use here, no need to wrap this so tightly.
> > > > >
> > > >
> > > > Ok...
> > > > so I need to have next patch to fix this format?
> > >
> > > Please do, because:
> > >
> > > >
> > > > > >
> > > > > > Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> > > > > > ---
> > > > > >  drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
> > > > > >  1 file changed, 7 insertions(+)
> > > > > >
> > > > > > diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > > > b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > > > index 2a3f14afe9f8..e016d720e453 100644
> > > > > > --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > > > +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> > > > > > @@ -940,10 +940,17 @@ static int sd_power_on(struct
> > > > > > realtek_pci_sdmmc
> > > > > *host)
> > > > > >  	if (err < 0)
> > > > > >  		return err;
> > > > > >
> > > > > > +	mdelay(1);
> > > > >
> > > > > What is this delay for?
> > > > >
> > > >
> > > > Spec definition, need to wait 1ms for voltage stable and below
> > > > mdelay(5) is our device send 74 Clocks time
> > >
> > > Clock cycles and mdelay() are not going to always stay the same, right?
> > >
> > > I really have no idea what "74 clocks time" means, is this some
> > > specific timing value for this hardware?  What is the units?  This
> > > needs to be documented better in both the changelog and in the code.
> > >
> > > thanks,
> > >
> >
> > Please ref: https://www.sdcard.org/downloads/pls/ Version8
> 
> I can not download those specifications according to the license that they ask
> me to abide by.
> 
> > And see the 6.4.1.2 Power Up Time of Host Figure 6-5: Power Up Diagram
> > of Host
> > mdelay(1) corresponds to Stable supply voltage
> > mdelay(5) corresponds to Host provides at least 74 Clocks before
> > issuing first command our device need 5ms to issue 74 Clocks
> 
> What is a "clock"?  The kernel works with time units, how does "5" equal to
> 74?
> 

spec original is
"Host provides at least 74 Clocks before issuing first command"
Let me clarify it, 
74 Clocks means 74 clock signals, our Card Reader need to issue more than 74 Clock signals to Card before first command
So mdelay(5) , our device will keep issue signal to card in this 5ms make sure over 74 

> thanks,
> 
> greg k-h
> ------Please consider the environment before printing this e-mail.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-02-22  7:27 [PATCH] mmc: rtsx: add 74 Clocks in power on flow Ricky WU
  2022-02-22  7:42 ` gregkh
@ 2022-02-28 16:12 ` Ulf Hansson
  2022-05-09  9:35   ` Christian Löhle
  1 sibling, 1 reply; 19+ messages in thread
From: Ulf Hansson @ 2022-02-28 16:12 UTC (permalink / raw)
  To: Ricky WU; +Cc: gregkh, kai.heng.feng, tommyhebb, linux-mmc, linux-kernel

On Tue, 22 Feb 2022 at 08:28, Ricky WU <ricky_wu@realtek.com> wrote:
>
> After 1ms stabilizing the voltage time
> add "Host provides at least 74 Clocks
> before issuing first command" that is
> spec definition
>
> Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> ---
>  drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
> index 2a3f14afe9f8..e016d720e453 100644
> --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> @@ -940,10 +940,17 @@ static int sd_power_on(struct realtek_pci_sdmmc *host)
>         if (err < 0)
>                 return err;
>
> +       mdelay(1);
> +
>         err = rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN);
>         if (err < 0)
>                 return err;
>
> +       /* send init 74 clocks */
> +       rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN);
> +       mdelay(5);
> +       rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0);
> +
>         if (PCI_PID(pcr) == PID_5261) {
>                 /*
>                  * If test mode is set switch to SD Express mandatorily,

As you probably are aware of, the mmc core uses three power states
(MMC_POWER_ON, MMC_POWER_UP and MMC_POWER_OFF) to manage the
initialization, while it invokes the ->set_ios() callback for the mmc
host driver. During these steps the core also tries to manage the
different delays that are needed according to the eMMC/SD specs. You
may have a look at mmc_power_up() in drivers/mmc/core/core.c. In the
rtsx case, MMC_POWER_ON and MMC_POWER_UP are treated as one single
step.

Moreover, it has turned out that some mmc HWs are actually controlling
these delays during the initialization themselves, which makes the
delays in the core superfluous. Therefore we have made the delays
configurable for host drivers. For DT based platforms, we have the DT
property "post-power-on-delay-ms" and for others, it's perfectly fine
to update host->power_delay_ms before calling mmc_add_host().

Would it be possible to take advantage of the above "features" from
the core, to avoid hard coded and superfluous delays?

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-02-28 16:12 ` Ulf Hansson
@ 2022-05-09  9:35   ` Christian Löhle
  2022-05-09  9:47     ` gregkh
  0 siblings, 1 reply; 19+ messages in thread
From: Christian Löhle @ 2022-05-09  9:35 UTC (permalink / raw)
  To: Ulf Hansson, Ricky WU, gregkh; +Cc: linux-mmc, stable

Can we get 1f311c94aabdb419c28e3147bcc8ab89269f1a7e merged into the stable tree?
I have some compatibility issues on Realtek chips because of the missing initialization clocks.

Thanks!
Regards,
Christian



From: Ulf Hansson <ulf.hansson@linaro.org>
Sent: Monday, February 28, 2022 5:12 PM
To: Ricky WU
Cc: gregkh@linuxfoundation.org; kai.heng.feng@canonical.com; tommyhebb@gmail.com; linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
    
On Tue, 22 Feb 2022 at 08:28, Ricky WU <ricky_wu@realtek.com> wrote:
>
> After 1ms stabilizing the voltage time
> add "Host provides at least 74 Clocks
> before issuing first command" that is
> spec definition
>
> Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> ---
>  drivers/mmc/host/rtsx_pci_sdmmc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
> index 2a3f14afe9f8..e016d720e453 100644
> --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> @@ -940,10 +940,17 @@ static int sd_power_on(struct realtek_pci_sdmmc *host)
>         if (err < 0)
>                 return err;
>
> +       mdelay(1);
> +
>         err = rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN);
>         if (err < 0)
>                 return err;
>
> +       /* send init 74 clocks */
> +       rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN);
> +       mdelay(5);
> +       rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0);
> +
>         if (PCI_PID(pcr) == PID_5261) {
>                 /*
>                  * If test mode is set switch to SD Express mandatorily,

As you probably are aware of, the mmc core uses three power states
(MMC_POWER_ON, MMC_POWER_UP and MMC_POWER_OFF) to manage the
initialization, while it invokes the ->set_ios() callback for the mmc
host driver. During these steps the core also tries to manage the
different delays that are needed according to the eMMC/SD specs. You
may have a look at mmc_power_up() in drivers/mmc/core/core.c. In the
rtsx case, MMC_POWER_ON and MMC_POWER_UP are treated as one single
step.

Moreover, it has turned out that some mmc HWs are actually controlling
these delays during the initialization themselves, which makes the
delays in the core superfluous. Therefore we have made the delays
configurable for host drivers. For DT based platforms, we have the DT
property "post-power-on-delay-ms" and for others, it's perfectly fine
to update host->power_delay_ms before calling mmc_add_host().

Would it be possible to take advantage of the above "features" from
the core, to avoid hard coded and superfluous delays?

Kind regards
Uffe
    =
Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-05-09  9:35   ` Christian Löhle
@ 2022-05-09  9:47     ` gregkh
  2022-05-09 10:12       ` Christian Löhle
  0 siblings, 1 reply; 19+ messages in thread
From: gregkh @ 2022-05-09  9:47 UTC (permalink / raw)
  To: Christian Löhle; +Cc: Ulf Hansson, Ricky WU, linux-mmc, stable

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Mon, May 09, 2022 at 09:35:25AM +0000, Christian Löhle wrote:
> Can we get 1f311c94aabdb419c28e3147bcc8ab89269f1a7e merged into the stable tree?

Which stable branches do you want this added to?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-05-09  9:47     ` gregkh
@ 2022-05-09 10:12       ` Christian Löhle
  2022-05-10  9:56         ` Ulf Hansson
  0 siblings, 1 reply; 19+ messages in thread
From: Christian Löhle @ 2022-05-09 10:12 UTC (permalink / raw)
  To: gregkh; +Cc: Ulf Hansson, Ricky WU, linux-mmc, stable

>> Can we get 1f311c94aabdb419c28e3147bcc8ab89269f1a7e merged into the stable tree?
>
>Which stable branches do you want this added to?
>
>thanks,
>
>greg k-h

From what I can tell the issue is present since the addition of the driver in ff984e57d36e8
So I would suggest adding them to all? Maybe Ricky and Ulf could comment?

Regards,
Christian=
Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-05-09 10:12       ` Christian Löhle
@ 2022-05-10  9:56         ` Ulf Hansson
  2022-05-10 10:21           ` gregkh
  0 siblings, 1 reply; 19+ messages in thread
From: Ulf Hansson @ 2022-05-10  9:56 UTC (permalink / raw)
  To: Christian Löhle, gregkh; +Cc: Ricky WU, linux-mmc, stable

On Mon, 9 May 2022 at 12:12, Christian Löhle <CLoehle@hyperstone.com> wrote:
>
> >> Can we get 1f311c94aabdb419c28e3147bcc8ab89269f1a7e merged into the stable tree?
> >
> >Which stable branches do you want this added to?
> >
> >thanks,
> >
> >greg k-h
>
> From what I can tell the issue is present since the addition of the driver in ff984e57d36e8
> So I would suggest adding them to all? Maybe Ricky and Ulf could comment?

That seems correct.

Although, it's likely that 1f311c94aabd doesn't apply to older stable
trees, but I guess we can try and see how it goes.

Perhaps an even better option is that you submit a backported patch to
Greg for those stable kernels you want it to be applied to.

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-05-10  9:56         ` Ulf Hansson
@ 2022-05-10 10:21           ` gregkh
  0 siblings, 0 replies; 19+ messages in thread
From: gregkh @ 2022-05-10 10:21 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: Christian Löhle, Ricky WU, linux-mmc, stable

On Tue, May 10, 2022 at 11:56:38AM +0200, Ulf Hansson wrote:
> On Mon, 9 May 2022 at 12:12, Christian Löhle <CLoehle@hyperstone.com> wrote:
> >
> > >> Can we get 1f311c94aabdb419c28e3147bcc8ab89269f1a7e merged into the stable tree?
> > >
> > >Which stable branches do you want this added to?
> > >
> > >thanks,
> > >
> > >greg k-h
> >
> > From what I can tell the issue is present since the addition of the driver in ff984e57d36e8
> > So I would suggest adding them to all? Maybe Ricky and Ulf could comment?
> 
> That seems correct.
> 
> Although, it's likely that 1f311c94aabd doesn't apply to older stable
> trees, but I guess we can try and see how it goes.
> 
> Perhaps an even better option is that you submit a backported patch to
> Greg for those stable kernels you want it to be applied to.

It only applies cleanly to 5.17.y and 5.15.y, so I've added it there.
If anyone wants it to be added to older kernels, they need to provide
working backports.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-05-10 13:02 ` Christian Löhle
@ 2022-05-13  7:54   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 19+ messages in thread
From: Greg Kroah-Hartman @ 2022-05-13  7:54 UTC (permalink / raw)
  To: Christian Löhle; +Cc: Ulf Hansson, stable, Ricky WU

On Tue, May 10, 2022 at 01:02:24PM +0000, Christian Löhle wrote:
> >commit 1f311c94aabd ("mmc: rtsx: add 74 Clocks in power on flow") upstream.
> >backport note: removed unavailable power_delay_ms 5ms as 10ms is fine, too.
> >
> >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
> >
> >if POWER STATE is
> >MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card
> >MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card
> >
> >Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> >Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> >Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
> >---
> 
> Now for 4.9.y and 4.14.y, my bad and thanks a lot.

Now queued up, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-05-10 13:00 Christian Löhle
@ 2022-05-10 13:02 ` Christian Löhle
  2022-05-13  7:54   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 19+ messages in thread
From: Christian Löhle @ 2022-05-10 13:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ulf Hansson; +Cc: stable, Ricky WU

>commit 1f311c94aabd ("mmc: rtsx: add 74 Clocks in power on flow") upstream.
>backport note: removed unavailable power_delay_ms 5ms as 10ms is fine, too.
>
>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
>
>if POWER STATE is
>MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card
>MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card
>
>Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
>Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
>---

Now for 4.9.y and 4.14.y, my bad and thanks a lot.

Regards,
Christian=
Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] mmc: rtsx: add 74 Clocks in power on flow
@ 2022-05-10 13:00 Christian Löhle
  2022-05-10 13:02 ` Christian Löhle
  0 siblings, 1 reply; 19+ messages in thread
From: Christian Löhle @ 2022-05-10 13:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ulf Hansson; +Cc: stable, Ricky WU

commit 1f311c94aabd ("mmc: rtsx: add 74 Clocks in power on flow") upstream.
backport note: removed unavailable power_delay_ms 5ms as 10ms is fine, too.

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

if POWER STATE is
MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card
MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card

Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 9de6a32f0c9f..0b1d4f2b5862 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -49,10 +49,7 @@ struct realtek_pci_sdmmc {
 	bool			double_clk;
 	bool			eject;
 	bool			initial_mode;
-	int			power_state;
-#define SDMMC_POWER_ON		1
-#define SDMMC_POWER_OFF		0
-
+	int			prev_power_state;
 	int			sg_count;
 	s32			cookie;
 	int			cookie_sg_count;
@@ -913,14 +910,21 @@ static int sd_set_bus_width(struct realtek_pci_sdmmc *host,
 	return err;
 }
 
-static int sd_power_on(struct realtek_pci_sdmmc *host)
+static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode)
 {
 	struct rtsx_pcr *pcr = host->pcr;
 	int err;
 
-	if (host->power_state == SDMMC_POWER_ON)
+	if (host->prev_power_state == MMC_POWER_ON)
 		return 0;
 
+	if (host->prev_power_state == MMC_POWER_UP) {
+		rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0);
+		goto finish;
+	}
+
+	msleep(100);
+
 	rtsx_pci_init_cmd(pcr);
 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_SELECT, 0x07, SD_MOD_SEL);
 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_SHARE_MODE,
@@ -939,11 +943,17 @@ static int sd_power_on(struct realtek_pci_sdmmc *host)
 	if (err < 0)
 		return err;
 
+	mdelay(1);
+
 	err = rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN);
 	if (err < 0)
 		return err;
 
-	host->power_state = SDMMC_POWER_ON;
+	/* send at least 74 clocks */
+	rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN);
+
+finish:
+	host->prev_power_state = power_mode;
 	return 0;
 }
 
@@ -952,7 +962,7 @@ static int sd_power_off(struct realtek_pci_sdmmc *host)
 	struct rtsx_pcr *pcr = host->pcr;
 	int err;
 
-	host->power_state = SDMMC_POWER_OFF;
+	host->prev_power_state = MMC_POWER_OFF;
 
 	rtsx_pci_init_cmd(pcr);
 
@@ -978,7 +988,7 @@ static int sd_set_power_mode(struct realtek_pci_sdmmc *host,
 	if (power_mode == MMC_POWER_OFF)
 		err = sd_power_off(host);
 	else
-		err = sd_power_on(host);
+		err = sd_power_on(host, power_mode);
 
 	return err;
 }
@@ -1416,7 +1426,7 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
 	host->mmc = mmc;
 	host->pdev = pdev;
 	host->cookie = -1;
-	host->power_state = SDMMC_POWER_OFF;
+	host->prev_power_state = MMC_POWER_OFF;
 	INIT_WORK(&host->work, sd_request);
 	platform_set_drvdata(pdev, host);
 	pcr->slots[RTSX_SD_CARD].p_dev = pdev;
-- 
2.34.1=
Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-05-10 12:09 ` Christian Löhle
@ 2022-05-10 12:40   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 19+ messages in thread
From: Greg Kroah-Hartman @ 2022-05-10 12:40 UTC (permalink / raw)
  To: Christian Löhle; +Cc: Ulf Hansson, Ricky WU, stable

On Tue, May 10, 2022 at 12:09:45PM +0000, Christian Löhle wrote:
> >commit 1f311c94aabd ("mmc: rtsx: add 74 Clocks in power on flow") upstream.
> >
> >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
> >
> >if POWER STATE is
> >MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card
> >MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card
> >
> >Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
> >Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> >Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
> 
> Based on 5.10.y, applies to all down to 4.9.y=

It breaks the build on 4.14.y and 4.9.y :(


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] mmc: rtsx: add 74 Clocks in power on flow
  2022-05-10 12:08 Christian Löhle
@ 2022-05-10 12:09 ` Christian Löhle
  2022-05-10 12:40   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 19+ messages in thread
From: Christian Löhle @ 2022-05-10 12:09 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ulf Hansson; +Cc: Ricky WU, stable

>commit 1f311c94aabd ("mmc: rtsx: add 74 Clocks in power on flow") upstream.
>
>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
>
>if POWER STATE is
>MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card
>MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card
>
>Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
>Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>Signed-off-by: Christian Loehle <cloehle@hyperstone.com>

Based on 5.10.y, applies to all down to 4.9.y=
Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] mmc: rtsx: add 74 Clocks in power on flow
@ 2022-05-10 12:08 Christian Löhle
  2022-05-10 12:09 ` Christian Löhle
  0 siblings, 1 reply; 19+ messages in thread
From: Christian Löhle @ 2022-05-10 12:08 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ulf Hansson; +Cc: Ricky WU, stable

commit 1f311c94aabd ("mmc: rtsx: add 74 Clocks in power on flow") upstream.

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

if POWER STATE is
MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card
MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card

Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index e00167bcfaf6..b5cb83bb9b85 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -37,10 +37,7 @@ struct realtek_pci_sdmmc {
 	bool			double_clk;
 	bool			eject;
 	bool			initial_mode;
-	int			power_state;
-#define SDMMC_POWER_ON		1
-#define SDMMC_POWER_OFF		0
-
+	int			prev_power_state;
 	int			sg_count;
 	s32			cookie;
 	int			cookie_sg_count;
@@ -902,14 +899,21 @@ static int sd_set_bus_width(struct realtek_pci_sdmmc *host,
 	return err;
 }
 
-static int sd_power_on(struct realtek_pci_sdmmc *host)
+static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode)
 {
 	struct rtsx_pcr *pcr = host->pcr;
 	int err;
 
-	if (host->power_state == SDMMC_POWER_ON)
+	if (host->prev_power_state == MMC_POWER_ON)
 		return 0;
 
+	if (host->prev_power_state == MMC_POWER_UP) {
+		rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0);
+		goto finish;
+	}
+
+	msleep(100);
+
 	rtsx_pci_init_cmd(pcr);
 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_SELECT, 0x07, SD_MOD_SEL);
 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_SHARE_MODE,
@@ -928,11 +932,17 @@ static int sd_power_on(struct realtek_pci_sdmmc *host)
 	if (err < 0)
 		return err;
 
+	mdelay(1);
+
 	err = rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN);
 	if (err < 0)
 		return err;
 
-	host->power_state = SDMMC_POWER_ON;
+	/* send at least 74 clocks */
+	rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN);
+
+finish:
+	host->prev_power_state = power_mode;
 	return 0;
 }
 
@@ -941,7 +951,7 @@ static int sd_power_off(struct realtek_pci_sdmmc *host)
 	struct rtsx_pcr *pcr = host->pcr;
 	int err;
 
-	host->power_state = SDMMC_POWER_OFF;
+	host->prev_power_state = MMC_POWER_OFF;
 
 	rtsx_pci_init_cmd(pcr);
 
@@ -967,7 +977,7 @@ static int sd_set_power_mode(struct realtek_pci_sdmmc *host,
 	if (power_mode == MMC_POWER_OFF)
 		err = sd_power_off(host);
 	else
-		err = sd_power_on(host);
+		err = sd_power_on(host, power_mode);
 
 	return err;
 }
@@ -1404,10 +1414,11 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
 
 	host = mmc_priv(mmc);
 	host->pcr = pcr;
+	mmc->ios.power_delay_ms = 5;
 	host->mmc = mmc;
 	host->pdev = pdev;
 	host->cookie = -1;
-	host->power_state = SDMMC_POWER_OFF;
+	host->prev_power_state = MMC_POWER_OFF;
 	INIT_WORK(&host->work, sd_request);
 	platform_set_drvdata(pdev, host);
 	pcr->slots[RTSX_SD_CARD].p_dev = pdev;
-- 
2.34.1
Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-05-13  7:54 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22  7:27 [PATCH] mmc: rtsx: add 74 Clocks in power on flow Ricky WU
2022-02-22  7:42 ` gregkh
2022-02-22  8:48   ` Ricky WU
2022-02-22  8:59     ` gregkh
2022-02-22 12:31       ` Ricky WU
2022-02-22 14:18         ` gregkh
2022-02-24  5:49           ` Ricky WU
2022-02-28 16:12 ` Ulf Hansson
2022-05-09  9:35   ` Christian Löhle
2022-05-09  9:47     ` gregkh
2022-05-09 10:12       ` Christian Löhle
2022-05-10  9:56         ` Ulf Hansson
2022-05-10 10:21           ` gregkh
2022-05-10 12:08 Christian Löhle
2022-05-10 12:09 ` Christian Löhle
2022-05-10 12:40   ` Greg Kroah-Hartman
2022-05-10 13:00 Christian Löhle
2022-05-10 13:02 ` Christian Löhle
2022-05-13  7:54   ` Greg Kroah-Hartman

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.