From patchwork Thu Aug 25 06:26:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 1095322 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7P6Rc1U020386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 25 Aug 2011 06:27:59 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QwTPL-00083N-9X; Thu, 25 Aug 2011 06:27:19 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QwTPK-0004qC-Ob; Thu, 25 Aug 2011 06:27:18 +0000 Received: from dakia2.marvell.com ([65.219.4.35]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QwTP1-0004mz-Ij for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2011 06:27:00 +0000 X-ASG-Debug-ID: 1314253618-082d46f40001-tbGyMd Received: from maili.marvell.com (maili.marvell.com [10.68.76.51]) by dakia2.marvell.com with ESMTP id IuSGoVeQBhWfJfJo; Wed, 24 Aug 2011 23:26:58 -0700 (PDT) X-Barracuda-Envelope-From: zhangfei.gao@marvell.com Received: from localhost (unknown [10.38.164.217]) by maili.marvell.com (Postfix) with ESMTP id 6FAF28A009; Wed, 24 Aug 2011 23:26:58 -0700 (PDT) From: Zhangfei Gao To: Chris Ball , Ohad Ben-Cohen , Daniel Drake , Arnd Bergmann , Nicolas Pitre , "linux-mmc@vger.kernel.org" , Eric Miao , linux-arm-kernel , Bing Zhao X-ASG-Orig-Subj: [PATCH v3 1/2] mmc: sdio add regulator vsdio Subject: [PATCH v3 1/2] mmc: sdio add regulator vsdio Date: Thu, 25 Aug 2011 14:26:14 +0800 X-ASG-Orig-Subj: [PATCH v3 1/2] mmc: sdio add regulator vsdio Message-Id: <1314253575-2602-2-git-send-email-zhangfei.gao@marvell.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1314253575-2602-1-git-send-email-zhangfei.gao@marvell.com> References: <1314253575-2602-1-git-send-email-zhangfei.gao@marvell.com> X-Barracuda-Connect: maili.marvell.com[10.68.76.51] X-Barracuda-Start-Time: 1314253618 X-Barracuda-URL: http://10.68.76.222:80/cgi-mod/mark.cgi X-Barracuda-Spam-Score: -1002.00 X-Barracuda-Spam-Status: No, SCORE=-1002.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110825_022659_795604_460AFFB1 X-CRM114-Status: GOOD ( 15.41 ) X-Spam-Score: -0.5 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Ohad Ben-Cohen , Zhangfei Gao X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 25 Aug 2011 06:27:59 +0000 (UTC) sdio client may be required power on/off dynamically. With regulator vsdio, sdio client power on/off could be executed by mmc_power_up/down CC: Ohad Ben-Cohen Signed-off-by: Zhangfei Gao --- drivers/mmc/host/sdhci.c | 22 ++++++++++++++++++++++ include/linux/mmc/sdhci.h | 2 ++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0e02cc1..e0ef7d3 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1424,6 +1424,18 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) out: mmiowb(); spin_unlock_irqrestore(&host->lock, flags); + + if (host->vsdio) { + if (ios->power_mode != host->power_mode_old) { + if (ios->power_mode == MMC_POWER_OFF) + regulator_disable(host->vsdio); + + if (ios->power_mode == MMC_POWER_UP) + regulator_enable(host->vsdio); + } + + host->power_mode_old = ios->power_mode; + } } static int check_ro(struct sdhci_host *host) @@ -2748,6 +2760,13 @@ int sdhci_add_host(struct sdhci_host *host) regulator_enable(host->vmmc); } + host->vsdio = regulator_get(mmc_dev(mmc), "vsdio"); + if (IS_ERR(host->vsdio)) + host->vsdio = NULL; + else + printk(KERN_INFO "%s: vsdio regulator found\n", + mmc_hostname(mmc)); + sdhci_init(host, 0); #ifdef CONFIG_MMC_DEBUG @@ -2839,6 +2858,9 @@ void sdhci_remove_host(struct sdhci_host *host, int dead) regulator_put(host->vmmc); } + if (host->vsdio) + regulator_put(host->vsdio); + kfree(host->adma_desc); kfree(host->align_buffer); diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h index 5666f3a..201207a 100644 --- a/include/linux/mmc/sdhci.h +++ b/include/linux/mmc/sdhci.h @@ -94,6 +94,8 @@ struct sdhci_host { const struct sdhci_ops *ops; /* Low level hw interface */ struct regulator *vmmc; /* Power regulator */ + struct regulator *vsdio; /* sdio Power regulator */ + unsigned char power_mode_old; /* power supply mode */ /* Internal data */ struct mmc_host *mmc; /* MMC structure */