Skip to content

Commit

Permalink
mmc: mmci: stm32: Check when the voltage switch procedure should be done
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Yann Gautier <[email protected]>
Change-Id: Ie46dbe2b0d72291ee0874ee8fcebdf9f2f8391fa
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/227066
Reviewed-by: CITOOLS <[email protected]>
Reviewed-by: CIBUILD <[email protected]>
Reviewed-by: Christophe KERELLO <[email protected]>
  • Loading branch information
Yann-lms authored and fourmone committed Nov 23, 2021
1 parent c506f6d commit 672032a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/mmc/host/mmci_stm32_sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,9 @@ static int sdmmc_vswitch(struct mmci_host *host, struct mmc_ios *ios)
u32 status;
int ret = 0;

if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) {
spin_lock_irqsave(&host->lock, flags);
spin_lock_irqsave(&host->lock, flags);
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180 &&
host->pwr_reg & MCI_STM32_VSWITCHEN) {
mmci_write_pwrreg(host, host->pwr_reg | MCI_STM32_VSWITCH);
spin_unlock_irqrestore(&host->lock, flags);

Expand All @@ -492,8 +493,8 @@ static int sdmmc_vswitch(struct mmci_host *host, struct mmc_ios *ios)
spin_lock_irqsave(&host->lock, flags);
mmci_write_pwrreg(host, host->pwr_reg &
~(MCI_STM32_VSWITCHEN | MCI_STM32_VSWITCH));
spin_unlock_irqrestore(&host->lock, flags);
}
spin_unlock_irqrestore(&host->lock, flags);

return ret;
}
Expand Down

0 comments on commit 672032a

Please sign in to comment.