mmc: dw_mmc: Make sure we only adjust the clock when power is on
Subsystems (2)
PATCH 1/2 mmc: dw_mmc: Make sure we only adjust the clock when power is on
It appears that we can confuse things if we try to turn on the MMC clock when the power is off. Adjust is so that we turn the clock on (using dw_mci_setup_bus) after power is all the way on and we turn the clock off before the power goes off.
--- drivers/mmc/host/dw_mmc.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/mmc/host/dw_mmc.c +10 -6
@@ -1101,12 +1101,6 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)if (drv_data && drv_data->set_ios) drv_data->set_ios (slot->host, ios); -/* Slot specific timing and width adjustment */ -dw_mci_setup_bus (slot, false); - -if (slot->host->state ==STATE_WAITING_CMD11_DONE && ios->clock !=0 ) - slot->host->state =STATE_IDLE ; -switch (ios->power_mode) {case MMC_POWER_UP :if (!IS_ERR (mmc->supply.vmmc)) {
@@ -1133,8 +1127,15 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)else slot->host->vqmmc_enabled = true; } + +/* Adjust clock / bus width after power is up */ +dw_mci_setup_bus (slot, false); +break ;case MMC_POWER_OFF : +/* Turn clock off before power goes down */ +dw_mci_setup_bus (slot, false); +if (!IS_ERR (mmc->supply.vmmc))mmc_regulator_set_ocr (mmc, mmc->supply.vmmc,0 );
@@ -1150,6 +1151,9 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)default :break ; } + +if (slot->host->state ==STATE_WAITING_CMD11_DONE && ios->clock !=0 ) + slot->host->state =STATE_IDLE ; }static int dw_mci_card_busy (struct mmc_host *mmc)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 2/2 mmc: dw_mmc: Give a good reset after we give power
We should give dw_mmc a good reset after we apply power. On some boards vqmmc may actually be connected to the IP block in the SoC so it's good to reset after power comes in.
Without this we sometimes see failures enumerating cards on rk3288.
--- drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/mmc/host/dw_mmc.c +18 -9
@@ -1119,13 +1119,23 @@ 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 (!IS_ERR (mmc->supply.vqmmc) && !slot->host->vqmmc_enabled) { - ret =regulator_enable (mmc->supply.vqmmc); -if (ret <0 ) -dev_err (slot->host->dev, -"failed to enable vqmmc regulator\n" ); -else +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 ); }/* Adjust clock / bus width after power is up */
@@ -1139,10 +1149,9 @@ 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) { +if (!IS_ERR (mmc->supply.vqmmc) && slot->host->vqmmc_enabled)regulator_disable (mmc->supply.vqmmc); - slot->host->vqmmc_enabled = false; - } + slot->host->vqmmc_enabled = false; regs =mci_readl (slot->host,PWREN ); regs &= ~(1 << slot->id);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Re: [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power
Dear, Doug.
Looks good to me. Thanks!
Best Regards,
Jaehoon Chung
Quoted 59 lines · Doug Anderson
We should give
dw_mmca good reset after we apply power. On some boards vqmmc may actually be connected to the IP block in the SoC so it's good to reset after power comes in.Without this we sometimes see failures enumerating cards on rk3288.
Signed-off-by Doug Anderson <[email protected]>--- drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/mmc/host/dw_mmc.c +18
-9@@ -1119,13 +1119,23 @@ 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 (!IS_ERR (mmc->supply.vqmmc) && !slot->host->vqmmc_enabled) { - ret =regulator_enable (mmc->supply.vqmmc); -if (ret <0 ) -dev_err (slot->host->dev, -"failed to enable vqmmc regulator\n" ); -else +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 ); }/* Adjust clock / bus width after power is up */ @@ -1139,10 +1149,9 @@ 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) { +if (!IS_ERR (mmc->supply.vqmmc) && slot->host->vqmmc_enabled)regulator_disable (mmc->supply.vqmmc); - slot->host->vqmmc_enabled = false; - } + slot->host->vqmmc_enabled = false; regs =mci_readl (slot->host,PWREN ); regs &= ~(1 << slot->id);
Re: [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power
In reply to Doug AndersonHello Doug,
Quoted 7 lines · Doug Anderson
We should give
dw_mmca good reset after we apply power. On some boards vqmmc may actually be connected to the IP block in the SoC so it's good to reset after power comes in.Without this we sometimes see failures enumerating cards on rk3288.
Signed-off-by Doug Anderson <[email protected]>
On an Exynos5250 Snow, Exynos5420 Peach Pit and Exynos5800 Peach Pi:
Best regards,
Javier
Hi, Doug.
It makes sense. Looks good to me. Thanks!
Best Regards,
Jaehoon Chung
Quoted 54 lines · Doug Anderson
It appears that we can confuse things if we try to turn on the MMC clock when the power is off. Adjust is so that we turn the clock on (using
dw_mci_setup_bus) after power is all the way on and we turn the clock off before the power goes off.Signed-off-by Doug Anderson <[email protected]>--- drivers/mmc/host/dw_mmc.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/mmc/host/dw_mmc.c +10
-6@@ -1101,12 +1101,6 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)if (drv_data && drv_data->set_ios) drv_data->set_ios (slot->host, ios); -/* Slot specific timing and width adjustment */ -dw_mci_setup_bus (slot, false); - -if (slot->host->state ==STATE_WAITING_CMD11_DONE && ios->clock !=0 ) - slot->host->state =STATE_IDLE ; -switch (ios->power_mode) {case MMC_POWER_UP :if (!IS_ERR (mmc->supply.vmmc)) {@@ -1133,8 +1127,15 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)else slot->host->vqmmc_enabled = true; } + +/* Adjust clock / bus width after power is up */ +dw_mci_setup_bus (slot, false); +break ;case MMC_POWER_OFF : +/* Turn clock off before power goes down */ +dw_mci_setup_bus (slot, false); +if (!IS_ERR (mmc->supply.vmmc))mmc_regulator_set_ocr (mmc, mmc->supply.vmmc,0 );@@ -1150,6 +1151,9 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)default :break ; } + +if (slot->host->state ==STATE_WAITING_CMD11_DONE && ios->clock !=0 ) + slot->host->state =STATE_IDLE ; }static int dw_mci_card_busy (struct mmc_host *mmc)
Hello Doug,
Quoted 6 lines · Doug Anderson
It appears that we can confuse things if we try to turn on the MMC clock when the power is off. Adjust is so that we turn the clock on (using
dw_mci_setup_bus) after power is all the way on and we turn the clock off before the power goes off.Signed-off-by Doug Anderson <[email protected]>
On an Exynos5250 Snow, Exynos5420 Peach Pit and Exynos5800 Peach Pi:
Best regards,
Javier