Skip to content

Commit 672032a

Browse files
Yann-lmsfourmone
authored andcommitted
mmc: mmci: stm32: Check when the voltage switch procedure should be done
If the card has not been power cycled, it may still be using 1.8V signaling. This situation is detected in mmc_sd_init_card function and should be handled in mmci stm32 variant. The host->pwr_reg variable is also correctly protected with spin locks. Fixes: 94b94a9 ("mmc: mmci_sdmmc: Implement signal voltage callbacks") Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com> Change-Id: Ie46dbe2b0d72291ee0874ee8fcebdf9f2f8391fa Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/227066 Reviewed-by: CITOOLS <MDG-smet-aci-reviews@list.st.com> Reviewed-by: CIBUILD <MDG-smet-aci-builds@list.st.com> Reviewed-by: Christophe KERELLO <christophe.kerello@st.com>
1 parent c506f6d commit 672032a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/mmc/host/mmci_stm32_sdmmc.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,9 @@ static int sdmmc_vswitch(struct mmci_host *host, struct mmc_ios *ios)
475475
u32 status;
476476
int ret = 0;
477477

478-
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) {
479-
spin_lock_irqsave(&host->lock, flags);
478+
spin_lock_irqsave(&host->lock, flags);
479+
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180 &&
480+
host->pwr_reg & MCI_STM32_VSWITCHEN) {
480481
mmci_write_pwrreg(host, host->pwr_reg | MCI_STM32_VSWITCH);
481482
spin_unlock_irqrestore(&host->lock, flags);
482483

@@ -492,8 +493,8 @@ static int sdmmc_vswitch(struct mmci_host *host, struct mmc_ios *ios)
492493
spin_lock_irqsave(&host->lock, flags);
493494
mmci_write_pwrreg(host, host->pwr_reg &
494495
~(MCI_STM32_VSWITCHEN | MCI_STM32_VSWITCH));
495-
spin_unlock_irqrestore(&host->lock, flags);
496496
}
497+
spin_unlock_irqrestore(&host->lock, flags);
497498

498499
return ret;
499500
}

0 commit comments

Comments
 (0)