* Re: [PATCH v3 2/2] mmc: litex_mmc: Set mandatory idle clocks before CMD0
[not found] ` <20260426112016.1370929-3-inochiama@gmail.com>
@ 2026-05-11 14:52 ` Ulf Hansson
2026-05-12 0:35 ` Inochi Amaoto
0 siblings, 1 reply; 2+ messages in thread
From: Ulf Hansson @ 2026-05-11 14:52 UTC (permalink / raw)
To: Inochi Amaoto
Cc: Ulf Hansson, Karol Gugala, Mateusz Holenko, Gabriel Somlo,
Joel Stanley, Paul Mackerras, Maciej Dudek, Andy Shevchenko,
linux-mmc, linux-kernel, Yixun Lan, Longbin Li
On Sun, 26 Apr 2026 at 13:20, Inochi Amaoto <inochiama@gmail.com> wrote:
>
> The litex_mmc driver assumes the card is already probed in the BIOS
> and skip the phy initialization. This will cause the command fail
> like the following when the old card is unplugged and then insert
> a new card:
>
> [ 62.923593] litex-mmc f0004000.mmc: Command (cmd 8) error, status -110
> [ 62.949717] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110
> [ 62.976606] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110
> [ 63.002516] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110
> [ 63.028442] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110
>
> Add required clock settings and initialization for the CMD 0, so it can
> probe the new card.
>
> Fixes: 92e099104729 ("mmc: Add driver for LiteX's LiteSDCard interface")
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> ---
> drivers/mmc/host/litex_mmc.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/mmc/host/litex_mmc.c b/drivers/mmc/host/litex_mmc.c
> index a8d9c0ece16a..c984398d0803 100644
> --- a/drivers/mmc/host/litex_mmc.c
> +++ b/drivers/mmc/host/litex_mmc.c
> @@ -68,6 +68,9 @@
> #define SD_SLEEP_US 5
> #define SD_TIMEOUT_US 20000
>
> +#define SD_INIT_DELAY_US 1000
> +#define SD_INIT_CLK_HZ 400000
> +
> #define SDIRQ_CARD_DETECT 1
> #define SDIRQ_SD_TO_MEM_DONE 2
> #define SDIRQ_MEM_TO_SD_DONE 4
> @@ -142,6 +145,12 @@ static int litex_mmc_send_cmd(struct litex_mmc_host *host,
> int ret;
> u8 evt;
>
> + if (cmd == MMC_GO_IDLE_STATE) {
Rather than doing this explicit check for each command being sent, we
have the ->set_ios() callback where things like this belong. Please
move it there instead.
> + litex_mmc_setclk(host, SD_INIT_CLK_HZ);
> + litex_write8(host->sdphy + LITEX_PHY_INITIALIZE, 1);
> + fsleep(SD_INIT_DELAY_US);
> + }
> +
> litex_write32(host->sdcore + LITEX_CORE_CMDARG, arg);
> litex_write32(host->sdcore + LITEX_CORE_CMDCMD,
> cmd << 8 | transfer << 5 | response_len);
> --
> 2.54.0
>
Kind regards
Uffe
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3 2/2] mmc: litex_mmc: Set mandatory idle clocks before CMD0
2026-05-11 14:52 ` [PATCH v3 2/2] mmc: litex_mmc: Set mandatory idle clocks before CMD0 Ulf Hansson
@ 2026-05-12 0:35 ` Inochi Amaoto
0 siblings, 0 replies; 2+ messages in thread
From: Inochi Amaoto @ 2026-05-12 0:35 UTC (permalink / raw)
To: Ulf Hansson, Inochi Amaoto
Cc: Ulf Hansson, Karol Gugala, Mateusz Holenko, Gabriel Somlo,
Joel Stanley, Paul Mackerras, Maciej Dudek, Andy Shevchenko,
linux-mmc, linux-kernel, Yixun Lan, Longbin Li
On Mon, May 11, 2026 at 04:52:21PM +0200, Ulf Hansson wrote:
> On Sun, 26 Apr 2026 at 13:20, Inochi Amaoto <inochiama@gmail.com> wrote:
> >
> > The litex_mmc driver assumes the card is already probed in the BIOS
> > and skip the phy initialization. This will cause the command fail
> > like the following when the old card is unplugged and then insert
> > a new card:
> >
> > [ 62.923593] litex-mmc f0004000.mmc: Command (cmd 8) error, status -110
> > [ 62.949717] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110
> > [ 62.976606] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110
> > [ 63.002516] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110
> > [ 63.028442] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110
> >
> > Add required clock settings and initialization for the CMD 0, so it can
> > probe the new card.
> >
> > Fixes: 92e099104729 ("mmc: Add driver for LiteX's LiteSDCard interface")
> > Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> > ---
> > drivers/mmc/host/litex_mmc.c | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/drivers/mmc/host/litex_mmc.c b/drivers/mmc/host/litex_mmc.c
> > index a8d9c0ece16a..c984398d0803 100644
> > --- a/drivers/mmc/host/litex_mmc.c
> > +++ b/drivers/mmc/host/litex_mmc.c
> > @@ -68,6 +68,9 @@
> > #define SD_SLEEP_US 5
> > #define SD_TIMEOUT_US 20000
> >
> > +#define SD_INIT_DELAY_US 1000
> > +#define SD_INIT_CLK_HZ 400000
> > +
> > #define SDIRQ_CARD_DETECT 1
> > #define SDIRQ_SD_TO_MEM_DONE 2
> > #define SDIRQ_MEM_TO_SD_DONE 4
> > @@ -142,6 +145,12 @@ static int litex_mmc_send_cmd(struct litex_mmc_host *host,
> > int ret;
> > u8 evt;
> >
> > + if (cmd == MMC_GO_IDLE_STATE) {
>
> Rather than doing this explicit check for each command being sent, we
> have the ->set_ios() callback where things like this belong. Please
> move it there instead.
>
OK, And I think the patch 1 can be removed if this got moved
to set_ios(). I will prepare a new version for it.
Regards,
Inochi
> > + litex_mmc_setclk(host, SD_INIT_CLK_HZ);
> > + litex_write8(host->sdphy + LITEX_PHY_INITIALIZE, 1);
> > + fsleep(SD_INIT_DELAY_US);
> > + }
> > +
> > litex_write32(host->sdcore + LITEX_CORE_CMDARG, arg);
> > litex_write32(host->sdcore + LITEX_CORE_CMDCMD,
> > cmd << 8 | transfer << 5 | response_len);
> > --
> > 2.54.0
> >
>
> Kind regards
> Uffe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-12 0:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260426112016.1370929-1-inochiama@gmail.com>
[not found] ` <20260426112016.1370929-3-inochiama@gmail.com>
2026-05-11 14:52 ` [PATCH v3 2/2] mmc: litex_mmc: Set mandatory idle clocks before CMD0 Ulf Hansson
2026-05-12 0:35 ` Inochi Amaoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox