linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mmc: renesas_sdhi: Set the SDBUF after reset
@ 2024-04-10 13:54 Claudiu Beznea
  2024-04-26  5:08 ` Ulf Hansson
  2024-04-30  9:10 ` Wolfram Sang
  0 siblings, 2 replies; 5+ messages in thread
From: Claudiu Beznea @ 2024-04-10 13:54 UTC (permalink / raw)
  To: wsa+renesas, ulf.hansson
  Cc: linux-mmc, linux-renesas-soc, linux-kernel, Claudiu Beznea, Hien Huynh

For development purpose, renesas_sdhi_probe() could be called w/
dma_ops = NULL to force the usage of PIO mode. In this case the
renesas_sdhi_enable_dma() will not be called before transferring data.

If renesas_sdhi_enable_dma() is not called, renesas_sdhi_clk_enable()
call from renesas_sdhi_probe() will configure SDBUF by calling the
renesas_sdhi_sdbuf_width() function, but then SDBUF will be reset in
tmio_mmc_host_probe() when calling tmio_mmc_reset() though host->reset().
If SDBUF is zero the data transfer will not work in PIO mode for RZ/G3S.

To fix this call again the renesas_sdhi_sdbuf_width(host, 16) in
renesas_sdhi_reset(). The call of renesas_sdhi_sdbuf_width() was not
removed from renesas_sdhi_clk_enable() as the host->reset() is optional.

Co-developed-by: Hien Huynh <hien.huynh.px@renesas.com>
Signed-off-by: Hien Huynh <hien.huynh.px@renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v2:
- fixed typos in commit description
- limit the comment lines to 80 chars

 drivers/mmc/host/renesas_sdhi_core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index f84f60139bcf..5233731a94c4 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -589,6 +589,12 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host, bool preserve)
 			sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
 			priv->needs_adjust_hs400 = false;
 			renesas_sdhi_set_clock(host, host->clk_cache);
+
+			/*
+			 * In case the controller works in PIO mode the SDBUF
+			 * needs to be set as its reset value is zero.
+			 */
+			renesas_sdhi_sdbuf_width(host, 16);
 		} else if (priv->scc_ctl) {
 			renesas_sdhi_scc_reset(host, priv);
 		}
-- 
2.39.2


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

* Re: [PATCH v2] mmc: renesas_sdhi: Set the SDBUF after reset
  2024-04-10 13:54 [PATCH v2] mmc: renesas_sdhi: Set the SDBUF after reset Claudiu Beznea
@ 2024-04-26  5:08 ` Ulf Hansson
  2024-04-26  6:19   ` Wolfram Sang
  2024-04-30  9:10 ` Wolfram Sang
  1 sibling, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2024-04-26  5:08 UTC (permalink / raw)
  To: wsa+renesas
  Cc: Claudiu Beznea, linux-mmc, linux-renesas-soc, linux-kernel,
	Claudiu Beznea, Hien Huynh

On Wed, 10 Apr 2024 at 15:54, Claudiu Beznea <claudiu.beznea@tuxon.dev> wrote:
>
> For development purpose, renesas_sdhi_probe() could be called w/
> dma_ops = NULL to force the usage of PIO mode. In this case the
> renesas_sdhi_enable_dma() will not be called before transferring data.
>
> If renesas_sdhi_enable_dma() is not called, renesas_sdhi_clk_enable()
> call from renesas_sdhi_probe() will configure SDBUF by calling the
> renesas_sdhi_sdbuf_width() function, but then SDBUF will be reset in
> tmio_mmc_host_probe() when calling tmio_mmc_reset() though host->reset().
> If SDBUF is zero the data transfer will not work in PIO mode for RZ/G3S.
>
> To fix this call again the renesas_sdhi_sdbuf_width(host, 16) in
> renesas_sdhi_reset(). The call of renesas_sdhi_sdbuf_width() was not
> removed from renesas_sdhi_clk_enable() as the host->reset() is optional.
>
> Co-developed-by: Hien Huynh <hien.huynh.px@renesas.com>
> Signed-off-by: Hien Huynh <hien.huynh.px@renesas.com>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Wolfram, when you have the time, can we get your opinion on this one?

Kind regards
Uffe

> ---
>
> Changes in v2:
> - fixed typos in commit description
> - limit the comment lines to 80 chars
>
>  drivers/mmc/host/renesas_sdhi_core.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
> index f84f60139bcf..5233731a94c4 100644
> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -589,6 +589,12 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host, bool preserve)
>                         sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
>                         priv->needs_adjust_hs400 = false;
>                         renesas_sdhi_set_clock(host, host->clk_cache);
> +
> +                       /*
> +                        * In case the controller works in PIO mode the SDBUF
> +                        * needs to be set as its reset value is zero.
> +                        */
> +                       renesas_sdhi_sdbuf_width(host, 16);
>                 } else if (priv->scc_ctl) {
>                         renesas_sdhi_scc_reset(host, priv);
>                 }
> --
> 2.39.2
>

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

* Re: [PATCH v2] mmc: renesas_sdhi: Set the SDBUF after reset
  2024-04-26  5:08 ` Ulf Hansson
@ 2024-04-26  6:19   ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2024-04-26  6:19 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Claudiu Beznea, linux-mmc, linux-renesas-soc, linux-kernel,
	Claudiu Beznea, Hien Huynh

[-- Attachment #1: Type: text/plain, Size: 1315 bytes --]

On Fri, Apr 26, 2024 at 07:08:10AM +0200, Ulf Hansson wrote:
> On Wed, 10 Apr 2024 at 15:54, Claudiu Beznea <claudiu.beznea@tuxon.dev> wrote:
> >
> > For development purpose, renesas_sdhi_probe() could be called w/
> > dma_ops = NULL to force the usage of PIO mode. In this case the
> > renesas_sdhi_enable_dma() will not be called before transferring data.
> >
> > If renesas_sdhi_enable_dma() is not called, renesas_sdhi_clk_enable()
> > call from renesas_sdhi_probe() will configure SDBUF by calling the
> > renesas_sdhi_sdbuf_width() function, but then SDBUF will be reset in
> > tmio_mmc_host_probe() when calling tmio_mmc_reset() though host->reset().
> > If SDBUF is zero the data transfer will not work in PIO mode for RZ/G3S.
> >
> > To fix this call again the renesas_sdhi_sdbuf_width(host, 16) in
> > renesas_sdhi_reset(). The call of renesas_sdhi_sdbuf_width() was not
> > removed from renesas_sdhi_clk_enable() as the host->reset() is optional.
> >
> > Co-developed-by: Hien Huynh <hien.huynh.px@renesas.com>
> > Signed-off-by: Hien Huynh <hien.huynh.px@renesas.com>
> > Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Wolfram, when you have the time, can we get your opinion on this one?

Sure, I'll try to squeeze it in today. Thanks for the heads up!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2] mmc: renesas_sdhi: Set the SDBUF after reset
  2024-04-10 13:54 [PATCH v2] mmc: renesas_sdhi: Set the SDBUF after reset Claudiu Beznea
  2024-04-26  5:08 ` Ulf Hansson
@ 2024-04-30  9:10 ` Wolfram Sang
  2024-04-30  9:27   ` claudiu beznea
  1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2024-04-30  9:10 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: ulf.hansson, linux-mmc, linux-renesas-soc, linux-kernel,
	Claudiu Beznea, Hien Huynh

[-- Attachment #1: Type: text/plain, Size: 1407 bytes --]

Hi Claudiu,

On Wed, Apr 10, 2024 at 04:54:16PM +0300, Claudiu Beznea wrote:
> For development purpose, renesas_sdhi_probe() could be called w/
> dma_ops = NULL to force the usage of PIO mode. In this case the
> renesas_sdhi_enable_dma() will not be called before transferring data.
> 
> If renesas_sdhi_enable_dma() is not called, renesas_sdhi_clk_enable()
> call from renesas_sdhi_probe() will configure SDBUF by calling the
> renesas_sdhi_sdbuf_width() function, but then SDBUF will be reset in
> tmio_mmc_host_probe() when calling tmio_mmc_reset() though host->reset().
> If SDBUF is zero the data transfer will not work in PIO mode for RZ/G3S.
> 
> To fix this call again the renesas_sdhi_sdbuf_width(host, 16) in
> renesas_sdhi_reset(). The call of renesas_sdhi_sdbuf_width() was not
> removed from renesas_sdhi_clk_enable() as the host->reset() is optional.

So, I tried to find a place where we would need only one call to
renesas_sdhi_sdbuf_width() but I also couldn't find a sweet spot. So,
this approach seems also best to me.

> +
> +			/*
> +			 * In case the controller works in PIO mode the SDBUF
> +			 * needs to be set as its reset value is zero.
> +			 */

But I think we can shorten the above comment to something like:

			/* Ensure default value for this driver */
> +			renesas_sdhi_sdbuf_width(host, 16);

D'accord?

Happy hacking,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2] mmc: renesas_sdhi: Set the SDBUF after reset
  2024-04-30  9:10 ` Wolfram Sang
@ 2024-04-30  9:27   ` claudiu beznea
  0 siblings, 0 replies; 5+ messages in thread
From: claudiu beznea @ 2024-04-30  9:27 UTC (permalink / raw)
  To: Wolfram Sang, ulf.hansson, linux-mmc, linux-renesas-soc,
	linux-kernel, Claudiu Beznea, Hien Huynh

Hi, Wolfram,

On 30.04.2024 12:10, Wolfram Sang wrote:
> Hi Claudiu,
> 
> On Wed, Apr 10, 2024 at 04:54:16PM +0300, Claudiu Beznea wrote:
>> For development purpose, renesas_sdhi_probe() could be called w/
>> dma_ops = NULL to force the usage of PIO mode. In this case the
>> renesas_sdhi_enable_dma() will not be called before transferring data.
>>
>> If renesas_sdhi_enable_dma() is not called, renesas_sdhi_clk_enable()
>> call from renesas_sdhi_probe() will configure SDBUF by calling the
>> renesas_sdhi_sdbuf_width() function, but then SDBUF will be reset in
>> tmio_mmc_host_probe() when calling tmio_mmc_reset() though host->reset().
>> If SDBUF is zero the data transfer will not work in PIO mode for RZ/G3S.
>>
>> To fix this call again the renesas_sdhi_sdbuf_width(host, 16) in
>> renesas_sdhi_reset(). The call of renesas_sdhi_sdbuf_width() was not
>> removed from renesas_sdhi_clk_enable() as the host->reset() is optional.
> 
> So, I tried to find a place where we would need only one call to
> renesas_sdhi_sdbuf_width() but I also couldn't find a sweet spot. So,
> this approach seems also best to me.
> 
>> +
>> +			/*
>> +			 * In case the controller works in PIO mode the SDBUF
>> +			 * needs to be set as its reset value is zero.
>> +			 */
> 
> But I think we can shorten the above comment to something like:
> 
> 			/* Ensure default value for this driver */
>> +			renesas_sdhi_sdbuf_width(host, 16);
> 
> D'accord?

Ok! I'm going to prepare a new version to change the comment.

Thank you,
Claudiu Beznea

> 
> Happy hacking,
> 
>    Wolfram
> 

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

end of thread, other threads:[~2024-04-30  9:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10 13:54 [PATCH v2] mmc: renesas_sdhi: Set the SDBUF after reset Claudiu Beznea
2024-04-26  5:08 ` Ulf Hansson
2024-04-26  6:19   ` Wolfram Sang
2024-04-30  9:10 ` Wolfram Sang
2024-04-30  9:27   ` claudiu beznea

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