LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Peter Geis <pgwipeout@gmail.com>
To: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	linux-mmc@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	devicetree@vger.kernel.org
Subject: Re: [BUG] mmc_regulator_set_ocr can't cope with regulator-fixed
Date: Thu, 5 Aug 2021 07:38:06 -0400	[thread overview]
Message-ID: <CAMdYzYr9PX-9=kkCAfGe8Q0-D+gRo_qCwse8SiGVsmod7fffiA@mail.gmail.com> (raw)
In-Reply-To: <a9aa636e-326f-a848-dd69-41df87c013af@samsung.com>

On Thu, Aug 5, 2021 at 5:59 AM Jaehoon Chung <jh80.chung@samsung.com> wrote:
>
> Hi,
>
> On 8/4/21 11:32 PM, Peter Geis wrote:
> > Good Morning,
> >
> > I've encountered a fun issue with the dw-mmc driver while working on
> > enabling support for the Quartz-64 Model A.
> > The regulator-fixed driver supports enabling via a gpio, but does not
> > have the ops to set voltage as it is fixed.
> > The dw-mmc calls mmc_regulator_set_ocr for vmmc, which attempts to set
> > the voltage first but fails due to the lack of the voltage ops. It
> > then bails returning -EINVAL.
> > This leads to the following message :
> > dwmmc_rockchip fe2b0000.mmc: could not set regulator OCR (-22)
>
> What is vdd value (ocr_avail value) on your target?
> I didn't see its case until now. If there is a real bug, I will try to check again.

What brought this front and center is actually another bug with the
dw-mmc-rk driver (I don't know if it affects other dw-mmc drivers)
vmmc is 3.3v on this board, but with broken-cd set polling causes the
following splat constantly.

[   30.719846] dwmmc_rockchip fe2b0000.mmc: could not set regulator OCR (-22)
[   30.720488] dwmmc_rockchip fe2b0000.mmc: failed to enable vmmc regulator
[   30.763736] dwmmc_rockchip fe2b0000.mmc: could not set regulator OCR (-22)
[   30.764379] dwmmc_rockchip fe2b0000.mmc: failed to enable vmmc regulator
[   30.778231] dwmmc_rockchip fe2b0000.mmc: failed to set rate 300000Hz
[   30.795042] dwmmc_rockchip fe2b0000.mmc: failed to set rate 300000Hz
[   30.798735] dwmmc_rockchip fe2b0000.mmc: failed to set rate 300000Hz
[   30.816591] dwmmc_rockchip fe2b0000.mmc: failed to set rate 300000Hz
[   30.820303] dwmmc_rockchip fe2b0000.mmc: could not set regulator OCR (-22)
[   30.820944] dwmmc_rockchip fe2b0000.mmc: failed to enable vmmc regulator
[   30.834794] dwmmc_rockchip fe2b0000.mmc: failed to set rate 200000Hz
[   30.851606] dwmmc_rockchip fe2b0000.mmc: failed to set rate 200000Hz
[   30.855264] dwmmc_rockchip fe2b0000.mmc: failed to set rate 200000Hz
[   30.873197] dwmmc_rockchip fe2b0000.mmc: failed to set rate 200000Hz
[   30.876908] dwmmc_rockchip fe2b0000.mmc: could not set regulator OCR (-22)
[   30.877549] dwmmc_rockchip fe2b0000.mmc: failed to enable vmmc regulator
[   30.891396] dwmmc_rockchip fe2b0000.mmc: failed to set rate 100000Hz
[   30.911704] dwmmc_rockchip fe2b0000.mmc: failed to set rate 100000Hz
[   30.915586] dwmmc_rockchip fe2b0000.mmc: failed to set rate 100000Hz
[   30.948637] dwmmc_rockchip fe2b0000.mmc: failed to set rate 100000Hz

I looked through the code path and if the OCR voltage is set to the
fixed regulator voltage it should just return success. I think I need
to change that error to output the voltage it tried to set, just to
see if something weird is going on.

Also, I've got a possible fix to the dw-mmc issue, the following patch
changes the behavior to only enable a fixed regulator, not try to set
the voltage. It's a split between the behavior when vmmc isn't defined
at all and when its a variable regulator:

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index d333130d1531..b30102980261 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1446,11 +1446,13 @@ static void dw_mci_set_ios(struct mmc_host
*mmc, struct mmc_ios *ios)
  switch (ios->power_mode) {
  case MMC_POWER_UP:
  if (!IS_ERR(mmc->supply.vmmc)) {
- ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc,
- ios->vdd);
+ if (mmc->ocr_avail > 0)
+ ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
+ else
+ ret = regulator_enable(mmc->supply.vmmc);
+
  if (ret) {
- dev_err(slot->host->dev,
- "failed to enable vmmc regulator\n");
+ dev_err(slot->host->dev, "failed to enable vmmc regulator\n");
  /*return, if failed turn on vmmc*/
  return;
  }

>
> Best Regards,
> Jaehoon Chung
>
> >
> > This can be fixed by switching to regulator-gpio for the vmmc supply
> > to the sdmmc controller, however the sdio controller vmmc is provided
> > by a fixed regulator that is always on. Obviously the regulator-gpio
> > isn't an option, as it has no gpio to enable.
> >
> > Removing the vmmc phandle from the sdio node is an option, but then it
> > doesn't fully describe the hardware (it's also a non-standard 4.4v).
> > I had considered changing the check in dw-mmc.c [1] to continue in the
> > case of -EINVAL, but there are other places in the regulator framework
> > that can also return that and it doesn't address the underlying issue.
> >
> > As such I'm reaching out to the experts to see what the best course of
> > action is here.
> > Please weigh in with what you think.
> >
> > Very Respectfully,
> > Peter Geis
> >
>

  reply	other threads:[~2021-08-05 11:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210804143357epcas1p1c67eca591d8bb557c11b8175baaa8550@epcas1p1.samsung.com>
2021-08-04 14:32 ` Peter Geis
2021-08-04 16:15   ` Mark Brown
2021-08-05 10:00   ` Jaehoon Chung
2021-08-05 11:38     ` Peter Geis [this message]
2021-08-05 12:46       ` Mark Brown
2021-08-05 12:58         ` Peter Geis
2021-08-05 13:08           ` Mark Brown
2021-08-06  8:14             ` Ravikumar Kattekola
2021-08-06 10:59               ` Mark Brown

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='CAMdYzYr9PX-9=kkCAfGe8Q0-D+gRo_qCwse8SiGVsmod7fffiA@mail.gmail.com' \
    --to=pgwipeout@gmail.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jh80.chung@samsung.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=robh+dt@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --subject='Re: [BUG] mmc_regulator_set_ocr can'\''t cope with regulator-fixed' \
    /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

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