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: 993602 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6L2YtEg012037 for ; Thu, 21 Jul 2011 02:34:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751814Ab1GUCe5 (ORCPT ); Wed, 20 Jul 2011 22:34:57 -0400 Received: from dakia2.marvell.com ([65.219.4.35]:37101 "EHLO dakia2.marvell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818Ab1GUCe5 (ORCPT ); Wed, 20 Jul 2011 22:34:57 -0400 X-ASG-Debug-ID: 1311215696-082ee0830001-IEKb4K 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 Cc: Zhangfei Gao , Ohad Ben-Cohen 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 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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:34:58 +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 */