When using a fixed 1.8V regulator for vqmmc (indicated by vs18_enable),
attempting to change the voltage produces spurious errors since the
regulator cannot be adjusted. The driver currently attempts the voltage
change, receives -ENOSYS from the regulator subsystem, and reports:

  Setting to 1.8V error: -38
  esdhc_set_voltage error -5

Fix this by checking vs18_enable early in esdhc_set_voltage() and
returning -ENOTSUPP for all voltage switch requests, not just 3.3V.
This prevents unnecessary regulator operations and eliminates the
error messages when the hardware is correctly configured with a fixed
1.8V supply.

Signed-off-by: Kory Maincent <[email protected]>
---
 drivers/mmc/fsl_esdhc_imx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 7dc76563b7e..335b44a8a1a 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -752,10 +752,11 @@ static int esdhc_set_voltage(struct mmc *mmc)
        int ret;
 
        priv->signal_voltage = mmc->signal_voltage;
+       if (priv->vs18_enable)
+               return -ENOTSUPP;
+
        switch (mmc->signal_voltage) {
        case MMC_SIGNAL_VOLTAGE_330:
-               if (priv->vs18_enable)
-                       return -ENOTSUPP;
                if (CONFIG_IS_ENABLED(DM_REGULATOR) &&
                    !IS_ERR_OR_NULL(priv->vqmmc_dev)) {
                        ret = regulator_set_value(priv->vqmmc_dev,
-- 
2.43.0

Reply via email to