Skip to content

Commit db58532

Browse files
Sarthak GargUlf Hansson
authored andcommitted
mmc: sdhci-msm: Ensure SD card power isn't ON when card removed
Many mobile phones feature multi-card tray designs, where the same tray is used for both SD and SIM cards. If the SD card is placed at the outermost location in the tray, the SIM card may come in contact with SD card power-supply while removing the tray, possibly resulting in SIM damage. To prevent that, make sure the SD card is really inserted by reading the Card Detect pin state. If it's not, turn off the power in sdhci_msm_check_power_status() and also set the BUS_FAIL power state on the controller as part of pwr_irq handling for BUS_ON request. Signed-off-by: Sarthak Garg <quic_sartgarg@quicinc.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/20250701100659.3310386-1-quic_sartgarg@quicinc.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 886eade commit db58532

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

drivers/mmc/host/sdhci-msm.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ static void sdhci_msm_check_power_status(struct sdhci_host *host, u32 req_type)
15641564
{
15651565
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
15661566
struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
1567+
struct mmc_host *mmc = host->mmc;
15671568
bool done = false;
15681569
u32 val = SWITCHABLE_SIGNALING_VOLTAGE;
15691570
const struct sdhci_msm_offset *msm_offset =
@@ -1621,6 +1622,12 @@ static void sdhci_msm_check_power_status(struct sdhci_host *host, u32 req_type)
16211622
"%s: pwr_irq for req: (%d) timed out\n",
16221623
mmc_hostname(host->mmc), req_type);
16231624
}
1625+
1626+
if ((req_type & REQ_BUS_ON) && mmc->card && !mmc->ops->get_cd(mmc)) {
1627+
sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
1628+
host->pwr = 0;
1629+
}
1630+
16241631
pr_debug("%s: %s: request %d done\n", mmc_hostname(host->mmc),
16251632
__func__, req_type);
16261633
}
@@ -1679,6 +1686,13 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
16791686
udelay(10);
16801687
}
16811688

1689+
if ((irq_status & CORE_PWRCTL_BUS_ON) && mmc->card &&
1690+
!mmc->ops->get_cd(mmc)) {
1691+
msm_host_writel(msm_host, CORE_PWRCTL_BUS_FAIL, host,
1692+
msm_offset->core_pwrctl_ctl);
1693+
return;
1694+
}
1695+
16821696
/* Handle BUS ON/OFF*/
16831697
if (irq_status & CORE_PWRCTL_BUS_ON) {
16841698
pwr_state = REQ_BUS_ON;

0 commit comments

Comments
 (0)