All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frieder Schrempf <frieder@fris.de>
To: Fabio Estevam <festevam@gmail.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Stefano Babic <sbabic@denx.de>,
	u-boot@lists.denx.de
Cc: Marek Vasut <marex@denx.de>, Fabio Estevam <festevam@denx.de>,
	Heiko Thiery <heiko.thiery@gmail.com>,
	"NXP i.MX U-Boot Team" <uboot-imx@nxp.com>
Subject: [PATCH] imx: kontron-sl-mx8mm: Fix SD card IO voltage level
Date: Wed, 25 Jan 2023 14:41:39 +0100	[thread overview]
Message-ID: <20230125134139.50791-1-frieder@fris.de> (raw)

From: Frieder Schrempf <frieder.schrempf@kontron.de>

The LDO5 of the PCA9450 PMIC can be switched between two different
voltage settings (defaulting to 1.8V and 3.3V) using an external
signal SD_VSEL that is connected to the VSELECT signal of the SD
card interface.

As the regulator driver can't deal with both LDO registers (LDO5CTRL_H
and LDO5CTRL_L) it only uses one of them, which means reading the
voltage from the regulator can potentially return a value that does not
reflect the actual state of the LDO5 output.

In our case, after booting U-Boot we read 1.8V from the regulator
while in fact as the VSELECT signal is still low the regulator outputs
3.3V. This confusion causes the MMC driver to think it is dealing with
a 1.8V-only device. This in turn leads to SD cards being addressed
with 1.8V IO levels even if UHS support is not available or disabled.

Some cards with UHS support still work even if they are addressed
with 1.8V levels in non-UHS modes, but a lot of cards also fail with
timeout errors like:

  Card did not respond to voltage select! : -110

As a workaorund we disable the vqmmc regulator for now so we can make
sure no wrong values are read from the regulator. The switching
between 1.8V and 3.3V still works as the ESDHC driver sets the
VSELECT signal accordingly.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
By the way: I suspect that other boards using the PCA9450 might also be affected
by this. I didn't find a nice generic solution so far. It would be possible to
patch the pca9450 driver to use the PCA9450_LDO5CTRL_L instead of the
PCA9450_LDO5CTRL_H register for LDO5. This would fix this particular case,
but still not the root problem of the regulator driver returning wrong values.
So if anyone got some idea how to properly handle this, let me know.
The same issue is also present in Linux. While I didn't notice any problems
with the SD card being addressed with incorrect voltage levels so far,
reading the regulator doesn't return the correct value if VSELECT is low.
---
---
 arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
index 5b8b472159..8321424649 100644
--- a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
@@ -137,6 +137,12 @@
 
 &usdhc2 {
 	u-boot,dm-spl;
+	/*
+	 * Delete the reference to the IO voltage regulator in order to prevent
+	 * wrong information being passed to the MMC driver by reading the current
+	 * voltage of the PCA9450 LDO5.
+	 */
+	/delete-property/ vqmmc-supply;
 };
 
 &wdog1 {
-- 
2.39.1


             reply	other threads:[~2023-01-25 13:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25 13:41 Frieder Schrempf [this message]
2023-01-25 17:15 ` [PATCH] imx: kontron-sl-mx8mm: Fix SD card IO voltage level Marek Vasut
2023-01-25 17:30   ` Frieder Schrempf
2023-01-25 18:02     ` Marek Vasut
2023-01-26 15:47       ` Frieder Schrempf

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=20230125134139.50791-1-frieder@fris.de \
    --to=frieder@fris.de \
    --cc=festevam@denx.de \
    --cc=festevam@gmail.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=heiko.thiery@gmail.com \
    --cc=marex@denx.de \
    --cc=sbabic@denx.de \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    /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.