* [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on
@ 2015-02-20 18:57 Doug Anderson
2015-02-20 18:57 ` [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power Doug Anderson
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Doug Anderson @ 2015-02-20 18:57 UTC (permalink / raw)
To: Jaehoon Chung, Seungwon Jeon, Ulf Hansson
Cc: Alim Akhtar, Sonny Rao, Andrew Bresticker, Heiko Stuebner,
Addy Ke, Alexandru Stan, javier.martinez, Doug Anderson, chris,
linux-mmc, linux-kernel
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 <dianders@chromium.org>
---
drivers/mmc/host/dw_mmc.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 4d2e3c2..43fcae1 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -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)
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power
2015-02-20 18:57 [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on Doug Anderson
@ 2015-02-20 18:57 ` Doug Anderson
2015-02-25 10:35 ` Jaehoon Chung
2015-02-25 18:26 ` Javier Martinez Canillas
2015-02-25 10:34 ` [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on Jaehoon Chung
2015-02-25 18:25 ` Javier Martinez Canillas
2 siblings, 2 replies; 6+ messages in thread
From: Doug Anderson @ 2015-02-20 18:57 UTC (permalink / raw)
To: Jaehoon Chung, Seungwon Jeon, Ulf Hansson
Cc: Alim Akhtar, Sonny Rao, Andrew Bresticker, Heiko Stuebner,
Addy Ke, Alexandru Stan, javier.martinez, Doug Anderson, chris,
linux-mmc, linux-kernel
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.
Signed-off-by: Doug Anderson <dianders@chromium.org>
---
drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 43fcae1..6a712ae 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -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);
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on
2015-02-20 18:57 [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on Doug Anderson
2015-02-20 18:57 ` [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power Doug Anderson
@ 2015-02-25 10:34 ` Jaehoon Chung
2015-02-25 18:25 ` Javier Martinez Canillas
2 siblings, 0 replies; 6+ messages in thread
From: Jaehoon Chung @ 2015-02-25 10:34 UTC (permalink / raw)
To: Doug Anderson, Seungwon Jeon, Ulf Hansson
Cc: Alim Akhtar, Sonny Rao, Andrew Bresticker, Heiko Stuebner,
Addy Ke, Alexandru Stan, javier.martinez, chris, linux-mmc,
linux-kernel
Hi, Doug.
It makes sense. Looks good to me. Thanks!
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
On 02/21/2015 03:57 AM, Doug Anderson wrote:
> 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 <dianders@chromium.org>
> ---
> drivers/mmc/host/dw_mmc.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 4d2e3c2..43fcae1 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -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)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power
2015-02-20 18:57 ` [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power Doug Anderson
@ 2015-02-25 10:35 ` Jaehoon Chung
2015-02-25 18:26 ` Javier Martinez Canillas
1 sibling, 0 replies; 6+ messages in thread
From: Jaehoon Chung @ 2015-02-25 10:35 UTC (permalink / raw)
To: Doug Anderson, Seungwon Jeon, Ulf Hansson
Cc: Alim Akhtar, Sonny Rao, Andrew Bresticker, Heiko Stuebner,
Addy Ke, Alexandru Stan, javier.martinez, chris, linux-mmc,
linux-kernel
Dear, Doug.
Looks good to me. Thanks!
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
On 02/21/2015 03:57 AM, Doug Anderson wrote:
> 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.
>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
> drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++++++---------
> 1 file changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 43fcae1..6a712ae 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -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);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on
2015-02-20 18:57 [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on Doug Anderson
2015-02-20 18:57 ` [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power Doug Anderson
2015-02-25 10:34 ` [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on Jaehoon Chung
@ 2015-02-25 18:25 ` Javier Martinez Canillas
2 siblings, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2015-02-25 18:25 UTC (permalink / raw)
To: Doug Anderson, Jaehoon Chung, Seungwon Jeon, Ulf Hansson
Cc: Alim Akhtar, Sonny Rao, Andrew Bresticker, Heiko Stuebner,
Addy Ke, Alexandru Stan, chris, linux-mmc, linux-kernel
Hello Doug,
On 02/20/2015 07:57 PM, Doug Anderson wrote:
> 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 <dianders@chromium.org>
On an Exynos5250 Snow, Exynos5420 Peach Pit and Exynos5800 Peach Pi:
Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Best regards,
Javier
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power
2015-02-20 18:57 ` [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power Doug Anderson
2015-02-25 10:35 ` Jaehoon Chung
@ 2015-02-25 18:26 ` Javier Martinez Canillas
1 sibling, 0 replies; 6+ messages in thread
From: Javier Martinez Canillas @ 2015-02-25 18:26 UTC (permalink / raw)
To: Doug Anderson, Jaehoon Chung, Seungwon Jeon, Ulf Hansson
Cc: Alim Akhtar, Sonny Rao, Andrew Bresticker, Heiko Stuebner,
Addy Ke, Alexandru Stan, chris, linux-mmc, linux-kernel
Hello Doug,
On 02/20/2015 07:57 PM, Doug Anderson wrote:
> 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.
>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
On an Exynos5250 Snow, Exynos5420 Peach Pit and Exynos5800 Peach Pi:
Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Best regards,
Javier
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-02-25 18:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-20 18:57 [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on Doug Anderson
2015-02-20 18:57 ` [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power Doug Anderson
2015-02-25 10:35 ` Jaehoon Chung
2015-02-25 18:26 ` Javier Martinez Canillas
2015-02-25 10:34 ` [PATCH 1/2] mmc: dw_mmc: Make sure we only adjust the clock when power is on Jaehoon Chung
2015-02-25 18:25 ` Javier Martinez Canillas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).