mmc: rtsx_pci_sdmmc: simplify voltage switch handling after card_busy()

Now that the Realtek PCIe SDMMC host implements the card_busy() callback,
the MMC core performs the required DAT[3:0] validation during the signal
voltage switch sequence.

As a result, the driver-side voltage stabilization helpers
sd_wait_voltage_stable_1() and sd_wait_voltage_stable_2() become redundant.
These helpers duplicate DAT line checks that are now handled centrally by
the MMC core via card_busy().

Remove the two stabilization helpers and simplify sdmmc_switch_voltage()
accordingly, keeping only the minimal clock control needed around the
voltage switch.

No functional changes and intended.

Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
master
Ricky Wu 2026-01-30 11:05:01 +08:00 committed by Ulf Hansson
parent 6a4a4c1cc0
commit 1e31a3e867
1 changed files with 6 additions and 82 deletions

View File

@ -1181,79 +1181,6 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
return cd;
}
static int sd_wait_voltage_stable_1(struct realtek_pci_sdmmc *host)
{
struct rtsx_pcr *pcr = host->pcr;
int err;
u8 stat;
/* Reference to Signal Voltage Switch Sequence in SD spec.
* Wait for a period of time so that the card can drive SD_CMD and
* SD_DAT[3:0] to low after sending back CMD11 response.
*/
mdelay(1);
/* SD_CMD, SD_DAT[3:0] should be driven to low by card;
* If either one of SD_CMD,SD_DAT[3:0] is not low,
* abort the voltage switch sequence;
*/
err = rtsx_pci_read_register(pcr, SD_BUS_STAT, &stat);
if (err < 0)
return err;
if (stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS |
SD_DAT1_STATUS | SD_DAT0_STATUS))
return -EINVAL;
/* Stop toggle SD clock */
err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
0xFF, SD_CLK_FORCE_STOP);
if (err < 0)
return err;
return 0;
}
static int sd_wait_voltage_stable_2(struct realtek_pci_sdmmc *host)
{
struct rtsx_pcr *pcr = host->pcr;
int err;
u8 stat, mask, val;
/* Wait 1.8V output of voltage regulator in card stable */
msleep(50);
/* Toggle SD clock again */
err = rtsx_pci_write_register(pcr, SD_BUS_STAT, 0xFF, SD_CLK_TOGGLE_EN);
if (err < 0)
return err;
/* Wait for a period of time so that the card can drive
* SD_DAT[3:0] to high at 1.8V
*/
msleep(20);
/* SD_CMD, SD_DAT[3:0] should be pulled high by host */
err = rtsx_pci_read_register(pcr, SD_BUS_STAT, &stat);
if (err < 0)
return err;
mask = SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS |
SD_DAT1_STATUS | SD_DAT0_STATUS;
val = SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS |
SD_DAT1_STATUS | SD_DAT0_STATUS;
if ((stat & mask) != val) {
dev_dbg(sdmmc_dev(host),
"%s: SD_BUS_STAT = 0x%x\n", __func__, stat);
rtsx_pci_write_register(pcr, SD_BUS_STAT,
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
rtsx_pci_write_register(pcr, CARD_CLK_EN, 0xFF, 0);
return -EINVAL;
}
return 0;
}
static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
{
struct realtek_pci_sdmmc *host = mmc_priv(mmc);
@ -1281,7 +1208,9 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
voltage = OUTPUT_1V8;
if (voltage == OUTPUT_1V8) {
err = sd_wait_voltage_stable_1(host);
/* Stop toggle SD clock */
err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
0xFF, SD_CLK_FORCE_STOP);
if (err < 0)
goto out;
}
@ -1290,16 +1219,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
if (err < 0)
goto out;
if (voltage == OUTPUT_1V8) {
err = sd_wait_voltage_stable_2(host);
if (err < 0)
goto out;
}
out:
/* Stop toggle SD clock in idle */
err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
if (err < 0)
rtsx_pci_write_register(pcr, SD_BUS_STAT,
SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
mutex_unlock(&pcr->pcr_mutex);