Skip to content

Commit d8e193f

Browse files
Christophe Kerellostorulf
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 <[email protected]> Signed-off-by: Yann Gautier <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 25f8203 commit d8e193f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/mmc/host/mmci_stm32_sdmmc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,9 @@ static int sdmmc_post_sig_volt_switch(struct mmci_host *host,
479479
u32 status;
480480
int ret = 0;
481481

482-
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) {
483-
spin_lock_irqsave(&host->lock, flags);
482+
spin_lock_irqsave(&host->lock, flags);
483+
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180 &&
484+
host->pwr_reg & MCI_STM32_VSWITCHEN) {
484485
mmci_write_pwrreg(host, host->pwr_reg | MCI_STM32_VSWITCH);
485486
spin_unlock_irqrestore(&host->lock, flags);
486487

@@ -492,9 +493,11 @@ static int sdmmc_post_sig_volt_switch(struct mmci_host *host,
492493

493494
writel_relaxed(MCI_STM32_VSWENDC | MCI_STM32_CKSTOPC,
494495
host->base + MMCICLEAR);
496+
spin_lock_irqsave(&host->lock, flags);
495497
mmci_write_pwrreg(host, host->pwr_reg &
496498
~(MCI_STM32_VSWITCHEN | MCI_STM32_VSWITCH));
497499
}
500+
spin_unlock_irqrestore(&host->lock, flags);
498501

499502
return ret;
500503
}

0 commit comments

Comments
 (0)