From: Zhangfei Gao <zhangfei.gao@marvell.com> To: Chris Ball <cjb@laptop.org>, Daniel Drake <dsd@laptop.org>, Arnd Bergmann <arnd@arndb.de>, Nicolas Pitre <nico@fluxnic.net>, linux-mmc@vger.kernel.o Cc: Zhangfei Gao <zhangfei.gao@marvell.com>, Ohad Ben-Cohen <ohad@wizery.com> Subject: [PATCH 1/2] mmc: sdhci move vmmc to set_ios Date: Tue, 26 Jul 2011 15:06:12 +0800 [thread overview] Message-ID: <1311663973-23715-2-git-send-email-zhangfei.gao@marvell.com> (raw) In-Reply-To: <1311663973-23715-1-git-send-email-zhangfei.gao@marvell.com> Move vmmc to set_ios, as a result mmc_power_up/down handles regulator_enable/disable vmmc Move regulator outof spin_lock, since usually i2c operation is called Remove vmmc from suspend/resume function, instead vmmc is handled properly in mmc_suspend/resume_host according to mmc_card_keep_power CC: Ohad Ben-Cohen <ohad@wizery.com> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com> --- drivers/mmc/host/sdhci.c | 27 +++++++++++++++------------ include/linux/mmc/sdhci.h | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c31a334..ce4f97f 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1279,6 +1279,13 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) host = mmc_priv(mmc); + if (host->vmmc) { + if (ios->power_mode != host->power_mode_old) { + if (ios->power_mode == MMC_POWER_UP) + regulator_enable(host->vmmc); + } + } + spin_lock_irqsave(&host->lock, flags); if (host->flags & SDHCI_DEVICE_DEAD) @@ -1426,6 +1433,14 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) out: mmiowb(); spin_unlock_irqrestore(&host->lock, flags); + + if (host->vmmc) { + if (ios->power_mode != host->power_mode_old) { + if (ios->power_mode == MMC_POWER_OFF) + regulator_disable(host->vmmc); + } + host->power_mode_old = ios->power_mode; + } } static int check_ro(struct sdhci_host *host) @@ -2262,9 +2277,6 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state) free_irq(host->irq, host); - if (host->vmmc) - ret = regulator_disable(host->vmmc); - return ret; } @@ -2274,13 +2286,6 @@ int sdhci_resume_host(struct sdhci_host *host) { int ret; - if (host->vmmc) { - int ret = regulator_enable(host->vmmc); - if (ret) - return ret; - } - - if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) { if (host->ops->enable_dma) host->ops->enable_dma(host); @@ -2749,8 +2754,6 @@ int sdhci_add_host(struct sdhci_host *host) if (IS_ERR(host->vmmc)) { printk(KERN_INFO "%s: no vmmc regulator found\n", mmc_hostname(mmc)); host->vmmc = NULL; - } else { - regulator_enable(host->vmmc); } sdhci_init(host, 0); diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h index 5666f3a..2e6e711 100644 --- a/include/linux/mmc/sdhci.h +++ b/include/linux/mmc/sdhci.h @@ -94,6 +94,7 @@ struct sdhci_host { const struct sdhci_ops *ops; /* Low level hw interface */ struct regulator *vmmc; /* Power regulator */ + unsigned char power_mode_old; /* power supply mode */ /* Internal data */ struct mmc_host *mmc; /* MMC structure */ -- 1.7.0.4
WARNING: multiple messages have this Message-ID (diff)
From: zhangfei.gao@marvell.com (Zhangfei Gao) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] mmc: sdhci move vmmc to set_ios Date: Tue, 26 Jul 2011 15:06:12 +0800 [thread overview] Message-ID: <1311663973-23715-2-git-send-email-zhangfei.gao@marvell.com> (raw) In-Reply-To: <1311663973-23715-1-git-send-email-zhangfei.gao@marvell.com> Move vmmc to set_ios, as a result mmc_power_up/down handles regulator_enable/disable vmmc Move regulator outof spin_lock, since usually i2c operation is called Remove vmmc from suspend/resume function, instead vmmc is handled properly in mmc_suspend/resume_host according to mmc_card_keep_power CC: Ohad Ben-Cohen <ohad@wizery.com> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com> --- drivers/mmc/host/sdhci.c | 27 +++++++++++++++------------ include/linux/mmc/sdhci.h | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c31a334..ce4f97f 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1279,6 +1279,13 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) host = mmc_priv(mmc); + if (host->vmmc) { + if (ios->power_mode != host->power_mode_old) { + if (ios->power_mode == MMC_POWER_UP) + regulator_enable(host->vmmc); + } + } + spin_lock_irqsave(&host->lock, flags); if (host->flags & SDHCI_DEVICE_DEAD) @@ -1426,6 +1433,14 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) out: mmiowb(); spin_unlock_irqrestore(&host->lock, flags); + + if (host->vmmc) { + if (ios->power_mode != host->power_mode_old) { + if (ios->power_mode == MMC_POWER_OFF) + regulator_disable(host->vmmc); + } + host->power_mode_old = ios->power_mode; + } } static int check_ro(struct sdhci_host *host) @@ -2262,9 +2277,6 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state) free_irq(host->irq, host); - if (host->vmmc) - ret = regulator_disable(host->vmmc); - return ret; } @@ -2274,13 +2286,6 @@ int sdhci_resume_host(struct sdhci_host *host) { int ret; - if (host->vmmc) { - int ret = regulator_enable(host->vmmc); - if (ret) - return ret; - } - - if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) { if (host->ops->enable_dma) host->ops->enable_dma(host); @@ -2749,8 +2754,6 @@ int sdhci_add_host(struct sdhci_host *host) if (IS_ERR(host->vmmc)) { printk(KERN_INFO "%s: no vmmc regulator found\n", mmc_hostname(mmc)); host->vmmc = NULL; - } else { - regulator_enable(host->vmmc); } sdhci_init(host, 0); diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h index 5666f3a..2e6e711 100644 --- a/include/linux/mmc/sdhci.h +++ b/include/linux/mmc/sdhci.h @@ -94,6 +94,7 @@ struct sdhci_host { const struct sdhci_ops *ops; /* Low level hw interface */ struct regulator *vmmc; /* Power regulator */ + unsigned char power_mode_old; /* power supply mode */ /* Internal data */ struct mmc_host *mmc; /* MMC structure */ -- 1.7.0.4
next prev parent reply other threads:[~2011-07-26 7:06 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-07-26 7:06 [PATCH v2 0/2] set_ios handle vmmc Zhangfei Gao 2011-07-26 7:06 ` Zhangfei Gao 2011-07-26 7:06 ` Zhangfei Gao [this message] 2011-07-26 7:06 ` [PATCH 1/2] mmc: sdhci move vmmc to set_ios Zhangfei Gao 2011-08-24 13:22 ` zhangfei gao 2011-08-24 13:22 ` zhangfei gao 2011-07-26 7:06 ` [PATCH 2/2] ARM: mmp2: support sdio device 8787 Zhangfei Gao 2011-07-26 7:06 ` Zhangfei Gao
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1311663973-23715-2-git-send-email-zhangfei.gao@marvell.com \ --to=zhangfei.gao@marvell.com \ --cc=arnd@arndb.de \ --cc=cjb@laptop.org \ --cc=dsd@laptop.org \ --cc=linux-mmc@vger.kernel.o \ --cc=nico@fluxnic.net \ --cc=ohad@wizery.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.