From: Kaustabh Chakraborty <kauschluss@disroot.org>
To: Peng Fan <peng.fan@oss.nxp.com>
Cc: u-boot@lists.denx.de, Peng Fan <peng.fan@nxp.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
Jonas Karlman <jonas@kwiboo.se>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Bhimeswararao Matsa <bhimeswararao.matsa@gmail.com>,
Andrew Goodbody <andrew.goodbody@linaro.org>,
Jean-Jacques Hiblot <jjhiblot@ti.com>,
Ronald Wahl <ronald.wahl@legrand.com>,
Anand Moon <linux.amoon@gmail.com>,
Sam Protsenko <semen.protsenko@linaro.org>,
Henrik Grimler <henrik@grimler.se>
Subject: Re: [PATCH 4/9] mmc: dw_mmc: add voltage switch command flag
Date: Wed, 22 Oct 2025 20:25:54 +0000 [thread overview]
Message-ID: <3e1fac47c324d389a14342fa430aad44@disroot.org> (raw)
In-Reply-To: <20251022081410.GC30163@nxa18884-linux.ap.freescale.net>
On 2025-10-22 08:14, Peng Fan wrote:
> Hi Kaustabh,
>
> On Fri, Oct 17, 2025 at 08:54:09PM +0530, Kaustabh Chakraborty wrote:
>> During a voltage switch command (CMD11, opcode: SD_CMD_SWITCH_UHS18V),
>> certain hosts tend to stop responding to subsequent commands. This is
>> addressed by introducing an additional command flag,
>> DWMCI_CMD_VOLT_SWITCH.
>
> is there any errata or spec have this information public?
I'm not aware of any. However, this behavior is found in the Linux
kernel
driver. See commit 0173055842cd1 ("mmc: dw_mmc: Support voltage
changes").
The state tracking in the kernel is however much more complex.
>
>>
>> The associated interrupt bit is defined as DWMCI_INTMSK_VOLTSW. This
>> is
>> set high when a voltage switch is issued, this needs to be waited for
>> and set to low. Implement the same in the timeout loop. Do note that
>> since DWMCI_INTMSK_VOLTSW shares the same bit as DWMCI_INTMSK_HTO (bit
>> 10), the interrupt bit needs to be polled for only if the volt switch
>> command is issued.
>>
>> DWMCI_CMD_VOLT_SWITCH also needs to be set for subsequent clken
>> commands
>> after the volt switch. To ensure this, add a boolean member in the
>> host
>> private struct (herein named volt_switching), which informs if the
>> last
>> command issued was for volt switching or not.
>>
>> Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
>> ---
>> drivers/mmc/dw_mmc.c | 15 +++++++++++++--
>> include/dwmmc.h | 4 ++++
>> 2 files changed, 17 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
>> index
>> 1aa992c352c3f11ccdd1c02745fa988646952261..94b6641c44c39e67aac453c027d519c0e1580de6
>> 100644
>> --- a/drivers/mmc/dw_mmc.c
>> +++ b/drivers/mmc/dw_mmc.c
>> @@ -419,6 +419,10 @@ static int dwmci_send_cmd_common(struct
>> dwmci_host *host, struct mmc_cmd *cmd,
>> if (cmd->resp_type & MMC_RSP_CRC)
>> flags |= DWMCI_CMD_CHECK_CRC;
>>
>> + host->volt_switching = (cmd->cmdidx == SD_CMD_SWITCH_UHS18V);
[1]
>> + if (host->volt_switching)
>> + flags |= DWMCI_CMD_VOLT_SWITCH;
>> +
>> flags |= cmd->cmdidx | DWMCI_CMD_START | DWMCI_CMD_USE_HOLD_REG;
>>
>> debug("Sending CMD%d\n", cmd->cmdidx);
>> @@ -427,6 +431,10 @@ static int dwmci_send_cmd_common(struct
>> dwmci_host *host, struct mmc_cmd *cmd,
>>
>> for (i = 0; i < retry; i++) {
>> mask = dwmci_readl(host, DWMCI_RINTSTS);
>> + if (host->volt_switching && (mask & DWMCI_INTMSK_VOLTSW)) {
>> + dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_VOLTSW);
>> + break;
>> + }
>> if (mask & DWMCI_INTMSK_CDONE) {
>> if (!data)
>> dwmci_writel(host, DWMCI_RINTSTS, mask);
>> @@ -508,12 +516,15 @@ static int dwmci_control_clken(struct dwmci_host
>> *host, bool on)
>> const u32 val = on ? DWMCI_CLKEN_ENABLE | DWMCI_CLKEN_LOW_PWR : 0;
>> const u32 cmd_only_clk = DWMCI_CMD_PRV_DAT_WAIT | DWMCI_CMD_UPD_CLK;
>> int i, timeout = 10000;
>> - u32 mask;
>> + u32 flags, mask;
>>
>> dwmci_writel(host, DWMCI_CLKENA, val);
>>
>> /* Inform CIU */
>> - dwmci_writel(host, DWMCI_CMD, DWMCI_CMD_START | cmd_only_clk);
>> + flags = DWMCI_CMD_START | cmd_only_clk;
>> + if (host->volt_switching)
>> + flags |= DWMCI_CMD_VOLT_SWITCH;
>> + dwmci_writel(host, DWMCI_CMD, flags);
>>
>> for (i = 0; i < timeout; i++) {
>> mask = dwmci_readl(host, DWMCI_RINTSTS);
>> diff --git a/include/dwmmc.h b/include/dwmmc.h
>> index
>> 639a2d28e7860f2ceb09955ee11550e406fd1bd2..47e3220985e900050d9db9d80e0d45efe6c2e545
>> 100644
>> --- a/include/dwmmc.h
>> +++ b/include/dwmmc.h
>> @@ -72,6 +72,7 @@
>> #define DWMCI_INTMSK_RTO BIT(8)
>> #define DWMCI_INTMSK_DRTO BIT(9)
>> #define DWMCI_INTMSK_HTO BIT(10)
>> +#define DWMCI_INTMSK_VOLTSW BIT(10) /* overlap! */
>> #define DWMCI_INTMSK_FRUN BIT(11)
>> #define DWMCI_INTMSK_HLE BIT(12)
>> #define DWMCI_INTMSK_SBE BIT(13)
>> @@ -104,6 +105,7 @@
>> #define DWMCI_CMD_ABORT_STOP BIT(14)
>> #define DWMCI_CMD_PRV_DAT_WAIT BIT(13)
>> #define DWMCI_CMD_UPD_CLK BIT(21)
>> +#define DWMCI_CMD_VOLT_SWITCH BIT(28)
>> #define DWMCI_CMD_USE_HOLD_REG BIT(29)
>> #define DWMCI_CMD_START BIT(31)
>>
>> @@ -190,6 +192,7 @@ struct dwmci_idmac_regs {
>> * @cfg: Internal MMC configuration, for !CONFIG_BLK cases
>> * @fifo_mode: Use FIFO mode (not DMA) to read and write data
>> * @dma_64bit_address: Whether DMA supports 64-bit address mode or not
>> + * @volt_switching: Whether SD voltage switching is in process or not
>
> Since volt_switching y means in process, I not see it is cleared when
> it is
> not needed. Is this expected?
See [1] marked above. Its enabled when SD_CMD_SWITCH_UHS18V is the
opcode,
disabled otherwise.
>
> Thanks,
> Peng
>
>> * @regs: Registers that can vary for different DW MMC block versions
>> */
>> struct dwmci_host {
>> @@ -229,6 +232,7 @@ struct dwmci_host {
>>
>> bool fifo_mode;
>> bool dma_64bit_address;
>> + bool volt_switching;
>> const struct dwmci_idmac_regs *regs;
>> };
>>
>>
>> --
>> 2.51.0
>>
next prev parent reply other threads:[~2025-10-22 21:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 15:24 [PATCH 0/9] Support for Samsung Exynos 7870 DW-MMC device in driver Kaustabh Chakraborty
2025-10-17 15:24 ` [PATCH 1/9] mmc: dw_mmc: export dwmci_send_cmd() and dwmci_set_ios() Kaustabh Chakraborty
2025-10-22 8:15 ` Peng Fan
2025-10-17 15:24 ` [PATCH 2/9] mmc: dw_mmc: do not skip dwmci_setup_bus() for same non-zero clock frequency Kaustabh Chakraborty
2025-10-22 8:15 ` Peng Fan
2025-10-17 15:24 ` [PATCH 3/9] mmc: dw_mmc: properly address command completion in dwmci_control_clken() Kaustabh Chakraborty
2025-10-22 7:56 ` Peng Fan
2025-10-23 16:36 ` Kaustabh Chakraborty
2025-10-17 15:24 ` [PATCH 4/9] mmc: dw_mmc: add voltage switch command flag Kaustabh Chakraborty
2025-10-22 8:14 ` Peng Fan
2025-10-22 20:25 ` Kaustabh Chakraborty [this message]
2025-10-17 15:24 ` [PATCH 5/9] mmc: dw_mmc: return error for invalid voltage setting Kaustabh Chakraborty
2025-10-22 8:15 ` Peng Fan
2025-10-17 15:24 ` [PATCH 6/9] mmc: enable/disable VQMMC regulator only during MMC power cycle Kaustabh Chakraborty
2025-10-17 15:24 ` [PATCH 7/9] mmc: exynos_dw_mmc: add support for MMC HS200 and HS400 modes Kaustabh Chakraborty
2025-10-22 8:18 ` Peng Fan
2025-10-23 10:46 ` Tanmay Kathpalia
2025-10-17 15:24 ` [PATCH 8/9] mmc: exynos_dw_mmc: add support for SD UHS mode Kaustabh Chakraborty
2025-10-22 8:19 ` Peng Fan
2025-10-17 15:24 ` [PATCH 9/9] mmc: exynos_dw_mmc: add compatible for exynos7870-dw-mshc-smu Kaustabh Chakraborty
2025-10-22 8:20 ` Peng Fan
2025-10-23 8:46 ` [PATCH 0/9] Support for Samsung Exynos 7870 DW-MMC device in driver Peng Fan (OSS)
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=3e1fac47c324d389a14342fa430aad44@disroot.org \
--to=kauschluss@disroot.org \
--cc=andrew.goodbody@linaro.org \
--cc=bhimeswararao.matsa@gmail.com \
--cc=henrik@grimler.se \
--cc=jh80.chung@samsung.com \
--cc=jjhiblot@ti.com \
--cc=jonas@kwiboo.se \
--cc=linux.amoon@gmail.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=ronald.wahl@legrand.com \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.