From patchwork Thu Jul 21 02:34:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 993612 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 p6L2ZeKO013212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 21 Jul 2011 02:36:01 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qjj6i-0004zk-23; Thu, 21 Jul 2011 02:35:26 +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 1Qjj6h-0004bl-Le; Thu, 21 Jul 2011 02:35:23 +0000 Received: from dakia2.marvell.com ([65.219.4.35]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qjj6J-0004XP-0s for linux-arm-kernel@lists.infradead.org; Thu, 21 Jul 2011 02:34:59 +0000 X-ASG-Debug-ID: 1311215696-082ee0830001-tbGyMd Received: from maili.marvell.com (maili.marvell.com [10.68.76.51]) by dakia2.marvell.com with ESMTP id 9gVNzlUgqXk7DPsz; Wed, 20 Jul 2011 19:34:56 -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 AC6538A002; Wed, 20 Jul 2011 19:34:56 -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 , Frank@marvell.com, Huang@marvell.com, frankh@marvell.com X-ASG-Orig-Subj: [PATCH] mmc: sdio add regulator vsdio Subject: [PATCH] mmc: sdio add regulator vsdio Date: Thu, 21 Jul 2011 10:34:32 +0800 X-ASG-Orig-Subj: [PATCH] mmc: sdio add regulator vsdio Message-Id: <1311215673-2489-2-git-send-email-zhangfei.gao@marvell.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1311215673-2489-1-git-send-email-zhangfei.gao@marvell.com> References: <1311215673-2489-1-git-send-email-zhangfei.gao@marvell.com> X-Barracuda-Connect: maili.marvell.com[10.68.76.51] X-Barracuda-Start-Time: 1311215696 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-20110720_223459_237842_E13DE5C7 X-CRM114-Status: GOOD ( 14.48 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.2 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, 21 Jul 2011 02:36:01 +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 | 24 ++++++++++++++++++++++++ include/linux/mmc/sdhci.h | 2 ++ 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 790f959..61fff10 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1295,6 +1295,18 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) sdhci_set_clock(host, ios->clock); + 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; + } + if (ios->power_mode == MMC_POWER_OFF) sdhci_set_power(host, -1); else @@ -2751,6 +2763,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 @@ -2842,6 +2861,11 @@ void sdhci_remove_host(struct sdhci_host *host, int dead) regulator_put(host->vmmc); } + if (host->vsdio) { + regulator_disable(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 13c13f8..bea07c7 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 */