mmc: mmci: stm32: handle mmc power up
Subsystems (2)
PATCH 1/1 mmc: mmci: stm32: handle mmc power up
From: Christophe Kerello <[email protected]>
Manage MMC POWER UP state like MMC POWER OFF state. In case of low power use cases, it will avoid random initialization timeout. This fixes a failure to switch DDR52 eMMC to 8 bit mode due to -EILSEQ returned from mmc_get_ext_csd() in mmc_compare_ext_csds() called from mmc_select_bus_width() after Standby1 suspend/resume cycle.
---
Cc: Alexandre Torgue <[email protected]>
Cc: Christophe Kerello <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Marek: Update commit message
--- drivers/mmc/host/mmci_stm32_sdmmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/mmci_stm32_sdmmc.c +2 -1
@@ -368,7 +368,8 @@ static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr)if (dlyb && dlyb->ops->set_input_ck) dlyb->ops->set_input_ck (dlyb); -if (ios.power_mode ==MMC_POWER_OFF ) { +if (ios.power_mode ==MMC_POWER_OFF || + ios.power_mode ==MMC_POWER_UP ) {/* Only a reset could power-off sdmmc */ reset_control_assert (host->rst);udelay (2 );
Signature · 1 line
2.53.0
Quoted 33 lines · Marek Vasut
From: Christophe Kerello <[email protected]>
Manage MMC POWER UP state like MMC POWER OFF state. In case of low power use cases, it will avoid random initialization timeout. This fixes a failure to switch DDR52 eMMC to 8 bit mode due to
-EILSEQreturned frommmc_get_ext_csd()inmmc_compare_ext_csds()called frommmc_select_bus_width()after Standby1 suspend/resume cycle.Fixes 46b723dd867d ("mmc: mmci: add stm32 sdmmc variant")Signed-off-by Christophe Kerello <[email protected]>Signed-off-by Marek Vasut <[email protected]>---
Cc: Alexandre Torgue <[email protected]>
Cc: Christophe Kerello <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Marek: Update commit message--- drivers/mmc/host/mmci_stm32_sdmmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mmc/host/mmci_stm32_sdmmc.c +0
-0
drivers/mmc/host/mmci_stm32_sdmmc.c static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr) · line 375
Quoted 9 lines
drivers/mmc/host/mmci_stm32_sdmmc.c +2
-1@@ -368,7 +368,8 @@ static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr)if (dlyb && dlyb->ops->set_input_ck) dlyb->ops->set_input_ck (dlyb); -if (ios.power_mode ==MMC_POWER_OFF ) { +if (ios.power_mode ==MMC_POWER_OFF || + ios.power_mode ==MMC_POWER_UP ) {/* Only a reset could power-off sdmmc */ reset_control_assert (host->rst);udelay (2 );
What exactly will this reset?
Kind regards
Uffe
Quoted 37 lines · Ulf Hansson
Quoted 36 lines · Marek Vasut
From: Christophe Kerello <[email protected]>
Manage MMC POWER UP state like MMC POWER OFF state. In case of low power use cases, it will avoid random initialization timeout. This fixes a failure to switch DDR52 eMMC to 8 bit mode due to
-EILSEQreturned frommmc_get_ext_csd()inmmc_compare_ext_csds()called frommmc_select_bus_width()after Standby1 suspend/resume cycle.Fixes 46b723dd867d ("mmc: mmci: add stm32 sdmmc variant")Signed-off-by Christophe Kerello <[email protected]>Signed-off-by Marek Vasut <[email protected]>---
Cc: Alexandre Torgue <[email protected]>
Cc: Christophe Kerello <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Marek: Update commit message--- drivers/mmc/host/mmci_stm32_sdmmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mmc/host/mmci_stm32_sdmmc.c +0
-0@@ -368,7 +368,8 @@ static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr)if (dlyb && dlyb->ops->set_input_ck) dlyb->ops->set_input_ck (dlyb);
Quoted 8 lines
drivers/mmc/host/mmci_stm32_sdmmc.c static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr) · line 375
Quoted 6 lines
drivers/mmc/host/mmci_stm32_sdmmc.c +2
-1-if (ios.power_mode ==MMC_POWER_OFF ) { +if (ios.power_mode ==MMC_POWER_OFF || + ios.power_mode ==MMC_POWER_UP ) {/* Only a reset could power-off sdmmc */ reset_control_assert (host->rst);udelay (2 );What exactly will this reset?
The controller.
Quoted 47 lines · Marek Vasut
Quoted 37 lines · Ulf Hansson
Quoted 36 lines · Marek Vasut
From: Christophe Kerello <[email protected]>
Manage MMC POWER UP state like MMC POWER OFF state. In case of low power use cases, it will avoid random initialization timeout. This fixes a failure to switch DDR52 eMMC to 8 bit mode due to
-EILSEQreturned frommmc_get_ext_csd()inmmc_compare_ext_csds()called frommmc_select_bus_width()after Standby1 suspend/resume cycle.Fixes 46b723dd867d ("mmc: mmci: add stm32 sdmmc variant")Signed-off-by Christophe Kerello <[email protected]>Signed-off-by Marek Vasut <[email protected]>---
Cc: Alexandre Torgue <[email protected]>
Cc: Christophe Kerello <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Marek: Update commit message--- drivers/mmc/host/mmci_stm32_sdmmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mmc/host/mmci_stm32_sdmmc.c +0
-0@@ -368,7 +368,8 @@ static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr)if (dlyb && dlyb->ops->set_input_ck) dlyb->ops->set_input_ck (dlyb);Quoted 8 lines
drivers/mmc/host/mmci_stm32_sdmmc.c static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr) · line 375
Quoted 6 lines
drivers/mmc/host/mmci_stm32_sdmmc.c +2
-1-if (ios.power_mode ==MMC_POWER_OFF ) { +if (ios.power_mode ==MMC_POWER_OFF || + ios.power_mode ==MMC_POWER_UP ) {/* Only a reset could power-off sdmmc */ reset_control_assert (host->rst);udelay (2 );What exactly will this reset?
Quoted 1 line
The controller.
Okay, I see.
In that case, this reset also makes us reset preceding updates to any other registers, for example the clock register. I would not recommend doing that here, but perhaps there is no better option.
If I may I suggest an alternative solution, perhaps we can manage this in the ->runtime_resume() callback instead. If the power_mode == MMC_POWER_OFF, perhaps do this reset there instead? Would that work?
Anothing thing that caught my eyes was the MCI_STM32_PWR_CYC bit that gets written at MMC_POWER_OFF. This bit becomes cached in host->pwr_reg, hence it's also rewritten at MMC_POWER_ON. Is that intentional?
Kind regards
Uffe
On 11/11/26 12:45 PM, Ulf Hansson wrote:
Hello Ulf,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/mmc/host/mmci_stm32_sdmmc.c +2
-1-if (ios.power_mode ==MMC_POWER_OFF ) { +if (ios.power_mode ==MMC_POWER_OFF || + ios.power_mode ==MMC_POWER_UP ) {/* Only a reset could power-off sdmmc */ reset_control_assert (host->rst);udelay (2 );
Quoted 8 lines
Quoted 2 lines
Quoted 1 line
What exactly will this reset?
The controller.
Okay, I see.
In that case, this reset also makes us reset preceding updates to any other registers, for example the clock register. I would not recommend doing that here, but perhaps there is no better option.
Does that pose a problem in the MMC_POWER_OFF/UP state ? I agree this would pose a problem in the MMC_POWER_ON state, but here the card is not ON.
Quoted 8 lines
If I may I suggest an alternative solution, perhaps we can manage this in the ->runtime_resume() callback instead. If the
power_mode==MMC_POWER_OFF, perhaps do this reset there instead? Would that work?Anothing thing that caught my eyes was the
MCI_STM32_PWR_CYCbit that gets written atMMC_POWER_OFF. This bit becomes cached inhost->pwr_reg, hence it's also rewritten atMMC_POWER_ON. Is that intentional?
I _think_ so, this seems to be used to power cycle the card.
Quoted 15 lines · Marek Vasut
On 11/11/26 12:45 PM, Ulf Hansson wrote:
Hello Ulf,
Quoted 10 lines
Quoted 9 lines
Quoted 8 lines
drivers/mmc/host/mmci_stm32_sdmmc.c static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr) · line 375
Quoted 6 lines
drivers/mmc/host/mmci_stm32_sdmmc.c +2
-1-if (ios.power_mode ==MMC_POWER_OFF ) { +if (ios.power_mode ==MMC_POWER_OFF || + ios.power_mode ==MMC_POWER_UP ) {/* Only a reset could power-off sdmmc */ reset_control_assert (host->rst);udelay (2 );What exactly will this reset?
The controller.
Quoted 8 lines
Quoted 5 lines
Okay, I see.
In that case, this reset also makes us reset preceding updates to any other registers, for example the clock register. I would not recommend doing that here, but perhaps there is no better option.
Does that pose a problem in the MMC_POWER_OFF/UP state ? I agree this would pose a problem in the
MMC_POWER_ONstate, but here the card is not ON.
I think it is a problem, yes. If you have a closer look at what happens in mmci_set_ios(), I think you will agree.
Quoted 4 lines
Quoted 4 lines
If I may I suggest an alternative solution, perhaps we can manage this in the ->runtime_resume() callback instead. If the
power_mode==MMC_POWER_OFF, perhaps do this reset there instead? Would that work?
Can you try this?
Quoted 6 lines
Quoted 5 lines
Anothing thing that caught my eyes was the
MCI_STM32_PWR_CYCbit that gets written atMMC_POWER_OFF. This bit becomes cached inhost->pwr_reg, hence it's also rewritten atMMC_POWER_ON. Is that intentional?I _think_ so, this seems to be used to power cycle the card.
Well, we are not power-cycling the card at MMC_POWER_ON, we are turning it on.
Seems like we could use some support from the ST guys to understand this better.
Kind regards
Uffe
Hello Ulf,
Quoted 20 lines · Ulf Hansson
Quoted 11 lines · Marek Vasut
On 11/11/26 12:45 PM, Ulf Hansson wrote:
Hello Ulf,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/mmc/host/mmci_stm32_sdmmc.c static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr) · line 375
Quoted 6 lines
drivers/mmc/host/mmci_stm32_sdmmc.c +2
-1-if (ios.power_mode ==MMC_POWER_OFF ) { +if (ios.power_mode ==MMC_POWER_OFF || + ios.power_mode ==MMC_POWER_UP ) {/* Only a reset could power-off sdmmc */ reset_control_assert (host->rst);udelay (2 );What exactly will this reset?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
The controller.
Okay, I see.
In that case, this reset also makes us reset preceding updates to any other registers, for example the clock register. I would not recommend doing that here, but perhaps there is no better option.
Does that pose a problem in the MMC_POWER_OFF/UP state ? I agree this would pose a problem in the
MMC_POWER_ONstate, but here the card is not ON.
Quoted 7 lines
I think it is a problem, yes. If you have a closer look at what happens in
mmci_set_ios(), I think you will agree.Quoted 3 lines
Quoted 3 lines
If I may I suggest an alternative solution, perhaps we can manage this in the ->runtime_resume() callback instead. If the
power_mode==MMC_POWER_OFF, perhaps do this reset there instead? Would that work?Can you try this?
I have sent a new patch based on your proposal:
https://lore.kernel.org/linux-mmc/[email protected]/
It works fine on my side.
Hi Marek,
Could you also test it on your board to confirm that it fixes the issue you reported?
Regards,
Christophe Kerello.
Quoted 12 lines
Quoted 6 lines
Quoted 5 lines
Anothing thing that caught my eyes was the
MCI_STM32_PWR_CYCbit that gets written atMMC_POWER_OFF. This bit becomes cached inhost->pwr_reg, hence it's also rewritten atMMC_POWER_ON. Is that intentional?I _think_ so, this seems to be used to power cycle the card.
Well, we are not power-cycling the card at
MMC_POWER_ON, we are turning it on.Seems like we could use some support from the ST guys to understand this better.
Kind regards
Uffe
Quoted 31 lines · Christophe KERELLO
Hello Ulf,
Quoted 20 lines · Ulf Hansson
Quoted 11 lines · Marek Vasut
On 11/11/26 12:45 PM, Ulf Hansson wrote:
Hello Ulf,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
- if (ios.power_mode ==
MMC_POWER_OFF) {
+ if (ios.power_mode ==MMC_POWER_OFF||
+ ios.power_mode ==MMC_POWER_UP) {
/* Only a reset could power-off sdmmc */reset_control_assert(host->rst); udelay(2);What exactly will this reset?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
The controller.
Okay, I see.
In that case, this reset also makes us reset preceding updates to any other registers, for example the clock register. I would not recommend doing that here, but perhaps there is no better option.
Does that pose a problem in the MMC_POWER_OFF/UP state ? I agree this would pose a problem in the
MMC_POWER_ONstate, but here the card is not ON.Quoted 7 lines
I think it is a problem, yes. If you have a closer look at what happens in
mmci_set_ios(), I think you will agree.Quoted 3 lines
Quoted 3 lines
If I may I suggest an alternative solution, perhaps we can manage this in the ->runtime_resume() callback instead. If the
power_mode==MMC_POWER_OFF, perhaps do this reset there instead? Would that work?Can you try this?
Quoted 7 lines
I have sent a new patch based on your proposal:
https://lore.kernel.org/linux-mmc/20261113-fix-resume-reset- [email protected]/It works fine on my side.
Hi Marek,
Could you also test it on your board to confirm that it fixes the issue you reported?
This works too, thanks .