From patchwork Wed May 9 14:15:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 8500 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9C96D23E49 for ; Wed, 9 May 2012 14:16:59 +0000 (UTC) Received: from mail-we0-f180.google.com (mail-we0-f180.google.com [74.125.82.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8E0D0A18A34 for ; Wed, 9 May 2012 14:16:59 +0000 (UTC) Received: by werp13 with SMTP id p13so274594wer.11 for ; Wed, 09 May 2012 07:16:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=DPMgR9frMt9iSKLlp0w60ECxYhQqOmCT5G1GHqG3HqI=; b=gJq8AXHb8Tv5xQKSwxJmcc1Ih39+80CaD90vSB2z0pefptto2YPK6ZHVmRMJIXoIoJ CWD4U8QGoj488rmG/47wnz0AvUfbCjAR+pnxSlFzxoad2iRHRAc25rKDxOTWv/aj4zwV Nt/oDhLBdAtK4NmEWhtLtuf/HFFqfIoR9SWoW0JdY2sCn6xBOcKniBl4YdLIjTFy8pCq T6xsYWIQT/iygEOUidMhLEFBVapVYKZ3TDptJKHQlOux0GBXl8+I59IwS5hAf9L0xVy/ r7M5rjAuteYjoEgcuLQdkTXREy0t74EuNDxjDUgRNhIy7XZQYomHT4RbHGoTDiUW1zJx RpxA== Received: by 10.68.223.37 with SMTP id qr5mr9572345pbc.159.1336573018638; Wed, 09 May 2012 07:16:58 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.73.147 with SMTP id q19csp19514ibj; Wed, 9 May 2012 07:16:57 -0700 (PDT) Received: by 10.14.100.193 with SMTP id z41mr52613eef.112.1336573016998; Wed, 09 May 2012 07:16:56 -0700 (PDT) Received: from eu1sys200aog114.obsmtp.com (eu1sys200aog114.obsmtp.com. [207.126.144.137]) by mx.google.com with SMTP id c46si789810eei.190.2012.05.09.07.16.52 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 May 2012 07:16:56 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.137; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob114.postini.com ([207.126.147.11]) with SMTP ID DSNKT6p8RqC7u1nL0yOuy6mmbW7Gf1uUEavL@postini.com; Wed, 09 May 2012 14:16:56 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 2D33C58; Wed, 9 May 2012 14:15:40 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 5FB8265; Wed, 9 May 2012 11:54:02 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id C74A5A8065; Wed, 9 May 2012 16:15:49 +0200 (CEST) Received: from steludxu4020.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 9 May 2012 16:15:55 +0200 From: Ulf Hansson To: , Chris Ball Cc: Per Forlin , Ulf Hansson , Johan Rudholm , Lee Jones , Mark Brown , Jasi Brar , Ulf Hansson Subject: [PATCH] mmc: core: Prevent eMMC VCC supply to be cut from late init Date: Wed, 9 May 2012 16:15:26 +0200 Message-ID: <1336572926-21013-1-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.9 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkgsGXgedlAOxGtih4jSOFpYxWHvMB97A+uhQsnpCyWqIbulFXNBktil7G7z5D8T3oDZPGl From: Ulf Hansson 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 --- 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); }