From: Arindam Nath <arindam.nath@amd.com>
To: cjb@laptop.org
Cc: linux-mmc@vger.kernel.org, prakity@marvell.com,
subhashj@codeaurora.org, zhangfei.gao@gmail.com,
henry.su@amd.com, aaron.lu@amd.com, anath.amd@gmail.com,
Arindam Nath <arindam.nath@amd.com>
Subject: [PATCH v3 09/11] mmc: sdhci: enable preset value after uhs initialization
Date: Wed, 20 Apr 2011 15:00:59 +0530 [thread overview]
Message-ID: <1303291861-1788-10-git-send-email-arindam.nath@amd.com> (raw)
In-Reply-To: <1303291861-1788-1-git-send-email-arindam.nath@amd.com>
According to the Host Controller spec v3.00, setting Preset Value Enable
in the Host Control2 register lets SDCLK Frequency Select, Clock Generator
Select and Driver Strength Select to be set automatically by the Host
Controller based on the UHS-I mode set. This patch enables this feature.
We also reset Preset Value Enable next time before initialization.
Signed-off-by: Arindam Nath <arindam.nath@amd.com>
---
drivers/mmc/core/sd.c | 11 +++++++++++
drivers/mmc/host/sdhci.c | 32 ++++++++++++++++++++++++++++++++
include/linux/mmc/host.h | 1 +
3 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index f3ecdef..08305ab 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -959,6 +959,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
}
}
+ /*
+ * Since initialization is now complete, enable preset
+ * value registers.
+ */
+ if (host->ops->enable_preset_value)
+ host->ops->enable_preset_value(host, 1);
+
host->card = card;
return 0;
@@ -1109,6 +1116,10 @@ int mmc_attach_sd(struct mmc_host *host)
if (err)
return err;
+ /* Disable preset value enable if already set from last time */
+ if (host->ops->enable_preset_value)
+ host->ops->enable_preset_value(host, 0);
+
/*
* We need to get OCR a different way for SPI.
*/
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9065157..c25ab83 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1614,6 +1614,37 @@ out:
return err;
}
+static void sdhci_enable_preset_value(struct mmc_host *mmc, int enable)
+{
+ struct sdhci_host *host;
+ u16 ctrl;
+ unsigned long flags;
+
+ host = mmc_priv(mmc);
+
+ /* Host Controller v3.00 defines preset value registers */
+ if (host->version < SDHCI_SPEC_300)
+ return;
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
+
+ /*
+ * We only enable or disable Preset Value if they are not already
+ * enabled or disabled respectively. Otherwise, we bail out.
+ */
+ if (enable && !(ctrl & SDHCI_CTRL_PRESET_VAL_ENABLE)) {
+ ctrl |= SDHCI_CTRL_PRESET_VAL_ENABLE;
+ sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
+ } else if (!enable && (ctrl & SDHCI_CTRL_PRESET_VAL_ENABLE)) {
+ ctrl &= ~SDHCI_CTRL_PRESET_VAL_ENABLE;
+ sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
+ }
+
+ spin_unlock_irqrestore(&host->lock, flags);
+}
+
static const struct mmc_host_ops sdhci_ops = {
.request = sdhci_request,
.set_ios = sdhci_set_ios,
@@ -1621,6 +1652,7 @@ static const struct mmc_host_ops sdhci_ops = {
.enable_sdio_irq = sdhci_enable_sdio_irq,
.start_signal_voltage_switch = sdhci_start_signal_voltage_switch,
.execute_tuning = sdhci_execute_tuning,
+ .enable_preset_value = sdhci_enable_preset_value,
};
/*****************************************************************************\
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index ca7007f..2209e01 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -137,6 +137,7 @@ struct mmc_host_ops {
int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
int (*execute_tuning)(struct mmc_host *host);
+ void (*enable_preset_value)(struct mmc_host *host, int enable);
};
struct mmc_card;
--
1.7.1
next prev parent reply other threads:[~2011-04-20 9:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 9:30 [PATCH v3 00/11] add support for host controller v3.00 Arindam Nath
2011-04-20 9:30 ` [PATCH v3 01/11] mmc: sd: add support for signal voltage switch procedure Arindam Nath
2011-04-27 9:48 ` zhangfei gao
2011-04-27 10:17 ` Nath, Arindam
2011-04-28 3:17 ` zhangfei gao
2011-04-28 5:48 ` Nath, Arindam
2011-04-20 9:30 ` [PATCH v3 02/11] mmc: sd: query function modes for uhs cards Arindam Nath
2011-04-20 9:30 ` [PATCH v3 03/11] mmc: sd: add support for driver type selection Arindam Nath
2011-04-20 9:30 ` [PATCH v3 04/11] mmc: sdhci: reset sdclk before setting high speed enable Arindam Nath
2011-04-20 9:30 ` [PATCH v3 05/11] mmc: sd: add support for uhs bus speed mode selection Arindam Nath
2011-04-20 9:30 ` [PATCH v3 06/11] mmc: sd: set current limit for uhs cards Arindam Nath
2011-04-20 9:30 ` [PATCH v3 07/11] mmc: sd: report correct speed and capacity of " Arindam Nath
2011-04-20 9:30 ` [PATCH v3 08/11] mmc: sd: add support for tuning during uhs initialization Arindam Nath
2011-04-27 18:44 ` Philip Rakity
2011-04-28 6:02 ` Nath, Arindam
2011-04-28 8:29 ` Question about timer in struct sdhci_host Ryan Liu
2011-04-20 9:30 ` Arindam Nath [this message]
2011-04-28 5:16 ` [PATCH v3 09/11] mmc: sdhci: enable preset value after uhs initialization zhangfei gao
2011-04-28 5:50 ` Nath, Arindam
2011-04-20 9:31 ` [PATCH v3 10/11] mmc: sdhci: add support for programmable clock mode Arindam Nath
2011-04-20 9:31 ` [PATCH v3 11/11] mmc: sdhci: add support for retuning mode 1 Arindam Nath
2011-04-29 18:40 ` [PATCH v3 00/11] add support for host controller v3.00 Subhash Jadavani
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=1303291861-1788-10-git-send-email-arindam.nath@amd.com \
--to=arindam.nath@amd.com \
--cc=aaron.lu@amd.com \
--cc=anath.amd@gmail.com \
--cc=cjb@laptop.org \
--cc=henry.su@amd.com \
--cc=linux-mmc@vger.kernel.org \
--cc=prakity@marvell.com \
--cc=subhashj@codeaurora.org \
--cc=zhangfei.gao@gmail.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).