All of lore.kernel.org
 help / color / mirror / Atom feed
From: "michael@allwinnertech.com" <michael@allwinnertech.com>
To: "Ulf Hansson" <ulf.hansson@linaro.org>
Cc: mripard <mripard@kernel.org>, wens <wens@csie.org>,
	 samuel <samuel@sholland.org>,
	andre.przywara <andre.przywara@arm.com>,
	 jernej.skrabec <jernej.skrabec@gmail.com>,
	 linux-mmc <linux-mmc@vger.kernel.org>,
	 linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	 linux-sunxi <linux-sunxi@lists.linux.dev>,
	 linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] mmc:sunxi-mmc:add support on discrete device power supply
Date: Fri, 31 Dec 2021 22:06:23 +0800	[thread overview]
Message-ID: <2021123121313177857228@allwinnertech.com> (raw)
In-Reply-To: CAPDyKFpnTk9Ky-zr-dakTZJr1N_65_6py9=3_78vwOR930apEQ@mail.gmail.com

> On Fri, 31 Dec 2021 at 09:28, michael@allwinnertech.com
> <michael@allwinnertech.com> wrote:
> >
> > > From: Ulf Hansson
> > > Date: 2021-12-29 00:49
> > > To: Michael Wu
> > > CC: mripard; wens; samuel; andre.przywara; jernej.skrabec; linux-mmc; linux-arm-kernel; linux-sunxi; linux-kernel
> > > Subject: Re: [PATCH 1/3] mmc:sunxi-mmc:add support on discrete device power supply
> > > On Wed, 22 Dec 2021 at 04:07, Michael Wu <michael@allwinnertech.com> wrote:
> > > >
> > > > Because some platform has no regulator, only use discrete devices
> > > > to supply power,For this situation, to use sd/mmc card, we add ocr manually
> > > >
> > > > Signed-off-by: Michael Wu <michael@allwinnertech.com>
> > > > ---
> > > >  drivers/mmc/host/sunxi-mmc.c | 8 ++++++++
> > > >  1 file changed, 8 insertions(+)
> > > >
> > > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
> > > > index 2702736a1c57..afeefead6501 100644
> > > > --- a/drivers/mmc/host/sunxi-mmc.c
> > > > +++ b/drivers/mmc/host/sunxi-mmc.c
> > > > @@ -1300,6 +1300,14 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,
> > > >         if (ret)
> > > >                 return ret;
> > > >
> > > > +       /**
> > > > +        * Some platforms has no regulator. Discrete devices are used instead.
> > > > +        * To support sd/mmc card, we need to add ocr manually.
> > > > +        */
> > > > +       if (!host->mmc->ocr_avail)
> > > > +               host->mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
> > > > +
> > >
> > > Rather than doing this, I suggest you hook up a fixed vmmc regulator in the DTS.
> > >
> > > Nevertheless, it seems reasonable to check that the ocr_avail gets set
> > > up correctly. And if it doesn't, perhaps we should print a warning and
> > > return an error code.
> > >
> > > > +
> > > >         host->reg_base = devm_platform_ioremap_resource(pdev, 0);
> > > >         if (IS_ERR(host->reg_base))
> > > >                 return PTR_ERR(host->reg_base);
> > >
> > > Kind regards
> > > Uffe
> >
> > Dear Uffe,
> > Thanks for your suggestion. It is a better solution.
> > I've modified my patch. Please check if it's reasonable. If it is, I'll re-sumbit it later.
> >
> > ---
> > Subject: [PATCH v2] mmc: sunxi-mmc: check ocr_avail on resource request
> >
> > Some platforms have no regulator, discrete power devices are used instead.
> > However, sunxi_mmc_probe does not catch this exception when regulator is
> > absent in DTS. This leads to sd or eMMC init failure.
> > To solve this, a fixed vmmc regulator must be hooked up in DTS, like this:
> > reg_dummy_vmmc: dummy_vmmc {
> >         compatible = "regulator-fixed";
> >         regulator-name = "dummy-vmmc";
> >         regulator-min-microvolt = <500000>;
> >         regulator-max-microvolt = <3500000>;
> 
> The min/max should be set to the same value as you can't really change
> the voltage levels.
> 
> If you know the voltage level that is supplied for your platform, then
> state this value - otherwise I would suggest picking 3.3V, which is
> rather commonly used for MMC/SD.

Okay. The supplied voltage is 2.7V~3.6V. l'll correct the min/max value to 3.3V:

        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;

> > };
> > mmc0:mmc@4020000 {
> >         compatible = "allwinner,sun50i-a100-emmc";
> >         device_type = "mmc0";
> >         vmmc-supply = <&reg_dummy_vmmc>;
> > }
> > In this patch, we print an error message and abort the probe process if
> > the regulator is not specified in DTS.
> >
> > Signed-off-by: Michael Wu <michael@allwinnertech.com>
> > ---
> >
> > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
> > index 2702736..0da74bd 100644
> > --- a/drivers/mmc/host/sunxi-mmc.c
> > +++ b/drivers/mmc/host/sunxi-mmc.c
> > @@ -1300,6 +1300,11 @@
> >         if (ret)
> >                 return ret;
> >
> > +       if (!host->mmc->ocr_avail) {
> > +               dev_err(&pdev->dev, "Could not get mmc regulator\n");
> > +               return -EINVAL;
> > +       }
> > +
> >         host->reg_base = devm_platform_ioremap_resource(pdev, 0);
> >         if (IS_ERR(host->reg_base))
> >                 return PTR_ERR(host->reg_base);
> >
> > Best Regards,
> > Michael Wu
> 
> Yep, this looks good to me!
> 
> Kind regards
> Uffe

I'll submit the patch once I get back to work. Thanks for your effort and happy new year :)

Best Regards,
Michael Wu
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: "michael@allwinnertech.com" <michael@allwinnertech.com>
To: "Ulf Hansson" <ulf.hansson@linaro.org>
Cc: mripard <mripard@kernel.org>,  wens <wens@csie.org>,
	 samuel <samuel@sholland.org>,
	 andre.przywara <andre.przywara@arm.com>,
	 jernej.skrabec <jernej.skrabec@gmail.com>,
	 linux-mmc <linux-mmc@vger.kernel.org>,
	 linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	 linux-sunxi <linux-sunxi@lists.linux.dev>,
	 linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] mmc:sunxi-mmc:add support on discrete device power supply
Date: Fri, 31 Dec 2021 22:06:23 +0800	[thread overview]
Message-ID: <2021123121313177857228@allwinnertech.com> (raw)
In-Reply-To: CAPDyKFpnTk9Ky-zr-dakTZJr1N_65_6py9=3_78vwOR930apEQ@mail.gmail.com

> On Fri, 31 Dec 2021 at 09:28, michael@allwinnertech.com
> <michael@allwinnertech.com> wrote:
> >
> > > From: Ulf Hansson
> > > Date: 2021-12-29 00:49
> > > To: Michael Wu
> > > CC: mripard; wens; samuel; andre.przywara; jernej.skrabec; linux-mmc; linux-arm-kernel; linux-sunxi; linux-kernel
> > > Subject: Re: [PATCH 1/3] mmc:sunxi-mmc:add support on discrete device power supply
> > > On Wed, 22 Dec 2021 at 04:07, Michael Wu <michael@allwinnertech.com> wrote:
> > > >
> > > > Because some platform has no regulator, only use discrete devices
> > > > to supply power,For this situation, to use sd/mmc card, we add ocr manually
> > > >
> > > > Signed-off-by: Michael Wu <michael@allwinnertech.com>
> > > > ---
> > > >  drivers/mmc/host/sunxi-mmc.c | 8 ++++++++
> > > >  1 file changed, 8 insertions(+)
> > > >
> > > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
> > > > index 2702736a1c57..afeefead6501 100644
> > > > --- a/drivers/mmc/host/sunxi-mmc.c
> > > > +++ b/drivers/mmc/host/sunxi-mmc.c
> > > > @@ -1300,6 +1300,14 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,
> > > >         if (ret)
> > > >                 return ret;
> > > >
> > > > +       /**
> > > > +        * Some platforms has no regulator. Discrete devices are used instead.
> > > > +        * To support sd/mmc card, we need to add ocr manually.
> > > > +        */
> > > > +       if (!host->mmc->ocr_avail)
> > > > +               host->mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
> > > > +
> > >
> > > Rather than doing this, I suggest you hook up a fixed vmmc regulator in the DTS.
> > >
> > > Nevertheless, it seems reasonable to check that the ocr_avail gets set
> > > up correctly. And if it doesn't, perhaps we should print a warning and
> > > return an error code.
> > >
> > > > +
> > > >         host->reg_base = devm_platform_ioremap_resource(pdev, 0);
> > > >         if (IS_ERR(host->reg_base))
> > > >                 return PTR_ERR(host->reg_base);
> > >
> > > Kind regards
> > > Uffe
> >
> > Dear Uffe,
> > Thanks for your suggestion. It is a better solution.
> > I've modified my patch. Please check if it's reasonable. If it is, I'll re-sumbit it later.
> >
> > ---
> > Subject: [PATCH v2] mmc: sunxi-mmc: check ocr_avail on resource request
> >
> > Some platforms have no regulator, discrete power devices are used instead.
> > However, sunxi_mmc_probe does not catch this exception when regulator is
> > absent in DTS. This leads to sd or eMMC init failure.
> > To solve this, a fixed vmmc regulator must be hooked up in DTS, like this:
> > reg_dummy_vmmc: dummy_vmmc {
> >         compatible = "regulator-fixed";
> >         regulator-name = "dummy-vmmc";
> >         regulator-min-microvolt = <500000>;
> >         regulator-max-microvolt = <3500000>;
> 
> The min/max should be set to the same value as you can't really change
> the voltage levels.
> 
> If you know the voltage level that is supplied for your platform, then
> state this value - otherwise I would suggest picking 3.3V, which is
> rather commonly used for MMC/SD.

Okay. The supplied voltage is 2.7V~3.6V. l'll correct the min/max value to 3.3V:

        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;

> > };
> > mmc0:mmc@4020000 {
> >         compatible = "allwinner,sun50i-a100-emmc";
> >         device_type = "mmc0";
> >         vmmc-supply = <&reg_dummy_vmmc>;
> > }
> > In this patch, we print an error message and abort the probe process if
> > the regulator is not specified in DTS.
> >
> > Signed-off-by: Michael Wu <michael@allwinnertech.com>
> > ---
> >
> > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
> > index 2702736..0da74bd 100644
> > --- a/drivers/mmc/host/sunxi-mmc.c
> > +++ b/drivers/mmc/host/sunxi-mmc.c
> > @@ -1300,6 +1300,11 @@
> >         if (ret)
> >                 return ret;
> >
> > +       if (!host->mmc->ocr_avail) {
> > +               dev_err(&pdev->dev, "Could not get mmc regulator\n");
> > +               return -EINVAL;
> > +       }
> > +
> >         host->reg_base = devm_platform_ioremap_resource(pdev, 0);
> >         if (IS_ERR(host->reg_base))
> >                 return PTR_ERR(host->reg_base);
> >
> > Best Regards,
> > Michael Wu
> 
> Yep, this looks good to me!
> 
> Kind regards
> Uffe

I'll submit the patch once I get back to work. Thanks for your effort and happy new year :)

Best Regards,
Michael Wu

  reply	other threads:[~2021-12-31 14:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22  3:06 [PATCH 1/3] mmc:sunxi-mmc:add support on discrete device power supply Michael Wu
2021-12-22  3:06 ` Michael Wu
2021-12-28 16:49 ` Ulf Hansson
2021-12-28 16:49   ` Ulf Hansson
2021-12-31  8:27   ` michael
2021-12-31  8:27     ` michael
2021-12-31 12:14     ` Ulf Hansson
2021-12-31 12:14       ` Ulf Hansson
2021-12-31 14:06       ` michael [this message]
2021-12-31 14:06         ` michael

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=2021123121313177857228@allwinnertech.com \
    --to=michael@allwinnertech.com \
    --cc=andre.przywara@arm.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mripard@kernel.org \
    --cc=samuel@sholland.org \
    --cc=ulf.hansson@linaro.org \
    --cc=wens@csie.org \
    /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 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.