Skip to content

Commit 1226102

Browse files
matte-schwartzstorulf
authored andcommitted
mmc: rtsx_pci_sdmmc: implement sdmmc_card_busy function
rtsx_pci_sdmmc does not have an sdmmc_card_busy function, so any voltage switches cause a kernel warning, "mmc0: cannot verify signal voltage switch." Copy the sdmmc_card_busy function from rtsx_pci_usb to rtsx_pci_sdmmc to fix this. Fixes: ff984e5 ("mmc: Add realtek pcie sdmmc host driver") Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev> Tested-by: Ricky WU <ricky_wu@realtek.com> Reviewed-by: Ricky WU <ricky_wu@realtek.com> Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 3009738 commit 1226102

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

drivers/mmc/host/rtsx_pci_sdmmc.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,46 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
13061306
return err;
13071307
}
13081308

1309+
static int sdmmc_card_busy(struct mmc_host *mmc)
1310+
{
1311+
struct realtek_pci_sdmmc *host = mmc_priv(mmc);
1312+
struct rtsx_pcr *pcr = host->pcr;
1313+
int err;
1314+
u8 stat;
1315+
u8 mask = SD_DAT3_STATUS | SD_DAT2_STATUS | SD_DAT1_STATUS
1316+
| SD_DAT0_STATUS;
1317+
1318+
mutex_lock(&pcr->pcr_mutex);
1319+
1320+
rtsx_pci_start_run(pcr);
1321+
1322+
err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
1323+
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP,
1324+
SD_CLK_TOGGLE_EN);
1325+
if (err)
1326+
goto out;
1327+
1328+
mdelay(1);
1329+
1330+
err = rtsx_pci_read_register(pcr, SD_BUS_STAT, &stat);
1331+
if (err)
1332+
goto out;
1333+
1334+
err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
1335+
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
1336+
out:
1337+
mutex_unlock(&pcr->pcr_mutex);
1338+
1339+
if (err)
1340+
return err;
1341+
1342+
/* check if any pin between dat[0:3] is low */
1343+
if ((stat & mask) != mask)
1344+
return 1;
1345+
else
1346+
return 0;
1347+
}
1348+
13091349
static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
13101350
{
13111351
struct realtek_pci_sdmmc *host = mmc_priv(mmc);
@@ -1418,6 +1458,7 @@ static const struct mmc_host_ops realtek_pci_sdmmc_ops = {
14181458
.get_ro = sdmmc_get_ro,
14191459
.get_cd = sdmmc_get_cd,
14201460
.start_signal_voltage_switch = sdmmc_switch_voltage,
1461+
.card_busy = sdmmc_card_busy,
14211462
.execute_tuning = sdmmc_execute_tuning,
14221463
.init_sd_express = sdmmc_init_sd_express,
14231464
};

0 commit comments

Comments
 (0)