9
0
Fork 0

mci: add DSR support

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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Markus Niebel 2014-01-14 09:23:34 +01:00 committed by Sascha Hauer
parent 96da216991
commit 78b9e4e041
2 changed files with 30 additions and 0 deletions

View File

@ -101,6 +101,20 @@ static void mci_setup_cmd(struct mci_cmd *p, unsigned cmd, unsigned arg, unsigne
p->resp_type = response;
}
/**
* 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
@ -855,6 +869,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;
@ -1077,6 +1100,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) {
@ -1093,6 +1117,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 */

View File

@ -299,6 +299,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*);
@ -349,6 +351,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;