From: Markus Niebel <list-09_barebox@tqsc.de>
To: barebox@lists.infradead.org
Cc: Markus Niebel <Markus.Niebel@tqs.de>
Subject: [PATCH 1/4] mci: add DSR support
Date: Tue, 14 Jan 2014 09:23:34 +0100 [thread overview]
Message-ID: <1389687817-30882-2-git-send-email-list-09_barebox@tqsc.de> (raw)
In-Reply-To: <1389687817-30882-1-git-send-email-list-09_barebox@tqsc.de>
From: Markus Niebel <Markus.Niebel@tqs.de>
The eMMC and the SD-Card specifications describe the optional SET_DSR command.
During measurements at our lab we found that some cards implementing this feature
having really strong driver strengts per default. This can lead to voltage peaks
above the specification of the host on signal edges for data sent from a card to
the host.
Since availability of a given card type may be shorter than the time a certain
hardware will be produced it is useful to have support for this command (Alternative
would be changing termination resistors and adapting the driver strength of the
host to the used card.)
Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
---
drivers/mci/mci-core.c | 27 +++++++++++++++++++++++++++
include/mci.h | 3 +++
2 files changed, 30 insertions(+)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index a232679..2c91ff2 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -102,6 +102,20 @@ static void mci_setup_cmd(struct mci_cmd *p, unsigned cmd, unsigned arg, unsigne
}
/**
+ * configure optional DSR value
+ * @param mci_dev MCI instance
+ * @return Transaction status (0 on success)
+ */
+static int mci_set_dsr(struct mci *mci)
+{
+ struct mci_cmd cmd;
+
+ mci_setup_cmd(&cmd, MMC_CMD_SET_DSR,
+ (mci->host->dsr_val >> 16) | 0xffff, MMC_RSP_NONE);
+ return mci_send_cmd(mci, &cmd, NULL);
+}
+
+/**
* Setup SD/MMC card's blocklength to be used for future transmitts
* @param mci_dev MCI instance
* @param len Blocklength in bytes
@@ -836,6 +850,15 @@ static void mci_extract_card_capacity_from_csd(struct mci *mci)
dev_dbg(&mci->dev, "Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
}
+/**
+ * Extract card's DSR implementation state from CSD
+ * @param mci MCI instance
+ */
+static void mci_extract_card_dsr_imp_from_csd(struct mci *mci)
+{
+ mci->dsr_imp = UNSTUFF_BITS(mci->csd, 76, 1);
+}
+
static int mmc_compare_ext_csds(struct mci *mci, unsigned bus_width)
{
u8 *bw_ext_csd;
@@ -1058,6 +1081,7 @@ static int mci_startup(struct mci *mci)
mci_detect_version_from_csd(mci);
mci_extract_max_tran_speed_from_csd(mci);
mci_extract_block_lengths_from_csd(mci);
+ mci_extract_card_dsr_imp_from_csd(mci);
/* sanitiy? */
if (mci->read_bl_len > SECTOR_SIZE) {
@@ -1074,6 +1098,9 @@ static int mci_startup(struct mci *mci)
dev_dbg(&mci->dev, "Read block length: %u, Write block length: %u\n",
mci->read_bl_len, mci->write_bl_len);
+ if (mci->dsr_imp && mci->host->use_dsr)
+ mci_set_dsr(mci);
+
if (!mmc_host_is_spi(host)) { /* cmd not supported in spi */
dev_dbg(&mci->dev, "Select the card, and put it into Transfer Mode\n");
/* Select the card, and put it into Transfer Mode */
diff --git a/include/mci.h b/include/mci.h
index 0f10e8a..d3a553e 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -294,6 +294,8 @@ struct mci_host {
unsigned clock; /**< Current clock used to talk to the card */
unsigned bus_width; /**< used data bus width to the card */
unsigned max_req_size;
+ unsigned dsr_val; /**< optional dsr value */
+ int use_dsr; /**< optional dsr usage flag */
/** init the host interface */
int (*init)(struct mci_host*, struct device_d*);
@@ -344,6 +346,7 @@ struct mci {
unsigned write_bl_len;
uint64_t capacity; /**< Card's data capacity in bytes */
int ready_for_use; /** true if already probed */
+ int dsr_imp; /**< DSR implementation state from CSD */
char *ext_csd;
int probe;
struct param_d *param_probe;
--
1.7.9.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-01-14 8:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 8:23 [PATCH v2 0/4] mmc: add setdsr support Markus Niebel
2014-01-14 8:23 ` Markus Niebel [this message]
2014-01-14 8:23 ` [PATCH 2/4] mci: add device tree support for DSR Markus Niebel
2014-01-14 8:23 ` [PATCH 3/4] mci: imx-esdhc: add DSR support Markus Niebel
2014-01-14 8:49 ` Alexander Aring
2014-01-14 14:26 ` AW: " Markus Niebel
2014-01-14 8:23 ` [PATCH 4/4] boards: tqma53: add DSR support for eMMC Markus Niebel
2014-01-15 14:23 ` [PATCH v2 0/4] mmc: add setdsr support Sascha Hauer
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=1389687817-30882-2-git-send-email-list-09_barebox@tqsc.de \
--to=list-09_barebox@tqsc.de \
--cc=Markus.Niebel@tqs.de \
--cc=barebox@lists.infradead.org \
/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