[PATCH 1/3] mmc: renesas_sdhi: Deassert the reset signal on probe

Claudiu posted 3 patches 4 months ago
There is a newer version of this series
[PATCH 1/3] mmc: renesas_sdhi: Deassert the reset signal on probe
Posted by Claudiu 4 months ago
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Deassert the reset signal of the SDHI controller during probe to avoid
relying on the previous bootloaders. Without deasserting the reset signal,
the SDHI controller will not function.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
 drivers/mmc/host/renesas_sdhi_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index f56fa2cd208d..c4aaf534868c 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -1103,7 +1103,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 	if (IS_ERR(priv->clk_cd))
 		return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk_cd), "cannot get cd clock");
 
-	priv->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
+	priv->rstc = devm_reset_control_get_optional_exclusive_deasserted(&pdev->dev, NULL);
 	if (IS_ERR(priv->rstc))
 		return PTR_ERR(priv->rstc);
 
-- 
2.43.0
Re: [PATCH 1/3] mmc: renesas_sdhi: Deassert the reset signal on probe
Posted by Wolfram Sang 2 months, 4 weeks ago
On Wed, Oct 08, 2025 at 07:25:23AM +0300, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Deassert the reset signal of the SDHI controller during probe to avoid
> relying on the previous bootloaders. Without deasserting the reset signal,
> the SDHI controller will not function.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Re: [PATCH 1/3] mmc: renesas_sdhi: Deassert the reset signal on probe
Posted by Geert Uytterhoeven 4 months ago
Hi Claudiu,

On Fri, 10 Oct 2025 at 07:06, Claudiu <claudiu.beznea@tuxon.dev> wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> Deassert the reset signal of the SDHI controller during probe to avoid
> relying on the previous bootloaders. Without deasserting the reset signal,
> the SDHI controller will not function.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Thanks for your patch!

> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -1103,7 +1103,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
>         if (IS_ERR(priv->clk_cd))
>                 return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk_cd), "cannot get cd clock");
>
> -       priv->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
> +       priv->rstc = devm_reset_control_get_optional_exclusive_deasserted(&pdev->dev, NULL);

Note that this has the side effect of asserting reset again on probe
failure or unbind.  Also on SoCs that boot with reset already deasserted
(e.g. R-Car).  I don't know if that would be a problem.

>         if (IS_ERR(priv->rstc))
>                 return PTR_ERR(priv->rstc);

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH 1/3] mmc: renesas_sdhi: Deassert the reset signal on probe
Posted by Claudiu Beznea 4 months ago
Hi, Geert,

On 10/10/25 10:51, Geert Uytterhoeven wrote:
> Hi Claudiu,
> 
> On Fri, 10 Oct 2025 at 07:06, Claudiu <claudiu.beznea@tuxon.dev> wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> Deassert the reset signal of the SDHI controller during probe to avoid
>> relying on the previous bootloaders. Without deasserting the reset signal,
>> the SDHI controller will not function.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Thanks for your patch!
> 
>> --- a/drivers/mmc/host/renesas_sdhi_core.c
>> +++ b/drivers/mmc/host/renesas_sdhi_core.c
>> @@ -1103,7 +1103,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
>>         if (IS_ERR(priv->clk_cd))
>>                 return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk_cd), "cannot get cd clock");
>>
>> -       priv->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
>> +       priv->rstc = devm_reset_control_get_optional_exclusive_deasserted(&pdev->dev, NULL);
> 
> Note that this has the side effect of asserting reset again on probe
> failure or unbind.

I agree. I've tested unbind/bind on RZ/G3S and I saw no issue.

>  Also on SoCs that boot with reset already deasserted
> (e.g. R-Car).  I don't know if that would be a problem.

I think all SoCs boot with resets de-asserted as the driver does register
configuration before calling reset_control_reset() in renesas_sdhi_reset(),
e.g:
- one register configuration is just above reset_control_reset()
- one register configuration, through sd_ctrl_write32_as_16_and_16(), in
  renesas_sdhi_probe()
- register writes in tmio_mmc_reset() before host->reset() call

I did bonnie++ tests after boot on RZ/G2{H, M, N, L, UL}, RZ/V2L and saw no
issue.

Thank you for your review,
Claudiu

> 
>>         if (IS_ERR(priv->rstc))
>>                 return PTR_ERR(priv->rstc);
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
>