Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Ricky Wu and committed by
Ulf Hansson
1e31a3e8 6a4a4c1c

+6 -82
+6 -82
drivers/mmc/host/rtsx_pci_sdmmc.c
··· 1181 1181 return cd; 1182 1182 } 1183 1183 1184 - static int sd_wait_voltage_stable_1(struct realtek_pci_sdmmc *host) 1185 - { 1186 - struct rtsx_pcr *pcr = host->pcr; 1187 - int err; 1188 - u8 stat; 1189 - 1190 - /* Reference to Signal Voltage Switch Sequence in SD spec. 1191 - * Wait for a period of time so that the card can drive SD_CMD and 1192 - * SD_DAT[3:0] to low after sending back CMD11 response. 1193 - */ 1194 - mdelay(1); 1195 - 1196 - /* SD_CMD, SD_DAT[3:0] should be driven to low by card; 1197 - * If either one of SD_CMD,SD_DAT[3:0] is not low, 1198 - * abort the voltage switch sequence; 1199 - */ 1200 - err = rtsx_pci_read_register(pcr, SD_BUS_STAT, &stat); 1201 - if (err < 0) 1202 - return err; 1203 - 1204 - if (stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | 1205 - SD_DAT1_STATUS | SD_DAT0_STATUS)) 1206 - return -EINVAL; 1207 - 1208 - /* Stop toggle SD clock */ 1209 - err = rtsx_pci_write_register(pcr, SD_BUS_STAT, 1210 - 0xFF, SD_CLK_FORCE_STOP); 1211 - if (err < 0) 1212 - return err; 1213 - 1214 - return 0; 1215 - } 1216 - 1217 - static int sd_wait_voltage_stable_2(struct realtek_pci_sdmmc *host) 1218 - { 1219 - struct rtsx_pcr *pcr = host->pcr; 1220 - int err; 1221 - u8 stat, mask, val; 1222 - 1223 - /* Wait 1.8V output of voltage regulator in card stable */ 1224 - msleep(50); 1225 - 1226 - /* Toggle SD clock again */ 1227 - err = rtsx_pci_write_register(pcr, SD_BUS_STAT, 0xFF, SD_CLK_TOGGLE_EN); 1228 - if (err < 0) 1229 - return err; 1230 - 1231 - /* Wait for a period of time so that the card can drive 1232 - * SD_DAT[3:0] to high at 1.8V 1233 - */ 1234 - msleep(20); 1235 - 1236 - /* SD_CMD, SD_DAT[3:0] should be pulled high by host */ 1237 - err = rtsx_pci_read_register(pcr, SD_BUS_STAT, &stat); 1238 - if (err < 0) 1239 - return err; 1240 - 1241 - mask = SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | 1242 - SD_DAT1_STATUS | SD_DAT0_STATUS; 1243 - val = SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | 1244 - SD_DAT1_STATUS | SD_DAT0_STATUS; 1245 - if ((stat & mask) != val) { 1246 - dev_dbg(sdmmc_dev(host), 1247 - "%s: SD_BUS_STAT = 0x%x\n", __func__, stat); 1248 - rtsx_pci_write_register(pcr, SD_BUS_STAT, 1249 - SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0); 1250 - rtsx_pci_write_register(pcr, CARD_CLK_EN, 0xFF, 0); 1251 - return -EINVAL; 1252 - } 1253 - 1254 - return 0; 1255 - } 1256 - 1257 1184 static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios) 1258 1185 { 1259 1186 struct realtek_pci_sdmmc *host = mmc_priv(mmc); ··· 1208 1281 voltage = OUTPUT_1V8; 1209 1282 1210 1283 if (voltage == OUTPUT_1V8) { 1211 - err = sd_wait_voltage_stable_1(host); 1284 + /* Stop toggle SD clock */ 1285 + err = rtsx_pci_write_register(pcr, SD_BUS_STAT, 1286 + 0xFF, SD_CLK_FORCE_STOP); 1212 1287 if (err < 0) 1213 1288 goto out; 1214 1289 } ··· 1219 1290 if (err < 0) 1220 1291 goto out; 1221 1292 1222 - if (voltage == OUTPUT_1V8) { 1223 - err = sd_wait_voltage_stable_2(host); 1224 - if (err < 0) 1225 - goto out; 1226 - } 1227 - 1228 1293 out: 1229 1294 /* Stop toggle SD clock in idle */ 1230 - err = rtsx_pci_write_register(pcr, SD_BUS_STAT, 1231 - SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0); 1295 + if (err < 0) 1296 + rtsx_pci_write_register(pcr, SD_BUS_STAT, 1297 + SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0); 1232 1298 1233 1299 mutex_unlock(&pcr->pcr_mutex); 1234 1300