Re: [RFC PATCH 4/4] mmc: renesas_sdhi: Add support for RZ/V2H(P) SoC

Lad, Prabhakar
2024-06-06T09:50:04Z

Hi Biju,

On Thu, Jun 6, 2024 at 10:43 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
>
> Hi Prabhakar,
>
>
> > -----Original Message-----
> > From: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> > Sent: Thursday, June 6, 2024 10:38 AM
> > Subject: Re: [RFC PATCH 4/4] mmc: renesas_sdhi: Add support for RZ/V2H(P) SoC
> >
> > Hi Biju,
> >
> > Thank you for the review.
> >
> > On Thu, Jun 6, 2024 at 10:32 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > >
> > > Hi Prabhakar,
> > >
<snip>
> > > >
> > > > +static void renesas_sdhi_sd_status_pwen(struct tmio_mmc_host *host,
> > > > +bool on) {
> > > > + u32 sd_status;
> > > > +
> > > > + sd_ctrl_read32_rep(host, CTL_SD_STATUS, &sd_status, 1);
> > > > + if (on)
> > > > + sd_status |= SD_STATUS_PWEN;
> > > > + else
> > > > + sd_status &= ~SD_STATUS_PWEN;
> > > > +
> > > > + sd_ctrl_write32(host, CTL_SD_STATUS, sd_status); }
> > > > +
> > >
> > > May be use regulator_set_voltage() to set this??
> > >
> > This is the PWEN bit which is not modelled as a regulator, we cannot use regulator_set_voltage() to
> > set this bit.
>
> So, there may be a race between regulator driver and this bit??
>
No, there won't be any race between the regulator driver and this bit
as the regulator driver only controls the IOVS bit and not the PWEN
bit.

> >
> > > > static int renesas_sdhi_start_signal_voltage_switch(struct mmc_host *mmc,
> > > > struct mmc_ios
> > > > *ios) { @@ -587,6 +600,9 @@ static void renesas_sdhi_reset(struct
> > > > tmio_mmc_host *host, bool preserve)
> > > > false, priv->rstc);
> > > > /* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */
> > > > sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
> > > > + if (sdhi_has_quirk(priv, sd_pwen))
> > > > + renesas_sdhi_sd_status_pwen(host,
> > > > + true);
> > > > +
> > > > priv->needs_adjust_hs400 = false;
> > > > renesas_sdhi_set_clock(host, host->clk_cache);
> > > >
> > > > @@ -904,6 +920,34 @@ static void renesas_sdhi_enable_dma(struct tmio_mmc_host *host, bool
> > enable)
> > > > renesas_sdhi_sdbuf_width(host, enable ? width : 16); }
> > > >
> > > > +static int renesas_sdhi_internal_dmac_register_regulator(struct platform_device *pdev,
> > > > + const struct renesas_sdhi_quirks
> > *quirks) {
> > > > + struct tmio_mmc_host *host = platform_get_drvdata(pdev);
> > > > + struct renesas_sdhi *priv = host_to_priv(host);
> > > > + struct regulator_config rcfg = {
> > > > + .dev = &pdev->dev,
> > > > + .driver_data = priv,
> > > > + };
> > > > + struct regulator_dev *rdev;
> > > > + const char *devname;
> > > > +
> > > > + devname = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-vqmmc-regulator",
> > > > + dev_name(&pdev->dev));
> > > > + if (!devname)
> > > > + return -ENOMEM;
> > > > +
> > > > + quirks->rdesc->name = devname;
> > > > + rcfg.regmap = devm_regmap_init_mmio(&pdev->dev, host->ctl +
> > > > + quirks->rdesc_offset,
> > >
> > > This is (CTL_SD_STATUS << 2) , so the variable can be dropped from quirks.
> > >
> > rdesc_offset is added to make code generic, that is in future if there is a new chip with a
> > different offset which supports IOVS we can just pass the offset for it.
>
> Currently there is no consumer for it, so it can save memory. When a future chip comes
> we can bring back this variable??
>
OK.

Cheers,
Prabhakar