hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/drivers/mmc/host/dw_mmc.c
....@@ -246,7 +246,7 @@
246246 * ...also allow sending for SDMMC_CMD_VOLT_SWITCH where busy is
247247 * expected.
248248 */
249
-#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
249
+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT_MMC
250250 if (host->slot->mmc->restrict_caps & RESTRICT_CARD_TYPE_EMMC)
251251 delay = 0;
252252 #endif
....@@ -1508,6 +1508,9 @@
15081508
15091509 switch (ios->power_mode) {
15101510 case MMC_POWER_UP:
1511
+ if (!IS_ERR_OR_NULL(slot->host->pinctrl))
1512
+ pinctrl_select_state(slot->host->pinctrl, slot->host->idle_state);
1513
+
15111514 if (!IS_ERR(mmc->supply.vmmc)) {
15121515 ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc,
15131516 ios->vdd);
....@@ -1524,6 +1527,9 @@
15241527 mci_writel(slot->host, PWREN, regs);
15251528 break;
15261529 case MMC_POWER_ON:
1530
+ if (!IS_ERR_OR_NULL(slot->host->pinctrl))
1531
+ pinctrl_select_state(slot->host->pinctrl, slot->host->normal_state);
1532
+
15271533 if (!slot->host->vqmmc_enabled) {
15281534 if (!IS_ERR(mmc->supply.vqmmc)) {
15291535 ret = regulator_enable(mmc->supply.vqmmc);
....@@ -1548,6 +1554,9 @@
15481554
15491555 break;
15501556 case MMC_POWER_OFF:
1557
+ if (!IS_ERR_OR_NULL(slot->host->pinctrl))
1558
+ pinctrl_select_state(slot->host->pinctrl, slot->host->idle_state);
1559
+
15511560 /* Turn clock off before power goes down */
15521561 dw_mci_setup_bus(slot, false);
15531562
....@@ -3272,6 +3281,22 @@
32723281 return ERR_PTR(ret);
32733282 }
32743283
3284
+ host->pinctrl = devm_pinctrl_get(host->dev);
3285
+ if (!IS_ERR(host->pinctrl)) {
3286
+ host->normal_state = pinctrl_lookup_state(host->pinctrl, "normal");
3287
+ if (IS_ERR(host->normal_state))
3288
+ dev_warn(dev, "No normal pinctrl state\n");
3289
+
3290
+ host->idle_state = pinctrl_lookup_state(host->pinctrl, "idle");
3291
+ if (IS_ERR(host->idle_state))
3292
+ dev_warn(dev, "No idle pinctrl state\n");
3293
+
3294
+ if (!IS_ERR(host->normal_state) && !IS_ERR(host->idle_state))
3295
+ pinctrl_select_state(host->pinctrl, host->idle_state);
3296
+ else
3297
+ host->pinctrl = NULL;
3298
+ }
3299
+
32753300 return pdata;
32763301 }
32773302
....@@ -3329,7 +3354,7 @@
33293354 return ret;
33303355 }
33313356 }
3332
-#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
3357
+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT_MMC
33333358 if (device_property_read_bool(host->dev, "supports-emmc")) {
33343359 if (readl_poll_timeout(host->regs + SDMMC_STATUS,
33353360 fifo_size,