* [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init
@ 2012-05-09 14:15 Ulf Hansson
2012-05-09 15:56 ` Mark Brown
2012-07-10 15:19 ` Girish K S
0 siblings, 2 replies; 6+ messages in thread
From: Ulf Hansson @ 2012-05-09 14:15 UTC (permalink / raw)
To: linux-mmc, Chris Ball
Cc: Per Forlin, Ulf Hansson, Johan Rudholm, Lee Jones, Mark Brown,
Jasi Brar, Ulf Hansson
From: Ulf Hansson <ulf.hansson@linaro.org>
For eMMC cards that has been initialized from a bootloader,
the VCC voltage supply must not be cut in an uncontrolled
manner, without first sending SLEEP or POWEROFF_NOTIFY.
The regulator_init_complete late initcall, may cut the VCC
regulator if it's reference counter is zero. To be able to
prevent the regulator from being cut, mmc_start_host, which
should execute at device init and thus before late init,
calls mmc_power_up. Then the host driver is able to increase
the reference to the regulator.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/mmc/core/core.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index ba821fe..0b6141d 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -42,6 +42,7 @@
#include "sdio_ops.h"
static struct workqueue_struct *workqueue;
+static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
/*
* Enabling software CRCs on the data blocks can be a significant (30%)
@@ -1157,6 +1158,9 @@ static void mmc_power_up(struct mmc_host *host)
{
int bit;
+ if (host->ios.power_mode == MMC_POWER_ON)
+ return;
+
mmc_host_clk_hold(host);
/* If ocr is set, we use it */
@@ -1199,6 +1203,10 @@ static void mmc_power_up(struct mmc_host *host)
void mmc_power_off(struct mmc_host *host)
{
int err = 0;
+
+ if (host->ios.power_mode == MMC_POWER_OFF)
+ return;
+
mmc_host_clk_hold(host);
host->ios.clock = 0;
@@ -2005,7 +2013,6 @@ EXPORT_SYMBOL(mmc_detect_card_removed);
void mmc_rescan(struct work_struct *work)
{
- static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
struct mmc_host *host =
container_of(work, struct mmc_host, detect.work);
int i;
@@ -2044,8 +2051,12 @@ void mmc_rescan(struct work_struct *work)
*/
mmc_bus_put(host);
- if (host->ops->get_cd && host->ops->get_cd(host) == 0)
+ if (host->ops->get_cd && host->ops->get_cd(host) == 0) {
+ mmc_claim_host(host);
+ mmc_power_off(host);
+ mmc_release_host(host);
goto out;
+ }
mmc_claim_host(host);
for (i = 0; i < ARRAY_SIZE(freqs); i++) {
@@ -2063,7 +2074,8 @@ void mmc_rescan(struct work_struct *work)
void mmc_start_host(struct mmc_host *host)
{
- mmc_power_off(host);
+ host->f_init = max(freqs[0], host->f_min);
+ mmc_power_up(host);
mmc_detect_change(host, 0);
}
--
1.7.9
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init
2012-05-09 14:15 [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init Ulf Hansson
@ 2012-05-09 15:56 ` Mark Brown
2012-05-09 16:56 ` Chris Ball
2012-07-10 15:19 ` Girish K S
1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2012-05-09 15:56 UTC (permalink / raw)
To: Ulf Hansson
Cc: linux-mmc, Chris Ball, Per Forlin, Johan Rudholm, Lee Jones,
Jasi Brar, Ulf Hansson
[-- Attachment #1: Type: text/plain, Size: 899 bytes --]
On Wed, May 09, 2012 at 04:15:26PM +0200, Ulf Hansson wrote:
> From: Ulf Hansson <ulf.hansson@linaro.org>
>
> For eMMC cards that has been initialized from a bootloader,
> the VCC voltage supply must not be cut in an uncontrolled
> manner, without first sending SLEEP or POWEROFF_NOTIFY.
>
> The regulator_init_complete late initcall, may cut the VCC
> regulator if it's reference counter is zero. To be able to
> prevent the regulator from being cut, mmc_start_host, which
> should execute at device init and thus before late init,
> calls mmc_power_up. Then the host driver is able to increase
> the reference to the regulator.
This looks like a good, simple solution - working out how we avoid extra
power ups will probably be more invasive and might not be worth the
effort for something that's boot time only.
Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init
2012-05-09 15:56 ` Mark Brown
@ 2012-05-09 16:56 ` Chris Ball
0 siblings, 0 replies; 6+ messages in thread
From: Chris Ball @ 2012-05-09 16:56 UTC (permalink / raw)
To: Mark Brown
Cc: Ulf Hansson, linux-mmc, Per Forlin, Johan Rudholm, Lee Jones,
Jasi Brar, Ulf Hansson
Hi,
On Wed, May 09 2012, Mark Brown wrote:
> On Wed, May 09, 2012 at 04:15:26PM +0200, Ulf Hansson wrote:
>> From: Ulf Hansson <ulf.hansson@linaro.org>
>>
>> For eMMC cards that has been initialized from a bootloader,
>> the VCC voltage supply must not be cut in an uncontrolled
>> manner, without first sending SLEEP or POWEROFF_NOTIFY.
>>
>> The regulator_init_complete late initcall, may cut the VCC
>> regulator if it's reference counter is zero. To be able to
>> prevent the regulator from being cut, mmc_start_host, which
>> should execute at device init and thus before late init,
>> calls mmc_power_up. Then the host driver is able to increase
>> the reference to the regulator.
>
> This looks like a good, simple solution - working out how we avoid extra
> power ups will probably be more invasive and might not be worth the
> effort for something that's boot time only.
>
> Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Thanks, pushed to mmc-next for 3.5.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init
2012-05-09 14:15 [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init Ulf Hansson
2012-05-09 15:56 ` Mark Brown
@ 2012-07-10 15:19 ` Girish K S
2012-07-10 17:32 ` Chris Ball
1 sibling, 1 reply; 6+ messages in thread
From: Girish K S @ 2012-07-10 15:19 UTC (permalink / raw)
To: Ulf Hansson
Cc: linux-mmc, Chris Ball, Per Forlin, Johan Rudholm, Lee Jones,
Mark Brown, Jasi Brar, Ulf Hansson
On 9 May 2012 19:45, Ulf Hansson <ulf.hansson@stericsson.com> wrote:
> From: Ulf Hansson <ulf.hansson@linaro.org>
>
> For eMMC cards that has been initialized from a bootloader,
> the VCC voltage supply must not be cut in an uncontrolled
> manner, without first sending SLEEP or POWEROFF_NOTIFY.
>
> The regulator_init_complete late initcall, may cut the VCC
> regulator if it's reference counter is zero. To be able to
> prevent the regulator from being cut, mmc_start_host, which
> should execute at device init and thus before late init,
> calls mmc_power_up. Then the host driver is able to increase
> the reference to the regulator.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> drivers/mmc/core/core.c | 18 +++++++++++++++---
> 1 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index ba821fe..0b6141d 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -42,6 +42,7 @@
> #include "sdio_ops.h"
>
> static struct workqueue_struct *workqueue;
> +static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
>
> /*
> * Enabling software CRCs on the data blocks can be a significant (30%)
> @@ -1157,6 +1158,9 @@ static void mmc_power_up(struct mmc_host *host)
> {
> int bit;
>
> + if (host->ios.power_mode == MMC_POWER_ON)
> + return;
> +
> mmc_host_clk_hold(host);
>
> /* If ocr is set, we use it */
> @@ -1199,6 +1203,10 @@ static void mmc_power_up(struct mmc_host *host)
> void mmc_power_off(struct mmc_host *host)
> {
> int err = 0;
> +
> + if (host->ios.power_mode == MMC_POWER_OFF)
> + return;
> +
> mmc_host_clk_hold(host);
>
> host->ios.clock = 0;
> @@ -2005,7 +2013,6 @@ EXPORT_SYMBOL(mmc_detect_card_removed);
>
> void mmc_rescan(struct work_struct *work)
> {
> - static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
> struct mmc_host *host =
> container_of(work, struct mmc_host, detect.work);
> int i;
> @@ -2044,8 +2051,12 @@ void mmc_rescan(struct work_struct *work)
> */
> mmc_bus_put(host);
>
> - if (host->ops->get_cd && host->ops->get_cd(host) == 0)
> + if (host->ops->get_cd && host->ops->get_cd(host) == 0) {
> + mmc_claim_host(host);
> + mmc_power_off(host);
> + mmc_release_host(host);
> goto out;
> + }
>
> mmc_claim_host(host);
> for (i = 0; i < ARRAY_SIZE(freqs); i++) {
> @@ -2063,7 +2074,8 @@ void mmc_rescan(struct work_struct *work)
>
> void mmc_start_host(struct mmc_host *host)
> {
> - mmc_power_off(host);
> + host->f_init = max(freqs[0], host->f_min);
> + mmc_power_up(host);
> mmc_detect_change(host, 0);
> }
>
sorry to comment late on this.
This patch breaks the card detect with the designware host controller.
Anybody using the same host controller please let me know.
The problem is caused by the power_up call from the mmc_start_host
function. If i comment this powerup then card detect is fine
> --
> 1.7.9
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init
2012-07-10 15:19 ` Girish K S
@ 2012-07-10 17:32 ` Chris Ball
2012-07-11 12:40 ` Girish K S
0 siblings, 1 reply; 6+ messages in thread
From: Chris Ball @ 2012-07-10 17:32 UTC (permalink / raw)
To: Girish K S
Cc: Ulf Hansson, linux-mmc, Per Forlin, Johan Rudholm, Lee Jones,
Mark Brown, Jasi Brar, Ulf Hansson
Hi,
On Tue, Jul 10 2012, Girish K S wrote:
>> @@ -2063,7 +2074,8 @@ void mmc_rescan(struct work_struct *work)
>>
>> void mmc_start_host(struct mmc_host *host)
>> {
>> - mmc_power_off(host);
>> + host->f_init = max(freqs[0], host->f_min);
>> + mmc_power_up(host);
>> mmc_detect_change(host, 0);
>> }
>>
> sorry to comment late on this.
> This patch breaks the card detect with the designware host controller.
> Anybody using the same host controller please let me know.
> The problem is caused by the power_up call from the mmc_start_host
> function. If i comment this powerup then card detect is fine
Thanks. Ulf, sounds like we should revert this for 3.5-rc (which would
have to happen soon) while we investigate; let me know what you think.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init
2012-07-10 17:32 ` Chris Ball
@ 2012-07-11 12:40 ` Girish K S
0 siblings, 0 replies; 6+ messages in thread
From: Girish K S @ 2012-07-11 12:40 UTC (permalink / raw)
To: Chris Ball
Cc: Ulf Hansson, linux-mmc, Per Forlin, Johan Rudholm, Lee Jones,
Mark Brown, Jasi Brar, Ulf Hansson
On 10 July 2012 23:02, Chris Ball <cjb@laptop.org> wrote:
> Hi,
>
> On Tue, Jul 10 2012, Girish K S wrote:
>>> @@ -2063,7 +2074,8 @@ void mmc_rescan(struct work_struct *work)
>>>
>>> void mmc_start_host(struct mmc_host *host)
>>> {
>>> - mmc_power_off(host);
>>> + host->f_init = max(freqs[0], host->f_min);
>>> + mmc_power_up(host);
>>> mmc_detect_change(host, 0);
>>> }
>>>
>> sorry to comment late on this.
>> This patch breaks the card detect with the designware host controller.
>> Anybody using the same host controller please let me know.
>> The problem is caused by the power_up call from the mmc_start_host
>> function. If i comment this powerup then card detect is fine
>
> Thanks. Ulf, sounds like we should revert this for 3.5-rc (which would
> have to happen soon) while we investigate; let me know what you think.
power_up function in the mmc_start_host can be completely omitted as
it will be anyway called in the mmc_detect_change.
I will test this change on the available host controllers and will
publish the result. If this removal doesnt cause any side affect, will
post it as a patch.
Ulf,
waiting for your comments on the same
>
> - Chris.
> --
> Chris Ball <cjb@laptop.org> <http://printf.net/>
> One Laptop Per Child
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-07-11 12:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 14:15 [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init Ulf Hansson
2012-05-09 15:56 ` Mark Brown
2012-05-09 16:56 ` Chris Ball
2012-07-10 15:19 ` Girish K S
2012-07-10 17:32 ` Chris Ball
2012-07-11 12:40 ` Girish K S
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox