From: Shawn Lin <shawn.lin@rock-chips.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, Jaehoon Chung <jh80.chung@samsung.com>,
Shawn Lin <shawn.lin@rock-chips.com>
Subject: [PATCH v2 03/13] mmc: dw_mmc: Remove vqmmc_enabled from struct dw_mci and user helpers from core
Date: Wed, 26 Nov 2025 08:14:43 +0800 [thread overview]
Message-ID: <1764116093-5430-4-git-send-email-shawn.lin@rock-chips.com> (raw)
In-Reply-To: <1764116093-5430-1-git-send-email-shawn.lin@rock-chips.com>
commit 51da2240906c ("mmc: dw_mmc: use mmc_regulator_get_supply to handle regulators")
introduced tracking of vqmmc_enabled. Currently, mmc_regulator_enable_vqmmc() and
mmc_regulator_disable_vqmmc() well record the status of vqmmc, so use these two helpers
to remove vqmmc_enabled locally. And also remove the if(!IS_ERR..) check before calling
mmc_regulator_set_ocr() as mmc_regulator_set_ocr() already checks if vqmmc is correct.
This patch is tested on RK3588s EVB1 with TF cards with both vqmmc present or not.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
Changes in v2:
- Use helpers from regulator.c and remove check for mmc_regulator_set_ocr.
drivers/mmc/host/dw_mmc.c | 41 ++++++++++-------------------------------
drivers/mmc/host/dw_mmc.h | 2 --
2 files changed, 10 insertions(+), 33 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 2d81d021..1c352d2 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1424,15 +1424,12 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
switch (ios->power_mode) {
case MMC_POWER_UP:
- if (!IS_ERR(mmc->supply.vmmc)) {
- ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc,
- ios->vdd);
- if (ret) {
- dev_err(slot->host->dev,
- "failed to enable vmmc regulator\n");
- /*return, if failed turn on vmmc*/
- return;
- }
+ ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
+ if (ret) {
+ dev_err(slot->host->dev,
+ "failed to enable vmmc regulator\n");
+ /*return, if failed turn on vmmc*/
+ return;
}
set_bit(DW_MMC_CARD_NEED_INIT, &slot->flags);
regs = mci_readl(slot->host, PWREN);
@@ -1440,25 +1437,7 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
mci_writel(slot->host, PWREN, regs);
break;
case MMC_POWER_ON:
- if (!slot->host->vqmmc_enabled) {
- if (!IS_ERR(mmc->supply.vqmmc)) {
- ret = regulator_enable(mmc->supply.vqmmc);
- if (ret < 0)
- dev_err(slot->host->dev,
- "failed to enable vqmmc\n");
- else
- slot->host->vqmmc_enabled = true;
-
- } else {
- /* Keep track so we don't reset again */
- slot->host->vqmmc_enabled = true;
- }
-
- /* Reset our state machine after powering on */
- dw_mci_ctrl_reset(slot->host,
- SDMMC_CTRL_ALL_RESET_FLAGS);
- }
-
+ mmc_regulator_enable_vqmmc(mmc);
/* Adjust clock / bus width after power is up */
dw_mci_setup_bus(slot, false);
@@ -1470,13 +1449,13 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
if (!IS_ERR(mmc->supply.vmmc))
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
- if (!IS_ERR(mmc->supply.vqmmc) && slot->host->vqmmc_enabled)
- regulator_disable(mmc->supply.vqmmc);
- slot->host->vqmmc_enabled = false;
+ mmc_regulator_disable_vqmmc(mmc);
regs = mci_readl(slot->host, PWREN);
regs &= ~(1 << slot->id);
mci_writel(slot->host, PWREN, regs);
+ /* Reset our state machine after powering off */
+ dw_mci_ctrl_reset(slot->host, SDMMC_CTRL_ALL_RESET_FLAGS);
break;
default:
break;
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index b4ceca0..6faa63b 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -121,7 +121,6 @@ struct dw_mci_dma_slave {
* @push_data: Pointer to FIFO push function.
* @pull_data: Pointer to FIFO pull function.
* @quirks: Set of quirks that apply to specific versions of the IP.
- * @vqmmc_enabled: Status of vqmmc, should be true or false.
* @irq_flags: The flags to be passed to request_irq.
* @irq: The irq value to be passed to request_irq.
* @sdio_id0: Number of slot0 in the SDIO interrupt registers.
@@ -228,7 +227,6 @@ struct dw_mci {
void (*pull_data)(struct dw_mci *host, void *buf, int cnt);
u32 quirks;
- bool vqmmc_enabled;
unsigned long irq_flags; /* IRQ flags */
int irq;
--
2.7.4
next prev parent reply other threads:[~2025-11-26 0:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 0:14 [PATCH v2 0/13] dwmmc cleanup Shawn Lin
2025-11-26 0:14 ` [PATCH v2 01/13] mmc: dw_mmc: Remove unused struct dma_pdata Shawn Lin
2025-11-26 0:14 ` [PATCH v2 02/13] mmc: dw_mmc: add dw_mci_prepare_desc() for both of 32bit and 64bit DMA Shawn Lin
2025-11-26 0:14 ` Shawn Lin [this message]
2025-12-15 14:30 ` [PATCH v2 03/13] mmc: dw_mmc: Remove vqmmc_enabled from struct dw_mci and user helpers from core Ulf Hansson
2025-12-16 1:52 ` Shawn Lin
2025-12-16 10:51 ` Ulf Hansson
2025-11-26 0:14 ` [PATCH v2 04/13] mmc: dw_mmc: Remove unused header files and keep alphabetical order Shawn Lin
2025-11-26 0:14 ` [PATCH v2 05/13] mmc: dw_mmc: Move struct mmc_host from struct dw_mci_slot to struct dw_mci Shawn Lin
2025-11-26 0:14 ` [PATCH v2 06/13] mmc: dw_mmc: Let glue drivers to use struct dw_mci as possible Shawn Lin
2025-11-26 0:14 ` [PATCH v2 07/13] mmc: dw_mmc: Move flags from struct dw_mci_slot to struct dw_mci Shawn Lin
2025-11-26 0:14 ` [PATCH v2 08/13] mmc: dw_mmc: Remove id and ctype from dw_mci_slot Shawn Lin
2025-11-26 0:14 ` [PATCH v2 09/13] mmc: dw_mmc: Remove sdio_id from struct dw_mci_slot Shawn Lin
2025-11-26 0:14 ` [PATCH v2 10/13] mmc: dw_mmc: Move clock rate stuff from struct dw_mci_slot to struct dw_mci Shawn Lin
2025-11-26 0:14 ` [PATCH v2 11/13] mmc: dw_mmc: Remove mrq from struct dw_mci_slot Shawn Lin
2025-11-26 0:14 ` [PATCH v2 12/13] mmc: dw_mmc: Remove queue from dw_mci Shawn Lin
2025-11-26 0:14 ` [PATCH v2 13/13] mmc: dw_mmc: Remove struct dw_mci_slot Shawn Lin
2025-12-15 15:42 ` [PATCH v2 0/13] dwmmc cleanup Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1764116093-5430-4-git-send-email-shawn.lin@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=jh80.chung@samsung.com \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox